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

Commit 8e4b252c authored by Santiago Seifert's avatar Santiago Seifert
Browse files

Hide the BT address from apps that don't have BT permission

Bug: b/373646834
Test: atest CtsMediaRouterTestCases
Flag: com.android.media.flags.hide_bt_address_from_apps_without_bt_permission
Change-Id: I743bd72a2b6a5ec0e1b80d1d35100624a5fc38e4
parent 795d133e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -316,3 +316,13 @@ flag {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "hide_bt_address_from_apps_without_bt_permission"
    namespace: "media_better_together"
    description: "Hides the BT address of media routes to apps without BT permission."
    bug: "373646834"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+15 −5
Original line number Diff line number Diff line
@@ -70,8 +70,13 @@ class SystemMediaRoute2Provider extends MediaRoute2Provider {
    private final BluetoothRouteController mBluetoothRouteController;

    private String mSelectedRouteId;
    // For apps without MODIFYING_AUDIO_ROUTING permission.
    // This should be the currently selected route.

    /**
     * Placeholder {@link MediaRoute2Info} representation of the currently selected route for apps
     * without system routing permission (like MODIFY_AUDIO_ROUTING, of Bluetooth permissions - see
     * {@link MediaRouter2ServiceImpl} for details). It's created by copying the real selected
     * route, but hiding sensitive info like id and bluetooth address.
     */
    MediaRoute2Info mDefaultRoute;

    @GuardedBy("mLock")
@@ -491,11 +496,16 @@ class SystemMediaRoute2Provider extends MediaRoute2Provider {
                transferableRoutes.add(selectedDeviceRoute.getId());
            }
            mSelectedRouteId = selectedRoute.getId();
            mDefaultRoute =

            var defaultRouteBuilder =
                    new MediaRoute2Info.Builder(MediaRoute2Info.ROUTE_ID_DEFAULT, selectedRoute)
                            .setSystemRoute(true)
                            .setProviderId(mUniqueId)
                            .build();
                            .setProviderId(mUniqueId);
            if (Flags.hideBtAddressFromAppsWithoutBtPermission()) {
                defaultRouteBuilder.setAddress(null); // We clear the address field.
            }
            mDefaultRoute = defaultRouteBuilder.build();

            builder.addSelectedRoute(mSelectedRouteId);
            if (Flags.enableAudioPoliciesDeviceAndBluetoothController()) {
                for (MediaRoute2Info route : mDeviceRouteController.getAvailableRoutes()) {