Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 061c3b50 authored by Android (Google) Code Review's avatar Android (Google) Code Review Committed by The Android Open Source Project
Browse files

am fd5f0875: Merge change 4721 into donut

Merge commit 'fd5f0875'

* commit 'fd5f0875':
  Make signature checks on restore work with unsigned apps
parents ba165caf fd5f0875
Loading
Loading
Loading
Loading
+14 −11
Original line number Original line Diff line number Diff line
@@ -757,6 +757,16 @@ class BackupManagerService extends IBackupManager.Stub {
    }
    }


    private boolean signaturesMatch(Signature[] storedSigs, Signature[] deviceSigs) {
    private boolean signaturesMatch(Signature[] storedSigs, Signature[] deviceSigs) {
        // Allow unsigned apps, but not signed on one device and unsigned on the other
        // !!! TODO: is this the right policy?
        if ((storedSigs == null || storedSigs.length == 0)
                && (deviceSigs == null || deviceSigs.length == 0)) {
            return true;
        }
        if (storedSigs == null || deviceSigs == null) {
            return false;
        }

        // !!! TODO: this demands that every stored signature match one
        // !!! TODO: this demands that every stored signature match one
        // that is present on device, and does not demand the converse.
        // that is present on device, and does not demand the converse.
        // Is this this right policy?
        // Is this this right policy?
@@ -815,8 +825,6 @@ class BackupManagerService extends IBackupManager.Stub {
            }
            }


            if (err == 0) {
            if (err == 0) {
                // !!! TODO: do the package manager signatures restore first

                // build the set of apps to restore
                // build the set of apps to restore
                try {
                try {
                    RestoreSet[] images = mTransport.getAvailableRestoreSets();
                    RestoreSet[] images = mTransport.getAvailableRestoreSets();
@@ -841,17 +849,12 @@ class BackupManagerService extends IBackupManager.Stub {
                                // Validate against the backed-up signature block, too
                                // Validate against the backed-up signature block, too
                                Signature[] storedSigs
                                Signature[] storedSigs
                                        = pmAgent.getRestoredSignatures(app.packageName);
                                        = pmAgent.getRestoredSignatures(app.packageName);
                                if (storedSigs != null) {
                                // !!! TODO: check app version here as well
                                // !!! TODO: check app version here as well
                                if (signaturesMatch(storedSigs, app.signatures)) {
                                if (signaturesMatch(storedSigs, app.signatures)) {
                                    appsToRestore.add(app);
                                    appsToRestore.add(app);
                                } else {
                                } else {
                                    Log.w(TAG, "Sig mismatch on restore of " + app.packageName);
                                    Log.w(TAG, "Sig mismatch on restore of " + app.packageName);
                                }
                                }
                                } else {
                                    Log.i(TAG, "No stored sigs for " + app.packageName
                                            + " so not restoring");
                                }
                            }
                            }
                        }
                        }