Search in sources :

Example 11 with IBackupManager

use of android.app.backup.IBackupManager in project cornerstone by Onskreen.

the class ActivityManagerService method backupAgentCreated.

// A backup agent has just come up
public void backupAgentCreated(String agentPackageName, IBinder agent) {
    if (DEBUG_BACKUP)
        Slog.v(TAG, "backupAgentCreated: " + agentPackageName + " = " + agent);
    synchronized (this) {
        if (!agentPackageName.equals(mBackupAppName)) {
            Slog.e(TAG, "Backup agent created for " + agentPackageName + " but not requested!");
            return;
        }
    }
    long oldIdent = Binder.clearCallingIdentity();
    try {
        IBackupManager bm = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
        bm.agentConnected(agentPackageName, agent);
    } catch (RemoteException e) {
    // can't happen; the backup manager service is local
    } catch (Exception e) {
        Slog.w(TAG, "Exception trying to deliver BackupAgent binding: ");
        e.printStackTrace();
    } finally {
        Binder.restoreCallingIdentity(oldIdent);
    }
}
Also used : IBackupManager(android.app.backup.IBackupManager) RemoteException(android.os.RemoteException) RemoteException(android.os.RemoteException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) ActivityNotFoundException(android.content.ActivityNotFoundException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException)

Example 12 with IBackupManager

use of android.app.backup.IBackupManager in project android_frameworks_base by ParanoidAndroid.

the class ActivityManagerService method backupAgentCreated.

