diff options
author | Etienne Ruffieux <eruffieux@google.com> | 2021-12-22 15:44:54 +0000 |
---|---|---|
committer | Etienne Ruffieux <eruffieux@google.com> | 2022-01-25 13:42:37 +0000 |
commit | 46f0869e440ec05086a4916b95855b865eeb085c (patch) | |
tree | 6df241def1a198089e1094bef9842b8d0421b546 | |
parent | a81d2c64bbf3fa6e318538152d277423fe3aa506 (diff) |
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
20 files changed, 103 insertions, 83 deletions
diff --git a/android/app/res/values/config.xml b/android/app/res/values/config.xml index 1f86bc3c68..35d2271000 100644 --- a/android/app/res/values/config.xml +++ b/android/app/res/values/config.xml @@ -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> diff --git a/android/app/src/com/android/bluetooth/btservice/AdapterProperties.java b/android/app/src/com/android/bluetooth/btservice/AdapterProperties.java index 2e4837ebc6..743b85a92e 100644 --- a/android/app/src/com/android/bluetooth/btservice/AdapterProperties.java +++ b/android/app/src/com/android/bluetooth/btservice/AdapterProperties.java @@ -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, diff --git a/android/app/src/com/android/bluetooth/btservice/AdapterService.java b/android/app/src/com/android/bluetooth/btservice/AdapterService.java index 58faee23f1..48790c3ffe 100644 --- a/android/app/src/com/android/bluetooth/btservice/AdapterService.java +++ b/android/app/src/com/android/bluetooth/btservice/AdapterService.java @@ -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 diff --git a/android/app/src/com/android/bluetooth/btservice/Config.java b/android/app/src/com/android/bluetooth/btservice/Config.java index abbb9f45d8..f0252ea48e 100644 --- a/android/app/src/com/android/bluetooth/btservice/Config.java +++ b/android/app/src/com/android/bluetooth/btservice/Config.java @@ -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"); diff --git a/android/app/src/com/android/bluetooth/btservice/PhonePolicy.java b/android/app/src/com/android/bluetooth/btservice/PhonePolicy.java index 94a53553f3..50aff4ae61 100644 --- a/android/app/src/com/android/bluetooth/btservice/PhonePolicy.java +++ b/android/app/src/com/android/bluetooth/btservice/PhonePolicy.java @@ -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; diff --git a/android/app/src/com/android/bluetooth/hfp/HeadsetService.java b/android/app/src/com/android/bluetooth/hfp/HeadsetService.java index 728b82a38f..65ed8d98cf 100644 --- a/android/app/src/com/android/bluetooth/hfp/HeadsetService.java +++ b/android/app/src/com/android/bluetooth/hfp/HeadsetService.java @@ -1847,7 +1847,9 @@ public class HeadsetService extends ProfileService { } boolean isInbandRingingEnabled() { - return BluetoothHeadset.isInbandRingingSupported(this) && !SystemProperties.getBoolean( + boolean isInbandRingingSupported = getResources().getBoolean( + com.android.bluetooth.R.bool.config_bluetooth_hfp_inband_ringing_support); + return isInbandRingingSupported && !SystemProperties.getBoolean( DISABLE_INBAND_RINGING_PROPERTY, false) && !mInbandRingingRuntimeDisable; } @@ -2080,6 +2082,8 @@ public class HeadsetService extends ProfileService { @Override public void dump(StringBuilder sb) { boolean isScoOn = mSystemInterface.getAudioManager().isBluetoothScoOn(); + boolean isInbandRingingSupported = getResources().getBoolean( + com.android.bluetooth.R.bool.config_bluetooth_hfp_inband_ringing_support); synchronized (mStateMachines) { super.dump(sb); ProfileService.println(sb, "mMaxHeadsetConnections: " + mMaxHeadsetConnections); @@ -2088,7 +2092,7 @@ public class HeadsetService extends ProfileService { ProfileService.println(sb, "mActiveDevice: " + mActiveDevice); ProfileService.println(sb, "isInbandRingingEnabled: " + isInbandRingingEnabled()); ProfileService.println(sb, - "isInbandRingingSupported: " + BluetoothHeadset.isInbandRingingSupported(this)); + "isInbandRingingSupported: " + isInbandRingingSupported); ProfileService.println(sb, "mInbandRingingRuntimeDisable: " + mInbandRingingRuntimeDisable); ProfileService.println(sb, "mAudioRouteAllowed: " + mAudioRouteAllowed); diff --git a/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java b/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java index 10d39b3178..c5423941ed 100644 --- a/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java +++ b/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java @@ -358,7 +358,7 @@ class BluetoothOppNotification { Notification.Builder b = new Notification.Builder(mContext, OPP_NOTIFICATION_CHANNEL); b.setOnlyAlertOnce(true); b.setColor(mContext.getResources() - .getColor(com.android.internal.R.color.system_notification_accent_color, + .getColor(android.R.color.system_notification_accent_color, mContext.getTheme())); b.setContentTitle(item.description); b.setSubText( @@ -456,7 +456,7 @@ class BluetoothOppNotification { .setSmallIcon(android.R.drawable.stat_sys_upload_done) .setColor(mContext.getResources() .getColor( - com.android.internal.R.color + android.R.color .system_notification_accent_color, mContext.getTheme())) // TODO(b/171825892) Please replace FLAG_MUTABLE_UNAUDITED below @@ -526,7 +526,7 @@ class BluetoothOppNotification { .setSmallIcon(android.R.drawable.stat_sys_download_done) .setColor(mContext.getResources() .getColor( - com.android.internal.R.color + android.R.color .system_notification_accent_color, mContext.getTheme())) @@ -602,7 +602,7 @@ class BluetoothOppNotification { PendingIntent.FLAG_IMMUTABLE)) .setColor(mContext.getResources() .getColor( - com.android.internal.R.color + android.R.color .system_notification_accent_color, mContext.getTheme())) .setContentTitle(mContext.getText( @@ -631,7 +631,7 @@ class BluetoothOppNotification { PendingIntent.FLAG_IMMUTABLE)) .setColor(mContext.getResources() .getColor( - com.android.internal.R.color + android.R.color .system_notification_accent_color, mContext.getTheme())) .setContentTitle(mContext.getText( diff --git a/android/app/src/com/android/bluetooth/pan/PanService.java b/android/app/src/com/android/bluetooth/pan/PanService.java index 4cbeff3464..cb1e845c4b 100644 --- a/android/app/src/com/android/bluetooth/pan/PanService.java +++ b/android/app/src/com/android/bluetooth/pan/PanService.java @@ -148,7 +148,7 @@ public class PanService extends ProfileService { mPanDevices = new HashMap<BluetoothDevice, BluetoothPanDevice>(); try { mMaxPanDevices = getResources().getInteger( - com.android.internal.R.integer.config_max_pan_devices); + com.android.bluetooth.R.integer.config_max_pan_devices); } catch (NotFoundException e) { mMaxPanDevices = BLUETOOTH_MAX_PAN_CONNECTIONS; } diff --git a/android/app/src/com/android/bluetooth/pbap/PbapStateMachine.java b/android/app/src/com/android/bluetooth/pbap/PbapStateMachine.java index 3d4d129b12..ed1458d5aa 100644 --- a/android/app/src/com/android/bluetooth/pbap/PbapStateMachine.java +++ b/android/app/src/com/android/bluetooth/pbap/PbapStateMachine.java @@ -396,7 +396,7 @@ class PbapStateMachine extends StateMachine { .setTicker(mService.getString(R.string.auth_notif_ticker)) .setColor(mService.getResources() .getColor( - com.android.internal.R.color + android.R.color .system_notification_accent_color, mService.getTheme())) .setFlag(Notification.FLAG_AUTO_CANCEL, true) diff --git a/android/app/src/com/android/bluetooth/util/GsmAlphabet.java b/android/app/src/com/android/bluetooth/util/GsmAlphabet.java index 78b56afbd6..09e08740af 100644 --- a/android/app/src/com/android/bluetooth/util/GsmAlphabet.java +++ b/android/app/src/com/android/bluetooth/util/GsmAlphabet.java @@ -20,8 +20,6 @@ import android.content.res.Resources; import android.util.Log; import android.util.SparseIntArray; -import com.android.internal.R; - /** * This class implements the character set mapping between * the GSM SMS 7-bit alphabet specified in TS 23.038 6.2.1 @@ -316,8 +314,10 @@ public class GsmAlphabet { private static void enableCountrySpecificEncodings() { Resources r = Resources.getSystem(); // See comments in frameworks/base/core/res/res/values/config.xml for allowed values - sEnabledSingleShiftTables = r.getIntArray(R.array.config_sms_enabled_single_shift_tables); - sEnabledLockingShiftTables = r.getIntArray(R.array.config_sms_enabled_locking_shift_tables); + sEnabledSingleShiftTables = r.getIntArray(r.getIdentifier( + "config_sms_enabled_single_shift_tables", "array", "android")); + sEnabledLockingShiftTables = r.getIntArray(r.getIdentifier( + "config_sms_enabled_locking_shift_tables", "array", "android")); if (sEnabledSingleShiftTables.length > 0) { sHighestEnabledSingleShiftCode = diff --git a/android/app/tests/unit/Android.bp b/android/app/tests/unit/Android.bp index c0bc0ff300..5d0302f63e 100755 --- a/android/app/tests/unit/Android.bp +++ b/android/app/tests/unit/Android.bp @@ -27,6 +27,7 @@ android_test { "androidx.room_room-runtime", "androidx.room_room-testing", "truth-prebuilt", + "PlatformProperties" ], asset_dirs: ["src/com/android/bluetooth/btservice/storage/schemas"], diff --git a/android/app/tests/unit/src/com/android/bluetooth/btservice/ActiveDeviceManagerTest.java b/android/app/tests/unit/src/com/android/bluetooth/btservice/ActiveDeviceManagerTest.java index b2c68c647f..5f89d52119 100644 --- a/android/app/tests/unit/src/com/android/bluetooth/btservice/ActiveDeviceManagerTest.java +++ b/android/app/tests/unit/src/com/android/bluetooth/btservice/ActiveDeviceManagerTest.java @@ -27,6 +27,7 @@ import android.bluetooth.BluetoothProfile; import android.content.Context; import android.content.Intent; import android.media.AudioManager; +import android.sysprop.BluetoothProperties; import androidx.test.InstrumentationRegistry; import androidx.test.filters.MediumTest; @@ -219,8 +220,7 @@ public class ActiveDeviceManagerTest { @Test public void hearingAidActive_clearA2dpAndHeadsetActive() { Assume.assumeTrue("Ignore test when HearingAidService is not enabled", - mContext.getResources().getBoolean( - com.android.internal.R.bool.config_hearing_aid_profile_supported)); + BluetoothProperties.audioStreamingForHearingAidSupported().orElse(false)); a2dpConnected(mA2dpHeadsetDevice); headsetConnected(mA2dpHeadsetDevice); @@ -238,8 +238,7 @@ public class ActiveDeviceManagerTest { @Test public void hearingAidActive_dontSetA2dpAndHeadsetActive() { Assume.assumeTrue("Ignore test when HearingAidService is not enabled", - mContext.getResources().getBoolean( - com.android.internal.R.bool.config_hearing_aid_profile_supported)); + BluetoothProperties.audioStreamingForHearingAidSupported().orElse(false)); hearingAidActiveDeviceChanged(mHearingAidDevice); a2dpConnected(mA2dpHeadsetDevice); @@ -256,8 +255,7 @@ public class ActiveDeviceManagerTest { @Test public void hearingAidActive_setA2dpActiveExplicitly() { Assume.assumeTrue("Ignore test when HearingAidService is not enabled", - mContext.getResources().getBoolean( - com.android.internal.R.bool.config_hearing_aid_profile_supported)); + BluetoothProperties.audioStreamingForHearingAidSupported().orElse(false)); hearingAidActiveDeviceChanged(mHearingAidDevice); a2dpConnected(mA2dpHeadsetDevice); @@ -277,8 +275,7 @@ public class ActiveDeviceManagerTest { @Test public void hearingAidActive_setHeadsetActiveExplicitly() { Assume.assumeTrue("Ignore test when HearingAidService is not enabled", - mContext.getResources().getBoolean( - com.android.internal.R.bool.config_hearing_aid_profile_supported)); + BluetoothProperties.audioStreamingForHearingAidSupported().orElse(false)); hearingAidActiveDeviceChanged(mHearingAidDevice); headsetConnected(mA2dpHeadsetDevice); diff --git a/android/app/tests/unit/src/com/android/bluetooth/hearingaid/HearingAidServiceTest.java b/android/app/tests/unit/src/com/android/bluetooth/hearingaid/HearingAidServiceTest.java index 1f7b0a9d8b..8d60f9a348 100644 --- a/android/app/tests/unit/src/com/android/bluetooth/hearingaid/HearingAidServiceTest.java +++ b/android/app/tests/unit/src/com/android/bluetooth/hearingaid/HearingAidServiceTest.java @@ -31,6 +31,7 @@ import android.media.AudioManager; import android.media.BtProfileConnectionInfo; import android.os.Looper; import android.os.ParcelUuid; +import android.sysprop.BluetoothProperties; import androidx.test.InstrumentationRegistry; import androidx.test.filters.MediumTest; @@ -38,9 +39,10 @@ import androidx.test.rule.ServiceTestRule; import androidx.test.runner.AndroidJUnit4; import com.android.bluetooth.TestUtils; +import com.android.bluetooth.R; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.btservice.storage.DatabaseManager; -import com.android.internal.R; + import org.junit.After; import org.junit.Assert; @@ -82,8 +84,7 @@ public class HearingAidServiceTest { public void setUp() throws Exception { mTargetContext = InstrumentationRegistry.getTargetContext(); Assume.assumeTrue("Ignore test when HearingAidService is not enabled", - mTargetContext.getResources().getBoolean( - R.bool.config_hearing_aid_profile_supported)); + BluetoothProperties.audioStreamingForHearingAidSupported().orElse(false)); // Set up mocks and test assets MockitoAnnotations.initMocks(this); @@ -126,8 +127,7 @@ public class HearingAidServiceTest { @After public void tearDown() throws Exception { - if (!mTargetContext.getResources().getBoolean( - R.bool.config_hearing_aid_profile_supported)) { + if (!BluetoothProperties.audioStreamingForHearingAidSupported().orElse(false)) { return; } stopService(); diff --git a/android/app/tests/unit/src/com/android/bluetooth/hearingaid/HearingAidStateMachineTest.java b/android/app/tests/unit/src/com/android/bluetooth/hearingaid/HearingAidStateMachineTest.java index b8efd4705e..29f23c4a4a 100644 --- a/android/app/tests/unit/src/com/android/bluetooth/hearingaid/HearingAidStateMachineTest.java +++ b/android/app/tests/unit/src/com/android/bluetooth/hearingaid/HearingAidStateMachineTest.java @@ -25,14 +25,15 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.HandlerThread; +import android.sysprop.BluetoothProperties; import androidx.test.InstrumentationRegistry; import androidx.test.filters.MediumTest; import androidx.test.runner.AndroidJUnit4; import com.android.bluetooth.TestUtils; +import com.android.bluetooth.R; import com.android.bluetooth.btservice.AdapterService; -import com.android.internal.R; import org.hamcrest.core.IsInstanceOf; import org.junit.After; @@ -63,8 +64,7 @@ public class HearingAidStateMachineTest { public void setUp() throws Exception { mTargetContext = InstrumentationRegistry.getTargetContext(); Assume.assumeTrue("Ignore test when HearingAidService is not enabled", - mTargetContext.getResources().getBoolean( - R.bool.config_hearing_aid_profile_supported)); + BluetoothProperties.audioStreamingForHearingAidSupported().orElse(false)); // Set up mocks and test assets MockitoAnnotations.initMocks(this); TestUtils.setAdapterService(mAdapterService); @@ -86,8 +86,7 @@ public class HearingAidStateMachineTest { @After public void tearDown() throws Exception { - if (!mTargetContext.getResources().getBoolean( - R.bool.config_hearing_aid_profile_supported)) { + if (!BluetoothProperties.audioStreamingForHearingAidSupported().orElse(false)) { return; } mHearingAidStateMachine.doQuit(); diff --git a/android/app/tests/unit/src/com/android/bluetooth/tbs/TbsGattTest.java b/android/app/tests/unit/src/com/android/bluetooth/tbs/TbsGattTest.java index 7985e4448b..ae817b5d34 100644 --- a/android/app/tests/unit/src/com/android/bluetooth/tbs/TbsGattTest.java +++ b/android/app/tests/unit/src/com/android/bluetooth/tbs/TbsGattTest.java @@ -39,7 +39,6 @@ import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentat import com.android.bluetooth.TestUtils; import com.android.bluetooth.btservice.AdapterService; -import com.android.internal.R; import com.google.common.primitives.Bytes; import org.junit.After; diff --git a/android/app/tests/unit/src/com/android/bluetooth/tbs/TbsGenericTest.java b/android/app/tests/unit/src/com/android/bluetooth/tbs/TbsGenericTest.java index 5d3b0ab0d1..4a79b3904a 100644 --- a/android/app/tests/unit/src/com/android/bluetooth/tbs/TbsGenericTest.java +++ b/android/app/tests/unit/src/com/android/bluetooth/tbs/TbsGenericTest.java @@ -34,7 +34,6 @@ import androidx.test.runner.AndroidJUnit4; import com.android.bluetooth.TestUtils; import com.android.bluetooth.btservice.AdapterService; -import com.android.internal.R; import org.junit.After; import org.junit.Before; diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java index b70d268dee..8361eb1af3 100644 --- a/framework/java/android/bluetooth/BluetoothAdapter.java +++ b/framework/java/android/bluetooth/BluetoothAdapter.java @@ -2416,10 +2416,10 @@ public final class BluetoothAdapter { } /** - * Get the maximum number of connected audio devices. + * Get the maximum number of connected devices per audio profile for this device. * - * @return the maximum number of connected audio devices - * @hide + * @return the number of allowed simultaneous connected devices for each audio profile + * for this device, or -1 if the Bluetooth service can't be reached */ @RequiresLegacyBluetoothPermission @RequiresBluetoothConnectPermission @@ -2435,7 +2435,7 @@ public final class BluetoothAdapter { } finally { mServiceLock.readLock().unlock(); } - return 1; + return -1; } /** diff --git a/framework/java/android/bluetooth/BluetoothHeadset.java b/framework/java/android/bluetooth/BluetoothHeadset.java index 1b141c9afa..750e3a8323 100644 --- a/framework/java/android/bluetooth/BluetoothHeadset.java +++ b/framework/java/android/bluetooth/BluetoothHeadset.java @@ -911,16 +911,6 @@ public final class BluetoothHeadset implements BluetoothProfile { return defaultValue; } - /** - * Indicates if current platform supports voice dialing over bluetooth SCO. - * - * @return true if voice dialing over bluetooth is supported, false otherwise. - * @hide - */ - public static boolean isBluetoothVoiceDialingEnabled(Context context) { - return context.getResources().getBoolean( - com.android.internal.R.bool.config_bluetooth_sco_off_call); - } /** * Get the current audio state of the Headset. @@ -1433,17 +1423,6 @@ public final class BluetoothHeadset implements BluetoothProfile { return defaultValue; } - /** - * Check if in-band ringing is supported for this platform. - * - * @return true if in-band ringing is supported, false if in-band ringing is not supported - * @hide - */ - public static boolean isInbandRingingSupported(Context context) { - return context.getResources().getBoolean( - com.android.internal.R.bool.config_bluetooth_hfp_inband_ringing_support); - } - @SuppressLint("AndroidFrameworkBluetoothPermission") private final IBluetoothProfileServiceConnection mConnection = new IBluetoothProfileServiceConnection.Stub() { diff --git a/service/java/com/android/server/bluetooth/BluetoothManagerService.java b/service/java/com/android/server/bluetooth/BluetoothManagerService.java index e90b2b367c..7dd9ea4322 100644 --- a/service/java/com/android/server/bluetooth/BluetoothManagerService.java +++ b/service/java/com/android/server/bluetooth/BluetoothManagerService.java @@ -60,6 +60,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManagerInternal; import android.content.pm.UserInfo; +import android.content.res.Resources; import android.database.ContentObserver; import android.os.Binder; import android.os.Bundle; @@ -77,13 +78,13 @@ import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; +import android.sysprop.BluetoothProperties; import android.text.TextUtils; import android.util.FeatureFlagUtils; import android.util.Log; import android.util.Slog; import android.util.proto.ProtoOutputStream; -import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.DumpUtils; import com.android.internal.util.FrameworkStatsLog; @@ -167,6 +168,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub { private static final int SERVICE_IBLUETOOTH = 1; private static final int SERVICE_IBLUETOOTHGATT = 2; + private static final String BLUETOOTH_PACKAGE_NAME = "com.android.bluetooth"; + private final Context mContext; private final UserManager mUserManager; @@ -466,7 +469,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub { mContext = context; mWirelessConsentRequired = context.getResources() - .getBoolean(com.android.internal.R.bool.config_wirelessConsentRequired); + .getBoolean(Resources.getSystem().getIdentifier( + "config_wirelessConsentRequired", "bool", "android")); mCrashes = 0; mBluetooth = null; @@ -490,8 +494,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub { mUserManager = mContext.getSystemService(UserManager.class); - mIsHearingAidProfileSupported = context.getResources() - .getBoolean(com.android.internal.R.bool.config_hearing_aid_profile_supported); + mIsHearingAidProfileSupported = + BluetoothProperties.audioStreamingForHearingAidSupported().orElse(false); // TODO: We need a more generic way to initialize the persist keys of FeatureFlagUtils String value = SystemProperties.get(FeatureFlagUtils.PERSIST_PREFIX + FeatureFlagUtils.HEARING_AID_SETTINGS); @@ -542,7 +546,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub { int systemUiUid = -1; // Check if device is configured with no home screen, which implies no SystemUI. - boolean noHome = mContext.getResources().getBoolean(R.bool.config_noHomeScreen); + boolean noHome = context.getResources() + .getBoolean(Resources.getSystem().getIdentifier( + "config_noHomeScreen", "bool", "android")); if (!noHome) { PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class); systemUiUid = pm.getPackageUid(pm.getSystemUiServiceComponent().getPackageName(), @@ -557,6 +563,19 @@ class BluetoothManagerService extends IBluetoothManager.Stub { mSystemUiUid = systemUiUid; } + private boolean getBluetoothBooleanConfig(String name, boolean orElse) { + try { + Resources bluetoothRes = mContext.getPackageManager() + .getResourcesForApplication(BLUETOOTH_PACKAGE_NAME); + orElse = bluetoothRes.getBoolean(bluetoothRes.getIdentifier( + name, "bool", BLUETOOTH_PACKAGE_NAME)); + } catch (PackageManager.NameNotFoundException e) { + Log.e(TAG, "Unable to retrieve Bluetooth configuration " + name); + e.printStackTrace(); + } + return orElse; + } + /** * Returns true if airplane mode is currently on */ @@ -566,7 +585,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub { } private boolean supportBluetoothPersistedState() { - return mContext.getResources().getBoolean(R.bool.config_supportBluetoothPersistedState); + // Set default support to true to copy config default. + return getBluetoothBooleanConfig("config_supportBluetoothPersistedState", true); } /** @@ -639,8 +659,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { if (DBG) { Slog.d(TAG, "Loading stored name and address"); } - if (mContext.getResources() - .getBoolean(com.android.internal.R.bool.config_bluetooth_address_validation) + if (getBluetoothBooleanConfig("config_bluetooth_address_validation", false) && Settings.Secure.getIntForUser(mContentResolver, SECURE_SETTINGS_BLUETOOTH_ADDR_VALID, 0, mUserId) == 0) { diff --git a/service/java/com/android/server/bluetooth/BluetoothModeChangeHelper.java b/service/java/com/android/server/bluetooth/BluetoothModeChangeHelper.java index e5854c9682..a67c6caa63 100644 --- a/service/java/com/android/server/bluetooth/BluetoothModeChangeHelper.java +++ b/service/java/com/android/server/bluetooth/BluetoothModeChangeHelper.java @@ -28,7 +28,6 @@ import android.content.res.Resources; import android.provider.Settings; import android.widget.Toast; -import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; /** @@ -131,8 +130,8 @@ public class BluetoothModeChangeHelper { @VisibleForTesting public void showToastMessage() { Resources r = mContext.getResources(); - final CharSequence text = r.getString( - R.string.bluetooth_airplane_mode_toast, 0); + final CharSequence text = r.getString(Resources.getSystem().getIdentifier( + "bluetooth_airplane_mode_toast", "string", "android")); Toast.makeText(mContext, text, Toast.LENGTH_LONG).show(); } |