diff options
author | Kenny Guy <kennyguy@google.com> | 2015-04-01 19:14:10 +0100 |
---|---|---|
committer | Kenny Guy <kennyguy@google.com> | 2015-04-13 20:58:44 +0000 |
commit | 3094d4a1c08c7911247a41236ba4956f7e762c52 (patch) | |
tree | 188f43b9cee103b953a014c4cb24d4b6952ea77c /packages/SystemUI/src/com/android/systemui/statusbar | |
parent | be16bf4be12b352d8be1ee85ff414a46ed5daa27 (diff) | |
download | frameworks_base-3094d4a1c08c7911247a41236ba4956f7e762c52.zip frameworks_base-3094d4a1c08c7911247a41236ba4956f7e762c52.tar.gz frameworks_base-3094d4a1c08c7911247a41236ba4956f7e762c52.tar.bz2 |
Show a status bar icon for managed profile activities.
Show a work icon in the status bar when the foreground
activity is from an app in the managed profile.
Bug: 19532434
Change-Id: Ie96935c089d26f44bc5b1b8fcf60c83a32283a0f
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/statusbar')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java | 5 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java | 82 |
2 files changed, 83 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 7c199cd..b0d6178 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -3288,8 +3288,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) { mScrimController.setKeyguardShowing(true); + mIconPolicy.setKeyguardShowing(true); } else { mScrimController.setKeyguardShowing(false); + mIconPolicy.setKeyguardShowing(false); } mNotificationPanel.setBarState(mState, mKeyguardFadingAway, goingToFullShade); updateDozingState(); @@ -3724,6 +3726,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, if (!mKeyguardFadingAway) { mIconController.appTransitionStarting(startTime, duration); } + if (mIconPolicy != null) { + mIconPolicy.appTransitionStarting(startTime, duration); + } } private final class ShadeUpdates { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java index ac93ced..fb42ba1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java @@ -16,16 +16,22 @@ package com.android.systemui.statusbar.phone; +import android.app.ActivityManagerNative; import android.app.AlarmManager; +import android.app.IUserSwitchObserver; import android.app.StatusBarManager; import android.bluetooth.BluetoothAdapter; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.pm.UserInfo; import android.media.AudioManager; import android.os.Handler; +import android.os.IRemoteCallback; +import android.os.RemoteException; import android.os.UserHandle; +import android.os.UserManager; import android.provider.Settings.Global; import android.telecom.TelecomManager; import android.util.Log; @@ -54,6 +60,7 @@ public class PhoneStatusBarPolicy { private static final String SLOT_ZEN = "zen"; private static final String SLOT_VOLUME = "volume"; private static final String SLOT_ALARM_CLOCK = "alarm_clock"; + private static final String SLOT_MANAGED_PROFILE = "managed_profile"; private final Context mContext; private final StatusBarManager mService; @@ -72,6 +79,10 @@ public class PhoneStatusBarPolicy { private boolean mBluetoothEnabled = false; + private boolean mManagedProfileFocused = false; + private boolean mManagedProfileIconVisible = true; + + private boolean mKeyguardVisible = true; private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { @Override @@ -94,9 +105,6 @@ public class PhoneStatusBarPolicy { else if (action.equals(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED)) { updateTTY(intent); } - else if (action.equals(Intent.ACTION_USER_SWITCHED)) { - updateAlarm(); - } } }; @@ -115,9 +123,15 @@ public class PhoneStatusBarPolicy { filter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED); filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED); filter.addAction(TelecomManager.ACTION_CURRENT_TTY_MODE_CHANGED); - filter.addAction(Intent.ACTION_USER_SWITCHED); mContext.registerReceiver(mIntentReceiver, filter, null, mHandler); + // listen for user / profile change. + try { + ActivityManagerNative.getDefault().registerUserSwitchObserver(mUserSwitchListener); + } catch (RemoteException e) { + // Ignore + } + // TTY status mService.setIcon(SLOT_TTY, R.drawable.stat_sys_tty_mode, 0, null); mService.setIconVisibility(SLOT_TTY, false); @@ -147,6 +161,10 @@ public class PhoneStatusBarPolicy { mService.setIcon(SLOT_HOTSPOT, R.drawable.stat_sys_hotspot, 0, null); mService.setIconVisibility(SLOT_HOTSPOT, mHotspot.isHotspotEnabled()); mHotspot.addCallback(mHotspotCallback); + + // managed profile + mService.setIcon(SLOT_MANAGED_PROFILE, R.drawable.stat_sys_managed_profile_status, 0, null); + mService.setIconVisibility(SLOT_MANAGED_PROFILE, false); } public void setZenMode(int zen) { @@ -298,6 +316,53 @@ public class PhoneStatusBarPolicy { mService.setIconVisibility(SLOT_CAST, isCasting); } + private void profileChanged(int userId) { + UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); + UserInfo user = null; + if (userId == UserHandle.USER_CURRENT) { + try { + user = ActivityManagerNative.getDefault().getCurrentUser(); + } catch (RemoteException e) { + // Ignore + } + } else { + user = userManager.getUserInfo(userId); + } + + mManagedProfileFocused = user != null && user.isManagedProfile(); + if (DEBUG) Log.v(TAG, "profileChanged: mManagedProfileFocused: " + mManagedProfileFocused); + // Actually update the icon later when transition starts. + } + + private void updateManagedProfile() { + if (DEBUG) Log.v(TAG, "updateManagedProfile: mManagedProfileFocused: " + + mManagedProfileFocused + + " mKeyguardVisible: " + mKeyguardVisible); + boolean showIcon = mManagedProfileFocused && !mKeyguardVisible; + if (mManagedProfileIconVisible != showIcon) { + mService.setIconVisibility(SLOT_MANAGED_PROFILE, showIcon); + mManagedProfileIconVisible = showIcon; + } + } + + private final IUserSwitchObserver.Stub mUserSwitchListener = + new IUserSwitchObserver.Stub() { + @Override + public void onUserSwitching(int newUserId, IRemoteCallback reply) { + } + + @Override + public void onUserSwitchComplete(int newUserId) throws RemoteException { + updateAlarm(); + profileChanged(newUserId); + } + + @Override + public void onForegroundProfileSwitch(int newProfileId) { + profileChanged(newProfileId); + } + }; + private final HotspotController.Callback mHotspotCallback = new HotspotController.Callback() { @Override public void onHotspotChanged(boolean enabled) { @@ -311,4 +376,13 @@ public class PhoneStatusBarPolicy { updateCast(); } }; + + public void appTransitionStarting(long startTime, long duration) { + updateManagedProfile(); + } + + public void setKeyguardShowing(boolean visible) { + mKeyguardVisible = visible; + updateManagedProfile(); + } } |