From 87d0e254cdc639347b73aa5f60ec8ab6c5327c7e Mon Sep 17 00:00:00 2001 From: Xiaohui Chen Date: Thu, 30 Jul 2015 15:38:16 -0700 Subject: [PATCH] clean up UserHandle.USER_OWNER reference. Clean up system ui. As you can see, I can picking up the easy ones first. Bug: 19913735 Change-Id: I94d33b108ae8b40ec92bbfca0863e266549f9633 --- .../systemui/GuestResumeSessionReceiver.java | 6 +-- .../keyguard/KeyguardViewMediator.java | 2 +- .../com/android/systemui/recents/Recents.java | 45 +++++++++---------- .../recents/misc/SystemServicesProxy.java | 4 +- .../systemui/settings/CurrentUserTracker.java | 4 -- .../KeyguardIndicationController.java | 4 +- .../systemui/statusbar/StatusBarIconView.java | 2 +- .../statusbar/phone/DemoStatusIcons.java | 2 +- 8 files changed, 32 insertions(+), 37 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/GuestResumeSessionReceiver.java b/packages/SystemUI/src/com/android/systemui/GuestResumeSessionReceiver.java index 714b0a83900e2..ec19e5aca7ca4 100644 --- a/packages/SystemUI/src/com/android/systemui/GuestResumeSessionReceiver.java +++ b/packages/SystemUI/src/com/android/systemui/GuestResumeSessionReceiver.java @@ -47,7 +47,7 @@ public class GuestResumeSessionReceiver extends BroadcastReceiver { public void register(Context context) { IntentFilter f = new IntentFilter(Intent.ACTION_USER_SWITCHED); - context.registerReceiverAsUser(this, UserHandle.OWNER, + context.registerReceiverAsUser(this, UserHandle.SYSTEM, f, null /* permission */, null /* scheduler */); } @@ -121,8 +121,8 @@ public class GuestResumeSessionReceiver extends BroadcastReceiver { try { if (newGuest == null) { - Log.e(TAG, "Could not create new guest, switching back to owner"); - ActivityManagerNative.getDefault().switchUser(UserHandle.USER_OWNER); + Log.e(TAG, "Could not create new guest, switching back to system user"); + ActivityManagerNative.getDefault().switchUser(UserHandle.USER_SYSTEM); userManager.removeUser(currentUser.id); WindowManagerGlobal.getWindowManagerService().lockNow(null /* options */); return; diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index f0154a78d8d78..ae6ce538fd705 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -340,7 +340,7 @@ public class KeyguardViewMediator extends SystemUI { @Override public void onUserSwitchComplete(int userId) { mSwitchingUser = false; - if (userId != UserHandle.USER_OWNER) { + if (userId != UserHandle.USER_SYSTEM) { UserInfo info = UserManager.get(mContext).getUserInfo(userId); if (info != null && info.isGuest()) { // If we just switched to a guest, try to dismiss keyguard. diff --git a/packages/SystemUI/src/com/android/systemui/recents/Recents.java b/packages/SystemUI/src/com/android/systemui/recents/Recents.java index 8c2ac883dce92..0cfa7a18032dc 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/Recents.java +++ b/packages/SystemUI/src/com/android/systemui/recents/Recents.java @@ -20,7 +20,6 @@ import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityOptions; import android.app.ITaskStackListener; -import android.appwidget.AppWidgetProviderInfo; import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; import android.content.Context; @@ -62,15 +61,15 @@ import com.android.systemui.statusbar.phone.PhoneStatusBar; import java.util.ArrayList; /** - * Annotation for a method that is only called from the primary user's SystemUI process and will be + * Annotation for a method that is only called from the system user's SystemUI process and will be * proxied to the current user. */ -@interface ProxyFromPrimaryToCurrentUser {} +@interface ProxyFromSystemToCurrentUser {} /** * Annotation for a method that may be called from any user's SystemUI process and will be proxied - * to the primary user. + * to the system user. */ -@interface ProxyFromAnyToPrimaryUser {} +@interface ProxyFromAnyToSystemUser {} /** A proxy implementation for the recents component */ public class Recents extends SystemUI @@ -225,7 +224,7 @@ public class Recents extends SystemUI } /** Initializes the Recents. */ - @ProxyFromPrimaryToCurrentUser + @ProxyFromSystemToCurrentUser @Override public void start() { if (sInstance == null) { @@ -245,7 +244,7 @@ public class Recents extends SystemUI // Only the owner has the callback to update the SysUI visibility flags, so all non-owner // instances of AlternateRecentsComponent needs to notify the owner when the visibility // changes. - if (mSystemServicesProxy.isForegroundUserOwner()) { + if (mSystemServicesProxy.isForegroundUserSystem()) { mProxyBroadcastReceiver = new RecentsOwnerEventProxyReceiver(); IntentFilter filter = new IntentFilter(); filter.addAction(Recents.ACTION_PROXY_NOTIFY_RECENTS_VISIBLITY_TO_OWNER); @@ -278,10 +277,10 @@ public class Recents extends SystemUI } /** Shows the Recents. */ - @ProxyFromPrimaryToCurrentUser + @ProxyFromSystemToCurrentUser @Override public void showRecents(boolean triggeredFromAltTab, View statusBarView) { - if (mSystemServicesProxy.isForegroundUserOwner()) { + if (mSystemServicesProxy.isForegroundUserSystem()) { showRecentsInternal(triggeredFromAltTab); } else { Intent intent = createLocalBroadcastIntent(mContext, @@ -302,10 +301,10 @@ public class Recents extends SystemUI } /** Hides the Recents. */ - @ProxyFromPrimaryToCurrentUser + @ProxyFromSystemToCurrentUser @Override public void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { - if (mSystemServicesProxy.isForegroundUserOwner()) { + if (mSystemServicesProxy.isForegroundUserSystem()) { hideRecentsInternal(triggeredFromAltTab, triggeredFromHomeKey); } else { Intent intent = createLocalBroadcastIntent(mContext, @@ -328,10 +327,10 @@ public class Recents extends SystemUI } /** Toggles the Recents activity. */ - @ProxyFromPrimaryToCurrentUser + @ProxyFromSystemToCurrentUser @Override public void toggleRecents(Display display, int layoutDirection, View statusBarView) { - if (mSystemServicesProxy.isForegroundUserOwner()) { + if (mSystemServicesProxy.isForegroundUserSystem()) { toggleRecentsInternal(); } else { Intent intent = createLocalBroadcastIntent(mContext, @@ -351,10 +350,10 @@ public class Recents extends SystemUI } /** Preloads info for the Recents activity. */ - @ProxyFromPrimaryToCurrentUser + @ProxyFromSystemToCurrentUser @Override public void preloadRecents() { - if (mSystemServicesProxy.isForegroundUserOwner()) { + if (mSystemServicesProxy.isForegroundUserSystem()) { preloadRecentsInternal(); } else { Intent intent = createLocalBroadcastIntent(mContext, @@ -483,9 +482,9 @@ public class Recents extends SystemUI } /** Updates on configuration change. */ - @ProxyFromPrimaryToCurrentUser + @ProxyFromSystemToCurrentUser public void onConfigurationChanged(Configuration newConfig) { - if (mSystemServicesProxy.isForegroundUserOwner()) { + if (mSystemServicesProxy.isForegroundUserSystem()) { configurationChanged(); } else { Intent intent = createLocalBroadcastIntent(mContext, @@ -849,16 +848,16 @@ public class Recents extends SystemUI } /** Notifies the callbacks that the visibility of Recents has changed. */ - @ProxyFromAnyToPrimaryUser + @ProxyFromAnyToSystemUser public static void notifyVisibilityChanged(Context context, SystemServicesProxy ssp, boolean visible) { - if (ssp.isForegroundUserOwner()) { + if (ssp.isForegroundUserSystem()) { visibilityChanged(visible); } else { Intent intent = createLocalBroadcastIntent(context, ACTION_PROXY_NOTIFY_RECENTS_VISIBLITY_TO_OWNER); intent.putExtra(EXTRA_RECENTS_VISIBILITY, visible); - context.sendBroadcastAsUser(intent, UserHandle.OWNER); + context.sendBroadcastAsUser(intent, UserHandle.SYSTEM); } } static void visibilityChanged(boolean visible) { @@ -868,14 +867,14 @@ public class Recents extends SystemUI } /** Notifies the status bar to trigger screen pinning. */ - @ProxyFromAnyToPrimaryUser + @ProxyFromAnyToSystemUser public static void startScreenPinning(Context context, SystemServicesProxy ssp) { - if (ssp.isForegroundUserOwner()) { + if (ssp.isForegroundUserSystem()) { onStartScreenPinning(context); } else { Intent intent = createLocalBroadcastIntent(context, ACTION_PROXY_SCREEN_PINNING_REQUEST_TO_OWNER); - context.sendBroadcastAsUser(intent, UserHandle.OWNER); + context.sendBroadcastAsUser(intent, UserHandle.SYSTEM); } } static void onStartScreenPinning(Context context) { diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java index 14fba2b90488e..afa32cbdf9853 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java @@ -526,10 +526,10 @@ public class SystemServicesProxy { /** * Returns whether the foreground user is the owner. */ - public boolean isForegroundUserOwner() { + public boolean isForegroundUserSystem() { if (mAm == null) return false; - return mAm.getCurrentUser() == UserHandle.USER_OWNER; + return mAm.getCurrentUser() == UserHandle.USER_SYSTEM; } /** diff --git a/packages/SystemUI/src/com/android/systemui/settings/CurrentUserTracker.java b/packages/SystemUI/src/com/android/systemui/settings/CurrentUserTracker.java index f8ff616599cf0..d8a202c49e857 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/CurrentUserTracker.java +++ b/packages/SystemUI/src/com/android/systemui/settings/CurrentUserTracker.java @@ -58,8 +58,4 @@ public abstract class CurrentUserTracker extends BroadcastReceiver { } public abstract void onUserSwitched(int newUserId); - - public boolean isCurrentUserOwner() { - return mCurrentUserId == UserHandle.USER_OWNER; - } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java index 31c94f788a6f7..46b00c7bf2b76 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java @@ -79,8 +79,8 @@ public class KeyguardIndicationController { mBatteryInfo = IBatteryStats.Stub.asInterface( ServiceManager.getService(BatteryStats.SERVICE_NAME)); KeyguardUpdateMonitor.getInstance(context).registerCallback(mUpdateMonitor); - context.registerReceiverAsUser( - mReceiver, UserHandle.OWNER, new IntentFilter(Intent.ACTION_TIME_TICK), null, null); + context.registerReceiverAsUser(mReceiver, UserHandle.SYSTEM, + new IntentFilter(Intent.ACTION_TIME_TICK), null, null); } public void setVisible(boolean visible) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java index baac8aceaa206..db2415a2d41ed 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java @@ -194,7 +194,7 @@ public class StatusBarIconView extends AnimatedImageView { public static Drawable getIcon(Context context, StatusBarIcon icon) { int userId = icon.user.getIdentifier(); if (userId == UserHandle.USER_ALL) { - userId = UserHandle.USER_OWNER; + userId = UserHandle.USER_SYSTEM; } return icon.icon.loadDrawableAsUser(context, userId); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java index fcdd4b7cd24b4..4f57906a718e8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java @@ -149,7 +149,7 @@ public class DemoStatusIcons extends LinearLayout implements DemoMode { } return; } - StatusBarIcon icon = new StatusBarIcon(iconPkg, UserHandle.OWNER, iconId, 0, 0, "Demo"); + StatusBarIcon icon = new StatusBarIcon(iconPkg, UserHandle.SYSTEM, iconId, 0, 0, "Demo"); StatusBarIconView v = new StatusBarIconView(getContext(), null, null); v.setTag(slot); v.set(icon);