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

Commit 15283df5 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Move activity related operations to ActivityClientController

Including dismissKeyguard, restartActivityProcessIfVisible and
invalidateHomeTaskSnapshot.

Bug: 174041144
Test: ActivityTaskManagerServiceTests

Change-Id: I29b4f626baa2f3d6436e84e5364284fe42e5e7d1
(cherry picked from commit 5408d9af)
parent 77bb0b72
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -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);
+23 −0
Original line number Diff line number Diff line
@@ -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);

+0 −24
Original line number Diff line number Diff line
@@ -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);

@@ -308,14 +302,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.
     */
@@ -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);
}
+18 −22
Original line number Diff line number Diff line
@@ -598,8 +598,7 @@ public class KeyguardManager {
    @SystemApi
    public void requestDismissKeyguard(@NonNull Activity activity, @Nullable CharSequence message,
            @Nullable KeyguardDismissCallback callback) {
        try {
            ActivityTaskManager.getService().dismissKeyguard(
        ActivityClient.getInstance().dismissKeyguard(
                activity.getActivityToken(), new IKeyguardDismissCallback.Stub() {
            @Override
            public void onDismissError() throws RemoteException {
@@ -622,9 +621,6 @@ public class KeyguardManager {
                }
            }
        }, message);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
+4 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static android.app.ActivityTaskManager.getService;

import android.annotation.NonNull;
import android.app.Activity;
import android.app.ActivityClient;
import android.app.ActivityManager;
import android.app.ActivityManager.RecentTaskInfo;
import android.app.ActivityManager.RunningTaskInfo;
@@ -140,8 +141,9 @@ public class ActivityManagerWrapper {
     */
    public void invalidateHomeTaskSnapshot(final Activity homeActivity) {
        try {
            getService().invalidateHomeTaskSnapshot(homeActivity.getActivityToken());
        } catch (RemoteException e) {
            ActivityClient.getInstance().invalidateHomeTaskSnapshot(
                    homeActivity.getActivityToken());
        } catch (Throwable e) {
            Log.w(TAG, "Failed to invalidate home snapshot", e);
        }
    }
Loading