Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 58511259 authored by Hugh Chen's avatar Hugh Chen Committed by Nolen Johnson
Browse files

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 205752dc)
(cherry picked from commit 06139d3f)
Merged-In: I5490b58675b1fd9fc36305766867f65caa6ccb6c
parent fb484d68
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -44,6 +44,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";
@@ -94,15 +95,23 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
        super.onAttach(context);

        String callingAppPackageName = 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);
        use(PreviouslyConnectedDevicePreferenceController.class).init(this);
        use(DiscoverableFooterPreferenceController.class).init(this,
                TextUtils.equals(SETTINGS_PACKAGE_NAME, callingAppPackageName)
                        || TextUtils.equals(SYSTEMUI_PACKAGE_NAME, callingAppPackageName));
                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);
    }

    private String getCallingAppPackageName(IBinder activityToken) {