Loading core/java/android/app/ActivityThread.java +30 −20 Original line number Diff line number Diff line Loading @@ -1157,6 +1157,10 @@ public final class ActivityThread extends ClientTransactionHandler { sendMessage(H.ATTACH_AGENT, agent); } public void attachStartupAgents(String dataDir) { sendMessage(H.ATTACH_STARTUP_AGENTS, dataDir); } public void setSchedulingGroup(int group) { // Note: do this immediately, since going into the foreground // should happen regardless of what pending work we have to do Loading Loading @@ -1806,6 +1810,7 @@ public final class ActivityThread extends ClientTransactionHandler { public static final int EXECUTE_TRANSACTION = 159; public static final int RELAUNCH_ACTIVITY = 160; public static final int PURGE_RESOURCES = 161; public static final int ATTACH_STARTUP_AGENTS = 162; String codeToString(int code) { if (DEBUG_MESSAGES) { Loading Loading @@ -1849,6 +1854,7 @@ public final class ActivityThread extends ClientTransactionHandler { case EXECUTE_TRANSACTION: return "EXECUTE_TRANSACTION"; case RELAUNCH_ACTIVITY: return "RELAUNCH_ACTIVITY"; case PURGE_RESOURCES: return "PURGE_RESOURCES"; case ATTACH_STARTUP_AGENTS: return "ATTACH_STARTUP_AGENTS"; } } return Integer.toString(code); Loading Loading @@ -2031,6 +2037,9 @@ public final class ActivityThread extends ClientTransactionHandler { case PURGE_RESOURCES: schedulePurgeIdler(); break; case ATTACH_STARTUP_AGENTS: handleAttachStartupAgents((String) msg.obj); break; } Object obj = msg.obj; if (obj instanceof SomeArgs) { Loading Loading @@ -3729,6 +3738,27 @@ public final class ActivityThread extends ClientTransactionHandler { } } static void handleAttachStartupAgents(String dataDir) { try { Path code_cache = ContextImpl.getCodeCacheDirBeforeBind(new File(dataDir)).toPath(); if (!Files.exists(code_cache)) { return; } Path startup_path = code_cache.resolve("startup_agents"); if (Files.exists(startup_path)) { for (Path p : Files.newDirectoryStream(startup_path)) { handleAttachAgent( p.toAbsolutePath().toString() + "=" + dataDir, null); } } } catch (Exception e) { // Ignored. } } private static final ThreadLocal<Intent> sCurrentBroadcastIntent = new ThreadLocal<Intent>(); /** Loading Loading @@ -6366,26 +6396,6 @@ public final class ActivityThread extends ClientTransactionHandler { NetworkSecurityConfigProvider.install(appContext); Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); if (isAppDebuggable) { try { // Load all the agents in the code_cache/startup_agents directory. // We pass the absolute path to the data_dir as an argument. Path startup_path = appContext.getCodeCacheDir().toPath().resolve("startup_agents"); if (Files.exists(startup_path)) { for (Path p : Files.newDirectoryStream(startup_path)) { handleAttachAgent( p.toAbsolutePath().toString() + "=" + appContext.getDataDir().toPath().toAbsolutePath().toString(), data.info); } } } catch (Exception e) { // Ignored. } } // Continue loading instrumentation. if (ii != null) { ApplicationInfo instrApp; Loading core/java/android/app/ContextImpl.java +10 −1 Original line number Diff line number Diff line Loading @@ -739,12 +739,21 @@ class ContextImpl extends Context { public File getCodeCacheDir() { synchronized (mSync) { if (mCodeCacheDir == null) { mCodeCacheDir = new File(getDataDir(), "code_cache"); mCodeCacheDir = getCodeCacheDirBeforeBind(getDataDir()); } return ensurePrivateCacheDirExists(mCodeCacheDir, XATTR_INODE_CODE_CACHE); } } /** * Helper for getting code-cache dir potentially before application bind. * * @hide */ static File getCodeCacheDirBeforeBind(File dataDir) { return new File(dataDir, "code_cache"); } @Override public File getExternalCacheDir() { // Operates on primary external storage Loading core/java/android/app/IApplicationThread.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ oneway interface IApplicationThread { IVoiceInteractor voiceInteractor); void handleTrustStorageUpdate(); void attachAgent(String path); void attachStartupAgents(String dataDir); void scheduleApplicationInfoChanged(in ApplicationInfo ai); void setNetworkBlockSeq(long procStateSeq); void scheduleTransaction(in ClientTransaction transaction); Loading core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java +4 −0 Original line number Diff line number Diff line Loading @@ -610,6 +610,10 @@ public class TransactionParcelTests { public void attachAgent(String s) throws RemoteException { } @Override public void attachStartupAgents(String s) throws RemoteException { } @Override public void scheduleApplicationInfoChanged(ApplicationInfo applicationInfo) throws RemoteException { Loading services/core/java/com/android/server/am/ActivityManagerService.java +4 −2 Original line number Diff line number Diff line Loading @@ -271,8 +271,8 @@ import android.os.WorkSource; import android.os.storage.IStorageManager; import android.os.storage.StorageManager; import android.provider.DeviceConfig; import android.provider.Settings; import android.provider.DeviceConfig.Properties; import android.provider.Settings; import android.server.ServerProtoEnums; import android.sysprop.VoldProperties; import android.text.TextUtils; Loading Loading @@ -5013,7 +5013,9 @@ public class ActivityManagerService extends IActivityManager.Stub if (preBindAgent != null) { thread.attachAgent(preBindAgent); } if ((app.info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { thread.attachStartupAgents(app.info.dataDir); } // Figure out whether the app needs to run in autofill compat mode. AutofillOptions autofillOptions = null; Loading Loading
core/java/android/app/ActivityThread.java +30 −20 Original line number Diff line number Diff line Loading @@ -1157,6 +1157,10 @@ public final class ActivityThread extends ClientTransactionHandler { sendMessage(H.ATTACH_AGENT, agent); } public void attachStartupAgents(String dataDir) { sendMessage(H.ATTACH_STARTUP_AGENTS, dataDir); } public void setSchedulingGroup(int group) { // Note: do this immediately, since going into the foreground // should happen regardless of what pending work we have to do Loading Loading @@ -1806,6 +1810,7 @@ public final class ActivityThread extends ClientTransactionHandler { public static final int EXECUTE_TRANSACTION = 159; public static final int RELAUNCH_ACTIVITY = 160; public static final int PURGE_RESOURCES = 161; public static final int ATTACH_STARTUP_AGENTS = 162; String codeToString(int code) { if (DEBUG_MESSAGES) { Loading Loading @@ -1849,6 +1854,7 @@ public final class ActivityThread extends ClientTransactionHandler { case EXECUTE_TRANSACTION: return "EXECUTE_TRANSACTION"; case RELAUNCH_ACTIVITY: return "RELAUNCH_ACTIVITY"; case PURGE_RESOURCES: return "PURGE_RESOURCES"; case ATTACH_STARTUP_AGENTS: return "ATTACH_STARTUP_AGENTS"; } } return Integer.toString(code); Loading Loading @@ -2031,6 +2037,9 @@ public final class ActivityThread extends ClientTransactionHandler { case PURGE_RESOURCES: schedulePurgeIdler(); break; case ATTACH_STARTUP_AGENTS: handleAttachStartupAgents((String) msg.obj); break; } Object obj = msg.obj; if (obj instanceof SomeArgs) { Loading Loading @@ -3729,6 +3738,27 @@ public final class ActivityThread extends ClientTransactionHandler { } } static void handleAttachStartupAgents(String dataDir) { try { Path code_cache = ContextImpl.getCodeCacheDirBeforeBind(new File(dataDir)).toPath(); if (!Files.exists(code_cache)) { return; } Path startup_path = code_cache.resolve("startup_agents"); if (Files.exists(startup_path)) { for (Path p : Files.newDirectoryStream(startup_path)) { handleAttachAgent( p.toAbsolutePath().toString() + "=" + dataDir, null); } } } catch (Exception e) { // Ignored. } } private static final ThreadLocal<Intent> sCurrentBroadcastIntent = new ThreadLocal<Intent>(); /** Loading Loading @@ -6366,26 +6396,6 @@ public final class ActivityThread extends ClientTransactionHandler { NetworkSecurityConfigProvider.install(appContext); Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER); if (isAppDebuggable) { try { // Load all the agents in the code_cache/startup_agents directory. // We pass the absolute path to the data_dir as an argument. Path startup_path = appContext.getCodeCacheDir().toPath().resolve("startup_agents"); if (Files.exists(startup_path)) { for (Path p : Files.newDirectoryStream(startup_path)) { handleAttachAgent( p.toAbsolutePath().toString() + "=" + appContext.getDataDir().toPath().toAbsolutePath().toString(), data.info); } } } catch (Exception e) { // Ignored. } } // Continue loading instrumentation. if (ii != null) { ApplicationInfo instrApp; Loading
core/java/android/app/ContextImpl.java +10 −1 Original line number Diff line number Diff line Loading @@ -739,12 +739,21 @@ class ContextImpl extends Context { public File getCodeCacheDir() { synchronized (mSync) { if (mCodeCacheDir == null) { mCodeCacheDir = new File(getDataDir(), "code_cache"); mCodeCacheDir = getCodeCacheDirBeforeBind(getDataDir()); } return ensurePrivateCacheDirExists(mCodeCacheDir, XATTR_INODE_CODE_CACHE); } } /** * Helper for getting code-cache dir potentially before application bind. * * @hide */ static File getCodeCacheDirBeforeBind(File dataDir) { return new File(dataDir, "code_cache"); } @Override public File getExternalCacheDir() { // Operates on primary external storage Loading
core/java/android/app/IApplicationThread.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ oneway interface IApplicationThread { IVoiceInteractor voiceInteractor); void handleTrustStorageUpdate(); void attachAgent(String path); void attachStartupAgents(String dataDir); void scheduleApplicationInfoChanged(in ApplicationInfo ai); void setNetworkBlockSeq(long procStateSeq); void scheduleTransaction(in ClientTransaction transaction); Loading
core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java +4 −0 Original line number Diff line number Diff line Loading @@ -610,6 +610,10 @@ public class TransactionParcelTests { public void attachAgent(String s) throws RemoteException { } @Override public void attachStartupAgents(String s) throws RemoteException { } @Override public void scheduleApplicationInfoChanged(ApplicationInfo applicationInfo) throws RemoteException { Loading
services/core/java/com/android/server/am/ActivityManagerService.java +4 −2 Original line number Diff line number Diff line Loading @@ -271,8 +271,8 @@ import android.os.WorkSource; import android.os.storage.IStorageManager; import android.os.storage.StorageManager; import android.provider.DeviceConfig; import android.provider.Settings; import android.provider.DeviceConfig.Properties; import android.provider.Settings; import android.server.ServerProtoEnums; import android.sysprop.VoldProperties; import android.text.TextUtils; Loading Loading @@ -5013,7 +5013,9 @@ public class ActivityManagerService extends IActivityManager.Stub if (preBindAgent != null) { thread.attachAgent(preBindAgent); } if ((app.info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { thread.attachStartupAgents(app.info.dataDir); } // Figure out whether the app needs to run in autofill compat mode. AutofillOptions autofillOptions = null; Loading