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

Commit 46f0869e authored by Etienne Ruffieux's avatar Etienne Ruffieux
Browse files

Migrating Bluetooth resources to Bluetooth module

In order for the Bluetooth module to build as an apex
all non-public resources must be located in the same
package.
Made getMaxConnectedAudioDevices system API in order
for development Settings to access it.
Removed isInbandRingingSupported as only usage was by bt
service (config is now directly in service).
Removed isBluetoothVoiceDialingEnabled as there were no
usages, and no overlays.
All configs used only by the Bluetooth app are moved to
the Bluetooth module.

Tag: #feature
Bug: 211570675
Test: build
Test: make RunSettingsRoboTests
Change-Id: Ieed30c31fc44b5b477d43ae120ef11f96ab115ca
parent a81d2c64
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@
    <bool name="hfp_client_connection_service_support_emergency_call">false</bool>

    <!-- Enabling autoconnect over pan -->
    <bool name="config_bluetooth_pan_enable_autoconnect">true</bool>
    <bool name="config_bluetooth_pan_enable_autoconnect">false</bool>

    <!-- Enabling the phone policy -->
    <bool name="enable_phone_policy">true</bool>
@@ -150,5 +150,22 @@
    <!-- Service name of fastpair-->
    <string name="peripheral_link_service">.nearby.discovery.service.DiscoveryService</string>

    <!-- Max number of Bluetooth tethering connections allowed. If this is
         updated config_tether_dhcp_range has to be updated appropriately. -->
    <integer translatable="false" name="config_max_pan_devices">5</integer>

    <!-- Whether supported profiles should be reloaded upon enabling bluetooth -->
    <bool name="config_bluetooth_reload_supported_profiles_when_enabled">false</bool>

    <!-- Max number of connected audio devices supported by Bluetooth stack -->
    <integer name="config_bluetooth_max_connected_audio_devices">5</integer>

    <bool name="config_supportBluetoothPersistedState">true</bool>

    <!-- Boolean indicating if current platform need do one-time bluetooth address
    re-validation -->
    <bool name="config_bluetooth_address_validation">false</bool>

    <!-- Boolean indicating if current platform supports HFP inband ringing -->
    <bool name="config_bluetooth_hfp_inband_ringing_support">true</bool>
