diff options
author | Eric Laurent <elaurent@google.com> | 2014-05-06 10:49:04 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2014-05-06 10:49:04 -0700 |
commit | 4a5eeb9c727d77bb57fef87a70c8c9cc23dbfee3 (patch) | |
tree | 28a357f9dd84cede672e2f8d6281a130b6d4ce7b /services/core/java/com/android/server/WiredAccessoryManager.java | |
parent | ebb9e69513b690881a5bad7bf45c6f32e0fc7062 (diff) | |
download | frameworks_base-4a5eeb9c727d77bb57fef87a70c8c9cc23dbfee3.zip frameworks_base-4a5eeb9c727d77bb57fef87a70c8c9cc23dbfee3.tar.gz frameworks_base-4a5eeb9c727d77bb57fef87a70c8c9cc23dbfee3.tar.bz2 |
AudioService/WireAccessoryManager: change boot completion detection method
BOOT_COMPLETED intent is not a reliable way for system services
to detect boot completion. The intent broadcast can be significantly
delayed and there is no guaranty that system services
receive it before apps.
Use a systemReady() method called by SystemServer instead.
Bug: 14323903.
Change-Id: I781596a3545e7a1e719799982347cbcd9a4c9009
Diffstat (limited to 'services/core/java/com/android/server/WiredAccessoryManager.java')
-rw-r--r-- | services/core/java/com/android/server/WiredAccessoryManager.java | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/services/core/java/com/android/server/WiredAccessoryManager.java b/services/core/java/com/android/server/WiredAccessoryManager.java index 50cfe48..c32beda 100644 --- a/services/core/java/com/android/server/WiredAccessoryManager.java +++ b/services/core/java/com/android/server/WiredAccessoryManager.java @@ -70,6 +70,7 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks { private static final String NAME_HDMI = "hdmi"; private static final int MSG_NEW_DEVICE_STATE = 1; + private static final int MSG_SYSTEM_READY = 2; private final Object mLock = new Object(); @@ -96,19 +97,9 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks { context.getResources().getBoolean(R.bool.config_useDevInputEventForAudioJack); mObserver = new WiredAccessoryObserver(); - - IntentFilter filter = new IntentFilter(Intent.ACTION_BOOT_COMPLETED); - filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); - context.registerReceiver(new BroadcastReceiver() { - @Override - public void onReceive(Context ctx, Intent intent) { - bootCompleted(); - } - }, - filter, null, null); } - private void bootCompleted() { + private void onSystemReady() { if (mUseDevInputEventForAudioJack) { int switchValues = 0; if (mInputManager.getSwitchState(-1, InputDevice.SOURCE_ANY, SW_HEADPHONE_INSERT) == 1) { @@ -159,6 +150,16 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks { } } + @Override + public void systemReady() { + synchronized (mLock) { + mWakeLock.acquire(); + + Message msg = mHandler.obtainMessage(MSG_SYSTEM_READY, 0, 0, null); + mHandler.sendMessage(msg); + } + } + /** * Compare the existing headset state with the new state and pass along accordingly. Note * that this only supports a single headset at a time. Inserting both a usb and jacked headset @@ -220,6 +221,11 @@ final class WiredAccessoryManager implements WiredAccessoryCallbacks { case MSG_NEW_DEVICE_STATE: setDevicesState(msg.arg1, msg.arg2, (String)msg.obj); mWakeLock.release(); + break; + case MSG_SYSTEM_READY: + onSystemReady(); + mWakeLock.release(); + break; } } }; |