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 <san@google.com>
This commit is contained in:
@@ -115,8 +115,9 @@ class MountService extends IMountService.Stub
|
||||
private PackageManagerService mPms;
|
||||
private boolean mUmsEnabling;
|
||||
private ArrayList<MountServiceBinderListener> 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));
|
||||
|
||||
Reference in New Issue
Block a user