diff options
author | Jeff Sharkey <jsharkey@android.com> | 2015-04-18 21:38:05 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2015-04-18 23:11:00 -0700 |
commit | e6c04f9417cc4bff0f5f9e72f0d6d66d2aab6e80 (patch) | |
tree | cd544b7655f5a41228bfd1690cbd5164cf0e0bc5 /services/core | |
parent | 722743667110718acf473c92727b55581c0b9309 (diff) | |
download | frameworks_base-e6c04f9417cc4bff0f5f9e72f0d6d66d2aab6e80.zip frameworks_base-e6c04f9417cc4bff0f5f9e72f0d6d66d2aab6e80.tar.gz frameworks_base-e6c04f9417cc4bff0f5f9e72f0d6d66d2aab6e80.tar.bz2 |
Broadcast hidden volumes, notification polish.
Send limited broadcast intent when certain volume state changes
occur; the only customer for now is ExternalStorageProvider.
Change notification flow to be less bumpy. Pick USB icon based on
disk type, and avoid using "generic" disk labels.
Bug: 19993667
Change-Id: I263bc9e9aae2ae57eb4d1afe76da686aee5475fb
Diffstat (limited to 'services/core')
-rw-r--r-- | services/core/java/com/android/server/MountService.java | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/MountService.java b/services/core/java/com/android/server/MountService.java index cc27cfc..868d3d8 100644 --- a/services/core/java/com/android/server/MountService.java +++ b/services/core/java/com/android/server/MountService.java @@ -861,7 +861,7 @@ class MountService extends IMountService.Stub final int oldState = vol.state; final int newState = Integer.parseInt(cooked[2]); vol.state = newState; - onVolumeStateChangedLocked(vol, oldState, newState); + onVolumeStateChangedLocked(vol.clone(), oldState, newState); } break; } @@ -955,8 +955,37 @@ class MountService extends IMountService.Stub } } + private boolean isBroadcastWorthy(VolumeInfo vol) { + switch (vol.getType()) { + case VolumeInfo.TYPE_PUBLIC: + case VolumeInfo.TYPE_EMULATED: + break; + default: + return false; + } + + switch (vol.getState()) { + case VolumeInfo.STATE_MOUNTED: + case VolumeInfo.STATE_MOUNTED_READ_ONLY: + case VolumeInfo.STATE_EJECTING: + case VolumeInfo.STATE_UNMOUNTED: + break; + default: + return false; + } + + return true; + } + private void onVolumeStateChangedLocked(VolumeInfo vol, int oldState, int newState) { - mCallbacks.notifyVolumeStateChanged(vol.clone(), oldState, newState); + mCallbacks.notifyVolumeStateChanged(vol, oldState, newState); + + if (isBroadcastWorthy(vol)) { + final Intent intent = new Intent(VolumeInfo.ACTION_VOLUME_STATE_CHANGED); + intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); + // TODO: require receiver to hold permission + mContext.sendBroadcastAsUser(intent, UserHandle.ALL); + } final String oldStateEnv = VolumeInfo.getEnvironmentForState(oldState); final String newStateEnv = VolumeInfo.getEnvironmentForState(newState); |