</resources>
+2 −2
Original line number Diff line number Diff line
@@ -207,9 +207,9 @@ class AdapterProperties {
        mProfileConnectionState.clear();
        mRemoteDevices = remoteDevices;

        // Get default max connected audio devices from config.xml in frameworks/base/core
        // Get default max connected audio devices from config.xml
        int configDefaultMaxConnectedAudioDevices = mService.getResources().getInteger(
                com.android.internal.R.integer.config_bluetooth_max_connected_audio_devices);
                com.android.bluetooth.R.integer.config_bluetooth_max_connected_audio_devices);
        // Override max connected audio devices if MAX_CONNECTED_AUDIO_DEVICES_PROPERTY is set
        int propertyOverlayedMaxConnectedAudioDevices =
                SystemProperties.getInt(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY,
+7 −7
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ import android.util.SparseArray;

import com.android.bluetooth.BluetoothMetricsProto;
import com.android.bluetooth.BluetoothStatsLog;
import com.android.bluetooth.R;
import com.android.bluetooth.Utils;
import com.android.bluetooth.a2dp.A2dpService;
import com.android.bluetooth.a2dpsink.A2dpSinkService;
@@ -122,7 +123,6 @@ import com.android.bluetooth.sap.SapService;
import com.android.bluetooth.sdp.SdpManager;
import com.android.bluetooth.telephony.BluetoothInCallService;
import com.android.bluetooth.vc.VolumeControlService;
import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.BinderCallsStats;
@@ -502,7 +502,7 @@ public class AdapterService extends Service {

        // Phone policy is specific to phone implementations and hence if a device wants to exclude
        // it out then it can be disabled by using the flag below.
        if (getResources().getBoolean(com.android.bluetooth.R.bool.enable_phone_policy)) {
        if (getResources().getBoolean(R.bool.enable_phone_policy)) {
            Log.i(TAG, "Phone policy enabled");
            mPhonePolicy = new PhonePolicy(this, new ServiceFactory());
            mPhonePolicy.start();
@@ -2280,7 +2280,7 @@ public class AdapterService extends Service {
            AdapterService service = getService();
            if (service == null || !Utils.checkConnectPermissionForDataDelivery(
                    service, attributionSource, "AdapterService getMaxConnectedAudioDevices")) {
                return AdapterProperties.MAX_CONNECTED_AUDIO_DEVICES_LOWER_BOND;
                return -1;
            }

            return service.getMaxConnectedAudioDevices();
@@ -3780,19 +3780,19 @@ public class AdapterService extends Service {
    }

    private int getIdleCurrentMa() {
        return getResources().getInteger(R.integer.config_bluetooth_idle_cur_ma);
        return BluetoothProperties.getHardwareIdleCurrentMa().orElse(0);
    }

    private int getTxCurrentMa() {
        return getResources().getInteger(R.integer.config_bluetooth_tx_cur_ma);
        return BluetoothProperties.getHardwareTxCurrentMa().orElse(0);
    }

    private int getRxCurrentMa() {
        return getResources().getInteger(R.integer.config_bluetooth_rx_cur_ma);
        return BluetoothProperties.getHardwareRxCurrentMa().orElse(0);
    }

    private double getOperatingVolt() {
        return getResources().getInteger(R.integer.config_bluetooth_operating_voltage_mv) / 1000.0;
        return BluetoothProperties.getHardwareOperatingVoltageMv().orElse(0) / 1000.0;
    }

    @VisibleForTesting
+10 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.res.Resources;
import android.os.SystemConfigManager;
import android.os.SystemProperties;
import android.provider.Settings;
import android.sysprop.BluetoothProperties;
import android.text.TextUtils;
import android.util.Log;

@@ -49,8 +50,8 @@ import com.android.bluetooth.pan.PanService;
import com.android.bluetooth.pbap.BluetoothPbapService;
import com.android.bluetooth.pbapclient.PbapClientService;
import com.android.bluetooth.sap.SapService;
import com.android.bluetooth.vc.VolumeControlService;
import com.android.bluetooth.tbs.TbsService;
import com.android.bluetooth.vc.VolumeControlService;

import java.util.ArrayList;
import java.util.Arrays;
@@ -126,7 +127,7 @@ public class Config {
            new ProfileConfig(TbsService.class, R.bool.profile_supported_le_call_control,
                    (1 << BluetoothProfile.LE_CALL_CONTROL)),
            new ProfileConfig(HearingAidService.class,
                    com.android.internal.R.bool.config_hearing_aid_profile_supported,
                    -1,
                    (1 << BluetoothProfile.HEARING_AID)),
            new ProfileConfig(LeAudioService.class, R.bool.profile_supported_le_audio,
                    (1 << BluetoothProfile.LE_AUDIO)),
@@ -153,7 +154,13 @@ public class Config {

        ArrayList<Class> profiles = new ArrayList<>(PROFILE_SERVICES_AND_FLAGS.length);
        for (ProfileConfig config : PROFILE_SERVICES_AND_FLAGS) {
            boolean supported = resources.getBoolean(config.mSupported);
            boolean supported = false;
            if (config.mClass == HearingAidService.class) {
                supported =
                        BluetoothProperties.audioStreamingForHearingAidSupported().orElse(false);
            } else {
                supported = resources.getBoolean(config.mSupported);
            }

            if (!supported && (config.mClass == HearingAidService.class) && isHearingAidSettingsEnabled(ctx)) {
                Log.v(TAG, "Feature Flag enables support for HearingAidService");
+1 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.os.ParcelUuid;
import android.os.Parcelable;
import android.util.Log;

import com.android.bluetooth.R;
import com.android.bluetooth.Utils;
import com.android.bluetooth.a2dp.A2dpService;
import com.android.bluetooth.btservice.storage.DatabaseManager;
@@ -48,7 +49,6 @@ import com.android.bluetooth.hid.HidHostService;
import com.android.bluetooth.le_audio.LeAudioService;
import com.android.bluetooth.pan.PanService;
import com.android.bluetooth.vc.VolumeControlService;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;

import java.util.HashSet;
Loading