Fix hidden menu not showing phone information 100% of the time when opening.
The function that sends the special code is sending intents to all users, which is creating an activity for both the work profile and the system user. Whichever intent is received last will be the activity on top and displayed to the user, and since the work profile's hidden menu does not include the 'Phone information' option it creates this 'randomness' observed with opening the menu. This change ag/29101523 started sending the broadcast as UserHandle.ALL, instead of just from the current user causing the reception of more than one intent. This fix checks for the work profile and returns out of the function without starting another TestingSettings activity. Flag: EXEMPT bug fix Bug: 406016005 Test: manual test opening hidden menu, and opening after reboots (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:170fcaf31628d3faf689ce1b525bfba33052d877) Merged-In: I5a7937ba484afd3ba81c55e66bc53c217a778d18 Change-Id: I5a7937ba484afd3ba81c55e66bc53c217a778d18
This commit is contained in:
committed by
Android Build Coastguard Worker
parent
c8c292cede
commit
1127cfb00f
@@ -20,12 +20,17 @@ 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;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.Settings.TestingSettingsActivity;
|
||||
|
||||
|
||||
public class TestingSettingsBroadcastReceiver extends BroadcastReceiver {
|
||||
private final static String TAG = "TestingSettingsBroadcastReceiver";
|
||||
|
||||
public TestingSettingsBroadcastReceiver() {
|
||||
}
|
||||
@@ -35,10 +40,18 @@ public class TestingSettingsBroadcastReceiver extends BroadcastReceiver {
|
||||
if (intent != null && intent.getAction() != null
|
||||
&& 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()) {
|
||||
Intent i = new Intent(Intent.ACTION_MAIN);
|
||||
i.setClass(context, TestingSettingsActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(i);
|
||||
} else {
|
||||
Log.d(TAG, "Not main user, not starting TestingSettingsActivity.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user