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

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

Merge "Move task to back when the back button is pressed on root task"

parents 507092cf 2dec42fa
Loading
Loading
Loading
Loading
+0 −3
Original line number Original line Diff line number Diff line
@@ -417,9 +417,6 @@ android.app.INotificationManager
android.app.IProcessObserver$Stub$Proxy
android.app.IProcessObserver$Stub$Proxy
android.app.IProcessObserver$Stub
android.app.IProcessObserver$Stub
android.app.IProcessObserver
android.app.IProcessObserver
android.app.IRequestFinishCallback$Stub$Proxy
android.app.IRequestFinishCallback$Stub
android.app.IRequestFinishCallback
android.app.ISearchManager$Stub$Proxy
android.app.ISearchManager$Stub$Proxy
android.app.ISearchManager$Stub
android.app.ISearchManager$Stub
android.app.ISearchManager
android.app.ISearchManager
+2 −20
Original line number Original line Diff line number Diff line
@@ -150,7 +150,6 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Arrays;
import java.util.Collections;
import java.util.Collections;
@@ -3798,22 +3797,6 @@ public class Activity extends ContextThemeWrapper
        return false;
        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
     * Called when the activity has detected the user's press of the back
     * key.  The default implementation simply finishes the current activity,
     * key.  The default implementation simply finishes the current activity,
@@ -3837,9 +3820,8 @@ public class Activity extends ContextThemeWrapper
        try {
        try {
            // Inform activity task manager that the activity received a back press
            // Inform activity task manager that the activity received a back press
            // while at the root of the task. This call allows ActivityTaskManager
            // while at the root of the task. This call allows ActivityTaskManager
            // to intercept or defer finishing.
            // to intercept or move the task to the back.
            ActivityTaskManager.getService().onBackPressedOnTaskRoot(mToken,
            ActivityTaskManager.getService().onBackPressedOnTaskRoot(mToken);
                    new RequestFinishCallback(new WeakReference<>(this)));
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            finishAfterTransition();
            finishAfterTransition();
        }
        }
+2 −5
Original line number Original line Diff line number Diff line
@@ -26,7 +26,6 @@ import android.app.IAppTask;
import android.app.IAssistDataReceiver;
import android.app.IAssistDataReceiver;
import android.app.IInstrumentationWatcher;
import android.app.IInstrumentationWatcher;
import android.app.IProcessObserver;
import android.app.IProcessObserver;
import android.app.IRequestFinishCallback;
import android.app.IServiceConnection;
import android.app.IServiceConnection;
import android.app.IStopUserCallback;
import android.app.IStopUserCallback;
import android.app.ITaskStackListener;
import android.app.ITaskStackListener;
@@ -458,9 +457,7 @@ interface IActivityTaskManager {


    /**
    /**
     * Reports that an Activity received a back key press when there were no additional activities
     * Reports that an Activity received a back key press when there were no additional activities
     * on the back stack. If the Activity should be finished, the callback will be invoked. A
     * on the back stack.
     * callback is used instead of finishing the activity directly from the server such that the
     * client may perform actions prior to finishing.
     */
     */
    void onBackPressedOnTaskRoot(in IBinder activityToken, in IRequestFinishCallback callback);
    void onBackPressedOnTaskRoot(in IBinder activityToken);
}
}
+0 −27
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2019 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();
}
+4 −10
Original line number Original line Diff line number Diff line
@@ -145,7 +145,6 @@ import android.app.IActivityTaskManager;
import android.app.IApplicationThread;
import android.app.IApplicationThread;
import android.app.IAssistDataReceiver;
import android.app.IAssistDataReceiver;
import android.app.INotificationManager;
import android.app.INotificationManager;
import android.app.IRequestFinishCallback;
import android.app.ITaskStackListener;
import android.app.ITaskStackListener;
import android.app.Notification;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.NotificationManager;
@@ -2464,7 +2463,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    }
    }


    @Override
    @Override
    public void onBackPressedOnTaskRoot(IBinder token, IRequestFinishCallback callback) {
    public void onBackPressedOnTaskRoot(IBinder token) {
        synchronized (mGlobalLock) {
        synchronized (mGlobalLock) {
            ActivityRecord r = ActivityRecord.isInStackLocked(token);
            ActivityRecord r = ActivityRecord.isInStackLocked(token);
            if (r == null) {
            if (r == null) {
@@ -2478,18 +2477,13 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                // callback
                // callback
            } else if (stack != null && (stack.isSingleTaskInstance())) {
            } else if (stack != null && (stack.isSingleTaskInstance())) {
                // Single-task stacks are used for activities which are presented in floating
                // Single-task stacks are used for activities which are presented in floating
                // windows above full screen activities. Instead of directly finishing the
                // windows above full screen activities. A task change listener is used to notify
                // task, a task change listener is used to notify SystemUI so the action can be
                // SystemUI so the back action can be handled specially.
                // handled specially.
                final Task task = r.getTask();
                final Task task = r.getTask();
                mTaskChangeNotificationController
                mTaskChangeNotificationController
                        .notifyBackPressedOnTaskRoot(task.getTaskInfo());
                        .notifyBackPressedOnTaskRoot(task.getTaskInfo());
            } else {
            } else {
                try {
                moveActivityTaskToBack(token, false /* nonRoot */);
                    callback.requestFinish();
                } catch (RemoteException e) {
                    Slog.e(TAG, "Failed to invoke request finish callback", e);
                }
            }
            }
        }
        }
    }
    }
Loading