From 6a965af2d76f6cf3ec980c8ecfd257f49b3c97e3 Mon Sep 17 00:00:00 2001 From: San Mehat Date: Wed, 24 Feb 2010 17:47:30 -0800 Subject: [PATCH] MountService: Send UMS_CONNECTED broadcast on boot if UMS connected. UMS detection is now done wayyyy before the system is booted, so set a flag to send our intent broadcast once we've booted. Signed-off-by: San Mehat --- .../java/com/android/server/MountService.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java index 2dc12f6e53479..fb17538f67775 100644 --- a/services/java/com/android/server/MountService.java +++ b/services/java/com/android/server/MountService.java @@ -115,8 +115,9 @@ class MountService extends IMountService.Stub private PackageManagerService mPms; private boolean mUmsEnabling; private ArrayList mListeners; - private boolean mBooted; - private boolean mReady; + private boolean mBooted = false; + private boolean mReady = false; + private boolean mSendUmsConnectedOnBoot = false; /** * Private hash of currently mounted secure containers. @@ -162,6 +163,14 @@ class MountService extends IMountService.Stub Log.e(TAG, String.format("Boot-time mount failed (%d)", rc)); } } + /* + * If UMS is connected in boot, send the connected event + * now that we're up. + */ + if (mSendUmsConnectedOnBoot) { + sendUmsIntent(true); + mSendUmsConnectedOnBoot = false; + } } catch (Exception ex) { Log.e(TAG, "Boot-time mount exception", ex); } @@ -636,16 +645,17 @@ class MountService extends IMountService.Stub } if (mBooted == true) { - Intent intent; - if (avail) { - intent = new Intent(Intent.ACTION_UMS_CONNECTED); - } else { - intent = new Intent(Intent.ACTION_UMS_DISCONNECTED); - } - mContext.sendBroadcast(intent); + sendUmsIntent(avail); + } else { + mSendUmsConnectedOnBoot = avail; } } + private void sendUmsIntent(boolean c) { + mContext.sendBroadcast( + new Intent((c ? Intent.ACTION_UMS_CONNECTED : Intent.ACTION_UMS_DISCONNECTED))); + } + private void validatePermission(String perm) { if (mContext.checkCallingOrSelfPermission(perm) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException(String.format("Requires %s permission", perm));