diff options
author | Joseph Pirozzo <pirozzoj@google.com> | 2018-11-12 13:37:06 -0800 |
---|---|---|
committer | Ram Periathiruvadi <ramperry@google.com> | 2019-03-11 13:25:38 +0000 |
commit | 60cae8d359f8bd5cf019cb3b901b941eedf25c1d (patch) | |
tree | 994a863d63906b9377f39ede1163099d5c8b5af6 | |
parent | 789635b6c12b916c779ed07eefb117e9093bd953 (diff) |
[DO NOT MERGE] Bluetooth support for Headless User
If Headless User 0 is enabled then don't launch Bluetooth until after
user has switched out of 0. This is specifically an issue for
automotive platforms.
Bug: 118400949
Test: Boot device while headless user 0 is enabled, with a paired
Bluetooth device in a phonecall.
Change-Id: I9ea833df7ae7dc8841102ab9693f3810b31f672f
(cherry picked from commit 195a1c026fb17ab8b4fa0dd812381fe39126d213)
-rw-r--r-- | services/core/java/com/android/server/BluetoothService.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/BluetoothService.java b/services/core/java/com/android/server/BluetoothService.java index 1bf4e3a563c9..6018f008054c 100644 --- a/services/core/java/com/android/server/BluetoothService.java +++ b/services/core/java/com/android/server/BluetoothService.java @@ -18,15 +18,26 @@ package com.android.server; import android.bluetooth.BluetoothAdapter; import android.content.Context; +import android.os.SystemProperties; class BluetoothService extends SystemService { + private static final String HEADLESS_SYSTEM_USER = "android.car.systemuser.headless"; + private BluetoothManagerService mBluetoothManagerService; + private boolean mInitialized = false; public BluetoothService(Context context) { super(context); mBluetoothManagerService = new BluetoothManagerService(context); } + private void initialize() { + if (!mInitialized) { + mBluetoothManagerService.handleOnBootPhase(); + mInitialized = true; + } + } + @Override public void onStart() { } @@ -36,13 +47,15 @@ class BluetoothService extends SystemService { if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) { publishBinderService(BluetoothAdapter.BLUETOOTH_MANAGER_SERVICE, mBluetoothManagerService); - } else if (phase == SystemService.PHASE_ACTIVITY_MANAGER_READY) { - mBluetoothManagerService.handleOnBootPhase(); + } else if (phase == SystemService.PHASE_ACTIVITY_MANAGER_READY && + !SystemProperties.getBoolean(HEADLESS_SYSTEM_USER, false)) { + initialize(); } } @Override public void onSwitchUser(int userHandle) { + initialize(); mBluetoothManagerService.handleOnSwitchUser(userHandle); } |