Search in sources :

Example 1 with IBackupManager

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

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);
        mProcessNames.remove(app.processName, app.uid);
        mIsolatedProcesses.remove(app.uid);
        if (mHeavyWeightProcess == app) {
            mHandler.sendMessage(mHandler.obtainMessage(CANCEL_HEAVY_NOTIFICATION_MSG, mHeavyWeightProcess.userId, 0));
            mHeavyWeightProcess = null;
        }
        // Take care of any launching providers waiting for this process.
        checkAppInLaunchingProvidersLocked(app, true);
        // Take care of any services that are waiting for the process.
        mServices.processStartTimedOutLocked(app);
        EventLog.writeEvent(EventLogTags.AM_KILL, app.userId, pid, app.processName, app.setAdj, "start timeout");
        Process.killProcessQuiet(pid);
        if (mBackupTarget != null && mBackupTarget.app.pid == pid) {
            Slog.w(TAG, "Unattached app died before backup, skipping");
            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)

Example 2 with IBackupManager

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

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.
     */
private final void cleanUpApplicationRecordLocked(ProcessRecord app, boolean restarting, boolean allowRestart, int index) {
    if (index >= 0) {
        mLruProcesses.remove(index);
    }
    mProcessesToGc.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();
    app.unlinkDeathRecipient();
    app.thread = null;
    app.forcingToForeground = null;
    app.foregroundServices = false;
    app.foregroundActivities = false;
    app.hasShownUi = false;
    app.hasAboveClient = false;
    mServices.killServicesLocked(app, allowRestart);
    boolean restart = false;
    // Remove published content providers.
    if (!app.pubProviders.isEmpty()) {
        Iterator<ContentProviderRecord> it = app.pubProviders.values().iterator();
        while (it.hasNext()) {
            ContentProviderRecord cpr = it.next();
            final boolean always = app.bad || !allowRestart;
            if (removeDyingProviderLocked(app, cpr, always) || always) {
                // 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 (checkAppInLaunchingProvidersLocked(app, false)) {
        restart = true;
    }
    // Unregister from connected content providers.
    if (!app.conProviders.isEmpty()) {
        for (int i = 0; i < app.conProviders.size(); i++) {
            ContentProviderConnection conn = app.conProviders.get(i);
            conn.provider.connections.remove(conn);
        }
        app.conProviders.clear();
    }
    // the actual situation to identify what is actually going on.
    if (false) {
        for (int i = 0; i < mLaunchingProviders.size(); i++) {
            ContentProviderRecord cpr = (ContentProviderRecord) mLaunchingProviders.get(i);
            if (cpr.connections.size() <= 0 && !cpr.hasExternalProcessHandles()) {
                synchronized (cpr) {
                    cpr.launchingApp = null;
                    cpr.notifyAll();
                }
            }
        }
    }
    skipCurrentReceiverLocked(app);
    // Unregister any receivers.
    if (app.receivers.size() > 0) {
        Iterator<ReceiverList> it = app.receivers.iterator();
        while (it.hasNext()) {
            removeReceiverLocked(it.next());
        }
        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, "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);
        }
    }
    mHandler.obtainMessage(DISPATCH_PROCESS_DIED, app.pid, app.info.uid, null).sendToTarget();
    // current lists and let the caller take care of it.
    if (restarting) {
        return;
    }
    if (!app.persistent || app.isolated) {
        if (DEBUG_PROCESSES || DEBUG_CLEANUP)
            Slog.v(TAG, "Removing non-persistent process during cleanup: " + app);
        mProcessNames.remove(app.processName, app.uid);
        mIsolatedProcesses.remove(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, "Clean-up removing on hold: " + app);
    mProcessesOnHold.remove(app);
    if (app == mHomeProcess) {
        mHomeProcess = null;
    }
    if (app == mPreviousProcess) {
        mPreviousProcess = null;
    }
    if (restart && !app.isolated) {
        // We have components that still need to be running in the
        // process, so re-launch it.
        mProcessNames.put(app.processName, app.uid, app);
        startProcessLocked(app, "restart", app.processName);
    } else if (app.pid > 0 && app.pid != MY_PID) {
        // Goodbye!
        synchronized (mPidsSelfLocked) {
            mPidsSelfLocked.remove(app.pid);
            mHandler.removeMessages(PROC_START_TIMEOUT_MSG, app);
        }
        app.setPid(0);
    }
}
Also used : IBackupManager(android.app.backup.IBackupManager) RemoteException(android.os.RemoteException)

Example 3 with IBackupManager

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

the class BackupSettingsActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String backup = getResources().getString(R.string.config_backup_settings_intent);
    if (!TextUtils.isEmpty(backup)) {
        try {
            Intent intent = Intent.parseUri(backup, 0);
            if (intent.resolveActivity(getPackageManager()) != null) {
                // use startActivityForResult to let the activity check the caller signature
                IBackupManager bmgr = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
                boolean backupOkay;
                try {
                    backupOkay = bmgr.isBackupServiceActive(UserHandle.myUserId());
                } catch (Exception e) {
                    // things go wrong talking to the backup system => ignore and
                    // pass the default 'false' as the "backup is a thing?" state.
                    backupOkay = false;
                }
                intent.putExtra(BackupManager.EXTRA_BACKUP_SERVICES_AVAILABLE, backupOkay);
                startActivityForResult(intent, -1);
            } else {
                Log.e(TAG, "Backup component not found!");
            }
        } catch (URISyntaxException e) {
            Log.e(TAG, "Invalid backup component URI!", e);
        }
    }
    finish();
}
Also used : IBackupManager(android.app.backup.IBackupManager) Intent(android.content.Intent) URISyntaxException(java.net.URISyntaxException) URISyntaxException(java.net.URISyntaxException)

Example 4 with IBackupManager

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

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");
            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 5 with IBackupManager

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

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) FileNotFoundException(java.io.FileNotFoundException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) InstallerException(com.android.internal.os.InstallerConnection.InstallerException)

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