Search in sources :

Example 26 with IBackupTransport

use of com.android.internal.backup.IBackupTransport in project android_frameworks_base by ResurrectionRemix.

the class BackupManagerService method clearBackupData.

// Clear the given package's backup data from the current transport
public void clearBackupData(String transportName, String packageName) {
    if (DEBUG)
        Slog.v(TAG, "clearBackupData() of " + packageName + " on " + transportName);
    PackageInfo info;
    try {
        info = mPackageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
    } catch (NameNotFoundException e) {
        Slog.d(TAG, "No such package '" + packageName + "' - not clearing backup data");
        return;
    }
    // If the caller does not hold the BACKUP permission, it can only request a
    // wipe of its own backed-up data.
    HashSet<String> apps;
    if ((mContext.checkPermission(android.Manifest.permission.BACKUP, Binder.getCallingPid(), Binder.getCallingUid())) == PackageManager.PERMISSION_DENIED) {
        apps = mBackupParticipants.get(Binder.getCallingUid());
    } else {
        // !!! TODO: allow data-clear of ANY app?
        if (MORE_DEBUG)
            Slog.v(TAG, "Privileged caller, allowing clear of other apps");
        apps = new HashSet<String>();
        int N = mBackupParticipants.size();
        for (int i = 0; i < N; i++) {
            HashSet<String> s = mBackupParticipants.valueAt(i);
            if (s != null) {
                apps.addAll(s);
            }
        }
    }
    // Is the given app an available participant?
    if (apps.contains(packageName)) {
        // found it; fire off the clear request
        if (MORE_DEBUG)
            Slog.v(TAG, "Found the app - running clear process");
        mBackupHandler.removeMessages(MSG_RETRY_CLEAR);
        synchronized (mQueueLock) {
            final IBackupTransport transport = getTransport(transportName);
            if (transport == null) {
                // transport is currently unavailable -- make sure to retry
                Message msg = mBackupHandler.obtainMessage(MSG_RETRY_CLEAR, new ClearRetryParams(transportName, packageName));
                mBackupHandler.sendMessageDelayed(msg, TRANSPORT_RETRY_INTERVAL);
                return;
            }
            long oldId = Binder.clearCallingIdentity();
            mWakelock.acquire();
            Message msg = mBackupHandler.obtainMessage(MSG_RUN_CLEAR, new ClearParams(transport, info));
            mBackupHandler.sendMessage(msg);
            Binder.restoreCallingIdentity(oldId);
        }
    }
}
Also used : IBackupTransport(com.android.internal.backup.IBackupTransport) Message(android.os.Message) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) PackageInfo(android.content.pm.PackageInfo)

Aggregations

IBackupTransport (com.android.internal.backup.IBackupTransport)26 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)25 RemoteException (android.os.RemoteException)22 IOException (java.io.IOException)22 ActivityNotFoundException (android.content.ActivityNotFoundException)21 EOFException (java.io.EOFException)21 FileNotFoundException (java.io.FileNotFoundException)21 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)21 InvalidKeyException (java.security.InvalidKeyException)21 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)21 InvalidKeySpecException (java.security.spec.InvalidKeySpecException)21 BadPaddingException (javax.crypto.BadPaddingException)21 IllegalBlockSizeException (javax.crypto.IllegalBlockSizeException)21 NoSuchPaddingException (javax.crypto.NoSuchPaddingException)21 ErrnoException (android.system.ErrnoException)20 PackageInfo (android.content.pm.PackageInfo)12 Message (android.os.Message)12 File (java.io.File)10 RandomAccessFile (java.io.RandomAccessFile)10 AtomicFile (android.util.AtomicFile)8