diff options
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/Activity.java | 20 | ||||
| -rw-r--r-- | core/java/android/app/ActivityClient.java | 4 | ||||
| -rw-r--r-- | core/java/android/app/IActivityClientController.aidl | 4 | ||||
| -rw-r--r-- | core/java/android/app/IRequestFinishCallback.aidl | 27 |
4 files changed, 51 insertions, 4 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 992d054737b9..a73fe71cfe1a 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -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. diff --git a/core/java/android/app/ActivityClient.java b/core/java/android/app/ActivityClient.java index e3b5e9a32324..fbabfac706e1 100644 --- a/core/java/android/app/ActivityClient.java +++ b/core/java/android/app/ActivityClient.java @@ -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(); } diff --git a/core/java/android/app/IActivityClientController.aidl b/core/java/android/app/IActivityClientController.aidl index bb743b89e00f..573931ed228e 100644 --- a/core/java/android/app/IActivityClientController.aidl +++ b/core/java/android/app/IActivityClientController.aidl @@ -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); diff --git a/core/java/android/app/IRequestFinishCallback.aidl b/core/java/android/app/IRequestFinishCallback.aidl new file mode 100644 index 000000000000..22c20c840e99 --- /dev/null +++ b/core/java/android/app/IRequestFinishCallback.aidl @@ -0,0 +1,27 @@ +/* + * 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(); +} |
