summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorRiddle Hsu <riddlehsu@google.com>2020-12-15 21:47:14 +0800
committerRiddle Hsu <riddlehsu@google.com>2021-01-27 05:29:24 +0000
commit15283df51985652971a71b5bf8bfd5c227dadf29 (patch)
treecd8969536d07423fe814b12881eb2f9322e6648b /core/java/android
parent77bb0b72919bb93d89095f2f78accac160633c02 (diff)
Move activity related operations to ActivityClientController
Including dismissKeyguard, restartActivityProcessIfVisible and invalidateHomeTaskSnapshot. Bug: 174041144 Test: ActivityTaskManagerServiceTests Change-Id: I29b4f626baa2f3d6436e84e5364284fe42e5e7d1 (cherry picked from commit 5408d9af70db95ce3cb854f213c6635dc8ffce35)
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/ActivityClient.java33
-rw-r--r--core/java/android/app/IActivityClientController.aidl23
-rw-r--r--core/java/android/app/IActivityTaskManager.aidl24
-rw-r--r--core/java/android/app/KeyguardManager.java40
4 files changed, 74 insertions, 46 deletions
diff --git a/core/java/android/app/ActivityClient.java b/core/java/android/app/ActivityClient.java
index d465b220f854..401f8cc13bad 100644
--- a/core/java/android/app/ActivityClient.java
+++ b/core/java/android/app/ActivityClient.java
@@ -26,6 +26,8 @@ import android.os.RemoteException;
import android.util.Singleton;
import android.view.RemoteAnimationDefinition;
+import com.android.internal.policy.IKeyguardDismissCallback;
+
/**
* Provides the activity associated operations that communicate with system.
*
@@ -431,6 +433,37 @@ public class ActivityClient {
}
}
+ /**
+ * Restart the process and activity to adopt the latest configuration for size compat mode.
+ * This only takes effect for visible activity because invisible background activity can be
+ * restarted naturally when it becomes visible.
+ */
+ public void restartActivityProcessIfVisible(IBinder token) {
+ try {
+ getActivityClientController().restartActivityProcessIfVisible(token);
+ } catch (RemoteException e) {
+ e.rethrowFromSystemServer();
+ }
+ }
+
+ /** Removes the snapshot of home task. */
+ public void invalidateHomeTaskSnapshot(IBinder homeToken) {
+ try {
+ getActivityClientController().invalidateHomeTaskSnapshot(homeToken);
+ } catch (RemoteException e) {
+ e.rethrowFromSystemServer();
+ }
+ }
+
+ void dismissKeyguard(IBinder token, IKeyguardDismissCallback callback,
+ CharSequence message) {
+ try {
+ getActivityClientController().dismissKeyguard(token, callback, message);
+ } catch (RemoteException e) {
+ e.rethrowFromSystemServer();
+ }
+ }
+
void registerRemoteAnimations(IBinder token, RemoteAnimationDefinition definition) {
try {
getActivityClientController().registerRemoteAnimations(token, definition);
diff --git a/core/java/android/app/IActivityClientController.aidl b/core/java/android/app/IActivityClientController.aidl
index ebf1027382c5..9127ebb4eb83 100644
--- a/core/java/android/app/IActivityClientController.aidl
+++ b/core/java/android/app/IActivityClientController.aidl
@@ -25,6 +25,8 @@ import android.os.Bundle;
import android.os.PersistableBundle;
import android.view.RemoteAnimationDefinition;
+import com.android.internal.policy.IKeyguardDismissCallback;
+
/**
* Interface for the callback and request from an activity to system.
*
@@ -95,6 +97,27 @@ interface IActivityClientController {
/** See {@link android.app.Activity#setDisablePreviewScreenshots}. */
oneway void setDisablePreviewScreenshots(in IBinder token, boolean disable);
+ /**
+ * Restarts the activity by killing its process if it is visible. If the activity is not
+ * visible, the activity will not be restarted immediately and just keep the activity record in
+ * the stack. It also resets the current override configuration so the activity will use the
+ * configuration according to the latest state.
+ *
+ * @param activityToken The token of the target activity to restart.
+ */
+ void restartActivityProcessIfVisible(in IBinder activityToken);
+
+ /**
+ * It should only be called from home activity to remove its outdated snapshot. The home
+ * snapshot is used to speed up entering home from screen off. If the content of home activity
+ * is significantly different from before taking the snapshot, then the home activity can use
+ * this method to avoid inconsistent transition.
+ */
+ void invalidateHomeTaskSnapshot(IBinder homeToken);
+
+ void dismissKeyguard(in IBinder token, in IKeyguardDismissCallback callback,
+ in CharSequence message);
+
/** Registers remote animations for a specific activity. */
void registerRemoteAnimations(in IBinder token, in RemoteAnimationDefinition definition);
diff --git a/core/java/android/app/IActivityTaskManager.aidl b/core/java/android/app/IActivityTaskManager.aidl
index b0853404a0aa..38a3e70b3742 100644
--- a/core/java/android/app/IActivityTaskManager.aidl
+++ b/core/java/android/app/IActivityTaskManager.aidl
@@ -72,7 +72,6 @@ import android.view.RemoteAnimationAdapter;
import android.window.IWindowOrganizerController;
import com.android.internal.app.IVoiceInteractor;
import com.android.internal.os.IResultReceiver;
-import com.android.internal.policy.IKeyguardDismissCallback;
import java.util.List;
@@ -85,8 +84,6 @@ import java.util.List;
// TODO(b/174040395): Make this interface private to ActivityTaskManager.java and have external
// caller go through that call instead. This would help us better separate and control the API
// surface exposed.
-// TODO(b/174041144): Move callback methods from Activity (Things that take param 'IBinder token')
-// to a separate interface that is only available to the Activity.
// TODO(b/174041603): Create a builder interface for things like startActivityXXX(...) to reduce
// interface duplication.
// TODO(b/174040691): Clean-up/remove all obsolete or unused interfaces like things that should be
@@ -294,9 +291,6 @@ interface IActivityTaskManager {
// Get device configuration
ConfigurationInfo getDeviceConfigurationInfo();
- void dismissKeyguard(in IBinder token, in IKeyguardDismissCallback callback,
- in CharSequence message);
-
/** Cancels the window transitions for the given task. */
void cancelTaskWindowTransition(int taskId);
@@ -309,14 +303,6 @@ interface IActivityTaskManager {
android.window.TaskSnapshot getTaskSnapshot(int taskId, boolean isLowResolution);
/**
- * It should only be called from home activity to remove its outdated snapshot. The home
- * snapshot is used to speed up entering home from screen off. If the content of home activity
- * is significantly different from before taking the snapshot, then the home activity can use
- * this method to avoid inconsistent transition.
- */
- void invalidateHomeTaskSnapshot(IBinder homeToken);
-
- /**
* Return the user id of last resumed activity.
*/
int getLastResumedActivityUserId();
@@ -362,14 +348,4 @@ interface IActivityTaskManager {
* Clears launch params for given packages.
*/
void clearLaunchParamsForPackages(in List<String> packageNames);
-
- /**
- * Restarts the activity by killing its process if it is visible. If the activity is not
- * visible, the activity will not be restarted immediately and just keep the activity record in
- * the stack. It also resets the current override configuration so the activity will use the
- * configuration according to the latest state.
- *
- * @param activityToken The token of the target activity to restart.
- */
- void restartActivityProcessIfVisible(in IBinder activityToken);
}
diff --git a/core/java/android/app/KeyguardManager.java b/core/java/android/app/KeyguardManager.java
index 545c3f70d466..b6d25cfb26ce 100644
--- a/core/java/android/app/KeyguardManager.java
+++ b/core/java/android/app/KeyguardManager.java
@@ -598,33 +598,29 @@ public class KeyguardManager {
@SystemApi
public void requestDismissKeyguard(@NonNull Activity activity, @Nullable CharSequence message,
@Nullable KeyguardDismissCallback callback) {
- try {
- ActivityTaskManager.getService().dismissKeyguard(
- activity.getActivityToken(), new IKeyguardDismissCallback.Stub() {
- @Override
- public void onDismissError() throws RemoteException {
- if (callback != null && !activity.isDestroyed()) {
- activity.mHandler.post(callback::onDismissError);
- }
+ ActivityClient.getInstance().dismissKeyguard(
+ activity.getActivityToken(), new IKeyguardDismissCallback.Stub() {
+ @Override
+ public void onDismissError() throws RemoteException {
+ if (callback != null && !activity.isDestroyed()) {
+ activity.mHandler.post(callback::onDismissError);
}
+ }
- @Override
- public void onDismissSucceeded() throws RemoteException {
- if (callback != null && !activity.isDestroyed()) {
- activity.mHandler.post(callback::onDismissSucceeded);
- }
+ @Override
+ public void onDismissSucceeded() throws RemoteException {
+ if (callback != null && !activity.isDestroyed()) {
+ activity.mHandler.post(callback::onDismissSucceeded);
}
+ }
- @Override
- public void onDismissCancelled() throws RemoteException {
- if (callback != null && !activity.isDestroyed()) {
- activity.mHandler.post(callback::onDismissCancelled);
- }
+ @Override
+ public void onDismissCancelled() throws RemoteException {
+ if (callback != null && !activity.isDestroyed()) {
+ activity.mHandler.post(callback::onDismissCancelled);
}
- }, message);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
+ }
+ }, message);
}
/**