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

Commit 04d9bf62 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move launcher activities to the back when back pressed on root task" into sc-dev

parents d9c4e6fa 50b3cc03
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -400,6 +400,9 @@ android.app.INotificationManager
android.app.IProcessObserver$Stub$Proxy
android.app.IProcessObserver$Stub
android.app.IProcessObserver
android.app.IRequestFinishCallback$Stub$Proxy
android.app.IRequestFinishCallback$Stub
android.app.IRequestFinishCallback
android.app.ISearchManager$Stub$Proxy
android.app.ISearchManager$Stub
android.app.ISearchManager
+19 −1
Original line number Diff line number Diff line
@@ -156,6 +156,7 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -3811,6 +3812,22 @@ public class Activity extends ContextThemeWrapper
        return false;
    }

    private static final class RequestFinishCallback extends IRequestFinishCallback.Stub {
        private final WeakReference<Activity> mActivityRef;

        RequestFinishCallback(WeakReference<Activity> activityRef) {
            mActivityRef = activityRef;
        }

        @Override
        public void requestFinish() {
            Activity activity = mActivityRef.get();
            if (activity != null) {
                activity.mHandler.post(activity::finishAfterTransition);
            }
        }
    }

    /**
     * Called when the activity has detected the user's press of the back
     * key.  The default implementation simply finishes the current activity,
@@ -3834,7 +3851,8 @@ public class Activity extends ContextThemeWrapper
        // Inform activity task manager that the activity received a back press while at the
        // root of the task. This call allows ActivityTaskManager to intercept or move the task
        // to the back.
        ActivityClient.getInstance().onBackPressedOnTaskRoot(mToken);
        ActivityClient.getInstance().onBackPressedOnTaskRoot(mToken,
                new RequestFinishCallback(new WeakReference<>(this)));

        // Activity was launched when user tapped a link in the Autofill Save UI - Save UI must
        // be restored now.
+2 −2
Original line number Diff line number Diff line
@@ -480,9 +480,9 @@ public class ActivityClient {
        }
    }

    void onBackPressedOnTaskRoot(IBinder token) {
    void onBackPressedOnTaskRoot(IBinder token, IRequestFinishCallback callback) {
        try {
            getActivityClientController().onBackPressedOnTaskRoot(token);
            getActivityClientController().onBackPressedOnTaskRoot(token, callback);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
+3 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.app;

import android.app.ActivityManager;
import android.app.IRequestFinishCallback;
import android.app.PictureInPictureParams;
import android.content.ComponentName;
import android.content.Intent;
@@ -141,7 +142,8 @@ interface IActivityClientController {
     * Reports that an Activity received a back key press when there were no additional activities
     * on the back stack.
     */
    oneway void onBackPressedOnTaskRoot(in IBinder token);
    oneway void onBackPressedOnTaskRoot(in IBinder activityToken,
            in IRequestFinishCallback callback);

    /** Reports that the splash screen view has attached to activity.  */
    oneway void splashScreenAttached(in IBinder token);
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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;

/**
 * This callback allows ActivityTaskManager to ask the calling Activity
 * to finish in response to a call to onBackPressedOnTaskRoot.
 *
 * {@hide}
 */
oneway interface IRequestFinishCallback {
    void requestFinish();
}
Loading