Loading Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ java_defaults { "core/java/android/app/IInstrumentationWatcher.aidl", "core/java/android/app/INotificationManager.aidl", "core/java/android/app/IProcessObserver.aidl", "core/java/android/app/IRequestFinishCallback.aidl", "core/java/android/app/ISearchManager.aidl", "core/java/android/app/ISearchManagerCallback.aidl", "core/java/android/app/IServiceConnection.aidl", Loading core/java/android/app/Activity.java +19 −1 Original line number Diff line number Diff line Loading @@ -3666,7 +3666,25 @@ public class Activity extends ContextThemeWrapper FragmentManager fragmentManager = mFragments.getFragmentManager(); if (fragmentManager.isStateSaved() || !fragmentManager.popBackStackImmediate()) { if (!fragmentManager.isStateSaved() && fragmentManager.popBackStackImmediate()) { return; } if (!isTaskRoot()) { // If the activity is not the root of the task, allow finish to proceed normally. finishAfterTransition(); return; } try { // 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 defer finishing. ActivityTaskManager.getService().onBackPressedOnTaskRoot(mToken, new IRequestFinishCallback.Stub() { public void requestFinish() { finishAfterTransition(); } }); } catch (RemoteException e) { finishAfterTransition(); } } Loading core/java/android/app/IActivityTaskManager.aidl +9 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.app.IAppTask; import android.app.IAssistDataReceiver; import android.app.IInstrumentationWatcher; import android.app.IProcessObserver; import android.app.IRequestFinishCallback; import android.app.IServiceConnection; import android.app.IStopUserCallback; import android.app.ITaskStackListener; Loading Loading @@ -484,4 +485,12 @@ interface IActivityTaskManager { * @param activityToken The token of the target activity to restart. */ void restartActivityProcessIfVisible(in IBinder activityToken); /** * 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 * 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); } core/java/android/app/IRequestFinishCallback.aidl 0 → 100644 +27 −0 Original line number 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(); } core/java/android/app/ITaskStackListener.aidl +8 −0 Original line number Diff line number Diff line Loading @@ -161,4 +161,12 @@ oneway interface ITaskStackListener { * @see com.android.server.wm.AppWindowToken#inSizeCompatMode */ void onSizeCompatModeActivityChanged(int displayId, in IBinder activityToken); /** * Reports that an Activity received a back key press when there were no additional activities * on the back stack. * * @param taskInfo info about the task which received the back press */ void onBackPressedOnTaskRoot(in ActivityManager.RunningTaskInfo taskInfo); } Loading
Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ java_defaults { "core/java/android/app/IInstrumentationWatcher.aidl", "core/java/android/app/INotificationManager.aidl", "core/java/android/app/IProcessObserver.aidl", "core/java/android/app/IRequestFinishCallback.aidl", "core/java/android/app/ISearchManager.aidl", "core/java/android/app/ISearchManagerCallback.aidl", "core/java/android/app/IServiceConnection.aidl", Loading
core/java/android/app/Activity.java +19 −1 Original line number Diff line number Diff line Loading @@ -3666,7 +3666,25 @@ public class Activity extends ContextThemeWrapper FragmentManager fragmentManager = mFragments.getFragmentManager(); if (fragmentManager.isStateSaved() || !fragmentManager.popBackStackImmediate()) { if (!fragmentManager.isStateSaved() && fragmentManager.popBackStackImmediate()) { return; } if (!isTaskRoot()) { // If the activity is not the root of the task, allow finish to proceed normally. finishAfterTransition(); return; } try { // 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 defer finishing. ActivityTaskManager.getService().onBackPressedOnTaskRoot(mToken, new IRequestFinishCallback.Stub() { public void requestFinish() { finishAfterTransition(); } }); } catch (RemoteException e) { finishAfterTransition(); } } Loading
core/java/android/app/IActivityTaskManager.aidl +9 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.app.IAppTask; import android.app.IAssistDataReceiver; import android.app.IInstrumentationWatcher; import android.app.IProcessObserver; import android.app.IRequestFinishCallback; import android.app.IServiceConnection; import android.app.IStopUserCallback; import android.app.ITaskStackListener; Loading Loading @@ -484,4 +485,12 @@ interface IActivityTaskManager { * @param activityToken The token of the target activity to restart. */ void restartActivityProcessIfVisible(in IBinder activityToken); /** * 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 * 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); }
core/java/android/app/IRequestFinishCallback.aidl 0 → 100644 +27 −0 Original line number 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(); }
core/java/android/app/ITaskStackListener.aidl +8 −0 Original line number Diff line number Diff line Loading @@ -161,4 +161,12 @@ oneway interface ITaskStackListener { * @see com.android.server.wm.AppWindowToken#inSizeCompatMode */ void onSizeCompatModeActivityChanged(int displayId, in IBinder activityToken); /** * Reports that an Activity received a back key press when there were no additional activities * on the back stack. * * @param taskInfo info about the task which received the back press */ void onBackPressedOnTaskRoot(in ActivityManager.RunningTaskInfo taskInfo); }