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

Commit f121b48e authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Hide the BT address from apps that don't have BT permission" into main

parents f9a6e543 8e4b252c
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -326,3 +326,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()) {