From 8cef068117d15802595a558281c1d1efe3d62da2 Mon Sep 17 00:00:00 2001 From: Jason Chiu Date: Thu, 23 Jun 2022 12:12:23 +0800 Subject: [PATCH 1/2] Make bluetooth not discoverable via large screen deep link flow Deep links on large screen devices starts a homepage activity on the left pane, and then starts the target activity on the right pane. This flow overrides the calling package, and the target activity can't know who initially calls it. Thus, we store the initial calling package in the intent, so the Connected devices page is able to make bluetooth not discoverable when it's called from unintended apps on large screen devices. Bug: 234440688 Test: robotest, manual Change-Id: I4ddcd4e083c002ece9d10aabdb4af4a41de55ce7 Merged-In: I4ddcd4e083c002ece9d10aabdb4af4a41de55ce7 (cherry picked from commit 5df14831b8d0bbae062c644cfa987378ea2ca9d4) Merged-In: I4ddcd4e083c002ece9d10aabdb4af4a41de55ce7 --- src/com/android/settings/SettingsActivity.java | 15 +++++++++++++++ .../ConnectedDeviceDashboardFragment.java | 6 +++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java index f9515017406..4341851c3fa 100644 --- a/src/com/android/settings/SettingsActivity.java +++ b/src/com/android/settings/SettingsActivity.java @@ -70,6 +70,7 @@ import com.android.settings.homepage.DeepLinkHomepageActivityInternal; import com.android.settings.homepage.SettingsHomepageActivity; import com.android.settings.homepage.TopLevelSettings; import com.android.settings.overlay.FeatureFactory; +import com.android.settings.password.PasswordUtils; import com.android.settings.wfd.WifiDisplaySettings; import com.android.settings.widget.SettingsMainSwitchBar; import com.android.settingslib.core.instrumentation.Instrumentable; @@ -154,6 +155,7 @@ public class SettingsActivity extends SettingsBaseActivity public static final String EXTRA_IS_FROM_SLICE = "is_from_slice"; public static final String EXTRA_USER_HANDLE = "user_handle"; + public static final String EXTRA_INITIAL_CALLING_PACKAGE = "initial_calling_package"; /** * Personal or Work profile tab of {@link ProfileSelectFragment} @@ -418,6 +420,8 @@ public class SettingsActivity extends SettingsBaseActivity } private boolean tryStartTwoPaneDeepLink(Intent intent) { + intent.putExtra(EXTRA_INITIAL_CALLING_PACKAGE, PasswordUtils.getCallingAppPackageName( + getActivityToken())); final Intent trampolineIntent; if (intent.getBooleanExtra(EXTRA_IS_FROM_SLICE, false)) { // Get menu key for slice deep link case. @@ -505,6 +509,17 @@ public class SettingsActivity extends SettingsBaseActivity return true; } + /** Returns the initial calling package name that launches the activity. */ + public String getInitialCallingPackage() { + String callingPackage = PasswordUtils.getCallingAppPackageName(getActivityToken()); + if (!TextUtils.equals(callingPackage, getPackageName())) { + return callingPackage; + } + + String initialCallingPackage = getIntent().getStringExtra(EXTRA_INITIAL_CALLING_PACKAGE); + return TextUtils.isEmpty(initialCallingPackage) ? callingPackage : initialCallingPackage; + } + /** Returns the initial fragment name that the activity will launch. */ @VisibleForTesting public String getInitialFragmentName(Intent intent) { diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java index 7e6eefe2e41..ea8a5f560f9 100644 --- a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java +++ b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java @@ -25,9 +25,9 @@ import android.util.Log; import androidx.annotation.VisibleForTesting; import com.android.settings.R; +import com.android.settings.SettingsActivity; import com.android.settings.core.SettingsUIDeviceConfig; import com.android.settings.dashboard.DashboardFragment; -import com.android.settings.password.PasswordUtils; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.slices.SlicePreferenceController; import com.android.settingslib.search.SearchIndexable; @@ -71,8 +71,8 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment { super.onAttach(context); final boolean nearbyEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI, SettingsUIDeviceConfig.BT_NEAR_BY_SUGGESTION_ENABLED, true); - String callingAppPackageName = PasswordUtils.getCallingAppPackageName( - getActivity().getActivityToken()); + String callingAppPackageName = ((SettingsActivity) getActivity()) + .getInitialCallingPackage(); String action = getIntent() != null ? getIntent().getAction() : ""; if (DEBUG) { Log.d(TAG, "onAttach() calling package name is : " + callingAppPackageName From 34dac9cb7394b5bea864b23e28621296fdaf7f9b Mon Sep 17 00:00:00 2001 From: SongFerngWang Date: Thu, 7 Jul 2022 06:21:50 +0800 Subject: [PATCH 2/2] [MEP] Hide the preferred SIM dialog when the user has replaced the SIM Since there is the race condition and it causes UI hides the preferred SIM dialog. Therefore, to hide the preferred SIM dialog under the specific condition which the user has replaced the SIM during the SIM switching. Bug: 238061853 Test: Manually testing. Device has the psim+esim and the esim's mobile data on. The tester disables the esim and then UI shows the preferred SIM dialog. Change-Id: I01e7d60170c5053730fd3113abd914fb5c0d11c9 (cherry picked from commit 286dce6b6ed8f06d8599c2a3de34c36ddd4445dd) Merged-In: I01e7d60170c5053730fd3113abd914fb5c0d11c9 --- .../SubscriptionActionDialogActivity.java | 14 +++++++++++++- .../ToggleSubscriptionDialogActivity.java | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/network/telephony/SubscriptionActionDialogActivity.java b/src/com/android/settings/network/telephony/SubscriptionActionDialogActivity.java index c509bac575c..391158f065b 100644 --- a/src/com/android/settings/network/telephony/SubscriptionActionDialogActivity.java +++ b/src/com/android/settings/network/telephony/SubscriptionActionDialogActivity.java @@ -60,8 +60,20 @@ public class SubscriptionActionDialogActivity extends FragmentActivity { * @param message The string content should be displayed in the progress dialog. */ protected void showProgressDialog(String message) { + showProgressDialog(message,false); + } + + /** + * Displays a loading dialog. + * + * @param message The string content should be displayed in the progress dialog. + * @param updateIfNeeded is whether to update the progress state in the SharedPreferences. + */ + protected void showProgressDialog(String message, boolean updateIfNeeded) { ProgressDialogFragment.show(getFragmentManager(), message, null); - setProgressState(PROGRESS_IS_SHOWING); + if (updateIfNeeded) { + setProgressState(PROGRESS_IS_SHOWING); + } } /** Dismisses the loading dialog. */ diff --git a/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java b/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java index f5f18b4b9ee..a878cb3ebd3 100644 --- a/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java +++ b/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java @@ -220,8 +220,8 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc showProgressDialog( getString( R.string.sim_action_switch_sub_dialog_progress, - SubscriptionUtil.getUniqueSubscriptionDisplayName( - mSubInfo, this))); + SubscriptionUtil.getUniqueSubscriptionDisplayName(mSubInfo, this)), + removedSubInfo != null ? true : false); if (mIsEsimOperation) { mSwitchToEuiccSubscriptionSidecar.run(mSubInfo.getSubscriptionId(), UiccSlotUtil.INVALID_PORT_ID,