Search in sources :

Example 6 with IBackupManager

use of android.app.backup.IBackupManager in project platform_frameworks_base by android.

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");
        mHandler.post(new Runnable() {

            @Override
            public void run() {
                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);
        }
        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 7 with IBackupManager

use of android.app.backup.IBackupManager in project platform_frameworks_base by android.

the class ActivityManagerService method processStartTimedOutLocked.

private final void processStartTimedOutLocked(ProcessRecord app) {
    final int pid = app.pid;
    boolean gone = false;
    synchronized (mPidsSelfLocked) {
        ProcessRecord knownApp = mPidsSelfLocked.get(pid);
        if (knownApp != null && knownApp.thread == null) {
            mPidsSelfLocked.remove(pid);
            gone = true;
        }
    }
    if (gone) {
        Slog.w(TAG, "Process " + app + " failed to attach");
        EventLog.writeEvent(EventLogTags.AM_PROCESS_START_TIMEOUT, app.userId, pid, app.uid, app.processName);
        removeProcessNameLocked(app.processName, app.uid);
        if (mHeavyWeightProcess == app) {
            mHandler.sendMessage(mHandler.obtainMessage(CANCEL_HEAVY_NOTIFICATION_MSG, mHeavyWeightProcess.userId, 0));
            mHeavyWeightProcess = null;
        }
        mBatteryStatsService.noteProcessFinish(app.processName, app.info.uid);
        if (app.isolated) {
            mBatteryStatsService.removeIsolatedUid(app.uid, app.info.uid);
        }
        // Take care of any launching providers waiting for this process.
        cleanupAppInLaunchingProvidersLocked(app, true);
        // Take care of any services that are waiting for the process.
        mServices.processStartTimedOutLocked(app);
        app.kill("start timeout", true);
        removeLruProcessLocked(app);
        if (mBackupTarget != null && mBackupTarget.app.pid == pid) {
            Slog.w(TAG, "Unattached app died before backup, skipping");
            mHandler.post(new Runnable() {

                @Override
                public void run() {
                    try {
                        IBackupManager bm = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
                        bm.agentDisconnected(app.info.packageName);
                    } catch (RemoteException e) {
                    // Can't happen; the backup manager is local
                    }
                }
            });
        }
        if (isPendingBroadcastProcessLocked(pid)) {
            Slog.w(TAG, "Unattached app died before broadcast acknowledged, skipping");
            skipPendingBroadcastLocked(pid);
        }
    } else {
        Slog.w(TAG, "Spurious process start timeout - pid not known for " + app);
    }
}
Also used : IBackupManager(android.app.backup.IBackupManager) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Example 8 with IBackupManager

use of android.app.backup.IBackupManager in project platform_frameworks_base by android.

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_BACKUP, "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) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) ActivityNotFoundException(android.content.ActivityNotFoundException) TransactionTooLargeException(android.os.TransactionTooLargeException) InstallerException(com.android.server.pm.Installer.InstallerException) FileNotFoundException(java.io.FileNotFoundException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException)

Example 9 with IBackupManager

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

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)

Example 10 with IBackupManager

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

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