use of android.app.backup.BackupAgent in project android_frameworks_base by AOSPA.
the class ActivityThread method handleDestroyBackupAgent.
// Tear down a BackupAgent
private void handleDestroyBackupAgent(CreateBackupAgentData data) {
if (DEBUG_BACKUP)
Slog.v(TAG, "handleDestroyBackupAgent: " + data);
LoadedApk packageInfo = getPackageInfoNoCheck(data.appInfo, data.compatInfo);
String packageName = packageInfo.mPackageName;
BackupAgent agent = mBackupAgents.get(packageName);
if (agent != null) {
try {
agent.onDestroy();
} catch (Exception e) {
Slog.w(TAG, "Exception thrown in onDestroy by backup agent of " + data.appInfo);
e.printStackTrace();
}
mBackupAgents.remove(packageName);
} else {
Slog.w(TAG, "Attempt to destroy unknown backup agent " + data);
}
}
use of android.app.backup.BackupAgent in project android_frameworks_base by ResurrectionRemix.
the class ActivityThread method handleDestroyBackupAgent.
// Tear down a BackupAgent
private void handleDestroyBackupAgent(CreateBackupAgentData data) {
if (DEBUG_BACKUP)
Slog.v(TAG, "handleDestroyBackupAgent: " + data);
LoadedApk packageInfo = getPackageInfoNoCheck(data.appInfo, data.compatInfo);
String packageName = packageInfo.mPackageName;
BackupAgent agent = mBackupAgents.get(packageName);
if (agent != null) {
try {
agent.onDestroy();
} catch (Exception e) {
Slog.w(TAG, "Exception thrown in onDestroy by backup agent of " + data.appInfo);
e.printStackTrace();
}
mBackupAgents.remove(packageName);
} else {
Slog.w(TAG, "Attempt to destroy unknown backup agent " + data);
}
}
use of android.app.backup.BackupAgent in project android_frameworks_base by crdroidandroid.
the class ActivityThread method handleCreateBackupAgent.
// Instantiate a BackupAgent and tell it that it's alive
private void handleCreateBackupAgent(CreateBackupAgentData data) {
if (DEBUG_BACKUP)
Slog.v(TAG, "handleCreateBackupAgent: " + data);
// Sanity check the requested target package's uid against ours
try {
PackageInfo requestedPackage = getPackageManager().getPackageInfo(data.appInfo.packageName, 0, UserHandle.myUserId());
if (requestedPackage.applicationInfo.uid != Process.myUid()) {
Slog.w(TAG, "Asked to instantiate non-matching package " + data.appInfo.packageName);
return;
}
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
// no longer idle; we have backup work to do
unscheduleGcIdler();
// instantiate the BackupAgent class named in the manifest
LoadedApk packageInfo = getPackageInfoNoCheck(data.appInfo, data.compatInfo);
String packageName = packageInfo.mPackageName;
if (packageName == null) {
Slog.d(TAG, "Asked to create backup agent for nonexistent package");
return;
}
String classname = data.appInfo.backupAgentName;
// full backup operation but no app-supplied agent? use the default implementation
if (classname == null && (data.backupMode == IApplicationThread.BACKUP_MODE_FULL || data.backupMode == IApplicationThread.BACKUP_MODE_RESTORE_FULL)) {
classname = "android.app.backup.FullBackupAgent";
}
try {
IBinder binder = null;
BackupAgent agent = mBackupAgents.get(packageName);
if (agent != null) {
// reusing the existing instance
if (DEBUG_BACKUP) {
Slog.v(TAG, "Reusing existing agent instance");
}
binder = agent.onBind();
} else {
try {
if (DEBUG_BACKUP)
Slog.v(TAG, "Initializing agent class " + classname);
java.lang.ClassLoader cl = packageInfo.getClassLoader();
agent = (BackupAgent) cl.loadClass(classname).newInstance();
// set up the agent's context
ContextImpl context = ContextImpl.createAppContext(this, packageInfo);
context.setOuterContext(agent);
agent.attach(context);
agent.onCreate();
binder = agent.onBind();
mBackupAgents.put(packageName, agent);
} catch (Exception e) {
// If this is during restore, fail silently; otherwise go
// ahead and let the user see the crash.
Slog.e(TAG, "Agent threw during creation: " + e);
if (data.backupMode != IApplicationThread.BACKUP_MODE_RESTORE && data.backupMode != IApplicationThread.BACKUP_MODE_RESTORE_FULL) {
throw e;
}
// falling through with 'binder' still null
}
}
// tell the OS that we're live now
try {
ActivityManagerNative.getDefault().backupAgentCreated(packageName, binder);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
} catch (Exception e) {
throw new RuntimeException("Unable to create BackupAgent " + classname + ": " + e.toString(), e);
}
}
use of android.app.backup.BackupAgent in project android_frameworks_base by crdroidandroid.
the class ActivityThread method handleDestroyBackupAgent.
// Tear down a BackupAgent
private void handleDestroyBackupAgent(CreateBackupAgentData data) {
if (DEBUG_BACKUP)
Slog.v(TAG, "handleDestroyBackupAgent: " + data);
LoadedApk packageInfo = getPackageInfoNoCheck(data.appInfo, data.compatInfo);
String packageName = packageInfo.mPackageName;
BackupAgent agent = mBackupAgents.get(packageName);
if (agent != null) {
try {
agent.onDestroy();
} catch (Exception e) {
Slog.w(TAG, "Exception thrown in onDestroy by backup agent of " + data.appInfo);
e.printStackTrace();
}
mBackupAgents.remove(packageName);
} else {
Slog.w(TAG, "Attempt to destroy unknown backup agent " + data);
}
}
Aggregations