Loading core/java/android/app/ActivityThread.java +3 −1 Original line number Diff line number Diff line Loading @@ -302,7 +302,9 @@ import java.util.function.Consumer; * {@hide} */ @android.ravenwood.annotation.RavenwoodPartiallyAllowlisted @android.ravenwood.annotation.RavenwoodKeepPartialClass @android.ravenwood.annotation.RavenwoodKeepPartialClass( comment = "We use Objenesis to instantiate it. No member fields are initialized." ) @android.ravenwood.annotation.RavenwoodRedirectionClass("ActivityThread_ravenwood") public final class ActivityThread extends ClientTransactionHandler implements ActivityThreadInternal { Loading core/java/android/app/ActivityThread_ravenwood.java +3 −24 Original line number Diff line number Diff line Loading @@ -16,8 +16,7 @@ package android.app; import android.content.Context; import java.util.Objects; import android.platform.test.ravenwood.RavenwoodAppDriver; /** * Inject Ravenwood methods to {@link ActivityThread}. Loading @@ -26,33 +25,13 @@ public class ActivityThread_ravenwood { private ActivityThread_ravenwood() { } /** * Equivalent to {@link ActivityThread#mInitialApplication}. */ private static volatile Application sApplication; /** * Equivalent to {@link ActivityThread#getSystemContext}. */ private static volatile Context sSystemContext; /** Initializer called by Ravenwood. */ public static void init(Application application, Context systemContext) { sApplication = Objects.requireNonNull(application); sSystemContext = Objects.requireNonNull(application); } private static <T> T ensureInitialized(T object) { return Objects.requireNonNull(object, "ActivityThread_ravenwood not initialized"); } /** Override the corresponding ActivityThread method. */ public static Context currentSystemContext() { return ensureInitialized(sSystemContext); return RavenwoodAppDriver.getInstance().getAndroidAppBridge().getSystemContext(); } /** Override the corresponding ActivityThread method. */ public static Application currentApplication() { return ensureInitialized(sApplication); return RavenwoodAppDriver.getInstance().getApplication(); } } core/java/android/app/AppComponentFactory.java +2 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.content.BroadcastReceiver; import android.content.ContentProvider; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.ravenwood.annotation.RavenwoodKeepWholeClass; /** * Interface used to control the instantiation of manifest elements. Loading @@ -32,6 +33,7 @@ import android.content.pm.ApplicationInfo; * @see #instantiateReceiver * @see #instantiateProvider */ @RavenwoodKeepWholeClass public class AppComponentFactory { /** Loading core/java/android/app/ContextImpl.java +60 −3 Original line number Diff line number Diff line Loading @@ -85,6 +85,12 @@ import android.os.UserManager; import android.os.storage.StorageManager; import android.permission.PermissionControllerManager; import android.permission.PermissionManager; import android.ravenwood.annotation.RavenwoodIgnore; import android.ravenwood.annotation.RavenwoodKeep; import android.ravenwood.annotation.RavenwoodKeepPartialClass; import android.ravenwood.annotation.RavenwoodRedirect; import android.ravenwood.annotation.RavenwoodRedirectionClass; import android.ravenwood.annotation.RavenwoodReplace; import android.system.ErrnoException; import android.system.Os; import android.system.OsConstants; Loading Loading @@ -198,6 +204,8 @@ class ReceiverRestrictedContext extends ContextWrapper { * Common implementation of Context API, which provides the base * context object for Activity and other application components. */ @RavenwoodKeepPartialClass @RavenwoodRedirectionClass("ContextImpl_ravenwood") class ContextImpl extends Context { private final static String TAG = "ContextImpl"; private final static boolean DEBUG = false; Loading Loading @@ -244,7 +252,7 @@ class ContextImpl extends Context { @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) private final String mOpPackageName; private final @NonNull ContextParams mParams; private @NonNull AttributionSource mAttributionSource; private @NonNull AttributionSource mAttributionSource; // Used by supported API private final @NonNull ResourcesManager mResourcesManager; @UnsupportedAppUsage Loading Loading @@ -373,7 +381,16 @@ class ContextImpl extends Context { // The system service cache for the system services that are cached per-ContextImpl. @UnsupportedAppUsage final Object[] mServiceCache = SystemServiceRegistry.createServiceCache(); final Object[] mServiceCache = createServiceCache(); @RavenwoodReplace private static Object[] createServiceCache() { return SystemServiceRegistry.createServiceCache(); } private static Object[] createServiceCache$ravenwood() { return new Object[0]; } static final int STATE_UNINITIALIZED = 0; static final int STATE_INITIALIZING = 1; Loading Loading @@ -426,11 +443,13 @@ class ContextImpl extends Context { } @Override @RavenwoodKeep public AssetManager getAssets() { return getResources().getAssets(); } @Override @RavenwoodKeep public Resources getResources() { return mResources; } Loading @@ -456,22 +475,26 @@ class ContextImpl extends Context { } @Override @RavenwoodKeep public Looper getMainLooper() { return mMainThread.getLooper(); } @Override @RavenwoodKeep public Executor getMainExecutor() { return mMainThread.getExecutor(); } @Override @RavenwoodKeep public Context getApplicationContext() { return (mPackageInfo != null) ? mPackageInfo.getApplication() : mMainThread.getApplication(); } @Override @RavenwoodKeep public void setTheme(int resId) { synchronized (mThemeLock) { if (mThemeResource != resId) { Loading Loading @@ -511,11 +534,13 @@ class ContextImpl extends Context { } @Override @RavenwoodKeep public ClassLoader getClassLoader() { return mClassLoader != null ? mClassLoader : (mPackageInfo != null ? mPackageInfo.getClassLoader() : ClassLoader.getSystemClassLoader()); } @Override @RavenwoodKeep public String getPackageName() { if (mPackageInfo != null) { return mPackageInfo.getPackageName(); Loading @@ -527,28 +552,33 @@ class ContextImpl extends Context { /** @hide */ @Override @RavenwoodKeep public String getBasePackageName() { return mBasePackageName != null ? mBasePackageName : getPackageName(); } /** @hide */ @Override @RavenwoodKeep public String getOpPackageName() { return mAttributionSource.getPackageName(); } /** @hide */ @Override @RavenwoodKeep public @Nullable String getAttributionTag() { return mAttributionSource.getAttributionTag(); } @Override @RavenwoodKeep public @Nullable ContextParams getParams() { return mParams; } @Override @RavenwoodKeep public @NonNull AttributionSource getAttributionSource() { return mAttributionSource; } Loading Loading @@ -2209,6 +2239,7 @@ class ContextImpl extends Context { /** @hide */ @Override @RavenwoodKeep public Handler getMainThreadHandler() { return mMainThread.getHandler(); } Loading Loading @@ -2956,6 +2987,7 @@ class ContextImpl extends Context { updateResourceOverlayConstraints(); } @RavenwoodKeep private void updateResourceOverlayConstraints() { if (mResources != null) { // Avoid calling getDisplay() here, as it makes a binder call into Loading Loading @@ -3147,6 +3179,7 @@ class ContextImpl extends Context { } @Override @RavenwoodKeep public boolean isRestricted() { return (mFlags & Context.CONTEXT_RESTRICTED) != 0; } Loading Loading @@ -3280,6 +3313,7 @@ class ContextImpl extends Context { } @Override @RavenwoodKeep public int getDeviceId() { return mDeviceId; } Loading Loading @@ -3390,12 +3424,14 @@ class ContextImpl extends Context { /** {@hide} */ @Override @RavenwoodKeep public UserHandle getUser() { return mUser; } /** {@hide} */ @Override @RavenwoodKeep public int getUserId() { return mUser.getIdentifier(); } Loading Loading @@ -3437,8 +3473,14 @@ class ContextImpl extends Context { } @UnsupportedAppUsage @RavenwoodKeep static ContextImpl createSystemContext(ActivityThread mainThread) { LoadedApk packageInfo = new LoadedApk(mainThread); return createSystemContextInner(mainThread, packageInfo); } @RavenwoodKeep static ContextImpl createSystemContextInner(ActivityThread mainThread, LoadedApk packageInfo) { ContextImpl context = new ContextImpl(null, mainThread, packageInfo, ContextParams.EMPTY, null, null, null, null, null, 0, null, null, DEVICE_ID_DEFAULT, false); Loading Loading @@ -3553,6 +3595,7 @@ class ContextImpl extends Context { return context; } @RavenwoodKeep private ContextImpl(@Nullable ContextImpl container, @NonNull ActivityThread mainThread, @NonNull LoadedApk packageInfo, @NonNull ContextParams params, @Nullable String attributionTag, @Nullable AttributionSource nextAttributionSource, Loading Loading @@ -3626,6 +3669,7 @@ class ContextImpl extends Context { mContentResolver = newApplicationContentResolver(this, mainThread); } @RavenwoodKeep private @NonNull AttributionSource createAttributionSource(@Nullable String attributionTag, @Nullable AttributionSource nextAttributionSource, @Nullable Set<String> renouncedPermissions, boolean shouldRegister, Loading @@ -3648,6 +3692,7 @@ class ContextImpl extends Context { return registerAttributionSourceIfNeeded(oldSource.withDeviceId(deviceId), shouldRegister); } @RavenwoodReplace(blockedBy = PermissionManager.class) private @NonNull AttributionSource registerAttributionSourceIfNeeded( @NonNull AttributionSource attributionSource, boolean shouldRegister) { if (shouldRegister || attributionSource.getNext() != null) { Loading @@ -3657,6 +3702,12 @@ class ContextImpl extends Context { return attributionSource; } private @NonNull AttributionSource registerAttributionSourceIfNeeded$ravenwood( @NonNull AttributionSource attributionSource, boolean shouldRegister) { return attributionSource; } @RavenwoodKeep void setResources(Resources r) { if (r instanceof CompatResources) { ((CompatResources) r).setContext(this); Loading Loading @@ -3828,6 +3879,12 @@ class ContextImpl extends Context { // ---------------------------------------------------------------------- // ---------------------------------------------------------------------- @RavenwoodIgnore private static ApplicationContentResolver newApplicationContentResolver( Context context, ActivityThread mainThread) { return new ApplicationContentResolver(context, mainThread); } private static final class ApplicationContentResolver extends ContentResolver { @UnsupportedAppUsage private final ActivityThread mMainThread; Loading core/java/android/app/ContextImpl_ravenwood.java 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app; public class ContextImpl_ravenwood { } Loading
core/java/android/app/ActivityThread.java +3 −1 Original line number Diff line number Diff line Loading @@ -302,7 +302,9 @@ import java.util.function.Consumer; * {@hide} */ @android.ravenwood.annotation.RavenwoodPartiallyAllowlisted @android.ravenwood.annotation.RavenwoodKeepPartialClass @android.ravenwood.annotation.RavenwoodKeepPartialClass( comment = "We use Objenesis to instantiate it. No member fields are initialized." ) @android.ravenwood.annotation.RavenwoodRedirectionClass("ActivityThread_ravenwood") public final class ActivityThread extends ClientTransactionHandler implements ActivityThreadInternal { Loading
core/java/android/app/ActivityThread_ravenwood.java +3 −24 Original line number Diff line number Diff line Loading @@ -16,8 +16,7 @@ package android.app; import android.content.Context; import java.util.Objects; import android.platform.test.ravenwood.RavenwoodAppDriver; /** * Inject Ravenwood methods to {@link ActivityThread}. Loading @@ -26,33 +25,13 @@ public class ActivityThread_ravenwood { private ActivityThread_ravenwood() { } /** * Equivalent to {@link ActivityThread#mInitialApplication}. */ private static volatile Application sApplication; /** * Equivalent to {@link ActivityThread#getSystemContext}. */ private static volatile Context sSystemContext; /** Initializer called by Ravenwood. */ public static void init(Application application, Context systemContext) { sApplication = Objects.requireNonNull(application); sSystemContext = Objects.requireNonNull(application); } private static <T> T ensureInitialized(T object) { return Objects.requireNonNull(object, "ActivityThread_ravenwood not initialized"); } /** Override the corresponding ActivityThread method. */ public static Context currentSystemContext() { return ensureInitialized(sSystemContext); return RavenwoodAppDriver.getInstance().getAndroidAppBridge().getSystemContext(); } /** Override the corresponding ActivityThread method. */ public static Application currentApplication() { return ensureInitialized(sApplication); return RavenwoodAppDriver.getInstance().getApplication(); } }
core/java/android/app/AppComponentFactory.java +2 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.content.BroadcastReceiver; import android.content.ContentProvider; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.ravenwood.annotation.RavenwoodKeepWholeClass; /** * Interface used to control the instantiation of manifest elements. Loading @@ -32,6 +33,7 @@ import android.content.pm.ApplicationInfo; * @see #instantiateReceiver * @see #instantiateProvider */ @RavenwoodKeepWholeClass public class AppComponentFactory { /** Loading
core/java/android/app/ContextImpl.java +60 −3 Original line number Diff line number Diff line Loading @@ -85,6 +85,12 @@ import android.os.UserManager; import android.os.storage.StorageManager; import android.permission.PermissionControllerManager; import android.permission.PermissionManager; import android.ravenwood.annotation.RavenwoodIgnore; import android.ravenwood.annotation.RavenwoodKeep; import android.ravenwood.annotation.RavenwoodKeepPartialClass; import android.ravenwood.annotation.RavenwoodRedirect; import android.ravenwood.annotation.RavenwoodRedirectionClass; import android.ravenwood.annotation.RavenwoodReplace; import android.system.ErrnoException; import android.system.Os; import android.system.OsConstants; Loading Loading @@ -198,6 +204,8 @@ class ReceiverRestrictedContext extends ContextWrapper { * Common implementation of Context API, which provides the base * context object for Activity and other application components. */ @RavenwoodKeepPartialClass @RavenwoodRedirectionClass("ContextImpl_ravenwood") class ContextImpl extends Context { private final static String TAG = "ContextImpl"; private final static boolean DEBUG = false; Loading Loading @@ -244,7 +252,7 @@ class ContextImpl extends Context { @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) private final String mOpPackageName; private final @NonNull ContextParams mParams; private @NonNull AttributionSource mAttributionSource; private @NonNull AttributionSource mAttributionSource; // Used by supported API private final @NonNull ResourcesManager mResourcesManager; @UnsupportedAppUsage Loading Loading @@ -373,7 +381,16 @@ class ContextImpl extends Context { // The system service cache for the system services that are cached per-ContextImpl. @UnsupportedAppUsage final Object[] mServiceCache = SystemServiceRegistry.createServiceCache(); final Object[] mServiceCache = createServiceCache(); @RavenwoodReplace private static Object[] createServiceCache() { return SystemServiceRegistry.createServiceCache(); } private static Object[] createServiceCache$ravenwood() { return new Object[0]; } static final int STATE_UNINITIALIZED = 0; static final int STATE_INITIALIZING = 1; Loading Loading @@ -426,11 +443,13 @@ class ContextImpl extends Context { } @Override @RavenwoodKeep public AssetManager getAssets() { return getResources().getAssets(); } @Override @RavenwoodKeep public Resources getResources() { return mResources; } Loading @@ -456,22 +475,26 @@ class ContextImpl extends Context { } @Override @RavenwoodKeep public Looper getMainLooper() { return mMainThread.getLooper(); } @Override @RavenwoodKeep public Executor getMainExecutor() { return mMainThread.getExecutor(); } @Override @RavenwoodKeep public Context getApplicationContext() { return (mPackageInfo != null) ? mPackageInfo.getApplication() : mMainThread.getApplication(); } @Override @RavenwoodKeep public void setTheme(int resId) { synchronized (mThemeLock) { if (mThemeResource != resId) { Loading Loading @@ -511,11 +534,13 @@ class ContextImpl extends Context { } @Override @RavenwoodKeep public ClassLoader getClassLoader() { return mClassLoader != null ? mClassLoader : (mPackageInfo != null ? mPackageInfo.getClassLoader() : ClassLoader.getSystemClassLoader()); } @Override @RavenwoodKeep public String getPackageName() { if (mPackageInfo != null) { return mPackageInfo.getPackageName(); Loading @@ -527,28 +552,33 @@ class ContextImpl extends Context { /** @hide */ @Override @RavenwoodKeep public String getBasePackageName() { return mBasePackageName != null ? mBasePackageName : getPackageName(); } /** @hide */ @Override @RavenwoodKeep public String getOpPackageName() { return mAttributionSource.getPackageName(); } /** @hide */ @Override @RavenwoodKeep public @Nullable String getAttributionTag() { return mAttributionSource.getAttributionTag(); } @Override @RavenwoodKeep public @Nullable ContextParams getParams() { return mParams; } @Override @RavenwoodKeep public @NonNull AttributionSource getAttributionSource() { return mAttributionSource; } Loading Loading @@ -2209,6 +2239,7 @@ class ContextImpl extends Context { /** @hide */ @Override @RavenwoodKeep public Handler getMainThreadHandler() { return mMainThread.getHandler(); } Loading Loading @@ -2956,6 +2987,7 @@ class ContextImpl extends Context { updateResourceOverlayConstraints(); } @RavenwoodKeep private void updateResourceOverlayConstraints() { if (mResources != null) { // Avoid calling getDisplay() here, as it makes a binder call into Loading Loading @@ -3147,6 +3179,7 @@ class ContextImpl extends Context { } @Override @RavenwoodKeep public boolean isRestricted() { return (mFlags & Context.CONTEXT_RESTRICTED) != 0; } Loading Loading @@ -3280,6 +3313,7 @@ class ContextImpl extends Context { } @Override @RavenwoodKeep public int getDeviceId() { return mDeviceId; } Loading Loading @@ -3390,12 +3424,14 @@ class ContextImpl extends Context { /** {@hide} */ @Override @RavenwoodKeep public UserHandle getUser() { return mUser; } /** {@hide} */ @Override @RavenwoodKeep public int getUserId() { return mUser.getIdentifier(); } Loading Loading @@ -3437,8 +3473,14 @@ class ContextImpl extends Context { } @UnsupportedAppUsage @RavenwoodKeep static ContextImpl createSystemContext(ActivityThread mainThread) { LoadedApk packageInfo = new LoadedApk(mainThread); return createSystemContextInner(mainThread, packageInfo); } @RavenwoodKeep static ContextImpl createSystemContextInner(ActivityThread mainThread, LoadedApk packageInfo) { ContextImpl context = new ContextImpl(null, mainThread, packageInfo, ContextParams.EMPTY, null, null, null, null, null, 0, null, null, DEVICE_ID_DEFAULT, false); Loading Loading @@ -3553,6 +3595,7 @@ class ContextImpl extends Context { return context; } @RavenwoodKeep private ContextImpl(@Nullable ContextImpl container, @NonNull ActivityThread mainThread, @NonNull LoadedApk packageInfo, @NonNull ContextParams params, @Nullable String attributionTag, @Nullable AttributionSource nextAttributionSource, Loading Loading @@ -3626,6 +3669,7 @@ class ContextImpl extends Context { mContentResolver = newApplicationContentResolver(this, mainThread); } @RavenwoodKeep private @NonNull AttributionSource createAttributionSource(@Nullable String attributionTag, @Nullable AttributionSource nextAttributionSource, @Nullable Set<String> renouncedPermissions, boolean shouldRegister, Loading @@ -3648,6 +3692,7 @@ class ContextImpl extends Context { return registerAttributionSourceIfNeeded(oldSource.withDeviceId(deviceId), shouldRegister); } @RavenwoodReplace(blockedBy = PermissionManager.class) private @NonNull AttributionSource registerAttributionSourceIfNeeded( @NonNull AttributionSource attributionSource, boolean shouldRegister) { if (shouldRegister || attributionSource.getNext() != null) { Loading @@ -3657,6 +3702,12 @@ class ContextImpl extends Context { return attributionSource; } private @NonNull AttributionSource registerAttributionSourceIfNeeded$ravenwood( @NonNull AttributionSource attributionSource, boolean shouldRegister) { return attributionSource; } @RavenwoodKeep void setResources(Resources r) { if (r instanceof CompatResources) { ((CompatResources) r).setContext(this); Loading Loading @@ -3828,6 +3879,12 @@ class ContextImpl extends Context { // ---------------------------------------------------------------------- // ---------------------------------------------------------------------- @RavenwoodIgnore private static ApplicationContentResolver newApplicationContentResolver( Context context, ActivityThread mainThread) { return new ApplicationContentResolver(context, mainThread); } private static final class ApplicationContentResolver extends ContentResolver { @UnsupportedAppUsage private final ActivityThread mMainThread; Loading
core/java/android/app/ContextImpl_ravenwood.java 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app; public class ContextImpl_ravenwood { }