diff options
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 a75f7ac218..25c5001443 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; @@ -121,7 +122,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; @@ -501,7 +501,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(); @@ -2282,7 +2282,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 8dadbcfd3e..71235b441e 100644 --- a/android/app/src/com/android/bluetooth/hfp/HeadsetService.java +++ b/android/app/src/com/android/bluetooth/hfp/HeadsetService.java @@ -1859,7 +1859,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; } @@ -2096,6 +2098,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); @@ -2104,7 +2108,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 5a4524d5af..4223397caf 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( @@ -455,7 +455,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())) .setContentIntent( @@ -523,7 +523,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())) @@ -593,7 +593,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( @@ -620,7 +620,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 8d3604527b..0df5f1dde5 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 f302da12a8..1700254ba7 100644 --- a/framework/java/android/bluetooth/BluetoothAdapter.java +++ b/framework/java/android/bluetooth/BluetoothAdapter.java @@ -2397,10 +2397,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 @@ -2416,7 +2416,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 91449df0f4..f4fcf1dff6 100644 --- a/framework/java/android/bluetooth/BluetoothHeadset.java +++ b/framework/java/android/bluetooth/BluetoothHeadset.java @@ -887,16 +887,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); - } /** @hide */ @Retention(RetentionPolicy.SOURCE) @@ -1450,17 +1440,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 4e738a394d..d55c280f5c 100644 --- a/service/java/com/android/server/bluetooth/BluetoothManagerService.java +++ b/service/java/com/android/server/bluetooth/BluetoothManagerService.java @@ -58,6 +58,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; @@ -76,13 +77,13 @@ import android.os.UserManager; import android.permission.PermissionManager; 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; @@ -162,6 +163,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; @@ -461,7 +464,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; @@ -485,8 +489,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); @@ -537,7 +541,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(), @@ -552,6 +558,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 */ @@ -561,7 +580,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); } /** @@ -634,8 +654,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, Settings.Secure.BLUETOOTH_NAME, 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(); } |