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

Commit 3df21722 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Hide "Take bugreport" for secondary users

In QuickSettings and GlobalActions.

Bug: 9304471
Change-Id: Ia3118b3258b1f6983c47e96168b7b875b6fc798b
parent f24e16aa
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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 {

@@ -54,4 +55,8 @@ public abstract class CurrentUserTracker extends BroadcastReceiver {
    }

    public abstract void onUserSwitched(int newUserId);

    public boolean isCurrentUserOwner() {
        return mCurrentUserId == UserHandle.USER_OWNER;
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -580,7 +580,7 @@ class QuickSettingsModel implements BluetoothStateChangeCallback,
        } catch (SettingNotFoundException e) {
        }

        mBugreportState.enabled = enabled;
        mBugreportState.enabled = enabled && mUserTracker.isCurrentUserOwner();
        mBugreportCallback.refreshView(mBugreportTile, mBugreportState);
    }

+15 −7
Original line number Diff line number Diff line
@@ -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) {
@@ -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);