diff --git a/core/java/android/view/IApplicationToken.aidl b/core/java/android/view/IApplicationToken.aidl deleted file mode 100644 index a063a70a3181a..0000000000000 --- a/core/java/android/view/IApplicationToken.aidl +++ /dev/null @@ -1,25 +0,0 @@ -/* //device/java/android/android/view/IApplicationToken.aidl -** -** Copyright 2007, 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.view; - -/** {@hide} */ -interface IApplicationToken -{ - String getName(); -} - diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index f7d32d08c3821..f74008bb9469f 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -34,7 +34,6 @@ import android.os.IRemoteCallback; import android.os.ParcelFileDescriptor; import android.view.DisplayCutout; import android.view.DisplayInfo; -import android.view.IApplicationToken; import android.view.IAppTransitionAnimationSpecsFuture; import android.view.ICrossWindowBlurEnabledListener; import android.view.IDisplayWindowInsetsController; diff --git a/services/core/java/com/android/server/policy/WindowManagerPolicy.java b/services/core/java/com/android/server/policy/WindowManagerPolicy.java index 78b03b2b88e76..496cd9e3cadb9 100644 --- a/services/core/java/com/android/server/policy/WindowManagerPolicy.java +++ b/services/core/java/com/android/server/policy/WindowManagerPolicy.java @@ -27,6 +27,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVE import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_PANEL; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL; +import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS; import static android.view.WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; @@ -78,7 +79,6 @@ import android.os.RemoteException; import android.util.Slog; import android.util.proto.ProtoOutputStream; import android.view.Display; -import android.view.IApplicationToken; import android.view.IDisplayFoldListener; import android.view.IWindowManager; import android.view.KeyEvent; @@ -202,14 +202,6 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants { */ public int getBaseType(); - /** - * Return the token for the application (actually activity) that owns - * this window. May return null for system windows. - * - * @return An IApplicationToken identifying the owning activity. - */ - public IApplicationToken getAppToken(); - /** * Return true if this window (or a window it is attached to, but not * considering its app token) is currently animating. @@ -676,7 +668,7 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants { */ default boolean canBeHiddenByKeyguardLw(WindowState win) { // Keyguard visibility of window from activities are determined over activity visibility. - if (win.getAppToken() != null) { + if (win.getBaseType() == TYPE_BASE_APPLICATION) { return false; } switch (win.getAttrs().type) { diff --git a/services/core/java/com/android/server/wm/ActivityAssistInfo.java b/services/core/java/com/android/server/wm/ActivityAssistInfo.java index 054044b472457..e1e7ee4b3f9e8 100644 --- a/services/core/java/com/android/server/wm/ActivityAssistInfo.java +++ b/services/core/java/com/android/server/wm/ActivityAssistInfo.java @@ -30,7 +30,7 @@ public class ActivityAssistInfo { private final int mTaskId; public ActivityAssistInfo(ActivityRecord activityRecord) { - this.mActivityToken = activityRecord.appToken; + this.mActivityToken = activityRecord.token; this.mAssistToken = activityRecord.assistToken; this.mTaskId = activityRecord.getTask().mTaskId; } diff --git a/services/core/java/com/android/server/wm/ActivityClientController.java b/services/core/java/com/android/server/wm/ActivityClientController.java index ee72fc8622a52..6c9f1e5bee617 100644 --- a/services/core/java/com/android/server/wm/ActivityClientController.java +++ b/services/core/java/com/android/server/wm/ActivityClientController.java @@ -558,7 +558,7 @@ class ActivityClientController extends IActivityClientController.Stub { final ActivityRecord below = ar.getTask().getActivity((r) -> !r.finishing, ar, false /*includeBoundary*/, true /*traverseTopToBottom*/); if (below != null && below.getUid() == ar.getUid()) { - return below.appToken.asBinder(); + return below.token; } } } finally { diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index b19f23336d7a0..67e51e7e94ac7 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -300,7 +300,6 @@ import android.view.AppTransitionAnimationSpec; import android.view.DisplayCutout; import android.view.DisplayInfo; import android.view.IAppTransitionAnimationSpecsFuture; -import android.view.IApplicationToken; import android.view.InputApplicationHandle; import android.view.RemoteAnimationAdapter; import android.view.RemoteAnimationDefinition; @@ -423,8 +422,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A final ActivityTaskManagerService mAtmService; final ActivityInfo info; // activity info provided by developer in AndroidManifest - // TODO: rename to mActivityToken - final ActivityRecord.Token appToken; // Which user is this running for? final int mUserId; // The package implementing intent's component @@ -1222,7 +1219,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A TransferPipe tp = new TransferPipe(); try { r.app.getThread().dumpActivity( - tp.getWriteFd(), r.appToken, innerPrefix, args); + tp.getWriteFd(), r.token, innerPrefix, args); // Short timeout, since blocking here can deadlock with the application. tp.go(fd, 2000); } finally { @@ -1289,7 +1286,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A + "display, activityRecord=%s, displayId=%d, config=%s", this, displayId, config); - mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken, + mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), token, MoveToDisplayItem.obtain(displayId, config)); } catch (RemoteException e) { // If process died, whatever. @@ -1306,7 +1303,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A ProtoLog.v(WM_DEBUG_CONFIGURATION, "Sending new config to %s, " + "config: %s", this, config); - mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken, + mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), token, ActivityConfigurationChangeItem.obtain(config)); } catch (RemoteException e) { // If process died, whatever. @@ -1324,7 +1321,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A ProtoLog.v(WM_DEBUG_STATES, "Sending position change to %s, onTop: %b", this, onTop); - mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken, + mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), token, TopResumedActivityChangeItem.obtain(onTop)); } catch (RemoteException e) { // If process died, whatever. @@ -1574,60 +1571,27 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return mLetterboxUiController.isFullyTransparentBarAllowed(rect); } - static class Token extends IApplicationToken.Stub { - private WeakReference weakActivity; - private final String name; - private final String tokenString; - - Token(Intent intent) { - name = intent.getComponent().flattenToShortString(); - tokenString = "Token{" + Integer.toHexString(System.identityHashCode(this)) + "}"; - } - - private void attach(ActivityRecord activity) { - if (weakActivity != null) { - throw new IllegalStateException("Already attached..." + this); - } - weakActivity = new WeakReference<>(activity); - } - - private static @Nullable ActivityRecord tokenToActivityRecordLocked(Token token) { - if (token == null) { - return null; - } - ActivityRecord r = token.weakActivity.get(); - if (r == null || r.getRootTask() == null) { - return null; - } - return r; - } + private static class Token extends Binder { + @NonNull WeakReference mActivityRef; @Override public String toString() { - StringBuilder sb = new StringBuilder(128); - sb.append("Token{"); - sb.append(Integer.toHexString(System.identityHashCode(this))); - sb.append(' '); - if (weakActivity != null) { - sb.append(weakActivity.get()); - } - sb.append('}'); - return sb.toString(); - } - - @Override - public String getName() { - return name; + return "Token{" + Integer.toHexString(System.identityHashCode(this)) + " " + + mActivityRef.get() + "}"; } } static @Nullable ActivityRecord forTokenLocked(IBinder token) { + if (token == null) return null; + final Token activityToken; try { - return Token.tokenToActivityRecordLocked((Token)token); + activityToken = (Token) token; } catch (ClassCastException e) { Slog.w(TAG, "Bad activity token: " + token, e); return null; } + final ActivityRecord r = activityToken.mActivityRef.get(); + return r == null || r.getRootTask() == null ? null : r; } static boolean isResolverActivity(String className) { @@ -1659,11 +1623,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A boolean _rootVoiceInteraction, ActivityTaskSupervisor supervisor, ActivityOptions options, ActivityRecord sourceRecord, PersistableBundle persistentState, TaskDescription _taskDescription, long _createTime) { - super(_service.mWindowManager, new Token(_intent).asBinder(), TYPE_APPLICATION, true, + super(_service.mWindowManager, new Token(), TYPE_APPLICATION, true, null /* displayContent */, false /* ownerCanManageAppTokens */); mAtmService = _service; - appToken = (Token) token; + ((Token) token).mActivityRef = new WeakReference<>(this); info = aInfo; mUserId = UserHandle.getUserId(info.applicationInfo.uid); packageName = info.applicationInfo.packageName; @@ -1727,8 +1691,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A cds.attachColorTransformController(packageName, mUserId, new WeakReference<>(mColorTransformController)); - appToken.attach(this); - mRootWindowContainer = _service.mRootWindowContainer; launchedFromPid = _launchedFromPid; launchedFromUid = _launchedFromUid; @@ -1866,13 +1828,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A @NonNull InputApplicationHandle getInputApplicationHandle(boolean update) { if (mInputApplicationHandle == null) { - mInputApplicationHandle = new InputApplicationHandle(appToken, toString(), + mInputApplicationHandle = new InputApplicationHandle(token, toString(), mInputDispatchingTimeoutMillis); } else if (update) { final String name = toString(); if (mInputDispatchingTimeoutMillis != mInputApplicationHandle.dispatchingTimeoutMillis || !name.equals(mInputApplicationHandle.name)) { - mInputApplicationHandle = new InputApplicationHandle(appToken, name, + mInputApplicationHandle = new InputApplicationHandle(token, name, mInputDispatchingTimeoutMillis); } } @@ -2334,7 +2296,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A .applyStartingWindowAnimation(mStartingWindow); try { mTransferringSplashScreenState = TRANSFER_SPLASH_SCREEN_ATTACH_TO_CLIENT; - mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken, + mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), token, TransferSplashScreenViewStateItem.obtain(parcelable, windowAnimationLeash)); scheduleTransferSplashScreenTimeout(); @@ -2476,7 +2438,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A */ void reparent(TaskFragment newTaskFrag, int position, String reason) { if (getParent() == null) { - Slog.w(TAG, "reparent: Attempted to reparent non-existing app token: " + appToken); + Slog.w(TAG, "reparent: Attempted to reparent non-existing app token: " + token); return; } final TaskFragment prevTaskFrag = getTaskFragment(); @@ -3432,7 +3394,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A try { if (DEBUG_SWITCH) Slog.i(TAG_SWITCH, "Destroying: " + this); - mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken, + mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), token, DestroyActivityItem.obtain(finishing, configChangeFlags)); } catch (Exception e) { // We can just ignore exceptions here... if the process has crashed, our death @@ -3512,7 +3474,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A detachFromProcess(); // Resume key dispatching if it is currently paused before we remove the container. resumeKeyDispatchingLocked(); - mDisplayContent.removeAppToken(appToken); + mDisplayContent.removeAppToken(token); cleanUpActivityServices(); removeUriPermissionsLocked(); @@ -4299,7 +4261,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A try { final ArrayList list = new ArrayList(); list.add(new ResultInfo(resultWho, requestCode, resultCode, data)); - mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken, + mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), token, ActivityResultItem.obtain(list)); return; } catch (Exception e) { @@ -4347,7 +4309,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // Making sure the client state is RESUMED after transaction completed and doing // so only if activity is currently RESUMED. Otherwise, client may have extra // life-cycle calls to RESUMED (and PAUSED later). - mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken, + mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), token, NewIntentItem.obtain(ar, mState == RESUMED)); unsent = false; } catch (RemoteException e) { @@ -4708,8 +4670,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A */ void setVisibility(boolean visible) { if (getParent() == null) { - Slog.w(TAG_WM, "Attempted to set visibility of non-existing app token: " - + appToken); + Slog.w(TAG_WM, "Attempted to set visibility of non-existing app token: " + token); return; } if (visible) { @@ -4747,7 +4708,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A ProtoLog.v(WM_DEBUG_APP_TRANSITIONS, "setAppVisibility(%s, visible=%b): %s visible=%b mVisibleRequested=%b Callers=%s", - appToken, visible, appTransition, isVisible(), mVisibleRequested, + token, visible, appTransition, isVisible(), mVisibleRequested, Debug.getCallers(6)); // Before setting mVisibleRequested so we can track changes. @@ -5116,7 +5077,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (state == STOPPING && !isSleeping()) { if (getParent() == null) { Slog.w(TAG_WM, "Attempted to notify stopping on non-existing app token: " - + appToken); + + token); return; } } @@ -5247,8 +5208,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A void notifyAppResumed(boolean wasStopped) { if (getParent() == null) { - Slog.w(TAG_WM, "Attempted to notify resumed of non-existing app token: " - + appToken); + Slog.w(TAG_WM, "Attempted to notify resumed of non-existing app token: " + token); return; } ProtoLog.v(WM_DEBUG_ADD_REMOVE, "notifyAppResumed: wasStopped=%b %s", @@ -5464,7 +5424,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // the move to {@link PAUSED}. setState(PAUSING, "makeActiveIfNeeded"); try { - mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken, + mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), token, PauseActivityItem.obtain(finishing, false /* userLeaving */, configChangeFlags, false /* dontReport */)); } catch (Exception e) { @@ -5477,7 +5437,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A setState(STARTED, "makeActiveIfNeeded"); try { - mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken, + mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), token, StartActivityItem.obtain(takeOptions())); } catch (Exception e) { Slog.w(TAG, "Exception thrown sending start: " + intent.getComponent(), e); @@ -5585,7 +5545,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A stopFreezingScreenLocked(false); try { if (returningOptions != null) { - app.getThread().scheduleOnNewActivityOptions(appToken, returningOptions.toBundle()); + app.getThread().scheduleOnNewActivityOptions(token, returningOptions.toBundle()); } } catch(RemoteException e) { } @@ -5664,7 +5624,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } void activityPaused(boolean timeout) { - ProtoLog.v(WM_DEBUG_STATES, "Activity paused: token=%s, timeout=%b", appToken, + ProtoLog.v(WM_DEBUG_STATES, "Activity paused: token=%s, timeout=%b", token, timeout); final TaskFragment taskFragment = getTaskFragment(); @@ -5764,7 +5724,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } EventLogTags.writeWmStopActivity( mUserId, System.identityHashCode(this), shortComponentName); - mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken, + mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), token, StopActivityItem.obtain(configChangeFlags)); mAtmService.mH.postDelayed(mStopTimeoutRunnable, STOP_TIMEOUT); @@ -5912,14 +5872,14 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (mayFreezeScreenLocked(app)) { if (getParent() == null) { Slog.w(TAG_WM, - "Attempted to freeze screen with non-existing app token: " + appToken); + "Attempted to freeze screen with non-existing app token: " + token); return; } // Window configuration changes only effect windows, so don't require a screen freeze. int freezableConfigChanges = configChanges & ~(CONFIG_WINDOW_CONFIGURATION); if (freezableConfigChanges == 0 && okToDisplay()) { - ProtoLog.v(WM_DEBUG_ORIENTATION, "Skipping set freeze of %s", appToken); + ProtoLog.v(WM_DEBUG_ORIENTATION, "Skipping set freeze of %s", token); return; } @@ -5937,7 +5897,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } ProtoLog.i(WM_DEBUG_ORIENTATION, "Set freezing of %s: visible=%b freezing=%b visibleRequested=%b. %s", - appToken, isVisible(), mFreezingScreen, mVisibleRequested, + token, isVisible(), mFreezingScreen, mVisibleRequested, new RuntimeException().fillInStackTrace()); if (!mVisibleRequested) { return; @@ -5993,7 +5953,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return; } ProtoLog.v(WM_DEBUG_ORIENTATION, - "Clear freezing of %s: visible=%b freezing=%b", appToken, + "Clear freezing of %s: visible=%b freezing=%b", token, isVisible(), isFreezingScreen()); stopFreezingScreen(true, force); } @@ -6117,7 +6077,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A /** Called when the windows associated app window container are visible. */ void onWindowsVisible() { - if (DEBUG_VISIBILITY) Slog.v(TAG_WM, "Reporting visible in " + appToken); + if (DEBUG_VISIBILITY) Slog.v(TAG_WM, "Reporting visible in " + token); mTaskSupervisor.stopWaitingForActivityVisible(this); if (DEBUG_SWITCH) Log.v(TAG_SWITCH, "windowsVisibleLocked(): " + this); if (!nowVisible) { @@ -6143,7 +6103,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A /** Called when the windows associated app window container are no longer visible. */ void onWindowsGone() { - if (DEBUG_VISIBILITY) Slog.v(TAG_WM, "Reporting gone in " + appToken); + if (DEBUG_VISIBILITY) Slog.v(TAG_WM, "Reporting gone in " + token); if (DEBUG_SWITCH) Log.v(TAG_SWITCH, "windowsGone(): " + this); nowVisible = false; } @@ -8570,7 +8530,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } else { lifecycleItem = PauseActivityItem.obtain(); } - final ClientTransaction transaction = ClientTransaction.obtain(app.getThread(), appToken); + final ClientTransaction transaction = ClientTransaction.obtain(app.getThread(), token); transaction.addCallback(callbackItem); transaction.setLifecycleStateRequest(lifecycleItem); mAtmService.getLifecycleManager().scheduleTransaction(transaction); @@ -8643,7 +8603,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // The process will be killed until the activity reports stopped with saved state (see // {@link ActivityTaskManagerService.activityStopped}). try { - mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), appToken, + mAtmService.getLifecycleManager().scheduleTransaction(app.getThread(), token, StopActivityItem.obtain(0 /* configChanges */)); } catch (RemoteException e) { Slog.w(TAG, "Exception thrown during restart " + this, e); @@ -9010,7 +8970,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } void writeNameToProto(ProtoOutputStream proto, long fieldId) { - proto.write(fieldId, appToken.getName()); + proto.write(fieldId, shortComponentName); } @Override diff --git a/services/core/java/com/android/server/wm/ActivityStartController.java b/services/core/java/com/android/server/wm/ActivityStartController.java index 6ad2f7cad3c2e..210b0aebceb24 100644 --- a/services/core/java/com/android/server/wm/ActivityStartController.java +++ b/services/core/java/com/android/server/wm/ActivityStartController.java @@ -470,7 +470,7 @@ public class ActivityStartController { if (started != null && started.getUid() == filterCallingUid) { // Only the started activity which has the same uid as the source caller // can be the caller of next activity. - resultTo = started.appToken; + resultTo = started.token; } else { resultTo = sourceResultTo; // Different apps not adjacent to the caller are forced to be new task. diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java b/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java index 960fa5044e3c0..9c68f2df8b83e 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java @@ -265,7 +265,7 @@ public abstract class ActivityTaskManagerInternal { /** * Set focus on an activity. - * @param token The IApplicationToken for the activity + * @param token The activity token. */ public abstract void setFocusedActivity(IBinder token); diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index 48afb7c0c1b15..886b05f25dc86 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -1350,7 +1350,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { .setCaller(r.app.getThread()) .setResolvedType(r.resolvedType) .setActivityInfo(aInfo) - .setResultTo(resultTo != null ? resultTo.appToken : null) + .setResultTo(resultTo != null ? resultTo.token : null) .setResultWho(resultWho) .setRequestCode(requestCode) .setCallingPid(-1) @@ -3194,7 +3194,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { mViSessionId++; } try { - activity.app.getThread().requestAssistContextExtras(activity.appToken, pae, + activity.app.getThread().requestAssistContextExtras(activity.token, pae, requestType, mViSessionId, flags); mPendingAssistExtras.add(pae); mUiHandler.postDelayed(pae, timeout); @@ -3439,7 +3439,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { // If the keyguard is showing or occluded, then try and dismiss it before // entering picture-in-picture (this will prompt the user to authenticate if the // device is currently locked). - mActivityClientController.dismissKeyguard(r.appToken, new KeyguardDismissCallback() { + mActivityClientController.dismissKeyguard(r.token, new KeyguardDismissCallback() { @Override public void onDismissSucceeded() { mH.post(enterPipRunnable); @@ -4010,7 +4010,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { // to write to the file descriptor directly pw.flush(); try (TransferPipe tp = new TransferPipe()) { - appThread.dumpActivity(tp.getWriteFd(), r.appToken, innerPrefix, args); + appThread.dumpActivity(tp.getWriteFd(), r.token, innerPrefix, args); tp.go(fd); } catch (IOException e) { pw.println(innerPrefix + "Failure while dumping the activity: " + e); @@ -4639,7 +4639,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { final Message m = PooledLambda.obtainMessage( ActivityManagerInternal::updateActivityUsageStats, mAmInternal, - activity.mActivityComponent, activity.mUserId, event, activity.appToken, taskRoot); + activity.mActivityComponent, activity.mUserId, event, activity.token, taskRoot); mH.sendMessage(m); } @@ -5747,7 +5747,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { + activity); return null; } - return new ActivityTokens(activity.appToken, activity.assistToken, + return new ActivityTokens(activity.token, activity.assistToken, activity.app.getThread(), activity.shareableActivityToken); } } diff --git a/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java b/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java index ba305929d808a..11b685e8b87f6 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java +++ b/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java @@ -850,7 +850,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks { // Create activity launch transaction. final ClientTransaction clientTransaction = ClientTransaction.obtain( - proc.getThread(), r.appToken); + proc.getThread(), r.token); final boolean isTransitionForward = r.isTransitionForward(); clientTransaction.addCallback(LaunchActivityItem.obtain(new Intent(r.intent), diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 9d63a479a3fc2..7c75b200323d8 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -875,7 +875,7 @@ class Task extends TaskFragment { // entrance of the new window to be properly animated. // Note here we always set the replacing window first, as the flags might be needed // during the relaunch. If we end up not doing any relaunch, we clear the flags later. - windowManager.setWillReplaceWindow(topActivity.appToken, animate); + windowManager.setWillReplaceWindow(topActivity.token, animate); } mAtmService.deferWindowLayout(); @@ -932,7 +932,7 @@ class Task extends TaskFragment { // If we didn't actual do a relaunch (indicated by kept==true meaning we kept the old // window), we need to clear the replace window settings. Otherwise, we schedule a // timeout to remove the old window if the replacing window is not coming in time. - windowManager.scheduleClearWillReplaceWindows(topActivity.appToken, !kept); + windowManager.scheduleClearWillReplaceWindows(topActivity.token, !kept); } if (!deferResume) { @@ -3033,7 +3033,7 @@ class Task extends TaskFragment { } private static boolean isTopRunning(ActivityRecord r, int taskId, IBinder notTop) { - return r.getTask().mTaskId != taskId && r.appToken != notTop && r.canBeTopRunning(); + return r.getTask().mTaskId != taskId && r.token != notTop && r.canBeTopRunning(); } ActivityRecord getTopFullscreenActivity() { @@ -4853,11 +4853,11 @@ class Task extends TaskFragment { mHandler.removeMessages(TRANSLUCENT_TIMEOUT_MSG); if (waitingActivity != null) { - mWmService.setWindowOpaqueLocked(waitingActivity.appToken, false); + mWmService.setWindowOpaqueLocked(waitingActivity.token, false); if (waitingActivity.attachedToProcess()) { try { waitingActivity.app.getThread().scheduleTranslucentConversionComplete( - waitingActivity.appToken, r != null); + waitingActivity.token, r != null); } catch (RemoteException e) { } } @@ -5263,7 +5263,7 @@ class Task extends TaskFragment { // Inform of cancellation r.clearVoiceSessionLocked(); try { - r.app.getThread().scheduleLocalVoiceInteractionStarted(r.appToken, null); + r.app.getThread().scheduleLocalVoiceInteractionStarted(r.token, null); } catch (RemoteException re) { // Ok Boomer... } @@ -5359,7 +5359,7 @@ class Task extends TaskFragment { // We should consolidate. IActivityController controller = mAtmService.mController; if (controller != null) { - ActivityRecord next = topRunningActivity(srec.appToken, INVALID_TASK_ID); + ActivityRecord next = topRunningActivity(srec.token, INVALID_TASK_ID); if (next != null) { // ask watcher if this is allowed boolean resumeOK = true; @@ -5416,7 +5416,7 @@ class Task extends TaskFragment { .obtainStarter(destIntent, "navigateUpTo") .setCaller(srec.app.getThread()) .setActivityInfo(aInfo) - .setResultTo(parent.appToken) + .setResultTo(parent.token) .setCallingPid(-1) .setCallingUid(callingUid) .setCallingPackage(srec.packageName) diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java index 9a70bf7ae369f..b8393f642a206 100644 --- a/services/core/java/com/android/server/wm/TaskFragment.java +++ b/services/core/java/com/android/server/wm/TaskFragment.java @@ -1234,7 +1234,7 @@ class TaskFragment extends WindowContainer { try { final ClientTransaction transaction = - ClientTransaction.obtain(next.app.getThread(), next.appToken); + ClientTransaction.obtain(next.app.getThread(), next.token); // Deliver all pending results. ArrayList a = next.results; if (a != null) { @@ -1483,7 +1483,7 @@ class TaskFragment extends WindowContainer { prev.shortComponentName, "userLeaving=" + userLeaving, reason); mAtmService.getLifecycleManager().scheduleTransaction(prev.app.getThread(), - prev.appToken, PauseActivityItem.obtain(prev.finishing, userLeaving, + prev.token, PauseActivityItem.obtain(prev.finishing, userLeaving, prev.configChangeFlags, pauseImmediately)); } catch (Exception e) { // Ignore exception, if process died other code will cleanup. @@ -2164,7 +2164,7 @@ class TaskFragment extends WindowContainer { && wc.asActivityRecord() != null && wc.asActivityRecord().getPid() == mTaskFragmentOrganizerPid) { // Only includes Activities that belong to the organizer process for security. - childActivities.add(wc.asActivityRecord().appToken); + childActivities.add(wc.asActivityRecord().token); } } final Point positionInParent = new Point(); diff --git a/services/core/java/com/android/server/wm/TaskPositioningController.java b/services/core/java/com/android/server/wm/TaskPositioningController.java index 525420e045b5a..4d3219d0ec97c 100644 --- a/services/core/java/com/android/server/wm/TaskPositioningController.java +++ b/services/core/java/com/android/server/wm/TaskPositioningController.java @@ -158,7 +158,7 @@ class TaskPositioningController { + "win=" + win + ", resize=" + resize + ", preserveOrientation=" + preserveOrientation + ", {" + startX + ", " + startY + "}"); - if (win == null || win.getAppToken() == null) { + if (win == null || win.mActivityRecord == null) { Slog.w(TAG_WM, "startPositioningLocked: Bad window " + win); return false; } diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 0fb26d5a5519f..226793a45f885 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -1134,7 +1134,7 @@ public class WindowManagerService extends IWindowManager.Stub atoken.mEnteringAnimation = false; if (atoken.attachedToProcess()) { try { - atoken.app.getThread().scheduleEnterAnimationComplete(atoken.appToken); + atoken.app.getThread().scheduleEnterAnimationComplete(atoken.token); } catch (RemoteException e) { } } diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 9a43f6b5ac2e7..c31f439bf6b9d 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -225,7 +225,6 @@ import android.util.proto.ProtoOutputStream; import android.view.Display; import android.view.DisplayInfo; import android.view.Gravity; -import android.view.IApplicationToken; import android.view.IWindow; import android.view.IWindowFocusObserver; import android.view.IWindowId; @@ -1506,11 +1505,6 @@ class WindowState extends WindowContainer implements WindowManagerP return getTopParentWindow().mAttrs.type; } - @Override - public IApplicationToken getAppToken() { - return mActivityRecord != null ? mActivityRecord.appToken : null; - } - /** Returns true if this window is participating in voice interaction. */ boolean isVoiceInteraction() { return mActivityRecord != null && mActivityRecord.mVoiceInteraction; @@ -4771,7 +4765,7 @@ class WindowState extends WindowContainer implements WindowManagerP windowInfo.layer = mLayer; windowInfo.token = mClient.asBinder(); if (mActivityRecord != null) { - windowInfo.activityToken = mActivityRecord.appToken.asBinder(); + windowInfo.activityToken = mActivityRecord.token; } windowInfo.title = mAttrs.accessibilityTitle; // Panel windows have no public way to set the a11y title directly. Use the diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java index 5504f06236e39..1f7597e800d44 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -508,7 +508,7 @@ public class ActivityRecordTests extends WindowTestsBase { final ActivityConfigurationChangeItem expected = ActivityConfigurationChangeItem.obtain(newConfig); verify(mAtm.getLifecycleManager()).scheduleTransaction(eq(activity.app.getThread()), - eq(activity.appToken), eq(expected)); + eq(activity.token), eq(expected)); } @Test @@ -723,7 +723,7 @@ public class ActivityRecordTests extends WindowTestsBase { final ActivityConfigurationChangeItem expected = ActivityConfigurationChangeItem.obtain(newConfig); verify(mAtm.getLifecycleManager()).scheduleTransaction( - eq(activity.app.getThread()), eq(activity.appToken), eq(expected)); + eq(activity.app.getThread()), eq(activity.token), eq(expected)); } finally { stack.getDisplayArea().removeChild(stack); } @@ -787,7 +787,7 @@ public class ActivityRecordTests extends WindowTestsBase { final ActivityRecord activity = createActivityWithTask(); assertTrue(activity.hasSavedState()); - ActivityRecord.activityResumedLocked(activity.appToken, false /* handleSplashScreenExit */); + ActivityRecord.activityResumedLocked(activity.token, false /* handleSplashScreenExit */); assertFalse(activity.hasSavedState()); assertNull(activity.getSavedState()); } @@ -1610,7 +1610,7 @@ public class ActivityRecordTests extends WindowTestsBase { setup.accept(activity); activity.getTask().removeImmediately("test"); try { - verify(mAtm.getLifecycleManager()).scheduleTransaction(any(), eq(activity.appToken), + verify(mAtm.getLifecycleManager()).scheduleTransaction(any(), eq(activity.token), isA(DestroyActivityItem.class)); } catch (RemoteException ignored) { } diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java index 3e8a2e9b7b178..0cab9119a5f74 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java @@ -264,7 +264,7 @@ public class ActivityStarterTests extends WindowTestsBase { final IBinder resultTo = containsConditions(preconditions, PRECONDITION_SOURCE_PRESENT) || containsConditions(preconditions, PRECONDITION_SOURCE_VOICE_SESSION) - ? source.appToken : null; + ? source.token : null; final int requestCode = containsConditions(preconditions, PRECONDITION_REQUEST_CODE) ? 1 : 0; diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java index 5d1a06825a754..4c3c31849c2c3 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java @@ -104,12 +104,12 @@ public class ActivityTaskManagerServiceTests extends WindowTestsBase { final Task stack = new TaskBuilder(mSupervisor).setCreateActivity(true).build(); final ActivityRecord activity = stack.getBottomMostTask().getTopNonFinishingActivity(); assertTrue("Activity must be finished", mAtm.mActivityClientController.finishActivity( - activity.appToken, 0 /* resultCode */, null /* resultData */, + activity.token, 0 /* resultCode */, null /* resultData */, Activity.DONT_FINISH_TASK_WITH_ACTIVITY)); assertTrue(activity.finishing); assertTrue("Duplicate activity finish request must also return 'true'", - mAtm.mActivityClientController.finishActivity(activity.appToken, 0 /* resultCode */, + mAtm.mActivityClientController.finishActivity(activity.token, 0 /* resultCode */, null /* resultData */, Activity.DONT_FINISH_TASK_WITH_ACTIVITY)); } diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java index 6407c92ee2aa8..e04cff4bdbb42 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -149,7 +149,7 @@ public class SizeCompatTests extends WindowTestsBase { final Rect originalOverrideBounds = new Rect(mActivity.getBounds()); resizeDisplay(mTask.mDisplayContent, 600, 1200); // The visible activity should recompute configuration according to the last parent bounds. - mAtm.mActivityClientController.restartActivityProcessIfVisible(mActivity.appToken); + mAtm.mActivityClientController.restartActivityProcessIfVisible(mActivity.token); assertEquals(RESTARTING_PROCESS, mActivity.getState()); assertNotEquals(originalOverrideBounds, mActivity.getBounds()); diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentOrganizerControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentOrganizerControllerTest.java index d475c46eed0c3..cbdf4fe4551f9 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentOrganizerControllerTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentOrganizerControllerTest.java @@ -411,7 +411,7 @@ public class TaskFragmentOrganizerControllerTest extends WindowTestsBase { .build(); mAtm.mWindowOrganizerController.mLaunchTaskFragments .put(mFragmentToken, mTaskFragment); - mTransaction.reparentActivityToTaskFragment(mFragmentToken, activity.appToken); + mTransaction.reparentActivityToTaskFragment(mFragmentToken, activity.token); clearInvocations(mAtm.mRootWindowContainer); mAtm.getWindowOrganizerController().applyTransaction(mTransaction); diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java index ce568f152a5f2..5fde7eb895e4a 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java @@ -1056,9 +1056,9 @@ public class TaskTests extends WindowTestsBase { final ActivityRecord activity1 = task1.getBottomMostActivity(); assertEquals(task0.mTaskId, - ActivityRecord.getTaskForActivityLocked(activity0.appToken, false /* onlyRoot */)); + ActivityRecord.getTaskForActivityLocked(activity0.token, false /* onlyRoot */)); assertEquals(task1.mTaskId, - ActivityRecord.getTaskForActivityLocked(activity1.appToken, false /* onlyRoot */)); + ActivityRecord.getTaskForActivityLocked(activity1.token, false /* onlyRoot */)); } /** @@ -1077,11 +1077,11 @@ public class TaskTests extends WindowTestsBase { final ActivityRecord activity2 = new ActivityBuilder(mAtm).setTask(task).build(); assertEquals(task.mTaskId, - ActivityRecord.getTaskForActivityLocked(activity0.appToken, true /* onlyRoot */)); + ActivityRecord.getTaskForActivityLocked(activity0.token, true /* onlyRoot */)); assertEquals(task.mTaskId, - ActivityRecord.getTaskForActivityLocked(activity1.appToken, true /* onlyRoot */)); + ActivityRecord.getTaskForActivityLocked(activity1.token, true /* onlyRoot */)); assertEquals("No task must be reported for activity that is above root", INVALID_TASK_ID, - ActivityRecord.getTaskForActivityLocked(activity2.appToken, true /* onlyRoot */)); + ActivityRecord.getTaskForActivityLocked(activity2.token, true /* onlyRoot */)); } /** @@ -1100,11 +1100,11 @@ public class TaskTests extends WindowTestsBase { final ActivityRecord activity2 = new ActivityBuilder(mAtm).setTask(task).build(); assertEquals(task.mTaskId, - ActivityRecord.getTaskForActivityLocked(activity0.appToken, true /* onlyRoot */)); + ActivityRecord.getTaskForActivityLocked(activity0.token, true /* onlyRoot */)); assertEquals("No task must be reported for activity that is above root", INVALID_TASK_ID, - ActivityRecord.getTaskForActivityLocked(activity1.appToken, true /* onlyRoot */)); + ActivityRecord.getTaskForActivityLocked(activity1.token, true /* onlyRoot */)); assertEquals("No task must be reported for activity that is above root", INVALID_TASK_ID, - ActivityRecord.getTaskForActivityLocked(activity2.appToken, true /* onlyRoot */)); + ActivityRecord.getTaskForActivityLocked(activity2.token, true /* onlyRoot */)); } /** @@ -1126,11 +1126,11 @@ public class TaskTests extends WindowTestsBase { final ActivityRecord activity2 = new ActivityBuilder(mAtm).setTask(task).build(); assertEquals(task.mTaskId, - ActivityRecord.getTaskForActivityLocked(activity0.appToken, false /* onlyRoot */)); + ActivityRecord.getTaskForActivityLocked(activity0.token, false /* onlyRoot */)); assertEquals(task.mTaskId, - ActivityRecord.getTaskForActivityLocked(activity1.appToken, false /* onlyRoot */)); + ActivityRecord.getTaskForActivityLocked(activity1.token, false /* onlyRoot */)); assertEquals(task.mTaskId, - ActivityRecord.getTaskForActivityLocked(activity2.appToken, false /* onlyRoot */)); + ActivityRecord.getTaskForActivityLocked(activity2.token, false /* onlyRoot */)); } /**