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 /service/java/com/android/server/bluetooth/BluetoothManagerService.java | |
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
Diffstat (limited to 'service/java/com/android/server/bluetooth/BluetoothManagerService.java')
-rw-r--r-- | service/java/com/android/server/bluetooth/BluetoothManagerService.java | 35 |
1 files changed, 27 insertions, 8 deletions
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) { |