Loading core/java/android/os/Environment.java +7 −0 Original line number Diff line number Diff line Loading @@ -722,6 +722,13 @@ public class Environment { */ public static final String MEDIA_UNMOUNTABLE = "unmountable"; /** * Storage state if the media is present and in formatting state. * * @hide */ public static final String MEDIA_FORMATTING = "formatting"; /** * Returns the current state of the primary "external" storage device. * Loading core/java/android/os/storage/StorageVolume.java +9 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ public class StorageVolume implements Parcelable { private String mUuid; private String mUserLabel; private String mState; private boolean mIsFormatting; // StorageVolume extra for ACTION_MEDIA_REMOVED, ACTION_MEDIA_UNMOUNTED, ACTION_MEDIA_CHECKING, // ACTION_MEDIA_NOFS, ACTION_MEDIA_MOUNTED, ACTION_MEDIA_SHARED, ACTION_MEDIA_UNSHARED, Loading Loading @@ -238,6 +239,14 @@ public class StorageVolume implements Parcelable { return mState; } public void setIsFormatting(boolean isFormatting) { mIsFormatting = isFormatting; } public boolean getIsFormatting() { return mIsFormatting; } @Override public boolean equals(Object obj) { if (obj instanceof StorageVolume && mPath != null) { Loading services/core/java/com/android/server/MountService.java +9 −0 Original line number Diff line number Diff line Loading @@ -754,6 +754,9 @@ class MountService extends IMountService.Stub synchronized (mVolumesLock) { oldState = mVolumeStates.put(path, state); volume.setState(state); if (!Environment.MEDIA_FORMATTING.equals(state)) { volume.setIsFormatting(false); } } if (state.equals(oldState)) { Loading Loading @@ -1099,6 +1102,9 @@ class MountService extends IMountService.Stub } else if (newState == VolumeState.Unmounting) { action = Intent.ACTION_MEDIA_EJECT; } else if (newState == VolumeState.Formatting) { synchronized (mVolumesLock) { volume.setIsFormatting(true); } } else if (newState == VolumeState.Shared) { if (DEBUG_EVENTS) Slog.i(TAG, "Updating volume state media mounted"); /* Send the media unmounted event first */ Loading Loading @@ -1127,6 +1133,9 @@ class MountService extends IMountService.Stub final StorageVolume volume; synchronized (mVolumesLock) { volume = mVolumesByPath.get(path); if (volume.getIsFormatting()) { return StorageResultCode.OperationFailedStorageBusy; } } if (!volume.isEmulated() && hasUserRestriction(UserManager.DISALLOW_MOUNT_PHYSICAL_MEDIA)) { Loading Loading
core/java/android/os/Environment.java +7 −0 Original line number Diff line number Diff line Loading @@ -722,6 +722,13 @@ public class Environment { */ public static final String MEDIA_UNMOUNTABLE = "unmountable"; /** * Storage state if the media is present and in formatting state. * * @hide */ public static final String MEDIA_FORMATTING = "formatting"; /** * Returns the current state of the primary "external" storage device. * Loading
core/java/android/os/storage/StorageVolume.java +9 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ public class StorageVolume implements Parcelable { private String mUuid; private String mUserLabel; private String mState; private boolean mIsFormatting; // StorageVolume extra for ACTION_MEDIA_REMOVED, ACTION_MEDIA_UNMOUNTED, ACTION_MEDIA_CHECKING, // ACTION_MEDIA_NOFS, ACTION_MEDIA_MOUNTED, ACTION_MEDIA_SHARED, ACTION_MEDIA_UNSHARED, Loading Loading @@ -238,6 +239,14 @@ public class StorageVolume implements Parcelable { return mState; } public void setIsFormatting(boolean isFormatting) { mIsFormatting = isFormatting; } public boolean getIsFormatting() { return mIsFormatting; } @Override public boolean equals(Object obj) { if (obj instanceof StorageVolume && mPath != null) { Loading
services/core/java/com/android/server/MountService.java +9 −0 Original line number Diff line number Diff line Loading @@ -754,6 +754,9 @@ class MountService extends IMountService.Stub synchronized (mVolumesLock) { oldState = mVolumeStates.put(path, state); volume.setState(state); if (!Environment.MEDIA_FORMATTING.equals(state)) { volume.setIsFormatting(false); } } if (state.equals(oldState)) { Loading Loading @@ -1099,6 +1102,9 @@ class MountService extends IMountService.Stub } else if (newState == VolumeState.Unmounting) { action = Intent.ACTION_MEDIA_EJECT; } else if (newState == VolumeState.Formatting) { synchronized (mVolumesLock) { volume.setIsFormatting(true); } } else if (newState == VolumeState.Shared) { if (DEBUG_EVENTS) Slog.i(TAG, "Updating volume state media mounted"); /* Send the media unmounted event first */ Loading Loading @@ -1127,6 +1133,9 @@ class MountService extends IMountService.Stub final StorageVolume volume; synchronized (mVolumesLock) { volume = mVolumesByPath.get(path); if (volume.getIsFormatting()) { return StorageResultCode.OperationFailedStorageBusy; } } if (!volume.isEmulated() && hasUserRestriction(UserManager.DISALLOW_MOUNT_PHYSICAL_MEDIA)) { Loading