diff options
| -rw-r--r-- | libartservice/service/java/com/android/server/art/DexUseManagerLocal.java | 6 | ||||
| -rw-r--r-- | libartservice/service/javatests/com/android/server/art/DexUseManagerTest.java | 20 |
2 files changed, 14 insertions, 12 deletions
diff --git a/libartservice/service/java/com/android/server/art/DexUseManagerLocal.java b/libartservice/service/java/com/android/server/art/DexUseManagerLocal.java index fc30e359f7..8d47cb6ba0 100644 --- a/libartservice/service/java/com/android/server/art/DexUseManagerLocal.java +++ b/libartservice/service/java/com/android/server/art/DexUseManagerLocal.java @@ -413,7 +413,7 @@ public class DexUseManagerLocal { // TODO(jiakaiz): Investigate whether it should also be considered as isolated process if // `Process.isSdkSandboxUid` returns true. - boolean isolatedProcess = Process.isIsolatedUid(mInjector.getCallingUid()); + boolean isolatedProcess = mInjector.isIsolatedUid(mInjector.getCallingUid()); long lastUsedAtMs = mInjector.getCurrentTimeMillis(); for (var entry : classLoaderContextByDexContainerFile.entrySet()) { @@ -1400,5 +1400,9 @@ public class DexUseManagerLocal { public int getCallingUid() { return Binder.getCallingUid(); } + + public boolean isIsolatedUid(int uid) { + return Process.isIsolatedUid(uid); + } } } diff --git a/libartservice/service/javatests/com/android/server/art/DexUseManagerTest.java b/libartservice/service/javatests/com/android/server/art/DexUseManagerTest.java index 3ea3509b82..d404b4cbda 100644 --- a/libartservice/service/javatests/com/android/server/art/DexUseManagerTest.java +++ b/libartservice/service/javatests/com/android/server/art/DexUseManagerTest.java @@ -36,7 +36,6 @@ import android.content.Context; import android.content.Intent; import android.os.Binder; import android.os.Environment; -import android.os.Process; import android.os.SystemProperties; import android.os.UserHandle; import android.os.storage.StorageManager; @@ -88,7 +87,7 @@ public class DexUseManagerTest { @Rule public StaticMockitoRule mockitoRule = new StaticMockitoRule( - SystemProperties.class, Constants.class, Process.class, ArtJni.class); + SystemProperties.class, Constants.class, ArtJni.class); private final UserHandle mUserHandle = UserHandle.of(1); @@ -125,8 +124,6 @@ public class DexUseManagerTest { lenient().when(Constants.getNative64BitAbi()).thenReturn("arm64-v8a"); lenient().when(Constants.getNative32BitAbi()).thenReturn("armeabi-v7a"); - lenient().when(Process.isIsolatedUid(anyInt())).thenReturn(false); - // Use a LinkedHashMap so that we can control the iteration order. mPackageStates = new LinkedHashMap<>(); @@ -187,6 +184,7 @@ public class DexUseManagerTest { lenient().when(mInjector.getPackageManagerLocal()).thenReturn(mPackageManagerLocal); lenient().when(mInjector.getCallingUserHandle()).thenReturn(mUserHandle); lenient().when(mInjector.getCallingUid()).thenReturn(110001); + lenient().when(mInjector.isIsolatedUid(anyInt())).thenReturn(false); mDexUseManager = new DexUseManagerLocal(mInjector); mDexUseManager.systemReady(); @@ -208,7 +206,7 @@ public class DexUseManagerTest { @Test public void testPrimaryDexOwnedIsolated() { - when(Process.isIsolatedUid(anyInt())).thenReturn(true); + when(mInjector.isIsolatedUid(anyInt())).thenReturn(true); mDexUseManager.notifyDexContainersLoaded( mSnapshot, OWNING_PKG_NAME, Map.of(BASE_APK, "CLC")); @@ -223,7 +221,7 @@ public class DexUseManagerTest { @Test public void testPrimaryDexOwnedSplitIsolated() { - when(Process.isIsolatedUid(anyInt())).thenReturn(true); + when(mInjector.isIsolatedUid(anyInt())).thenReturn(true); mDexUseManager.notifyDexContainersLoaded( mSnapshot, OWNING_PKG_NAME, Map.of(SPLIT_APK, "CLC")); @@ -317,7 +315,7 @@ public class DexUseManagerTest { mDexUseManager.notifyDexContainersLoaded( mSnapshot, LOADING_PKG_NAME, Map.of(BASE_APK, "CLC")); - when(Process.isIsolatedUid(anyInt())).thenReturn(true); + when(mInjector.isIsolatedUid(anyInt())).thenReturn(true); mDexUseManager.notifyDexContainersLoaded( mSnapshot, OWNING_PKG_NAME, Map.of(BASE_APK, "CLC")); when(mInjector.getCurrentTimeMillis()).thenReturn(2000l); @@ -367,7 +365,7 @@ public class DexUseManagerTest { @Test public void testSecondaryDexOwnedIsolated() { - when(Process.isIsolatedUid(anyInt())).thenReturn(true); + when(mInjector.isIsolatedUid(anyInt())).thenReturn(true); mDexUseManager.notifyDexContainersLoaded( mSnapshot, OWNING_PKG_NAME, Map.of(mDeDir + "/foo.apk", "CLC")); @@ -529,7 +527,7 @@ public class DexUseManagerTest { mDexUseManager.notifyDexContainersLoaded(mSnapshot, OWNING_PKG_NAME, Map.of(mCeDir + "/baz.apk", SecondaryDexInfo.UNSUPPORTED_CLASS_LOADER_CONTEXT)); - when(Process.isIsolatedUid(anyInt())).thenReturn(true); + when(mInjector.isIsolatedUid(anyInt())).thenReturn(true); mDexUseManager.notifyDexContainersLoaded( mSnapshot, OWNING_PKG_NAME, Map.of(mCeDir + "/foo.apk", "CLC")); when(mInjector.getCurrentTimeMillis()).thenReturn(2000l); @@ -618,7 +616,7 @@ public class DexUseManagerTest { mDexUseManager.notifyDexContainersLoaded( mSnapshot, LOADING_PKG_NAME, Map.of(mCeDir + "/foo.apk", "CLC")); - when(Process.isIsolatedUid(anyInt())).thenReturn(true); + when(mInjector.isIsolatedUid(anyInt())).thenReturn(true); mDexUseManager.notifyDexContainersLoaded( mSnapshot, OWNING_PKG_NAME, Map.of(mCeDir + "/foo.apk", "CLC")); @@ -666,7 +664,7 @@ public class DexUseManagerTest { mDexUseManager.notifyDexContainersLoaded( mSnapshot, LOADING_PKG_NAME, Map.of(mCeDir + "/foo.apk", "CLC")); - when(Process.isIsolatedUid(anyInt())).thenReturn(true); + when(mInjector.isIsolatedUid(anyInt())).thenReturn(true); mDexUseManager.notifyDexContainersLoaded( mSnapshot, OWNING_PKG_NAME, Map.of(mCeDir + "/foo.apk", "CLC")); |