Loading android/app/src/com/android/bluetooth/Utils.java +38 −0 Original line number Diff line number Diff line Loading @@ -1190,4 +1190,42 @@ public final class Utils { return string; } /** * Check if BLE is supported by this platform * @param context current device context * @return true if BLE is supported, false otherwise */ public static boolean isBleSupported(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE); } /** * Check if this is an automotive device * @param context current device context * @return true if this Android device is an automotive device, false otherwise */ public static boolean isAutomotive(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE); } /** * Check if this is a watch device * @param context current device context * @return true if this Android device is a watch device, false otherwise */ public static boolean isWatch(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH); } /** * Check if this is a TV device * @param context current device context * @return true if this Android device is a TV device, false otherwise */ public static boolean isTv(Context context) { PackageManager pm = context.getPackageManager(); return pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION) || pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK); } } android/app/src/com/android/bluetooth/btservice/Config.java +14 −3 Original line number Diff line number Diff line Loading @@ -18,12 +18,13 @@ package com.android.bluetooth.btservice; import android.bluetooth.BluetoothProfile; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Resources; import android.os.SystemProperties; import android.sysprop.BluetoothProperties; import android.util.Log; import com.android.bluetooth.R; import com.android.bluetooth.Utils; import com.android.bluetooth.a2dp.A2dpService; import com.android.bluetooth.a2dpsink.A2dpSinkService; import com.android.bluetooth.avrcp.AvrcpTargetService; Loading Loading @@ -194,8 +195,18 @@ public class Config { } } // Disable ASHA if BLE is not supported on this platform if (!ctx.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { // Disable ASHA on Automotive, TV, and Watch devices if the system property is not set // This means that the OS will not automatically enable ASHA on these platforms, but these // platforms can choose to enable ASHA themselves if (BluetoothProperties.isProfileAshaCentralEnabled().isEmpty()) { if (Utils.isAutomotive(ctx) || Utils.isTv(ctx) || Utils.isWatch(ctx)) { setProfileEnabled(HearingAidService.class, false); } } // Disable ASHA if BLE is not supported on this platform even if the platform enabled ASHA // accidentally if (!Utils.isBleSupported(ctx)) { setProfileEnabled(HearingAidService.class, false); } Loading service/src/com/android/server/bluetooth/BluetoothManagerService.java +50 −4 Original line number Diff line number Diff line Loading @@ -646,11 +646,19 @@ public class BluetoothManagerService extends IBluetoothManager.Stub { mBluetoothNotificationManager = new BluetoothNotificationManager(mContext); // Disable ASHA if BLE is not supported on this platform mIsHearingAidProfileSupported = BluetoothProperties.isProfileAshaCentralEnabled().orElse(true); if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { // Disable ASHA if BLE is not supported, overriding any system property if (!isBleSupported(mContext)) { mIsHearingAidProfileSupported = false; } else { // ASHA default value is: // * disabled on Automotive, TV, and Watch. // * enabled for other form factor // This default value can be overridden with a system property final boolean isAshaEnabledByDefault = !(isAutomotive(mContext) || isWatch(mContext) || isTv(mContext)); mIsHearingAidProfileSupported = BluetoothProperties.isProfileAshaCentralEnabled() .orElse(isAshaEnabledByDefault); } String value = SystemProperties.get( Loading Loading @@ -3647,5 +3655,43 @@ public class BluetoothManagerService extends IBluetoothManager.Stub { } return BluetoothAdapter.BT_SNOOP_LOG_MODE_DISABLED; } /** * Check if BLE is supported by this platform * @param context current device context * @return true if BLE is supported, false otherwise */ private static boolean isBleSupported(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE); } /** * Check if this is an automotive device * @param context current device context * @return true if this Android device is an automotive device, false otherwise */ private static boolean isAutomotive(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE); } /** * Check if this is a watch device * @param context current device context * @return true if this Android device is a watch device, false otherwise */ private static boolean isWatch(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH); } /** * Check if this is a TV device * @param context current device context * @return true if this Android device is a TV device, false otherwise */ private static boolean isTv(Context context) { PackageManager pm = context.getPackageManager(); return pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION) || pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK); } } Loading
android/app/src/com/android/bluetooth/Utils.java +38 −0 Original line number Diff line number Diff line Loading @@ -1190,4 +1190,42 @@ public final class Utils { return string; } /** * Check if BLE is supported by this platform * @param context current device context * @return true if BLE is supported, false otherwise */ public static boolean isBleSupported(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE); } /** * Check if this is an automotive device * @param context current device context * @return true if this Android device is an automotive device, false otherwise */ public static boolean isAutomotive(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE); } /** * Check if this is a watch device * @param context current device context * @return true if this Android device is a watch device, false otherwise */ public static boolean isWatch(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH); } /** * Check if this is a TV device * @param context current device context * @return true if this Android device is a TV device, false otherwise */ public static boolean isTv(Context context) { PackageManager pm = context.getPackageManager(); return pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION) || pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK); } }
android/app/src/com/android/bluetooth/btservice/Config.java +14 −3 Original line number Diff line number Diff line Loading @@ -18,12 +18,13 @@ package com.android.bluetooth.btservice; import android.bluetooth.BluetoothProfile; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Resources; import android.os.SystemProperties; import android.sysprop.BluetoothProperties; import android.util.Log; import com.android.bluetooth.R; import com.android.bluetooth.Utils; import com.android.bluetooth.a2dp.A2dpService; import com.android.bluetooth.a2dpsink.A2dpSinkService; import com.android.bluetooth.avrcp.AvrcpTargetService; Loading Loading @@ -194,8 +195,18 @@ public class Config { } } // Disable ASHA if BLE is not supported on this platform if (!ctx.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { // Disable ASHA on Automotive, TV, and Watch devices if the system property is not set // This means that the OS will not automatically enable ASHA on these platforms, but these // platforms can choose to enable ASHA themselves if (BluetoothProperties.isProfileAshaCentralEnabled().isEmpty()) { if (Utils.isAutomotive(ctx) || Utils.isTv(ctx) || Utils.isWatch(ctx)) { setProfileEnabled(HearingAidService.class, false); } } // Disable ASHA if BLE is not supported on this platform even if the platform enabled ASHA // accidentally if (!Utils.isBleSupported(ctx)) { setProfileEnabled(HearingAidService.class, false); } Loading
service/src/com/android/server/bluetooth/BluetoothManagerService.java +50 −4 Original line number Diff line number Diff line Loading @@ -646,11 +646,19 @@ public class BluetoothManagerService extends IBluetoothManager.Stub { mBluetoothNotificationManager = new BluetoothNotificationManager(mContext); // Disable ASHA if BLE is not supported on this platform mIsHearingAidProfileSupported = BluetoothProperties.isProfileAshaCentralEnabled().orElse(true); if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { // Disable ASHA if BLE is not supported, overriding any system property if (!isBleSupported(mContext)) { mIsHearingAidProfileSupported = false; } else { // ASHA default value is: // * disabled on Automotive, TV, and Watch. // * enabled for other form factor // This default value can be overridden with a system property final boolean isAshaEnabledByDefault = !(isAutomotive(mContext) || isWatch(mContext) || isTv(mContext)); mIsHearingAidProfileSupported = BluetoothProperties.isProfileAshaCentralEnabled() .orElse(isAshaEnabledByDefault); } String value = SystemProperties.get( Loading Loading @@ -3647,5 +3655,43 @@ public class BluetoothManagerService extends IBluetoothManager.Stub { } return BluetoothAdapter.BT_SNOOP_LOG_MODE_DISABLED; } /** * Check if BLE is supported by this platform * @param context current device context * @return true if BLE is supported, false otherwise */ private static boolean isBleSupported(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE); } /** * Check if this is an automotive device * @param context current device context * @return true if this Android device is an automotive device, false otherwise */ private static boolean isAutomotive(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE); } /** * Check if this is a watch device * @param context current device context * @return true if this Android device is a watch device, false otherwise */ private static boolean isWatch(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH); } /** * Check if this is a TV device * @param context current device context * @return true if this Android device is a TV device, false otherwise */ private static boolean isTv(Context context) { PackageManager pm = context.getPackageManager(); return pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION) || pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK); } }