@@ -2450,6 +2450,21 @@ public void run() {
24502450 }
24512451 }
24522452
2453+ // Cull any packages that run as system-domain uids but do not define their
2454+ // own backup agents
2455+ for (int i = 0 ; i < packagesToBackup .size (); ) {
2456+ PackageInfo pkg = packagesToBackup .get (i );
2457+ if ((pkg .applicationInfo .uid < Process .FIRST_APPLICATION_UID )
2458+ && (pkg .applicationInfo .backupAgentName == null )) {
2459+ if (MORE_DEBUG ) {
2460+ Slog .i (TAG , "... ignoring non-agent system package " + pkg .packageName );
2461+ }
2462+ packagesToBackup .remove (i );
2463+ } else {
2464+ i ++;
2465+ }
2466+ }
2467+
24532468 FileOutputStream ofstream = new FileOutputStream (mOutputFile .getFileDescriptor ());
24542469 OutputStream out = null ;
24552470
@@ -3664,29 +3679,37 @@ RestorePolicy readAppManifest(FileMetadata info, InputStream instream)
36643679 // Fall through to IGNORE if the app explicitly disallows backup
36653680 final int flags = pkgInfo .applicationInfo .flags ;
36663681 if ((flags & ApplicationInfo .FLAG_ALLOW_BACKUP ) != 0 ) {
3667- // Verify signatures against any installed version; if they
3668- // don't match, then we fall though and ignore the data. The
3669- // signatureMatch() method explicitly ignores the signature
3670- // check for packages installed on the system partition, because
3671- // such packages are signed with the platform cert instead of
3672- // the app developer's cert, so they're different on every
3673- // device.
3674- if (signaturesMatch (sigs , pkgInfo )) {
3675- if (pkgInfo .versionCode >= version ) {
3676- Slog .i (TAG , "Sig + version match; taking data" );
3677- policy = RestorePolicy .ACCEPT ;
3682+ // Restore system-uid-space packages only if they have
3683+ // defined a custom backup agent
3684+ if ((pkgInfo .applicationInfo .uid >= Process .FIRST_APPLICATION_UID )
3685+ || (pkgInfo .applicationInfo .backupAgentName != null )) {
3686+ // Verify signatures against any installed version; if they
3687+ // don't match, then we fall though and ignore the data. The
3688+ // signatureMatch() method explicitly ignores the signature
3689+ // check for packages installed on the system partition, because
3690+ // such packages are signed with the platform cert instead of
3691+ // the app developer's cert, so they're different on every
3692+ // device.
3693+ if (signaturesMatch (sigs , pkgInfo )) {
3694+ if (pkgInfo .versionCode >= version ) {
3695+ Slog .i (TAG , "Sig + version match; taking data" );
3696+ policy = RestorePolicy .ACCEPT ;
3697+ } else {
3698+ // The data is from a newer version of the app than
3699+ // is presently installed. That means we can only
3700+ // use it if the matching apk is also supplied.
3701+ Slog .d (TAG , "Data version " + version
3702+ + " is newer than installed version "
3703+ + pkgInfo .versionCode + " - requiring apk" );
3704+ policy = RestorePolicy .ACCEPT_IF_APK ;
3705+ }
36783706 } else {
3679- // The data is from a newer version of the app than
3680- // is presently installed. That means we can only
3681- // use it if the matching apk is also supplied.
3682- Slog .d (TAG , "Data version " + version
3683- + " is newer than installed version "
3684- + pkgInfo .versionCode + " - requiring apk" );
3685- policy = RestorePolicy .ACCEPT_IF_APK ;
3707+ Slog .w (TAG , "Restore manifest signatures do not match "
3708+ + "installed application for " + info .packageName );
36863709 }
36873710 } else {
3688- Slog .w (TAG , "Restore manifest signatures do not match "
3689- + "installed application for " + info . packageName );
3711+ Slog .w (TAG , "Package " + info . packageName
3712+ + " is system level with no agent" );
36903713 }
36913714 } else {
36923715 if (DEBUG ) Slog .i (TAG , "Restore manifest from "
0 commit comments