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

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

Merge "Moved some activities implementation to ActivityTaskManagerService (2/n)"

parents 0ec06e34 04d9cb5f
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package android.accounts;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
@@ -72,8 +73,8 @@ public class ChooseAccountActivity extends Activity {

        try {
            IBinder activityToken = getActivityToken();
            mCallingUid = ActivityManager.getService().getLaunchedFromUid(activityToken);
            mCallingPackage = ActivityManager.getService().getLaunchedFromPackage(
            mCallingUid = ActivityTaskManager.getService().getLaunchedFromUid(activityToken);
            mCallingPackage = ActivityTaskManager.getService().getLaunchedFromPackage(
                    activityToken);
        } catch (RemoteException re) {
            // Couldn't figure out caller details
+3 −2
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package android.accounts;

import android.app.ActivityTaskManager;
import com.google.android.collect.Sets;

import android.app.Activity;
@@ -147,8 +148,8 @@ public class ChooseTypeAndAccountActivity extends Activity

        try {
            IBinder activityToken = getActivityToken();
            mCallingUid = ActivityManager.getService().getLaunchedFromUid(activityToken);
            mCallingPackage = ActivityManager.getService().getLaunchedFromPackage(
            mCallingUid = ActivityTaskManager.getService().getLaunchedFromUid(activityToken);
            mCallingPackage = ActivityTaskManager.getService().getLaunchedFromPackage(
                    activityToken);
            if (mCallingUid != 0 && mCallingPackage != null) {
                Bundle restrictions = UserManager.get(this)
+46 −48
Original line number Diff line number Diff line
@@ -1442,7 +1442,7 @@ public class Activity extends ContextThemeWrapper
    public boolean isVoiceInteractionRoot() {
        try {
            return mVoiceInteractor != null
                    && ActivityManager.getService().isRootVoiceInteraction(mToken);
                    && ActivityTaskManager.getService().isRootVoiceInteraction(mToken);
        } catch (RemoteException e) {
        }
        return false;
@@ -1465,7 +1465,7 @@ public class Activity extends ContextThemeWrapper
     */
    public boolean isLocalVoiceInteractionSupported() {
        try {
            return ActivityManager.getService().supportsLocalVoiceInteraction();
            return ActivityTaskManager.getService().supportsLocalVoiceInteraction();
        } catch (RemoteException re) {
        }
        return false;
@@ -1479,7 +1479,7 @@ public class Activity extends ContextThemeWrapper
     */
    public void startLocalVoiceInteraction(Bundle privateOptions) {
        try {
            ActivityManager.getService().startLocalVoiceInteraction(mToken, privateOptions);
            ActivityTaskManager.getService().startLocalVoiceInteraction(mToken, privateOptions);
        } catch (RemoteException re) {
        }
    }
@@ -1508,7 +1508,7 @@ public class Activity extends ContextThemeWrapper
     */
    public void stopLocalVoiceInteraction() {
        try {
            ActivityManager.getService().stopLocalVoiceInteraction(mToken);
            ActivityTaskManager.getService().stopLocalVoiceInteraction(mToken);
        } catch (RemoteException re) {
        }
    }
@@ -1886,7 +1886,7 @@ public class Activity extends ContextThemeWrapper
     */
    public boolean showAssist(Bundle args) {
        try {
            return ActivityManager.getService().showAssistFromActivity(mToken, args);
            return ActivityTaskManager.getService().showAssistFromActivity(mToken, args);
        } catch (RemoteException e) {
        }
        return false;
@@ -2019,7 +2019,8 @@ public class Activity extends ContextThemeWrapper
        if (mDoReportFullyDrawn) {
            mDoReportFullyDrawn = false;
            try {
                ActivityManager.getService().reportActivityFullyDrawn(mToken, mRestoredFromBundle);
                ActivityTaskManager.getService().reportActivityFullyDrawn(
                        mToken, mRestoredFromBundle);
            } catch (RemoteException e) {
            }
        }
@@ -2066,7 +2067,7 @@ public class Activity extends ContextThemeWrapper
     */
    public boolean isInMultiWindowMode() {
        try {
            return ActivityManager.getService().isInMultiWindowMode(mToken);
            return ActivityTaskManager.getService().isInMultiWindowMode(mToken);
        } catch (RemoteException e) {
        }
        return false;
@@ -2113,7 +2114,7 @@ public class Activity extends ContextThemeWrapper
     */
    public boolean isInPictureInPictureMode() {
        try {
            return ActivityManager.getService().isInPictureInPictureMode(mToken);
            return ActivityTaskManager.getService().isInPictureInPictureMode(mToken);
        } catch (RemoteException e) {
        }
        return false;
@@ -2168,7 +2169,7 @@ public class Activity extends ContextThemeWrapper
                throw new IllegalStateException("Activity must be resumed to enter"
                        + " picture-in-picture");
            }
            return ActivityManagerNative.getDefault().enterPictureInPictureMode(mToken, params);
            return ActivityTaskManager.getService().enterPictureInPictureMode(mToken, params);
        } catch (RemoteException e) {
            return false;
        }
@@ -2194,7 +2195,7 @@ public class Activity extends ContextThemeWrapper
            if (params == null) {
                throw new IllegalArgumentException("Expected non-null picture-in-picture params");
            }
            ActivityManagerNative.getDefault().setPictureInPictureParams(mToken, params);
            ActivityTaskManager.getService().setPictureInPictureParams(mToken, params);
        } catch (RemoteException e) {
        }
    }
@@ -2207,7 +2208,7 @@ public class Activity extends ContextThemeWrapper
     */
    public int getMaxNumPictureInPictureActions() {
        try {
            return ActivityManagerNative.getDefault().getMaxNumPictureInPictureActions(mToken);
            return ActivityTaskManager.getService().getMaxNumPictureInPictureActions(mToken);
        } catch (RemoteException e) {
            return 0;
        }
@@ -3321,7 +3322,7 @@ public class Activity extends ContextThemeWrapper
     */
    @Override
    public void exitFreeformMode() throws RemoteException {
        ActivityManager.getService().exitFreeformMode(mToken);
        ActivityTaskManager.getService().exitFreeformMode(mToken);
    }

    /**
@@ -4833,7 +4834,7 @@ public class Activity extends ContextThemeWrapper
                fillInIntent.prepareToLeaveProcess(this);
                resolvedType = fillInIntent.resolveTypeIfNeeded(getContentResolver());
            }
            int result = ActivityManager.getService()
            int result = ActivityTaskManager.getService()
                .startActivityIntentSender(mMainThread.getApplicationThread(),
                        intent != null ? intent.getTarget() : null,
                        intent != null ? intent.getWhitelistToken() : null,
@@ -5065,7 +5066,7 @@ public class Activity extends ContextThemeWrapper
                }
                intent.migrateExtraStreamToClipData();
                intent.prepareToLeaveProcess(this);
                result = ActivityManager.getService()
                result = ActivityTaskManager.getService()
                    .startActivity(mMainThread.getApplicationThread(), getBasePackageName(),
                            intent, intent.resolveTypeIfNeeded(getContentResolver()), mToken,
                            mEmbeddedID, requestCode, ActivityManager.START_FLAG_ONLY_IF_NEEDED,
@@ -5136,7 +5137,7 @@ public class Activity extends ContextThemeWrapper
            try {
                intent.migrateExtraStreamToClipData();
                intent.prepareToLeaveProcess(this);
                return ActivityManager.getService()
                return ActivityTaskManager.getService()
                    .startNextMatchingActivity(mToken, intent, options);
            } catch (RemoteException e) {
                // Empty
@@ -5351,7 +5352,7 @@ public class Activity extends ContextThemeWrapper
     */
    public void overridePendingTransition(int enterAnim, int exitAnim) {
        try {
            ActivityManager.getService().overridePendingTransition(
            ActivityTaskManager.getService().overridePendingTransition(
                    mToken, getPackageName(), enterAnim, exitAnim);
        } catch (RemoteException e) {
        }
@@ -5476,7 +5477,7 @@ public class Activity extends ContextThemeWrapper
    @Nullable
    public String getCallingPackage() {
        try {
            return ActivityManager.getService().getCallingPackage(mToken);
            return ActivityTaskManager.getService().getCallingPackage(mToken);
        } catch (RemoteException e) {
            return null;
        }
@@ -5499,7 +5500,7 @@ public class Activity extends ContextThemeWrapper
    @Nullable
    public ComponentName getCallingActivity() {
        try {
            return ActivityManager.getService().getCallingActivity(mToken);
            return ActivityTaskManager.getService().getCallingActivity(mToken);
        } catch (RemoteException e) {
            return null;
        }
@@ -5603,7 +5604,7 @@ public class Activity extends ContextThemeWrapper
                if (resultData != null) {
                    resultData.prepareToLeaveProcess(this);
                }
                if (ActivityManager.getService()
                if (ActivityTaskManager.getService()
                        .finishActivity(mToken, resultCode, resultData, finishTask)) {
                    mFinished = true;
                }
@@ -5653,7 +5654,7 @@ public class Activity extends ContextThemeWrapper
            throw new IllegalStateException("Can not be called to deliver a result");
        }
        try {
            if (ActivityManager.getService().finishActivityAffinity(mToken)) {
            if (ActivityTaskManager.getService().finishActivityAffinity(mToken)) {
                mFinished = true;
            }
        } catch (RemoteException e) {
@@ -5699,7 +5700,7 @@ public class Activity extends ContextThemeWrapper
    public void finishActivity(int requestCode) {
        if (mParent == null) {
            try {
                ActivityManager.getService()
                ActivityTaskManager.getService()
                    .finishSubActivity(mToken, mEmbeddedID, requestCode);
            } catch (RemoteException e) {
                // Empty
@@ -5719,7 +5720,7 @@ public class Activity extends ContextThemeWrapper
     */
    public void finishActivityFromChild(@NonNull Activity child, int requestCode) {
        try {
            ActivityManager.getService()
            ActivityTaskManager.getService()
                .finishSubActivity(mToken, child.mEmbeddedID, requestCode);
        } catch (RemoteException e) {
            // Empty
@@ -5747,7 +5748,7 @@ public class Activity extends ContextThemeWrapper
     */
    public boolean releaseInstance() {
        try {
            return ActivityManager.getService().releaseActivityInstance(mToken);
            return ActivityTaskManager.getService().releaseActivityInstance(mToken);
        } catch (RemoteException e) {
            // Empty
        }
@@ -5862,7 +5863,7 @@ public class Activity extends ContextThemeWrapper
    public void setRequestedOrientation(@ActivityInfo.ScreenOrientation int requestedOrientation) {
        if (mParent == null) {
            try {
                ActivityManager.getService().setRequestedOrientation(
                ActivityTaskManager.getService().setRequestedOrientation(
                        mToken, requestedOrientation);
            } catch (RemoteException e) {
                // Empty
@@ -5885,7 +5886,7 @@ public class Activity extends ContextThemeWrapper
    public int getRequestedOrientation() {
        if (mParent == null) {
            try {
                return ActivityManager.getService()
                return ActivityTaskManager.getService()
                        .getRequestedOrientation(mToken);
            } catch (RemoteException e) {
                // Empty
@@ -5904,8 +5905,7 @@ public class Activity extends ContextThemeWrapper
     */
    public int getTaskId() {
        try {
            return ActivityManager.getService()
                .getTaskForActivity(mToken, false);
            return ActivityTaskManager.getService().getTaskForActivity(mToken, false);
        } catch (RemoteException e) {
            return -1;
        }
@@ -5920,7 +5920,7 @@ public class Activity extends ContextThemeWrapper
    @Override
    public boolean isTaskRoot() {
        try {
            return ActivityManager.getService().getTaskForActivity(mToken, true) >= 0;
            return ActivityTaskManager.getService().getTaskForActivity(mToken, true) >= 0;
        } catch (RemoteException e) {
            return false;
        }
@@ -5939,8 +5939,7 @@ public class Activity extends ContextThemeWrapper
     */
    public boolean moveTaskToBack(boolean nonRoot) {
        try {
            return ActivityManager.getService().moveActivityTaskToBack(
                    mToken, nonRoot);
            return ActivityTaskManager.getService().moveActivityTaskToBack(mToken, nonRoot);
        } catch (RemoteException e) {
            // Empty
        }
@@ -6115,7 +6114,7 @@ public class Activity extends ContextThemeWrapper
            }
        }
        try {
            ActivityManager.getService().setTaskDescription(mToken, mTaskDescription);
            ActivityTaskManager.getService().setTaskDescription(mToken, mTaskDescription);
        } catch (RemoteException e) {
        }
    }
@@ -6390,7 +6389,7 @@ public class Activity extends ContextThemeWrapper
     */
    public boolean isImmersive() {
        try {
            return ActivityManager.getService().isImmersive(mToken);
            return ActivityTaskManager.getService().isImmersive(mToken);
        } catch (RemoteException e) {
            return false;
        }
@@ -6408,7 +6407,7 @@ public class Activity extends ContextThemeWrapper
            return false;
        }
        try {
            return ActivityManager.getService().isTopOfTask(getActivityToken());
            return ActivityTaskManager.getService().isTopOfTask(getActivityToken());
        } catch (RemoteException e) {
            return false;
        }
@@ -6434,7 +6433,7 @@ public class Activity extends ContextThemeWrapper
    public void convertFromTranslucent() {
        try {
            mTranslucentCallback = null;
            if (ActivityManager.getService().convertFromTranslucent(mToken)) {
            if (ActivityTaskManager.getService().convertFromTranslucent(mToken)) {
                WindowManagerGlobal.getInstance().changeCanvasOpacity(mToken, true);
            }
        } catch (RemoteException e) {
@@ -6473,7 +6472,7 @@ public class Activity extends ContextThemeWrapper
        boolean drawComplete;
        try {
            mTranslucentCallback = callback;
            mChangeCanvasToTranslucent = ActivityManager.getService().convertToTranslucent(
            mChangeCanvasToTranslucent = ActivityTaskManager.getService().convertToTranslucent(
                    mToken, options == null ? null : options.toBundle());
            WindowManagerGlobal.getInstance().changeCanvasOpacity(mToken, false);
            drawComplete = true;
@@ -6519,7 +6518,7 @@ public class Activity extends ContextThemeWrapper
    ActivityOptions getActivityOptions() {
        try {
            return ActivityOptions.fromBundle(
                    ActivityManager.getService().getActivityOptions(mToken));
                    ActivityTaskManager.getService().getActivityOptions(mToken));
        } catch (RemoteException e) {
        }
        return null;
@@ -6664,7 +6663,7 @@ public class Activity extends ContextThemeWrapper
     */
    public void setImmersive(boolean i) {
        try {
            ActivityManager.getService().setImmersive(mToken, i);
            ActivityTaskManager.getService().setImmersive(mToken, i);
        } catch (RemoteException e) {
            // pass
        }
@@ -6727,7 +6726,7 @@ public class Activity extends ContextThemeWrapper
    public void setVrModeEnabled(boolean enabled, @NonNull ComponentName requestedComponent)
          throws PackageManager.NameNotFoundException {
        try {
            if (ActivityManager.getService().setVrMode(mToken, enabled, requestedComponent)
            if (ActivityTaskManager.getService().setVrMode(mToken, enabled, requestedComponent)
                    != 0) {
                throw new PackageManager.NameNotFoundException(
                        requestedComponent.flattenToString());
@@ -6848,8 +6847,7 @@ public class Activity extends ContextThemeWrapper
            if (info.taskAffinity == null) {
                return false;
            }
            return ActivityManager.getService()
                    .shouldUpRecreateTask(mToken, info.taskAffinity);
            return ActivityTaskManager.getService().shouldUpRecreateTask(mToken, info.taskAffinity);
        } catch (RemoteException e) {
            return false;
        } catch (NameNotFoundException e) {
@@ -6901,7 +6899,7 @@ public class Activity extends ContextThemeWrapper
            }
            try {
                upIntent.prepareToLeaveProcess(this);
                return ActivityManager.getService().navigateUpTo(mToken, upIntent,
                return ActivityTaskManager.getService().navigateUpTo(mToken, upIntent,
                        resultCode, resultData);
            } catch (RemoteException e) {
                return false;
@@ -7508,7 +7506,7 @@ public class Activity extends ContextThemeWrapper
     */
    public void startLockTask() {
        try {
            ActivityManager.getService().startLockTaskModeByToken(mToken);
            ActivityTaskManager.getService().startLockTaskModeByToken(mToken);
        } catch (RemoteException e) {
        }
    }
@@ -7531,7 +7529,7 @@ public class Activity extends ContextThemeWrapper
     */
    public void stopLockTask() {
        try {
            ActivityManager.getService().stopLockTaskModeByToken(mToken);
            ActivityTaskManager.getService().stopLockTaskModeByToken(mToken);
        } catch (RemoteException e) {
        }
    }
@@ -7543,7 +7541,7 @@ public class Activity extends ContextThemeWrapper
     */
    public void showLockTaskEscapeMessage() {
        try {
            ActivityManager.getService().showLockTaskEscapeMessage(mToken);
            ActivityTaskManager.getService().showLockTaskEscapeMessage(mToken);
        } catch (RemoteException e) {
        }
    }
@@ -7813,7 +7811,7 @@ public class Activity extends ContextThemeWrapper
     */
    public void setDisablePreviewScreenshots(boolean disable) {
        try {
            ActivityManager.getService().setDisablePreviewScreenshots(mToken, disable);
            ActivityTaskManager.getService().setDisablePreviewScreenshots(mToken, disable);
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to call setDisablePreviewScreenshots", e);
        }
@@ -7834,7 +7832,7 @@ public class Activity extends ContextThemeWrapper
     */
    public void setShowWhenLocked(boolean showWhenLocked) {
        try {
            ActivityManager.getService().setShowWhenLocked(mToken, showWhenLocked);
            ActivityTaskManager.getService().setShowWhenLocked(mToken, showWhenLocked);
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to call setShowWhenLocked", e);
        }
@@ -7860,7 +7858,7 @@ public class Activity extends ContextThemeWrapper
     */
    public void setTurnScreenOn(boolean turnScreenOn) {
        try {
            ActivityManager.getService().setTurnScreenOn(mToken, turnScreenOn);
            ActivityTaskManager.getService().setTurnScreenOn(mToken, turnScreenOn);
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to call setTurnScreenOn", e);
        }
@@ -7876,7 +7874,7 @@ public class Activity extends ContextThemeWrapper
    @RequiresPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS)
    public void registerRemoteAnimations(RemoteAnimationDefinition definition) {
        try {
            ActivityManager.getService().registerRemoteAnimations(mToken, definition);
            ActivityTaskManager.getService().registerRemoteAnimations(mToken, definition);
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to call registerRemoteAnimations", e);
        }
+15 −11
Original line number Diff line number Diff line
@@ -746,7 +746,7 @@ public class ActivityManager {
    /** @hide */
    public int getFrontActivityScreenCompatMode() {
        try {
            return getService().getFrontActivityScreenCompatMode();
            return getTaskService().getFrontActivityScreenCompatMode();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -755,7 +755,7 @@ public class ActivityManager {
    /** @hide */
    public void setFrontActivityScreenCompatMode(int mode) {
        try {
            getService().setFrontActivityScreenCompatMode(mode);
            getTaskService().setFrontActivityScreenCompatMode(mode);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -1182,7 +1182,7 @@ public class ActivityManager {
        public static Bitmap loadTaskDescriptionIcon(String iconFilename, int userId) {
            if (iconFilename != null) {
                try {
                    return getService().getTaskDescriptionIcon(iconFilename,
                    return getTaskService().getTaskDescriptionIcon(iconFilename,
                            userId);
                } catch (RemoteException e) {
                    throw e.rethrowFromSystemServer();
@@ -1582,7 +1582,7 @@ public class ActivityManager {
            if (maxNum < 0) {
                throw new IllegalArgumentException("The requested number of tasks should be >= 0");
            }
            return getService().getRecentTasks(maxNum, flags, mContext.getUserId()).getList();
            return getTaskService().getRecentTasks(maxNum, flags, mContext.getUserId()).getList();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -1735,7 +1735,7 @@ public class ActivityManager {
        ArrayList<AppTask> tasks = new ArrayList<AppTask>();
        List<IBinder> appTasks;
        try {
            appTasks = getService().getAppTasks(mContext.getPackageName());
            appTasks = getTaskService().getAppTasks(mContext.getPackageName());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -1760,7 +1760,7 @@ public class ActivityManager {
    private void ensureAppTaskThumbnailSizeLocked() {
        if (mAppTaskThumbnailSize == null) {
            try {
                mAppTaskThumbnailSize = getService().getAppTaskThumbnailSize();
                mAppTaskThumbnailSize = getTaskService().getAppTaskThumbnailSize();
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
@@ -1825,7 +1825,7 @@ public class ActivityManager {
            description = new TaskDescription();
        }
        try {
            return getService().addAppTask(activity.getActivityToken(),
            return getTaskService().addAppTask(activity.getActivityToken(),
                    intent, description, thumbnail);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
@@ -1868,7 +1868,7 @@ public class ActivityManager {
    public List<RunningTaskInfo> getRunningTasks(int maxNum)
            throws SecurityException {
        try {
            return getService().getTasks(maxNum);
            return getTaskService().getTasks(maxNum);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -2077,7 +2077,7 @@ public class ActivityManager {
    @RequiresPermission(android.Manifest.permission.REORDER_TASKS)
    public void moveTaskToFront(int taskId, @MoveTaskFlags int flags, Bundle options) {
        try {
            getService().moveTaskToFront(taskId, flags, options);
            getTaskService().moveTaskToFront(taskId, flags, options);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -3584,7 +3584,7 @@ public class ActivityManager {
    @TestApi
    public void alwaysShowUnsupportedCompileSdkWarning(ComponentName activity) {
        try {
            getService().alwaysShowUnsupportedCompileSdkWarning(activity);
            getTaskService().alwaysShowUnsupportedCompileSdkWarning(activity);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -3907,6 +3907,10 @@ public class ActivityManager {
        return IActivityManagerSingleton.get();
    }

    private static IActivityTaskManager getTaskService() {
        return ActivityTaskManager.getService();
    }

    private static final Singleton<IActivityManager> IActivityManagerSingleton =
            new Singleton<IActivityManager>() {
                @Override
@@ -4022,7 +4026,7 @@ public class ActivityManager {
     */
    public int getLockTaskModeState() {
        try {
            return getService().getLockTaskModeState();
            return getTaskService().getLockTaskModeState();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+10 −10

File changed.

Preview size limit exceeded, changes collapsed.

Loading