// A backup agent has just come up                    
public void backupAgentCreated(String agentPackageName, IBinder agent) {
    if (DEBUG_BACKUP)
        Slog.v(TAG, "backupAgentCreated: " + agentPackageName + " = " + agent);
    synchronized (this) {
        if (!agentPackageName.equals(mBackupAppName)) {
            Slog.e(TAG, "Backup agent created for " + agentPackageName + " but not requested!");
            return;
        }
    }
    long oldIdent = Binder.clearCallingIdentity();
    try {
        IBackupManager bm = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
        bm.agentConnected(agentPackageName, agent);
    } catch (RemoteException e) {
    // can't happen; the backup manager service is local
    } catch (Exception e) {
        Slog.w(TAG, "Exception trying to deliver BackupAgent binding: ");
        e.printStackTrace();
    } finally {
        Binder.restoreCallingIdentity(oldIdent);
    }
}
Also used : IBackupManager(android.app.backup.IBackupManager) RemoteException(android.os.RemoteException) RemoteException(android.os.RemoteException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ActivityNotFoundException(android.content.ActivityNotFoundException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException)

Example 13 with IBackupManager

use of android.app.backup.IBackupManager in project android_frameworks_base by DirtyUnicorns.

the class ActivityManagerService method cleanUpApplicationRecordLocked.

/**
     * Main code for cleaning up a process when it has gone away.  This is
     * called both as a result of the process dying, or directly when stopping
     * a process when running in single process mode.
     *
     * @return Returns true if the given process has been restarted, so the
     * app that was passed in must remain on the process lists.
     */
private final boolean cleanUpApplicationRecordLocked(ProcessRecord app, boolean restarting, boolean allowRestart, int index, boolean replacingPid) {
    Slog.d(TAG, "cleanUpApplicationRecord -- " + app.pid);
    if (index >= 0) {
        removeLruProcessLocked(app);
        ProcessList.remove(app.pid);
    }
    mProcessesToGc.remove(app);
    mPendingPssProcesses.remove(app);
    // Dismiss any open dialogs.
    if (app.crashDialog != null && !app.forceCrashReport) {
        app.crashDialog.dismiss();
        app.crashDialog = null;
    }
    if (app.anrDialog != null) {
        app.anrDialog.dismiss();
        app.anrDialog = null;
    }
    if (app.waitDialog != null) {
        app.waitDialog.dismiss();
        app.waitDialog = null;
    }
    app.crashing = false;
    app.notResponding = false;
    app.resetPackageList(mProcessStats);
    app.unlinkDeathRecipient();
    app.makeInactive(mProcessStats);
    app.waitingToKill = null;
    app.forcingToForeground = null;
    updateProcessForegroundLocked(app, false, false);
    app.foregroundActivities = false;
    app.hasShownUi = false;
    app.treatLikeActivity = false;
    app.hasAboveClient = false;
    app.hasClientActivities = false;
    mServices.killServicesLocked(app, allowRestart);
    boolean restart = false;
    // Remove published content providers.
    for (int i = app.pubProviders.size() - 1; i >= 0; i--) {
        ContentProviderRecord cpr = app.pubProviders.valueAt(i);
        final boolean always = app.bad || !allowRestart;
        boolean inLaunching = removeDyingProviderLocked(app, cpr, always);
        if ((inLaunching || always) && cpr.hasConnectionOrHandle()) {
            // We left the provider in the launching list, need to
            // restart it.
            restart = true;
        }
        cpr.provider = null;
        cpr.proc = null;
    }
    app.pubProviders.clear();
    // Take care of any launching providers waiting for this process.
    if (cleanupAppInLaunchingProvidersLocked(app, false)) {
        restart = true;
    }
    // Unregister from connected content providers.
    if (!app.conProviders.isEmpty()) {
        for (int i = app.conProviders.size() - 1; i >= 0; i--) {
            ContentProviderConnection conn = app.conProviders.get(i);
            conn.provider.connections.remove(conn);
            stopAssociationLocked(app.uid, app.processName, conn.provider.uid, conn.provider.name);
        }
        app.conProviders.clear();
    }
    // the actual situation to identify what is actually going on.
    if (false) {
        for (int i = mLaunchingProviders.size() - 1; i >= 0; i--) {
            ContentProviderRecord cpr = mLaunchingProviders.get(i);
            if (cpr.connections.size() <= 0 && !cpr.hasExternalProcessHandles()) {
                synchronized (cpr) {
                    cpr.launchingApp = null;
                    cpr.notifyAll();
                }
            }
        }
    }
    skipCurrentReceiverLocked(app);
    // Unregister any receivers.
    for (int i = app.receivers.size() - 1; i >= 0; i--) {
        removeReceiverLocked(app.receivers.valueAt(i));
    }
    app.receivers.clear();
    // If the app is undergoing backup, tell the backup manager about it
    if (mBackupTarget != null && app.pid == mBackupTarget.app.pid) {
        if (DEBUG_BACKUP || DEBUG_CLEANUP)
            Slog.d(TAG_CLEANUP, "App " + mBackupTarget.appInfo + " died during backup");
        try {
            IBackupManager bm = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
            bm.agentDisconnected(app.info.packageName);
        } catch (RemoteException e) {
        // can't happen; backup manager is local
        }
    }
    for (int i = mPendingProcessChanges.size() - 1; i >= 0; i--) {
        ProcessChangeItem item = mPendingProcessChanges.get(i);
        if (item.pid == app.pid) {
            mPendingProcessChanges.remove(i);
            mAvailProcessChanges.add(item);
        }
    }
    mUiHandler.obtainMessage(DISPATCH_PROCESS_DIED_UI_MSG, app.pid, app.info.uid, null).sendToTarget();
    // current lists and let the caller take care of it.
    if (restarting) {
        return false;
    }
    if (!app.persistent || app.isolated) {
        if (DEBUG_PROCESSES || DEBUG_CLEANUP)
            Slog.v(TAG_CLEANUP, "Removing non-persistent process during cleanup: " + app);
        if (!replacingPid) {
            removeProcessNameLocked(app.processName, app.uid, app);
        }
        if (mHeavyWeightProcess == app) {
            mHandler.sendMessage(mHandler.obtainMessage(CANCEL_HEAVY_NOTIFICATION_MSG, mHeavyWeightProcess.userId, 0));
            mHeavyWeightProcess = null;
        }
    } else if (!app.removed) {
        // and start a new process for it.
        if (mPersistentStartingProcesses.indexOf(app) < 0) {
            mPersistentStartingProcesses.add(app);
            restart = true;
        }
    }
    if ((DEBUG_PROCESSES || DEBUG_CLEANUP) && mProcessesOnHold.contains(app))
        Slog.v(TAG_CLEANUP, "Clean-up removing on hold: " + app);
    mProcessesOnHold.remove(app);
    if (app == mHomeProcess) {
        mHomeProcess = null;
    }
    if (app == mPreviousProcess) {
        mPreviousProcess = null;
    }
    if (restart && !app.isolated) {
        // process, so re-launch it.
        if (index < 0) {
            ProcessList.remove(app.pid);
        }
        addProcessNameLocked(app);
        startProcessLocked(app, "restart", app.processName);
        return true;
    } else if (app.pid > 0 && app.pid != MY_PID) {
        // Goodbye!
        boolean removed;
        synchronized (mPidsSelfLocked) {
            mPidsSelfLocked.remove(app.pid);
            mHandler.removeMessages(PROC_START_TIMEOUT_MSG, app);
        }
        mBatteryStatsService.noteProcessFinish(app.processName, app.info.uid);
        if (app.isolated) {
            mBatteryStatsService.removeIsolatedUid(app.uid, app.info.uid);
        }
        app.setPid(0);
    }
    return false;
}
Also used : IBackupManager(android.app.backup.IBackupManager) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Example 14 with IBackupManager

use of android.app.backup.IBackupManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PrivacySettings method getNonVisibleKeys.

private static void getNonVisibleKeys(Context context, Collection<String> nonVisibleKeys) {
    final IBackupManager backupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
    boolean isServiceActive = false;
    try {
        isServiceActive = backupManager.isBackupServiceActive(UserHandle.myUserId());
    } catch (RemoteException e) {
        Log.w(TAG, "Failed querying backup manager service activity status. " + "Assuming it is inactive.");
    }
    boolean vendorSpecific = context.getPackageManager().resolveContentProvider(GSETTINGS_PROVIDER, 0) == null;
    if (vendorSpecific || isServiceActive) {
        nonVisibleKeys.add(BACKUP_INACTIVE);
    }
    if (vendorSpecific || !isServiceActive) {
        nonVisibleKeys.add(BACKUP_DATA);
        nonVisibleKeys.add(AUTO_RESTORE);
        nonVisibleKeys.add(CONFIGURE_ACCOUNT);
    }
    if (RestrictedLockUtils.hasBaseUserRestriction(context, UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId())) {
        nonVisibleKeys.add(FACTORY_RESET);
    }
    if (RestrictedLockUtils.hasBaseUserRestriction(context, UserManager.DISALLOW_NETWORK_RESET, UserHandle.myUserId())) {
        nonVisibleKeys.add(NETWORK_RESET);
    }
}
Also used : IBackupManager(android.app.backup.IBackupManager) RemoteException(android.os.RemoteException)

Example 15 with IBackupManager

use of android.app.backup.IBackupManager in project android_packages_apps_Settings by omnirom.

the class PrivacySettings method getNonVisibleKeys.

private static void getNonVisibleKeys(Context context, Collection<String> nonVisibleKeys) {
    final IBackupManager backupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
    boolean isServiceActive = false;
    try {
        isServiceActive = backupManager.isBackupServiceActive(UserHandle.myUserId());
    } catch (RemoteException e) {
        Log.w(TAG, "Failed querying backup manager service activity status. " + "Assuming it is inactive.");
    }
    boolean vendorSpecific = context.getPackageManager().resolveContentProvider(GSETTINGS_PROVIDER, 0) == null;
    if (vendorSpecific || isServiceActive) {
        nonVisibleKeys.add(BACKUP_INACTIVE);
    }
    if (vendorSpecific || !isServiceActive) {
        nonVisibleKeys.add(BACKUP_DATA);
        nonVisibleKeys.add(AUTO_RESTORE);
        nonVisibleKeys.add(CONFIGURE_ACCOUNT);
    }
    if (RestrictedLockUtils.hasBaseUserRestriction(context, UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId())) {
        nonVisibleKeys.add(FACTORY_RESET);
    }
}
Also used : IBackupManager(android.app.backup.IBackupManager) RemoteException(android.os.RemoteException)

Aggregations

IBackupManager (android.app.backup.IBackupManager)23 RemoteException (android.os.RemoteException)22 ActivityNotFoundException (android.content.ActivityNotFoundException)4 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)4 Point (android.graphics.Point)4 FileNotFoundException (java.io.FileNotFoundException)4 IOException (java.io.IOException)4 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)3 TransactionTooLargeException (android.os.TransactionTooLargeException)2 Intent (android.content.Intent)1 InstallerException (com.android.internal.os.InstallerConnection.InstallerException)1 InstallerException (com.android.server.pm.Installer.InstallerException)1 URISyntaxException (java.net.URISyntaxException)1 TreeSet (java.util.TreeSet)1