Fixed activity not started for current user
In headless mode, the activity started by the phone process needs
to be started for the current user, because phone process is always
running as the system user, and the actual user is running as
the secondary user.
Fix: 365861945
Test: Basic telephony functionality tests
Test: atest FrameworksTelephonyTests
Test: atest TeleServiceTests
Flag: EXEMPT bug fix
Change-Id: I4f12a3fd948fe590f19ec72551d1a347ac38962a
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index 1dfcde7..1c55256 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -35,6 +35,7 @@
import android.os.HandlerExecutor;
import android.os.Looper;
import android.os.PersistableBundle;
+import android.os.UserHandle;
import android.os.UserManager;
import android.preference.Preference;
import android.preference.PreferenceActivity;
@@ -233,7 +234,7 @@
getString(R.string.mobile_network_settings_package),
getString(R.string.mobile_network_settings_class));
intent.setComponent(mobileNetworkSettingsComponent);
- startActivity(intent);
+ startActivityAsUser(intent, UserHandle.CURRENT);
}
};
builder.setMessage(getResourcesForSubId().getString(
@@ -622,7 +623,7 @@
Intent intent = subscriptionInfoHelper.getIntent(CallFeaturesSetting.class);
intent.setAction(Intent.ACTION_MAIN);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- activity.startActivity(intent);
+ activity.startActivityAsUser(intent, UserHandle.CURRENT);
activity.finish();
}
diff --git a/src/com/android/phone/EmergencyCallbackModeService.java b/src/com/android/phone/EmergencyCallbackModeService.java
index 464db6f..70eb017 100644
--- a/src/com/android/phone/EmergencyCallbackModeService.java
+++ b/src/com/android/phone/EmergencyCallbackModeService.java
@@ -129,9 +129,9 @@
// Show dialog box
else if (intent.getAction().equals(
TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS)) {
- context.startActivity(
+ context.startActivityAsUser(
new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS)
- .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+ .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK), UserHandle.CURRENT);
}
}
};
diff --git a/src/com/android/phone/EmergencyDialer.java b/src/com/android/phone/EmergencyDialer.java
index a608b1b..d4fdca6 100644
--- a/src/com/android/phone/EmergencyDialer.java
+++ b/src/com/android/phone/EmergencyDialer.java
@@ -40,6 +40,7 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.PersistableBundle;
+import android.os.UserHandle;
import android.provider.Settings;
import android.telecom.PhoneAccount;
import android.telecom.TelecomManager;
@@ -511,7 +512,7 @@
Intent intent = (Intent) button.getTag(R.id.tag_intent);
if (intent != null) {
- startActivity(intent);
+ startActivityAsUser(intent, UserHandle.CURRENT);
}
}
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index ddd2f04..ae0cc3f 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -2613,7 +2613,7 @@
if (state != PhoneConstants.State.OFFHOOK && state != PhoneConstants.State.RINGING) {
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mApp.startActivity(intent);
+ mApp.startActivityAsUser(intent, UserHandle.CURRENT);
}
} finally {
Binder.restoreCallingIdentity(identity);
@@ -2628,7 +2628,7 @@
if (DBG) log("call: " + number);
// This is just a wrapper around the ACTION_CALL intent, but we still
- // need to do a permission check since we're calling startActivity()
+ // need to do a permission check since we're calling startActivityAsUser()
// from the context of the phone app.
enforceCallPermission();
@@ -2664,7 +2664,7 @@
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(url));
intent.putExtra(SUBSCRIPTION_KEY, subId);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mApp.startActivity(intent);
+ mApp.startActivityAsUser(intent, UserHandle.CURRENT);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -11032,7 +11032,7 @@
// Bring up choose default SMS subscription dialog right now
intent.putExtra(PickSmsSubscriptionActivity.DIALOG_TYPE_KEY,
PickSmsSubscriptionActivity.SMS_PICK_FOR_MESSAGE);
- mApp.startActivity(intent);
+ mApp.startActivityAsUser(intent, UserHandle.CURRENT);
}
@Override
@@ -11045,13 +11045,13 @@
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("smsto:"));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mApp.startActivity(intent);
+ mApp.startActivityAsUser(intent, UserHandle.CURRENT);
} catch (ActivityNotFoundException e) {
Log.w(LOG_TAG, "Unable to show intent forwarder, try showing error dialog instead");
Intent intent = new Intent();
intent.setClass(mApp, ErrorDialogActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mApp.startActivity(intent);
+ mApp.startActivityAsUser(intent, UserHandle.CURRENT);
}
}
diff --git a/src/com/android/phone/SimContacts.java b/src/com/android/phone/SimContacts.java
index 4229482..d5f7840 100644
--- a/src/com/android/phone/SimContacts.java
+++ b/src/com/android/phone/SimContacts.java
@@ -33,6 +33,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.os.RemoteException;
+import android.os.UserHandle;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.GroupMembership;
@@ -372,7 +373,7 @@
Uri.fromParts(PhoneAccount.SCHEME_TEL, phoneNumber, null));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
- startActivity(intent);
+ startActivityAsUser(intent, UserHandle.CURRENT);
finish();
return true;
}
diff --git a/src/com/android/phone/SpecialCharSequenceMgr.java b/src/com/android/phone/SpecialCharSequenceMgr.java
index 8fe084b..d0fe2c1 100644
--- a/src/com/android/phone/SpecialCharSequenceMgr.java
+++ b/src/com/android/phone/SpecialCharSequenceMgr.java
@@ -21,6 +21,7 @@
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
+import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.telephony.PhoneNumberUtils;
@@ -186,7 +187,7 @@
"com.android.phone.SimContacts");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("index", index);
- PhoneGlobals.getInstance().startActivity(intent);
+ PhoneGlobals.getInstance().startActivityAsUser(intent, UserHandle.CURRENT);
return true;
} catch (NumberFormatException ex) {}
@@ -313,9 +314,9 @@
log("handleRegulatoryInfoDisplay() sending intent to settings app");
Intent showRegInfoIntent = new Intent(Settings.ACTION_SHOW_REGULATORY_INFO);
try {
- context.startActivity(showRegInfoIntent);
+ context.startActivityAsUser(showRegInfoIntent, UserHandle.CURRENT);
} catch (ActivityNotFoundException e) {
- Log.e(TAG, "startActivity() failed: " + e);
+ Log.e(TAG, "startActivityAsUser() failed: " + e);
}
return true;
}
diff --git a/src/com/android/phone/euicc/EuiccUiDispatcherActivity.java b/src/com/android/phone/euicc/EuiccUiDispatcherActivity.java
index 3e44062..a75f26f 100644
--- a/src/com/android/phone/euicc/EuiccUiDispatcherActivity.java
+++ b/src/com/android/phone/euicc/EuiccUiDispatcherActivity.java
@@ -90,7 +90,7 @@
}
euiccUiIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
- startActivity(euiccUiIntent);
+ startActivityAsUser(euiccUiIntent, UserHandle.CURRENT);
} finally {
// Since we're using Theme.NO_DISPLAY, we must always finish() at the end of onCreate().
finish();
diff --git a/src/com/android/phone/settings/RadioInfo.java b/src/com/android/phone/settings/RadioInfo.java
index f00ef51..02fb820 100644
--- a/src/com/android/phone/settings/RadioInfo.java
+++ b/src/com/android/phone/settings/RadioInfo.java
@@ -44,6 +44,7 @@
import android.os.Message;
import android.os.PersistableBundle;
import android.os.SystemProperties;
+import android.os.UserHandle;
import android.os.UserManager;
import android.telephony.AccessNetworkConstants;
import android.telephony.CarrierConfigManager;
@@ -791,13 +792,15 @@
}
mSatelliteEnableNonEmergencyModeButton.setVisibility(View.GONE);
} else {
- mEsosButton.setOnClickListener(v -> startActivity(
+ mEsosButton.setOnClickListener(v -> startActivityAsUser(
new Intent(mActionEsos).addFlags(
- Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK))
+ Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK),
+ UserHandle.CURRENT)
);
- mEsosDemoButton.setOnClickListener(v -> startActivity(
+ mEsosDemoButton.setOnClickListener(v -> startActivityAsUser(
new Intent(mActionEsosDemo).addFlags(
- Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK))
+ Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK),
+ UserHandle.CURRENT)
);
mSatelliteEnableNonEmergencyModeButton.setOnClickListener(v ->
enableSatelliteNonEmergencyMode());
@@ -1676,49 +1679,50 @@
private MenuItem.OnMenuItemClickListener mViewADNCallback =
new MenuItem.OnMenuItemClickListener() {
- public boolean onMenuItemClick(MenuItem item) {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- // XXX We need to specify the component here because if we don't
- // the activity manager will try to resolve the type by calling
- // the content provider, which causes it to be loaded in a process
- // other than the Dialer process, which causes a lot of stuff to
- // break.
- intent.setClassName("com.android.phone", "com.android.phone.SimContacts");
- startActivity(intent);
- return true;
- }
- };
+ public boolean onMenuItemClick(MenuItem item) {
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ // XXX We need to specify the component here because if we don't
+ // the activity manager will try to resolve the type by calling
+ // the content provider, which causes it to be loaded in a process
+ // other than the Dialer process, which causes a lot of stuff to
+ // break.
+ intent.setClassName("com.android.phone", "com.android.phone.SimContacts");
+ startActivityAsUser(intent, UserHandle.CURRENT);
+ return true;
+ }
+ };
private MenuItem.OnMenuItemClickListener mViewFDNCallback =
new MenuItem.OnMenuItemClickListener() {
- public boolean onMenuItemClick(MenuItem item) {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- // XXX We need to specify the component here because if we don't
- // the activity manager will try to resolve the type by calling
- // the content provider, which causes it to be loaded in a process
- // other than the Dialer process, which causes a lot of stuff to
- // break.
- intent.setClassName("com.android.phone", "com.android.phone.settings.fdn.FdnList");
- startActivity(intent);
- return true;
- }
- };
+ public boolean onMenuItemClick(MenuItem item) {
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ // XXX We need to specify the component here because if we don't
+ // the activity manager will try to resolve the type by calling
+ // the content provider, which causes it to be loaded in a process
+ // other than the Dialer process, which causes a lot of stuff to
+ // break.
+ intent.setClassName("com.android.phone",
+ "com.android.phone.settings.fdn.FdnList");
+ startActivityAsUser(intent, UserHandle.CURRENT);
+ return true;
+ }
+ };
private MenuItem.OnMenuItemClickListener mViewSDNCallback =
new MenuItem.OnMenuItemClickListener() {
- public boolean onMenuItemClick(MenuItem item) {
- Intent intent = new Intent(
- Intent.ACTION_VIEW, Uri.parse("content://icc/sdn"));
- // XXX We need to specify the component here because if we don't
- // the activity manager will try to resolve the type by calling
- // the content provider, which causes it to be loaded in a process
- // other than the Dialer process, which causes a lot of stuff to
- // break.
- intent.setClassName("com.android.phone", "com.android.phone.ADNList");
- startActivity(intent);
- return true;
- }
- };
+ public boolean onMenuItemClick(MenuItem item) {
+ Intent intent = new Intent(
+ Intent.ACTION_VIEW, Uri.parse("content://icc/sdn"));
+ // XXX We need to specify the component here because if we don't
+ // the activity manager will try to resolve the type by calling
+ // the content provider, which causes it to be loaded in a process
+ // other than the Dialer process, which causes a lot of stuff to
+ // break.
+ intent.setClassName("com.android.phone", "com.android.phone.ADNList");
+ startActivityAsUser(intent, UserHandle.CURRENT);
+ return true;
+ }
+ };
private MenuItem.OnMenuItemClickListener mGetImsStatus =
new MenuItem.OnMenuItemClickListener() {
@@ -2297,7 +2301,7 @@
public void onClick(View v) {
Intent intent = new Intent(OEM_RADIO_INFO_INTENT);
try {
- startActivity(intent);
+ startActivityAsUser(intent, UserHandle.CURRENT);
} catch (android.content.ActivityNotFoundException ex) {
log("OEM-specific Info/Settings Activity Not Found : " + ex);
// If the activity does not exist, there are no OEM
diff --git a/src/com/android/phone/settings/SuppServicesUiUtil.java b/src/com/android/phone/settings/SuppServicesUiUtil.java
index 4f1a79f..c845e61 100644
--- a/src/com/android/phone/settings/SuppServicesUiUtil.java
+++ b/src/com/android/phone/settings/SuppServicesUiUtil.java
@@ -22,6 +22,7 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.os.UserHandle;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
@@ -72,7 +73,7 @@
context.getString(R.string.mobile_network_settings_package),
context.getString(R.string.mobile_network_settings_class));
intent.setComponent(mobileNetworkSettingsComponent);
- context.startActivity(intent);
+ context.startActivityAsUser(intent, UserHandle.CURRENT);
}
};
return builder.setMessage(message)
diff --git a/src/com/android/phone/settings/VoicemailSettingsActivity.java b/src/com/android/phone/settings/VoicemailSettingsActivity.java
index 817ca4c..909a3ad 100644
--- a/src/com/android/phone/settings/VoicemailSettingsActivity.java
+++ b/src/com/android/phone/settings/VoicemailSettingsActivity.java
@@ -42,7 +42,6 @@
import android.text.TextUtils;
import android.util.Log;
import android.view.MenuItem;
-import android.view.WindowManager;
import android.widget.ListAdapter;
import android.widget.Toast;
@@ -495,7 +494,7 @@
Intent i = new Intent(ACTION_ADD_VOICEMAIL);
i.putExtra(IGNORE_PROVIDER_EXTRA, victim);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- this.startActivity(i);
+ this.startActivityAsUser(i, UserHandle.CURRENT);
}
return;
}
diff --git a/src/com/android/phone/settings/fdn/EditFdnContactScreen.java b/src/com/android/phone/settings/fdn/EditFdnContactScreen.java
index 0884e12..6bf41f3 100644
--- a/src/com/android/phone/settings/fdn/EditFdnContactScreen.java
+++ b/src/com/android/phone/settings/fdn/EditFdnContactScreen.java
@@ -346,7 +346,7 @@
Intent intent = mSubscriptionInfoHelper.getIntent(DeleteFdnContactScreen.class);
intent.putExtra(INTENT_EXTRA_NAME, mName);
intent.putExtra(INTENT_EXTRA_NUMBER, mNumber);
- startActivity(intent);
+ startActivityAsUser(intent, UserHandle.CURRENT);
}
finish();
}
diff --git a/src/com/android/phone/settings/fdn/FdnList.java b/src/com/android/phone/settings/fdn/FdnList.java
index c2ecbc6..1b5a7af 100644
--- a/src/com/android/phone/settings/fdn/FdnList.java
+++ b/src/com/android/phone/settings/fdn/FdnList.java
@@ -23,6 +23,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.os.PersistableBundle;
+import android.os.UserHandle;
import android.telecom.PhoneAccount;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
@@ -167,7 +168,7 @@
Intent intent = mSubscriptionInfoHelper.getIntent(FdnSetting.class);
intent.setAction(Intent.ACTION_MAIN);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(intent);
+ startActivityAsUser(intent, UserHandle.CURRENT);
finish();
return true;
@@ -200,7 +201,7 @@
private void addContact() {
//If there is no INTENT_EXTRA_NAME provided, EditFdnContactScreen treats it as an "add".
Intent intent = mSubscriptionInfoHelper.getIntent(EditFdnContactScreen.class);
- startActivity(intent);
+ startActivityAsUser(intent, UserHandle.CURRENT);
}
/**
@@ -224,7 +225,7 @@
Intent intent = mSubscriptionInfoHelper.getIntent(EditFdnContactScreen.class);
intent.putExtra(INTENT_EXTRA_NAME, name);
intent.putExtra(INTENT_EXTRA_NUMBER, number);
- startActivity(intent);
+ startActivityAsUser(intent, UserHandle.CURRENT);
}
}
@@ -240,7 +241,7 @@
Intent intent = mSubscriptionInfoHelper.getIntent(DeleteFdnContactScreen.class);
intent.putExtra(INTENT_EXTRA_NAME, name);
intent.putExtra(INTENT_EXTRA_NUMBER, number);
- startActivity(intent);
+ startActivityAsUser(intent, UserHandle.CURRENT);
}
}
@@ -254,7 +255,7 @@
if (!TextUtils.isEmpty(number)) {
Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null);
final Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED, uri);
- startActivity(intent);
+ startActivityAsUser(intent, UserHandle.CURRENT);
}
}
}
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index e44dcef..429eeff 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -41,6 +41,7 @@
import android.os.Bundle;
import android.os.ParcelUuid;
import android.os.PersistableBundle;
+import android.os.UserHandle;
import android.telecom.Conference;
import android.telecom.Conferenceable;
import android.telecom.Connection;
@@ -1588,7 +1589,7 @@
simUnlockUiPackage, simUnlockUiClass));
simUnlockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
- context.startActivity(simUnlockIntent);
+ context.startActivityAsUser(simUnlockIntent, UserHandle.CURRENT);
} catch (ActivityNotFoundException exception) {
Log.e(this, exception, "Unable to find SIM unlock UI activity.");
}
@@ -2484,7 +2485,7 @@
if (SubscriptionManager.isValidSubscriptionId(subId)) {
SubscriptionManager.putSubscriptionIdExtra(intent, subId);
}
- startActivity(intent);
+ startActivityAsUser(intent, UserHandle.CURRENT);
}
return disconnectCause;
}
@@ -4383,7 +4384,7 @@
context.getString(
R.string.mobile_network_settings_class));
intent.setComponent(mobileNetworkSettingsComponent);
- context.startActivity(intent);
+ context.startActivityAsUser(intent, UserHandle.CURRENT);
}
};
Dialog dialog = builder.setMessage(message)