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

Commit 17159c2e authored by Steve Statia's avatar Steve Statia
Browse files

Get the userId from context instead of getting the UserHandle from the Process.

Add a log when null checking the UserManager to avoid a silent failure.

Flag: EXEMPT bug fix
Bug: 406016005
Test: manual test opening hidden menu, and opening after reboots
Change-Id: I3a70ecbbedc8428819fbde307384429b56cfcdce
parent d1e102fa
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
import android.telephony.TelephonyManager;
@@ -41,9 +40,8 @@ public class TestingSettingsBroadcastReceiver extends BroadcastReceiver {
            && intent.getAction().equals(TelephonyManager.ACTION_SECRET_CODE)
            && !isDisabled(context)) {
            UserManager userManager = context.getSystemService(UserManager.class);
            UserHandle currentUser = Process.myUserHandle();
            if (userManager != null) {
                if (userManager.getUserInfo(currentUser.hashCode()).isMain()) {
                if (userManager.getUserInfo(context.getUserId()).isMain()) {
                    Intent i = new Intent(Intent.ACTION_MAIN);
                    i.setClass(context, TestingSettingsActivity.class);
                    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -51,6 +49,8 @@ public class TestingSettingsBroadcastReceiver extends BroadcastReceiver {
                } else {
                    Log.d(TAG, "Not main user, not starting TestingSettingsActivity.");
                }
            } else {
                Log.w(TAG, "UserManager is null, not starting TestingSettingsActivity");
            }
        }
    }