Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 748a8dfd authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Support Application class" into main

parents 1757b7fc 88fe9528
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2948,6 +2948,7 @@ public final class ActivityThread extends ClientTransactionHandler
    }

    @UnsupportedAppUsage
    @android.ravenwood.annotation.RavenwoodRedirect
    public static Application currentApplication() {
        ActivityThread am = currentActivityThread();
        return am != null ? am.mInitialApplication : null;
+23 −5
Original line number Diff line number Diff line
@@ -26,15 +26,33 @@ public class ActivityThread_ravenwood {
    private ActivityThread_ravenwood() {
    }

    private static volatile Context sContext;
    /**
     * 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(Context context) {
        sContext = Objects.requireNonNull(context);
    public static void init(Application application, Context systemContext) {
        sApplication = Objects.requireNonNull(application);
        sSystemContext = Objects.requireNonNull(application);
    }

    /** Override {@link ActivityThread#currentSystemContext()}. */
    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 Objects.requireNonNull(sContext, "ActivityThread_ravenwood not initialized.");
        return ensureInitialized(sSystemContext);
    }

    /** Override the corresponding ActivityThread method. */
    public static Application currentApplication() {
        return ensureInitialized(sApplication);
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import java.util.ArrayList;
 * <code>getInstance()</code> method.
 * </p>
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class Application extends ContextWrapper implements ComponentCallbacks2 {
    private static final String TAG = "Application";

@@ -65,6 +66,7 @@ public class Application extends ContextWrapper implements ComponentCallbacks2 {

    /** @hide */
    @UnsupportedAppUsage
    @android.ravenwood.annotation.RavenwoodRemove(blockedBy = LoadedApk.class)
    public LoadedApk mLoadedApk;

    public interface ActivityLifecycleCallbacks {
@@ -344,6 +346,11 @@ public class Application extends ContextWrapper implements ComponentCallbacks2 {
    @UnsupportedAppUsage
    /* package */ final void attach(Context context) {
        attachBaseContext(context);
        setLoadedApk(context);
    }

    @android.ravenwood.annotation.RavenwoodIgnore(blockedBy = LoadedApk.class)
    private void setLoadedApk(Context context) {
        mLoadedApk = ContextImpl.getImpl(context).mPackageInfo;
    }

@@ -607,6 +614,7 @@ public class Application extends ContextWrapper implements ComponentCallbacks2 {

    /** @hide */
    @Override
    @android.ravenwood.annotation.RavenwoodIgnore(blockedBy = AutofillManager.class)
    public AutofillManager.AutofillClient getAutofillClient() {
        final AutofillManager.AutofillClient client = super.getAutofillClient();
        if (client != null) {
+31 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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;

import android.content.Context;

/**
 * Used on Ravenwood to access {@link Application}'s package private APIs.
 *
 * Unlike the name suggests, this is not used as a @RavenwoodRedirect class.
 * It's more of a "reverse" redirect class.
 */
public class Application_ravenwood {
    /** Calls {@link Application#attach} */
    public static void attach(Application application, Context context) {
        application.attach(context);
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import java.util.function.Consumer;
 *
 * @hide
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class ComponentCallbacksController {
    @GuardedBy("mLock")
    private List<ComponentCallbacks> mComponentCallbacks;
Loading