Loading packages/SystemUI/src/com/android/systemui/settings/CurrentUserTracker.java +5 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.UserHandle; public abstract class CurrentUserTracker extends BroadcastReceiver { Loading Loading @@ -54,4 +55,8 @@ public abstract class CurrentUserTracker extends BroadcastReceiver { } public abstract void onUserSwitched(int newUserId); public boolean isCurrentUserOwner() { return mCurrentUserId == UserHandle.USER_OWNER; } } packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java +1 −1 Original line number Diff line number Diff line Loading @@ -580,7 +580,7 @@ class QuickSettingsModel implements BluetoothStateChangeCallback, } catch (SettingNotFoundException e) { } mBugreportState.enabled = enabled; mBugreportState.enabled = enabled && mUserTracker.isCurrentUserOwner(); mBugreportCallback.refreshView(mBugreportTile, mBugreportState); } Loading policy/src/com/android/internal/policy/impl/GlobalActions.java +15 −7 Original line number Diff line number Diff line Loading @@ -265,7 +265,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac // next: bug report, if enabled if (Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.BUGREPORT_IN_POWER_MENU, 0) != 0) { Settings.Global.BUGREPORT_IN_POWER_MENU, 0) != 0 && isCurrentUserOwner()) { mItems.add( new SinglePressAction(com.android.internal.R.drawable.stat_sys_adb, R.string.global_action_bug_report) { Loading Loading @@ -349,16 +349,24 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac return dialog; } private UserInfo getCurrentUser() { try { return ActivityManagerNative.getDefault().getCurrentUser(); } catch (RemoteException re) { return null; } } private boolean isCurrentUserOwner() { UserInfo currentUser = getCurrentUser(); return currentUser == null || currentUser.isPrimary(); } private void addUsersToMenu(ArrayList<Action> items) { List<UserInfo> users = ((UserManager) mContext.getSystemService(Context.USER_SERVICE)) .getUsers(); if (users.size() > 1) { UserInfo currentUser; try { currentUser = ActivityManagerNative.getDefault().getCurrentUser(); } catch (RemoteException re) { currentUser = null; } UserInfo currentUser = getCurrentUser(); for (final UserInfo user : users) { boolean isCurrentUser = currentUser == null ? user.id == 0 : (currentUser.id == user.id); Loading Loading
packages/SystemUI/src/com/android/systemui/settings/CurrentUserTracker.java +5 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.UserHandle; public abstract class CurrentUserTracker extends BroadcastReceiver { Loading Loading @@ -54,4 +55,8 @@ public abstract class CurrentUserTracker extends BroadcastReceiver { } public abstract void onUserSwitched(int newUserId); public boolean isCurrentUserOwner() { return mCurrentUserId == UserHandle.USER_OWNER; } }
packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java +1 −1 Original line number Diff line number Diff line Loading @@ -580,7 +580,7 @@ class QuickSettingsModel implements BluetoothStateChangeCallback, } catch (SettingNotFoundException e) { } mBugreportState.enabled = enabled; mBugreportState.enabled = enabled && mUserTracker.isCurrentUserOwner(); mBugreportCallback.refreshView(mBugreportTile, mBugreportState); } Loading
policy/src/com/android/internal/policy/impl/GlobalActions.java +15 −7 Original line number Diff line number Diff line Loading @@ -265,7 +265,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac // next: bug report, if enabled if (Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.BUGREPORT_IN_POWER_MENU, 0) != 0) { Settings.Global.BUGREPORT_IN_POWER_MENU, 0) != 0 && isCurrentUserOwner()) { mItems.add( new SinglePressAction(com.android.internal.R.drawable.stat_sys_adb, R.string.global_action_bug_report) { Loading Loading @@ -349,16 +349,24 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac return dialog; } private UserInfo getCurrentUser() { try { return ActivityManagerNative.getDefault().getCurrentUser(); } catch (RemoteException re) { return null; } } private boolean isCurrentUserOwner() { UserInfo currentUser = getCurrentUser(); return currentUser == null || currentUser.isPrimary(); } private void addUsersToMenu(ArrayList<Action> items) { List<UserInfo> users = ((UserManager) mContext.getSystemService(Context.USER_SERVICE)) .getUsers(); if (users.size() > 1) { UserInfo currentUser; try { currentUser = ActivityManagerNative.getDefault().getCurrentUser(); } catch (RemoteException re) { currentUser = null; } UserInfo currentUser = getCurrentUser(); for (final UserInfo user : users) { boolean isCurrentUser = currentUser == null ? user.id == 0 : (currentUser.id == user.id); Loading