RESTRICT AUTOMERGE Make bluetooth not discoverable via SliceDeepLinkTrampoline
- Don't let device be discovered when the user launch "Connected Devices
settings" through SliceDeepLinkTrampoline.
Bug: 228450811
Test: make -j42 RunSettingsRoboTests and use test apk to manually test
to verify the device is not discoversable when open "Connected settings"
through test apk.
Change-Id: I5490b58675b1fd9fc36305766867f65caa6ccb6c
(cherry picked from commit 205752dcf2
)
This commit is contained in:
@@ -46,6 +46,7 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
|
||||
private static final String SETTINGS_PACKAGE_NAME = "com.android.settings";
|
||||
private static final String SYSTEMUI_PACKAGE_NAME = "com.android.systemui";
|
||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
private static final String SLICE_ACTION = "com.android.settings.SEARCH_RESULT_TRAMPOLINE";
|
||||
|
||||
@VisibleForTesting
|
||||
static final String KEY_CONNECTED_DEVICES = "connected_device_list";
|
||||
@@ -98,8 +99,10 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
|
||||
SettingsUIDeviceConfig.BT_NEAR_BY_SUGGESTION_ENABLED, true);
|
||||
String callingAppPackageName = PasswordUtils.getCallingAppPackageName(
|
||||
getActivity().getActivityToken());
|
||||
String action = getIntent() != null ? getIntent().getAction() : "";
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "onAttach() calling package name is : " + callingAppPackageName);
|
||||
Log.d(TAG, "onAttach() calling package name is : " + callingAppPackageName
|
||||
+ ", action : " + action);
|
||||
}
|
||||
use(AvailableMediaDeviceGroupController.class).init(this);
|
||||
use(ConnectedDeviceGroupController.class).init(this);
|
||||
@@ -108,9 +111,15 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
|
||||
use(SlicePreferenceController.class).setSliceUri(nearbyEnabled
|
||||
? Uri.parse(getString(R.string.config_nearby_devices_slice_uri))
|
||||
: null);
|
||||
use(DiscoverableFooterPreferenceController.class).setAlwaysDiscoverable(
|
||||
TextUtils.equals(SETTINGS_PACKAGE_NAME, callingAppPackageName)
|
||||
|| TextUtils.equals(SYSTEMUI_PACKAGE_NAME, callingAppPackageName));
|
||||
use(DiscoverableFooterPreferenceController.class)
|
||||
.setAlwaysDiscoverable(isAlwaysDiscoverable(callingAppPackageName, action));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isAlwaysDiscoverable(String callingAppPackageName, String action) {
|
||||
return TextUtils.equals(SLICE_ACTION, action) ? false
|
||||
: TextUtils.equals(SETTINGS_PACKAGE_NAME, callingAppPackageName)
|
||||
|| TextUtils.equals(SYSTEMUI_PACKAGE_NAME, callingAppPackageName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user