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 5df14831b8)
Merged-In: I4ddcd4e083c002ece9d10aabdb4af4a41de55ce7
This commit is contained in:
Jason Chiu
2022-06-23 12:12:23 +08:00
committed by Android Build Coastguard Worker
parent e41cbfdd30
commit 8cef068117
2 changed files with 18 additions and 3 deletions

View File

@@ -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