[Safer intents] Connectivity
To avoid implicit intents, make intents launch explicitly. Bug: 323061508 Test: build Change-Id: I44ff8a789d933f11ba7e68e52055575245276224
This commit is contained in:
@@ -35,7 +35,8 @@
|
|||||||
android:title="@string/mobile_network_list_add_more"
|
android:title="@string/mobile_network_list_add_more"
|
||||||
android:icon="@drawable/ic_menu_add_activated_tint"
|
android:icon="@drawable/ic_menu_add_activated_tint"
|
||||||
android:order="100">
|
android:order="100">
|
||||||
<intent android:action="android.telephony.euicc.action.PROVISION_EMBEDDED_SUBSCRIPTION">
|
<intent android:action="android.telephony.euicc.action.PROVISION_EMBEDDED_SUBSCRIPTION"
|
||||||
|
android:targetPackage="com.android.phone">
|
||||||
<extra android:name="android.telephony.euicc.extra.FORCE_PROVISION"
|
<extra android:name="android.telephony.euicc.extra.FORCE_PROVISION"
|
||||||
android:value="true"/>
|
android:value="true"/>
|
||||||
</intent>
|
</intent>
|
||||||
|
@@ -140,6 +140,8 @@ public final class Utils extends com.android.settingslib.Utils {
|
|||||||
|
|
||||||
public static final String SYSTEMUI_PACKAGE_NAME = "com.android.systemui";
|
public static final String SYSTEMUI_PACKAGE_NAME = "com.android.systemui";
|
||||||
|
|
||||||
|
public static final String PHONE_PACKAGE_NAME = "com.android.phone";
|
||||||
|
|
||||||
public static final String OS_PKG = "os";
|
public static final String OS_PKG = "os";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -70,7 +70,10 @@ object RequestPermissionHelper {
|
|||||||
private fun Context.isDisallowBluetooth() =
|
private fun Context.isDisallowBluetooth() =
|
||||||
if (userManager.hasUserRestriction(UserManager.DISALLOW_BLUETOOTH)) {
|
if (userManager.hasUserRestriction(UserManager.DISALLOW_BLUETOOTH)) {
|
||||||
devicePolicyManager.createAdminSupportIntent(UserManager.DISALLOW_BLUETOOTH)
|
devicePolicyManager.createAdminSupportIntent(UserManager.DISALLOW_BLUETOOTH)
|
||||||
?.let { startActivity(it) }
|
?.let {
|
||||||
|
it.setPackage(packageName)
|
||||||
|
startActivity(it)
|
||||||
|
}
|
||||||
true
|
true
|
||||||
} else false
|
} else false
|
||||||
|
|
||||||
|
@@ -34,6 +34,7 @@ import androidx.preference.TwoStatePreference;
|
|||||||
|
|
||||||
import com.android.settings.AirplaneModeEnabler;
|
import com.android.settings.AirplaneModeEnabler;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.core.TogglePreferenceController;
|
import com.android.settings.core.TogglePreferenceController;
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnDestroy;
|
import com.android.settingslib.core.lifecycle.events.OnDestroy;
|
||||||
@@ -84,7 +85,8 @@ public class AirplaneModePreferenceController extends TogglePreferenceController
|
|||||||
// In ECM mode launch ECM app dialog
|
// In ECM mode launch ECM app dialog
|
||||||
if (mFragment != null) {
|
if (mFragment != null) {
|
||||||
mFragment.startActivityForResult(
|
mFragment.startActivityForResult(
|
||||||
new Intent(TelephonyManager.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null),
|
new Intent(TelephonyManager.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null)
|
||||||
|
.setPackage(Utils.PHONE_PACKAGE_NAME),
|
||||||
REQUEST_CODE_EXIT_ECM);
|
REQUEST_CODE_EXIT_ECM);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@@ -146,6 +146,7 @@ public class MobileNetworkSummaryController extends AbstractPreferenceController
|
|||||||
|
|
||||||
private void startAddSimFlow() {
|
private void startAddSimFlow() {
|
||||||
final Intent intent = new Intent(EuiccManager.ACTION_PROVISION_EMBEDDED_SUBSCRIPTION);
|
final Intent intent = new Intent(EuiccManager.ACTION_PROVISION_EMBEDDED_SUBSCRIPTION);
|
||||||
|
intent.setPackage(com.android.settings.Utils.PHONE_PACKAGE_NAME);
|
||||||
intent.putExtra(EuiccManager.EXTRA_FORCE_PROVISION, true);
|
intent.putExtra(EuiccManager.EXTRA_FORCE_PROVISION, true);
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
@@ -108,6 +108,7 @@ public class ApnPreferenceController extends TelephonyBasePreferenceController i
|
|||||||
if (getPreferenceKey().equals(preference.getKey())) {
|
if (getPreferenceKey().equals(preference.getKey())) {
|
||||||
// This activity runs in phone process, we must use intent to start
|
// This activity runs in phone process, we must use intent to start
|
||||||
final Intent intent = new Intent(Settings.ACTION_APN_SETTINGS);
|
final Intent intent = new Intent(Settings.ACTION_APN_SETTINGS);
|
||||||
|
intent.setPackage(mContext.getPackageName());
|
||||||
// This will setup the Home and Search affordance
|
// This will setup the Home and Search affordance
|
||||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, true);
|
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, true);
|
||||||
intent.putExtra(ApnSettings.SUB_ID, mSubId);
|
intent.putExtra(ApnSettings.SUB_ID, mSubId);
|
||||||
|
@@ -75,6 +75,7 @@ class DataUsagePreferenceController(context: Context, key: String) :
|
|||||||
override fun handlePreferenceTreeClick(preference: Preference): Boolean {
|
override fun handlePreferenceTreeClick(preference: Preference): Boolean {
|
||||||
if (preference.key != preferenceKey || networkTemplate == null) return false
|
if (preference.key != preferenceKey || networkTemplate == null) return false
|
||||||
val intent = Intent(Settings.ACTION_MOBILE_DATA_USAGE).apply {
|
val intent = Intent(Settings.ACTION_MOBILE_DATA_USAGE).apply {
|
||||||
|
setPackage(mContext.packageName)
|
||||||
putExtra(Settings.EXTRA_NETWORK_TEMPLATE, networkTemplate)
|
putExtra(Settings.EXTRA_NETWORK_TEMPLATE, networkTemplate)
|
||||||
putExtra(Settings.EXTRA_SUB_ID, mSubId)
|
putExtra(Settings.EXTRA_SUB_ID, mSubId)
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,8 @@ import android.text.TextUtils;
|
|||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
|
import com.android.settings.Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preference controller for "Euicc preference"
|
* Preference controller for "Euicc preference"
|
||||||
*/
|
*/
|
||||||
@@ -57,7 +59,8 @@ public class EuiccPreferenceController extends TelephonyBasePreferenceController
|
|||||||
@Override
|
@Override
|
||||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||||
if (TextUtils.equals(preference.getKey(), getPreferenceKey())) {
|
if (TextUtils.equals(preference.getKey(), getPreferenceKey())) {
|
||||||
Intent intent = new Intent(EuiccManager.ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS);
|
Intent intent = new Intent(EuiccManager.ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS)
|
||||||
|
.setPackage(Utils.PHONE_PACKAGE_NAME);
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -43,6 +43,7 @@ import androidx.preference.Preference;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Settings.MobileNetworkActivity;
|
import com.android.settings.Settings.MobileNetworkActivity;
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.datausage.BillingCyclePreferenceController;
|
import com.android.settings.datausage.BillingCyclePreferenceController;
|
||||||
import com.android.settings.datausage.DataUsageSummaryPreferenceController;
|
import com.android.settings.datausage.DataUsageSummaryPreferenceController;
|
||||||
import com.android.settings.network.CarrierWifiTogglePreferenceController;
|
import com.android.settings.network.CarrierWifiTogglePreferenceController;
|
||||||
@@ -133,7 +134,8 @@ public class MobileNetworkSettings extends AbstractMobileNetworkSettings impleme
|
|||||||
|| TextUtils.equals(key, BUTTON_CDMA_SUBSCRIPTION_KEY)) {
|
|| TextUtils.equals(key, BUTTON_CDMA_SUBSCRIPTION_KEY)) {
|
||||||
if (mTelephonyManager.getEmergencyCallbackMode()) {
|
if (mTelephonyManager.getEmergencyCallbackMode()) {
|
||||||
startActivityForResult(
|
startActivityForResult(
|
||||||
new Intent(TelephonyManager.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null),
|
new Intent(TelephonyManager.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null)
|
||||||
|
.setPackage(Utils.PHONE_PACKAGE_NAME),
|
||||||
REQUEST_CODE_EXIT_ECM);
|
REQUEST_CODE_EXIT_ECM);
|
||||||
mClickedPrefKey = key;
|
mClickedPrefKey = key;
|
||||||
}
|
}
|
||||||
|
@@ -96,7 +96,8 @@ public class SatelliteSettingPreferenceController extends
|
|||||||
public boolean handlePreferenceTreeClick(@NonNull Preference preference) {
|
public boolean handlePreferenceTreeClick(@NonNull Preference preference) {
|
||||||
if (getPreferenceKey().equals(preference.getKey())) {
|
if (getPreferenceKey().equals(preference.getKey())) {
|
||||||
// This activity runs in phone process, we must use intent to start
|
// This activity runs in phone process, we must use intent to start
|
||||||
final Intent intent = new Intent(Settings.ACTION_SATELLITE_SETTING);
|
final Intent intent = new Intent(Settings.ACTION_SATELLITE_SETTING)
|
||||||
|
.setPackage(mContext.getPackageName());
|
||||||
// This will setup the Home and Search affordance
|
// This will setup the Home and Search affordance
|
||||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, true);
|
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, true);
|
||||||
intent.putExtra(SatelliteSetting.SUB_ID, mSubId);
|
intent.putExtra(SatelliteSetting.SUB_ID, mSubId);
|
||||||
|
@@ -45,7 +45,8 @@ public class SpatialAudioSettings extends DashboardFragment {
|
|||||||
footerPreference.setLearnMoreText(
|
footerPreference.setLearnMoreText(
|
||||||
getString(R.string.spatial_audio_footer_learn_more_text));
|
getString(R.string.spatial_audio_footer_learn_more_text));
|
||||||
footerPreference.setLearnMoreAction(
|
footerPreference.setLearnMoreAction(
|
||||||
view -> startActivity(new Intent(Settings.ACTION_BLUETOOTH_SETTINGS)));
|
view -> startActivity(new Intent(Settings.ACTION_BLUETOOTH_SETTINGS)
|
||||||
|
.setPackage(getContext().getPackageName())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -55,7 +55,8 @@ public abstract class ProfileSettingsPreferenceFragment extends RestrictedDashbo
|
|||||||
final UserHandle selectedUser = profileSpinnerAdapter.getUserHandle(position);
|
final UserHandle selectedUser = profileSpinnerAdapter.getUserHandle(position);
|
||||||
if (selectedUser.getIdentifier() != UserHandle.myUserId()) {
|
if (selectedUser.getIdentifier() != UserHandle.myUserId()) {
|
||||||
final Activity activity = getActivity();
|
final Activity activity = getActivity();
|
||||||
Intent intent = new Intent(getIntentActionString());
|
Intent intent = new Intent(getIntentActionString())
|
||||||
|
.setPackage(getContext().getPackageName());
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
activity.startActivityAsUser(intent, selectedUser);
|
activity.startActivityAsUser(intent, selectedUser);
|
||||||
|
@@ -31,6 +31,7 @@ import androidx.compose.ui.platform.LocalContext
|
|||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.android.settings.R
|
import com.android.settings.R
|
||||||
|
import com.android.settings.Utils
|
||||||
import com.android.settings.network.SubscriptionUtil
|
import com.android.settings.network.SubscriptionUtil
|
||||||
import com.android.settings.network.telephony.MobileNetworkUtils
|
import com.android.settings.network.telephony.MobileNetworkUtils
|
||||||
import com.android.settings.network.telephony.isSubscriptionEnabledFlow
|
import com.android.settings.network.telephony.isSubscriptionEnabledFlow
|
||||||
@@ -104,6 +105,7 @@ private fun AddSim() {
|
|||||||
|
|
||||||
private fun startAddSimFlow(context: Context) {
|
private fun startAddSimFlow(context: Context) {
|
||||||
val intent = Intent(EuiccManager.ACTION_PROVISION_EMBEDDED_SUBSCRIPTION)
|
val intent = Intent(EuiccManager.ACTION_PROVISION_EMBEDDED_SUBSCRIPTION)
|
||||||
|
intent.setPackage(Utils.PHONE_PACKAGE_NAME)
|
||||||
intent.putExtra(EuiccManager.EXTRA_FORCE_PROVISION, true)
|
intent.putExtra(EuiccManager.EXTRA_FORCE_PROVISION, true)
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
@@ -114,7 +114,8 @@ public class WifiWakeupPreferenceController extends TogglePreferenceController i
|
|||||||
throw new IllegalStateException("No fragment to start activity");
|
throw new IllegalStateException("No fragment to start activity");
|
||||||
}
|
}
|
||||||
|
|
||||||
final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
|
final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
|
||||||
|
.setPackage(mContext.getPackageName());
|
||||||
mFragment.startActivityForResult(intent, WIFI_WAKEUP_REQUEST_CODE);
|
mFragment.startActivityForResult(intent, WIFI_WAKEUP_REQUEST_CODE);
|
||||||
return false;
|
return false;
|
||||||
} else if (!getWifiScanningEnabled()) {
|
} else if (!getWifiScanningEnabled()) {
|
||||||
|
@@ -75,6 +75,7 @@ public class WifiDppConfiguratorAuthActivity extends InstrumentedActivity {
|
|||||||
Intent qrCodeIntent = new Intent();
|
Intent qrCodeIntent = new Intent();
|
||||||
qrCodeIntent.setAction(
|
qrCodeIntent.setAction(
|
||||||
WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
|
WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
|
||||||
|
qrCodeIntent.setPackage(getPackageName());
|
||||||
qrCodeIntent.putExtras(getIntent());
|
qrCodeIntent.putExtras(getIntent());
|
||||||
startActivity(qrCodeIntent);
|
startActivity(qrCodeIntent);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user