Loading Android.mk +1 −1 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ LOCAL_SRC_FILES += \ core/java/android/app/IActivityPendingResult.aidl \ core/java/android/app/IActivityWatcher.aidl \ core/java/android/app/IAlarmManager.aidl \ core/java/android/app/IBackupAgent.aidl \ core/java/android/app/IInstrumentationWatcher.aidl \ core/java/android/app/IIntentReceiver.aidl \ core/java/android/app/IIntentSender.aidl \ Loading @@ -85,7 +86,6 @@ LOCAL_SRC_FILES += \ core/java/android/app/IWallpaperService.aidl \ core/java/android/app/IWallpaperServiceCallback.aidl \ core/java/android/backup/IBackupManager.aidl \ core/java/android/backup/IBackupService.aidl \ core/java/android/bluetooth/IBluetoothA2dp.aidl \ core/java/android/bluetooth/IBluetoothDevice.aidl \ core/java/android/bluetooth/IBluetoothDeviceCallback.aidl \ Loading api/current.xml +24 −24 Original line number Diff line number Diff line Loading @@ -1167,11 +1167,11 @@ visibility="public" > </field> <field name="WRITE_SDCARD" <field name="WRITE_EXTERNAL_STORAGE" type="java.lang.String" transient="false" volatile="false" value=""android.permission.WRITE_SDCARD"" value=""android.permission.WRITE_EXTERNAL_STORAGE"" static="true" final="true" deprecated="not deprecated" Loading Loading @@ -2143,6 +2143,17 @@ visibility="public" > </field> <field name="allowBackup" type="int" transient="false" volatile="false" value="16843393" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="allowClearUserData" type="int" transient="false" Loading Loading @@ -2374,6 +2385,17 @@ visibility="public" > </field> <field name="backupAgent" type="int" transient="false" volatile="false" value="16843392" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="baselineAlignBottom" type="int" transient="false" Loading Loading @@ -3584,28 +3606,6 @@ visibility="public" > </field> <field name="donut_resource_pad31" type="int" transient="false" volatile="false" value="16843393" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="donut_resource_pad32" type="int" transient="false" volatile="false" value="16843392" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="donut_resource_pad4" type="int" transient="false" cmds/runtime/main_runtime.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,9 @@ #include "ServiceManager.h" #include "SignalHandler.h" #include <utils.h> #include <utils/threads.h> #include <utils/Errors.h> #include <binder/IPCThreadState.h> #include <binder/ProcessState.h> #include <utils/Log.h> Loading core/java/android/app/ActivityManagerNative.java +65 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.content.ComponentName; import android.content.ContentResolver; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ApplicationInfo; import android.content.pm.ConfigurationInfo; import android.content.pm.IPackageDataObserver; import android.content.res.Configuration; Loading Loading @@ -1021,6 +1022,33 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM reply.writeStrongBinder(binder); return true; } case START_BACKUP_AGENT_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data); int backupRestoreMode = data.readInt(); boolean success = bindBackupAgent(info, backupRestoreMode); reply.writeNoException(); reply.writeInt(success ? 1 : 0); return true; } case BACKUP_AGENT_CREATED_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); String packageName = data.readString(); IBinder agent = data.readStrongBinder(); backupAgentCreated(packageName, agent); reply.writeNoException(); return true; } case UNBIND_BACKUP_AGENT_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data); unbindBackupAgent(info); reply.writeNoException(); return true; } } return super.onTransact(code, data, reply, flags); Loading Loading @@ -1681,6 +1709,43 @@ class ActivityManagerProxy implements IActivityManager return binder; } public boolean bindBackupAgent(ApplicationInfo app, int backupRestoreMode) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); app.writeToParcel(data, 0); data.writeInt(backupRestoreMode); mRemote.transact(START_BACKUP_AGENT_TRANSACTION, data, reply, 0); reply.readException(); boolean success = reply.readInt() != 0; reply.recycle(); data.recycle(); return success; } public void backupAgentCreated(String packageName, IBinder agent) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeString(packageName); data.writeStrongBinder(agent); mRemote.transact(BACKUP_AGENT_CREATED_TRANSACTION, data, reply, 0); reply.recycle(); data.recycle(); } public void unbindBackupAgent(ApplicationInfo app) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); app.writeToParcel(data, 0); mRemote.transact(UNBIND_BACKUP_AGENT_TRANSACTION, data, reply, 0); reply.readException(); reply.recycle(); data.recycle(); } public boolean startInstrumentation(ComponentName className, String profileFile, int flags, Bundle arguments, IInstrumentationWatcher watcher) throws RemoteException { Loading core/java/android/app/ActivityThread.java +128 −7 Original line number Diff line number Diff line Loading @@ -115,6 +115,7 @@ public final class ActivityThread { private static final boolean localLOGV = DEBUG ? Config.LOGD : Config.LOGV; private static final boolean DEBUG_BROADCAST = false; private static final boolean DEBUG_RESULTS = false; private static final boolean DEBUG_BACKUP = true; private static final long MIN_TIME_BETWEEN_GCS = 5*1000; private static final Pattern PATTERN_SEMICOLON = Pattern.compile(";"); private static final int SQLITE_MEM_RELEASED_EVENT_LOG_TAG = 75003; Loading Loading @@ -499,7 +500,7 @@ public final class ActivityThread { return mResources; } public Application makeApplication() { public Application makeApplication(boolean forceDefaultAppClass) { if (mApplication != null) { return mApplication; } Loading @@ -507,7 +508,7 @@ public final class ActivityThread { Application app = null; String appClass = mApplicationInfo.className; if (appClass == null) { if (forceDefaultAppClass || (appClass == null)) { appClass = "android.app.Application"; } Loading Loading @@ -1199,6 +1200,16 @@ public final class ActivityThread { } } private static final class CreateBackupAgentData { ApplicationInfo appInfo; int backupMode; public String toString() { return "CreateBackupAgentData{appInfo=" + appInfo + " backupAgent=" + appInfo.backupAgentName + " mode=" + backupMode + "}"; } } private static final class CreateServiceData { IBinder token; ServiceInfo info; Loading Loading @@ -1239,6 +1250,7 @@ public final class ActivityThread { Bundle instrumentationArgs; IInstrumentationWatcher instrumentationWatcher; int debugMode; boolean restrictedBackupMode; Configuration config; boolean handlingProfiling; public String toString() { Loading Loading @@ -1374,6 +1386,21 @@ public final class ActivityThread { queueOrSendMessage(H.RECEIVER, r); } public final void scheduleCreateBackupAgent(ApplicationInfo app, int backupMode) { CreateBackupAgentData d = new CreateBackupAgentData(); d.appInfo = app; d.backupMode = backupMode; queueOrSendMessage(H.CREATE_BACKUP_AGENT, d); } public final void scheduleDestroyBackupAgent(ApplicationInfo app) { CreateBackupAgentData d = new CreateBackupAgentData(); d.appInfo = app; queueOrSendMessage(H.DESTROY_BACKUP_AGENT, d); } public final void scheduleCreateService(IBinder token, ServiceInfo info) { CreateServiceData s = new CreateServiceData(); Loading Loading @@ -1419,7 +1446,7 @@ public final class ActivityThread { ApplicationInfo appInfo, List<ProviderInfo> providers, ComponentName instrumentationName, String profileFile, Bundle instrumentationArgs, IInstrumentationWatcher instrumentationWatcher, int debugMode, Configuration config, int debugMode, boolean isRestrictedBackupMode, Configuration config, Map<String, IBinder> services) { Process.setArgV0(processName); Loading @@ -1437,6 +1464,7 @@ public final class ActivityThread { data.instrumentationArgs = instrumentationArgs; data.instrumentationWatcher = instrumentationWatcher; data.debugMode = debugMode; data.restrictedBackupMode = isRestrictedBackupMode; data.config = config; queueOrSendMessage(H.BIND_APPLICATION, data); } Loading Loading @@ -1718,6 +1746,8 @@ public final class ActivityThread { public static final int ACTIVITY_CONFIGURATION_CHANGED = 125; public static final int RELAUNCH_ACTIVITY = 126; public static final int PROFILER_CONTROL = 127; public static final int CREATE_BACKUP_AGENT = 128; public static final int DESTROY_BACKUP_AGENT = 129; String codeToString(int code) { if (localLOGV) { switch (code) { Loading Loading @@ -1749,6 +1779,8 @@ public final class ActivityThread { case ACTIVITY_CONFIGURATION_CHANGED: return "ACTIVITY_CONFIGURATION_CHANGED"; case RELAUNCH_ACTIVITY: return "RELAUNCH_ACTIVITY"; case PROFILER_CONTROL: return "PROFILER_CONTROL"; case CREATE_BACKUP_AGENT: return "CREATE_BACKUP_AGENT"; case DESTROY_BACKUP_AGENT: return "DESTROY_BACKUP_AGENT"; } } return "(unknown)"; Loading Loading @@ -1851,6 +1883,12 @@ public final class ActivityThread { case PROFILER_CONTROL: handleProfilerControl(msg.arg1 != 0, (String)msg.obj); break; case CREATE_BACKUP_AGENT: handleCreateBackupAgent((CreateBackupAgentData)msg.obj); break; case DESTROY_BACKUP_AGENT: handleDestroyBackupAgent((CreateBackupAgentData)msg.obj); break; } } } Loading Loading @@ -1908,6 +1946,8 @@ public final class ActivityThread { Application mInitialApplication; final ArrayList<Application> mAllApplications = new ArrayList<Application>(); // set of instantiated backup agents, keyed by package name final HashMap<String, BackupAgent> mBackupAgents = new HashMap<String, BackupAgent>(); static final ThreadLocal sThreadLocal = new ThreadLocal(); Instrumentation mInstrumentation; String mInstrumentationAppDir = null; Loading Loading @@ -2269,7 +2309,7 @@ public final class ActivityThread { } try { Application app = r.packageInfo.makeApplication(); Application app = r.packageInfo.makeApplication(false); if (localLOGV) Log.v(TAG, "Performing launch of " + r); if (localLOGV) Log.v( Loading Loading @@ -2464,7 +2504,7 @@ public final class ActivityThread { } try { Application app = packageInfo.makeApplication(); Application app = packageInfo.makeApplication(false); if (localLOGV) Log.v( TAG, "Performing receive of " + data.intent Loading Loading @@ -2507,6 +2547,85 @@ public final class ActivityThread { } } // Instantiate a BackupAgent and tell it that it's alive private final void handleCreateBackupAgent(CreateBackupAgentData data) { if (DEBUG_BACKUP) Log.v(TAG, "handleCreateBackupAgent: " + data); // no longer idle; we have backup work to do unscheduleGcIdler(); // instantiate the BackupAgent class named in the manifest PackageInfo packageInfo = getPackageInfoNoCheck(data.appInfo); String packageName = packageInfo.mPackageName; if (mBackupAgents.get(packageName) != null) { Log.d(TAG, "BackupAgent " + " for " + packageName + " already exists"); return; } BackupAgent agent = null; String classname = data.appInfo.backupAgentName; if (classname == null) { if (data.backupMode == IApplicationThread.BACKUP_MODE_INCREMENTAL) { Log.e(TAG, "Attempted incremental backup but no defined agent for " + packageName); return; } classname = "android.app.FullBackupAgent"; } try { java.lang.ClassLoader cl = packageInfo.getClassLoader(); agent = (BackupAgent) cl.loadClass(data.appInfo.backupAgentName).newInstance(); } catch (Exception e) { throw new RuntimeException("Unable to instantiate backup agent " + data.appInfo.backupAgentName + ": " + e.toString(), e); } // set up the agent's context try { if (DEBUG_BACKUP) Log.v(TAG, "Initializing BackupAgent " + data.appInfo.backupAgentName); ApplicationContext context = new ApplicationContext(); context.init(packageInfo, null, this); context.setOuterContext(agent); agent.attach(context); agent.onCreate(); // tell the OS that we're live now IBinder binder = agent.onBind(); try { ActivityManagerNative.getDefault().backupAgentCreated(packageName, binder); } catch (RemoteException e) { // nothing to do. } mBackupAgents.put(packageName, agent); } catch (Exception e) { throw new RuntimeException("Unable to create BackupAgent " + data.appInfo.backupAgentName + ": " + e.toString(), e); } } // Tear down a BackupAgent private final void handleDestroyBackupAgent(CreateBackupAgentData data) { if (DEBUG_BACKUP) Log.v(TAG, "handleDestroyBackupAgent: " + data); PackageInfo packageInfo = getPackageInfoNoCheck(data.appInfo); String packageName = packageInfo.mPackageName; BackupAgent agent = mBackupAgents.get(packageName); if (agent != null) { try { agent.onDestroy(); } catch (Exception e) { Log.w(TAG, "Exception thrown in onDestroy by backup agent of " + data.appInfo); e.printStackTrace(); } mBackupAgents.remove(packageName); } else { Log.w(TAG, "Attempt to destroy unknown backup agent " + data); } } private final void handleCreateService(CreateServiceData data) { // If we are getting ready to gc after going to the background, well // we are back active so skip it. Loading @@ -2532,7 +2651,7 @@ public final class ActivityThread { ApplicationContext context = new ApplicationContext(); context.init(packageInfo, null, this); Application app = packageInfo.makeApplication(); Application app = packageInfo.makeApplication(false); context.setOuterContext(service); service.attach(context, this, data.info.name, data.token, app, ActivityManagerNative.getDefault()); Loading Loading @@ -3694,7 +3813,9 @@ public final class ActivityThread { mInstrumentation = new Instrumentation(); } Application app = data.info.makeApplication(); // If the app is being launched for full backup or restore, bring it up in // a restricted environment with the base application class. Application app = data.info.makeApplication(data.restrictedBackupMode); mInitialApplication = app; List<ProviderInfo> providers = data.providers; Loading Loading
Android.mk +1 −1 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ LOCAL_SRC_FILES += \ core/java/android/app/IActivityPendingResult.aidl \ core/java/android/app/IActivityWatcher.aidl \ core/java/android/app/IAlarmManager.aidl \ core/java/android/app/IBackupAgent.aidl \ core/java/android/app/IInstrumentationWatcher.aidl \ core/java/android/app/IIntentReceiver.aidl \ core/java/android/app/IIntentSender.aidl \ Loading @@ -85,7 +86,6 @@ LOCAL_SRC_FILES += \ core/java/android/app/IWallpaperService.aidl \ core/java/android/app/IWallpaperServiceCallback.aidl \ core/java/android/backup/IBackupManager.aidl \ core/java/android/backup/IBackupService.aidl \ core/java/android/bluetooth/IBluetoothA2dp.aidl \ core/java/android/bluetooth/IBluetoothDevice.aidl \ core/java/android/bluetooth/IBluetoothDeviceCallback.aidl \ Loading
api/current.xml +24 −24 Original line number Diff line number Diff line Loading @@ -1167,11 +1167,11 @@ visibility="public" > </field> <field name="WRITE_SDCARD" <field name="WRITE_EXTERNAL_STORAGE" type="java.lang.String" transient="false" volatile="false" value=""android.permission.WRITE_SDCARD"" value=""android.permission.WRITE_EXTERNAL_STORAGE"" static="true" final="true" deprecated="not deprecated" Loading Loading @@ -2143,6 +2143,17 @@ visibility="public" > </field> <field name="allowBackup" type="int" transient="false" volatile="false" value="16843393" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="allowClearUserData" type="int" transient="false" Loading Loading @@ -2374,6 +2385,17 @@ visibility="public" > </field> <field name="backupAgent" type="int" transient="false" volatile="false" value="16843392" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="baselineAlignBottom" type="int" transient="false" Loading Loading @@ -3584,28 +3606,6 @@ visibility="public" > </field> <field name="donut_resource_pad31" type="int" transient="false" volatile="false" value="16843393" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="donut_resource_pad32" type="int" transient="false" volatile="false" value="16843392" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> <field name="donut_resource_pad4" type="int" transient="false"
cmds/runtime/main_runtime.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,9 @@ #include "ServiceManager.h" #include "SignalHandler.h" #include <utils.h> #include <utils/threads.h> #include <utils/Errors.h> #include <binder/IPCThreadState.h> #include <binder/ProcessState.h> #include <utils/Log.h> Loading
core/java/android/app/ActivityManagerNative.java +65 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.content.ComponentName; import android.content.ContentResolver; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ApplicationInfo; import android.content.pm.ConfigurationInfo; import android.content.pm.IPackageDataObserver; import android.content.res.Configuration; Loading Loading @@ -1021,6 +1022,33 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM reply.writeStrongBinder(binder); return true; } case START_BACKUP_AGENT_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data); int backupRestoreMode = data.readInt(); boolean success = bindBackupAgent(info, backupRestoreMode); reply.writeNoException(); reply.writeInt(success ? 1 : 0); return true; } case BACKUP_AGENT_CREATED_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); String packageName = data.readString(); IBinder agent = data.readStrongBinder(); backupAgentCreated(packageName, agent); reply.writeNoException(); return true; } case UNBIND_BACKUP_AGENT_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data); unbindBackupAgent(info); reply.writeNoException(); return true; } } return super.onTransact(code, data, reply, flags); Loading Loading @@ -1681,6 +1709,43 @@ class ActivityManagerProxy implements IActivityManager return binder; } public boolean bindBackupAgent(ApplicationInfo app, int backupRestoreMode) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); app.writeToParcel(data, 0); data.writeInt(backupRestoreMode); mRemote.transact(START_BACKUP_AGENT_TRANSACTION, data, reply, 0); reply.readException(); boolean success = reply.readInt() != 0; reply.recycle(); data.recycle(); return success; } public void backupAgentCreated(String packageName, IBinder agent) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeString(packageName); data.writeStrongBinder(agent); mRemote.transact(BACKUP_AGENT_CREATED_TRANSACTION, data, reply, 0); reply.recycle(); data.recycle(); } public void unbindBackupAgent(ApplicationInfo app) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); app.writeToParcel(data, 0); mRemote.transact(UNBIND_BACKUP_AGENT_TRANSACTION, data, reply, 0); reply.readException(); reply.recycle(); data.recycle(); } public boolean startInstrumentation(ComponentName className, String profileFile, int flags, Bundle arguments, IInstrumentationWatcher watcher) throws RemoteException { Loading
core/java/android/app/ActivityThread.java +128 −7 Original line number Diff line number Diff line Loading @@ -115,6 +115,7 @@ public final class ActivityThread { private static final boolean localLOGV = DEBUG ? Config.LOGD : Config.LOGV; private static final boolean DEBUG_BROADCAST = false; private static final boolean DEBUG_RESULTS = false; private static final boolean DEBUG_BACKUP = true; private static final long MIN_TIME_BETWEEN_GCS = 5*1000; private static final Pattern PATTERN_SEMICOLON = Pattern.compile(";"); private static final int SQLITE_MEM_RELEASED_EVENT_LOG_TAG = 75003; Loading Loading @@ -499,7 +500,7 @@ public final class ActivityThread { return mResources; } public Application makeApplication() { public Application makeApplication(boolean forceDefaultAppClass) { if (mApplication != null) { return mApplication; } Loading @@ -507,7 +508,7 @@ public final class ActivityThread { Application app = null; String appClass = mApplicationInfo.className; if (appClass == null) { if (forceDefaultAppClass || (appClass == null)) { appClass = "android.app.Application"; } Loading Loading @@ -1199,6 +1200,16 @@ public final class ActivityThread { } } private static final class CreateBackupAgentData { ApplicationInfo appInfo; int backupMode; public String toString() { return "CreateBackupAgentData{appInfo=" + appInfo + " backupAgent=" + appInfo.backupAgentName + " mode=" + backupMode + "}"; } } private static final class CreateServiceData { IBinder token; ServiceInfo info; Loading Loading @@ -1239,6 +1250,7 @@ public final class ActivityThread { Bundle instrumentationArgs; IInstrumentationWatcher instrumentationWatcher; int debugMode; boolean restrictedBackupMode; Configuration config; boolean handlingProfiling; public String toString() { Loading Loading @@ -1374,6 +1386,21 @@ public final class ActivityThread { queueOrSendMessage(H.RECEIVER, r); } public final void scheduleCreateBackupAgent(ApplicationInfo app, int backupMode) { CreateBackupAgentData d = new CreateBackupAgentData(); d.appInfo = app; d.backupMode = backupMode; queueOrSendMessage(H.CREATE_BACKUP_AGENT, d); } public final void scheduleDestroyBackupAgent(ApplicationInfo app) { CreateBackupAgentData d = new CreateBackupAgentData(); d.appInfo = app; queueOrSendMessage(H.DESTROY_BACKUP_AGENT, d); } public final void scheduleCreateService(IBinder token, ServiceInfo info) { CreateServiceData s = new CreateServiceData(); Loading Loading @@ -1419,7 +1446,7 @@ public final class ActivityThread { ApplicationInfo appInfo, List<ProviderInfo> providers, ComponentName instrumentationName, String profileFile, Bundle instrumentationArgs, IInstrumentationWatcher instrumentationWatcher, int debugMode, Configuration config, int debugMode, boolean isRestrictedBackupMode, Configuration config, Map<String, IBinder> services) { Process.setArgV0(processName); Loading @@ -1437,6 +1464,7 @@ public final class ActivityThread { data.instrumentationArgs = instrumentationArgs; data.instrumentationWatcher = instrumentationWatcher; data.debugMode = debugMode; data.restrictedBackupMode = isRestrictedBackupMode; data.config = config; queueOrSendMessage(H.BIND_APPLICATION, data); } Loading Loading @@ -1718,6 +1746,8 @@ public final class ActivityThread { public static final int ACTIVITY_CONFIGURATION_CHANGED = 125; public static final int RELAUNCH_ACTIVITY = 126; public static final int PROFILER_CONTROL = 127; public static final int CREATE_BACKUP_AGENT = 128; public static final int DESTROY_BACKUP_AGENT = 129; String codeToString(int code) { if (localLOGV) { switch (code) { Loading Loading @@ -1749,6 +1779,8 @@ public final class ActivityThread { case ACTIVITY_CONFIGURATION_CHANGED: return "ACTIVITY_CONFIGURATION_CHANGED"; case RELAUNCH_ACTIVITY: return "RELAUNCH_ACTIVITY"; case PROFILER_CONTROL: return "PROFILER_CONTROL"; case CREATE_BACKUP_AGENT: return "CREATE_BACKUP_AGENT"; case DESTROY_BACKUP_AGENT: return "DESTROY_BACKUP_AGENT"; } } return "(unknown)"; Loading Loading @@ -1851,6 +1883,12 @@ public final class ActivityThread { case PROFILER_CONTROL: handleProfilerControl(msg.arg1 != 0, (String)msg.obj); break; case CREATE_BACKUP_AGENT: handleCreateBackupAgent((CreateBackupAgentData)msg.obj); break; case DESTROY_BACKUP_AGENT: handleDestroyBackupAgent((CreateBackupAgentData)msg.obj); break; } } } Loading Loading @@ -1908,6 +1946,8 @@ public final class ActivityThread { Application mInitialApplication; final ArrayList<Application> mAllApplications = new ArrayList<Application>(); // set of instantiated backup agents, keyed by package name final HashMap<String, BackupAgent> mBackupAgents = new HashMap<String, BackupAgent>(); static final ThreadLocal sThreadLocal = new ThreadLocal(); Instrumentation mInstrumentation; String mInstrumentationAppDir = null; Loading Loading @@ -2269,7 +2309,7 @@ public final class ActivityThread { } try { Application app = r.packageInfo.makeApplication(); Application app = r.packageInfo.makeApplication(false); if (localLOGV) Log.v(TAG, "Performing launch of " + r); if (localLOGV) Log.v( Loading Loading @@ -2464,7 +2504,7 @@ public final class ActivityThread { } try { Application app = packageInfo.makeApplication(); Application app = packageInfo.makeApplication(false); if (localLOGV) Log.v( TAG, "Performing receive of " + data.intent Loading Loading @@ -2507,6 +2547,85 @@ public final class ActivityThread { } } // Instantiate a BackupAgent and tell it that it's alive private final void handleCreateBackupAgent(CreateBackupAgentData data) { if (DEBUG_BACKUP) Log.v(TAG, "handleCreateBackupAgent: " + data); // no longer idle; we have backup work to do unscheduleGcIdler(); // instantiate the BackupAgent class named in the manifest PackageInfo packageInfo = getPackageInfoNoCheck(data.appInfo); String packageName = packageInfo.mPackageName; if (mBackupAgents.get(packageName) != null) { Log.d(TAG, "BackupAgent " + " for " + packageName + " already exists"); return; } BackupAgent agent = null; String classname = data.appInfo.backupAgentName; if (classname == null) { if (data.backupMode == IApplicationThread.BACKUP_MODE_INCREMENTAL) { Log.e(TAG, "Attempted incremental backup but no defined agent for " + packageName); return; } classname = "android.app.FullBackupAgent"; } try { java.lang.ClassLoader cl = packageInfo.getClassLoader(); agent = (BackupAgent) cl.loadClass(data.appInfo.backupAgentName).newInstance(); } catch (Exception e) { throw new RuntimeException("Unable to instantiate backup agent " + data.appInfo.backupAgentName + ": " + e.toString(), e); } // set up the agent's context try { if (DEBUG_BACKUP) Log.v(TAG, "Initializing BackupAgent " + data.appInfo.backupAgentName); ApplicationContext context = new ApplicationContext(); context.init(packageInfo, null, this); context.setOuterContext(agent); agent.attach(context); agent.onCreate(); // tell the OS that we're live now IBinder binder = agent.onBind(); try { ActivityManagerNative.getDefault().backupAgentCreated(packageName, binder); } catch (RemoteException e) { // nothing to do. } mBackupAgents.put(packageName, agent); } catch (Exception e) { throw new RuntimeException("Unable to create BackupAgent " + data.appInfo.backupAgentName + ": " + e.toString(), e); } } // Tear down a BackupAgent private final void handleDestroyBackupAgent(CreateBackupAgentData data) { if (DEBUG_BACKUP) Log.v(TAG, "handleDestroyBackupAgent: " + data); PackageInfo packageInfo = getPackageInfoNoCheck(data.appInfo); String packageName = packageInfo.mPackageName; BackupAgent agent = mBackupAgents.get(packageName); if (agent != null) { try { agent.onDestroy(); } catch (Exception e) { Log.w(TAG, "Exception thrown in onDestroy by backup agent of " + data.appInfo); e.printStackTrace(); } mBackupAgents.remove(packageName); } else { Log.w(TAG, "Attempt to destroy unknown backup agent " + data); } } private final void handleCreateService(CreateServiceData data) { // If we are getting ready to gc after going to the background, well // we are back active so skip it. Loading @@ -2532,7 +2651,7 @@ public final class ActivityThread { ApplicationContext context = new ApplicationContext(); context.init(packageInfo, null, this); Application app = packageInfo.makeApplication(); Application app = packageInfo.makeApplication(false); context.setOuterContext(service); service.attach(context, this, data.info.name, data.token, app, ActivityManagerNative.getDefault()); Loading Loading @@ -3694,7 +3813,9 @@ public final class ActivityThread { mInstrumentation = new Instrumentation(); } Application app = data.info.makeApplication(); // If the app is being launched for full backup or restore, bring it up in // a restricted environment with the base application class. Application app = data.info.makeApplication(data.restrictedBackupMode); mInitialApplication = app; List<ProviderInfo> providers = data.providers; Loading