### Question:
AppMetadataBackupWriter { public void backupApk(PackageInfo packageInfo) { String appSourceDir = packageInfo.applicationInfo.getBaseCodePath(); String apkDir = new File(appSourceDir).getParent(); FullBackup.backupToTar( packageInfo.packageName, FullBackup.APK_TREE_TOKEN, null, apkDir, appSourceDir, mOutput); } AppMetadataBackupWriter(FullBackupDataOutput output, PackageManager packageManager); void backupManifest(
            PackageInfo packageInfo, File manifestFile, File filesDir, boolean withApk); void backupManifest(
            PackageInfo packageInfo,
            File manifestFile,
            File filesDir,
            @Nullable String domain,
            @Nullable String linkDomain,
            boolean withApk); void backupWidget(
            PackageInfo packageInfo, File metadataFile, File filesDir, byte[] widgetData); void backupApk(PackageInfo packageInfo); void backupObb(@UserIdInt int userId, PackageInfo packageInfo);  }### Answer:
@Test public void testBackupApk_writesCorrectBytesToOutput() throws Exception { PackageInfo packageInfo = createPackageInfo(TEST_PACKAGE, TEST_PACKAGE_INSTALLER, TEST_PACKAGE_VERSION_CODE); byte[] apkBytes = "apk".getBytes(); File apkFile = createApkFileAndWrite(apkBytes); packageInfo.applicationInfo = new ApplicationInfo(); packageInfo.applicationInfo.sourceDir = apkFile.getPath(); mBackupWriter.backupApk(packageInfo); byte[] writtenBytes = getWrittenBytes(mBackupDataOutputFile, false); assertThat(writtenBytes).isEqualTo(apkBytes); apkFile.delete(); }