List of usage examples for android.os Environment MEDIA_CHECKING
String MEDIA_CHECKING
To view the source code for android.os Environment MEDIA_CHECKING.
Click Source Link
From source file:Main.java
/** * Returns the current state of the storage device that provides the given path. * @param state "getExternalStorageState()" *//* w ww. j av a 2 s . co m*/ public static String getExternalStorageState(String state) { if (TextUtils.isEmpty(state)) { return UNKNOWN; } switch (state) { case Environment.MEDIA_BAD_REMOVAL://bad_removal return "MEDIA_BAD_REMOVAL"; case Environment.MEDIA_CHECKING://checking return "MEDIA_CHECKING"; case Environment.MEDIA_EJECTING://ejecting return "MEDIA_EJECTING"; case Environment.MEDIA_MOUNTED://mounted return "MEDIA_MOUNTED"; case Environment.MEDIA_MOUNTED_READ_ONLY://mounted_read_only return "MEDIA_MOUNTED_READ_ONLY"; case Environment.MEDIA_NOFS://nofs return "MEDIA_NOFS"; case Environment.MEDIA_REMOVED://removed return "MEDIA_REMOVED"; case Environment.MEDIA_SHARED://shared return "MEDIA_SHARED"; case Environment.MEDIA_UNKNOWN://unknown return "MEDIA_UNKNOWN"; case Environment.MEDIA_UNMOUNTABLE://unmountable return "MEDIA_UNMOUNTABLE"; case Environment.MEDIA_UNMOUNTED://unmounted return "MEDIA_UNMOUNTED"; default: return UNKNOWN; } }
From source file:eu.janmuller.android.simplecropimage.CropImage.java
public static void showStorageToast(Activity activity, int remaining) { String noStorageText = null;/*from w ww . j av a 2 s . c o m*/ if (remaining == NO_STORAGE_ERROR) { String state = Environment.getExternalStorageState(); if (state.equals(Environment.MEDIA_CHECKING)) { noStorageText = activity.getString(R.string.preparing_card); } else { noStorageText = activity.getString(R.string.no_storage_card); } } else if (remaining < 1) { noStorageText = activity.getString(R.string.not_enough_space); } if (noStorageText != null) { Toast.makeText(activity, noStorageText, Toast.LENGTH_LONG).show(); } }
From source file:com.android.server.MountService.java
private void notifyVolumeStateChange(String label, String path, int oldState, int newState) { final StorageVolume volume; final String state; synchronized (mVolumesLock) { volume = mVolumesByPath.get(path); state = getVolumeState(path);/* w ww .j av a 2s . c om*/ } if (DEBUG_EVENTS) Slog.i(TAG, "notifyVolumeStateChange::" + state); String action = null; if (oldState == VolumeState.Shared && newState != oldState) { if (LOCAL_LOGD) Slog.d(TAG, "Sending ACTION_MEDIA_UNSHARED intent"); sendStorageIntent(Intent.ACTION_MEDIA_UNSHARED, volume, UserHandle.ALL); } if (newState == VolumeState.Init) { } else if (newState == VolumeState.NoMedia) { // NoMedia is handled via Disk Remove events } else if (newState == VolumeState.Idle) { /* * Don't notify if we're in BAD_REMOVAL, NOFS, UNMOUNTABLE, or * if we're in the process of enabling UMS */ if (!state.equals(Environment.MEDIA_BAD_REMOVAL) && !state.equals(Environment.MEDIA_NOFS) && !state.equals(Environment.MEDIA_UNMOUNTABLE) && !getUmsEnabling()) { if (DEBUG_EVENTS) Slog.i(TAG, "updating volume state for media bad removal nofs and unmountable"); updatePublicVolumeState(volume, Environment.MEDIA_UNMOUNTED); action = Intent.ACTION_MEDIA_UNMOUNTED; } } else if (newState == VolumeState.Pending) { } else if (newState == VolumeState.Checking) { if (DEBUG_EVENTS) Slog.i(TAG, "updating volume state checking"); updatePublicVolumeState(volume, Environment.MEDIA_CHECKING); action = Intent.ACTION_MEDIA_CHECKING; } else if (newState == VolumeState.Mounted) { if (DEBUG_EVENTS) Slog.i(TAG, "updating volume state mounted"); updatePublicVolumeState(volume, Environment.MEDIA_MOUNTED); action = Intent.ACTION_MEDIA_MOUNTED; } else if (newState == VolumeState.Unmounting) { action = Intent.ACTION_MEDIA_EJECT; } else if (newState == VolumeState.Formatting) { } else if (newState == VolumeState.Shared) { if (DEBUG_EVENTS) Slog.i(TAG, "Updating volume state media mounted"); /* Send the media unmounted event first */ updatePublicVolumeState(volume, Environment.MEDIA_UNMOUNTED); sendStorageIntent(Intent.ACTION_MEDIA_UNMOUNTED, volume, UserHandle.ALL); if (DEBUG_EVENTS) Slog.i(TAG, "Updating media shared"); updatePublicVolumeState(volume, Environment.MEDIA_SHARED); action = Intent.ACTION_MEDIA_SHARED; if (LOCAL_LOGD) Slog.d(TAG, "Sending ACTION_MEDIA_SHARED intent"); } else if (newState == VolumeState.SharedMnt) { Slog.e(TAG, "Live shared mounts not supported yet!"); return; } else { Slog.e(TAG, "Unhandled VolumeState {" + newState + "}"); } if (action != null) { sendStorageIntent(action, volume, UserHandle.ALL); } }
From source file:com.android.server.MountService.java
public void shutdown(final IMountShutdownObserver observer) { validatePermission(android.Manifest.permission.SHUTDOWN); Slog.i(TAG, "Shutting down"); synchronized (mVolumesLock) { // Get all volumes to be unmounted. MountShutdownLatch mountShutdownLatch = new MountShutdownLatch(observer, mVolumeStates.size()); for (String path : mVolumeStates.keySet()) { String state = mVolumeStates.get(path); if (state.equals(Environment.MEDIA_SHARED)) { /*/*from w w w. j a va 2 s . c o m*/ * If the media is currently shared, unshare it. * XXX: This is still dangerous!. We should not * be rebooting at *all* if UMS is enabled, since * the UMS host could have dirty FAT cache entries * yet to flush. */ setUsbMassStorageEnabled(false); } else if (state.equals(Environment.MEDIA_CHECKING)) { /* * If the media is being checked, then we need to wait for * it to complete before being able to proceed. */ // XXX: @hackbod - Should we disable the ANR timer here? int retries = 30; while (state.equals(Environment.MEDIA_CHECKING) && (retries-- >= 0)) { try { Thread.sleep(1000); } catch (InterruptedException iex) { Slog.e(TAG, "Interrupted while waiting for media", iex); break; } state = Environment.getExternalStorageState(); } if (retries == 0) { Slog.e(TAG, "Timed out waiting for media to check"); } } if (state.equals(Environment.MEDIA_MOUNTED)) { // Post a unmount message. ShutdownCallBack ucb = new ShutdownCallBack(path, mountShutdownLatch); mHandler.sendMessage(mHandler.obtainMessage(H_UNMOUNT_PM_UPDATE, ucb)); } else if (observer != null) { /* * Count down, since nothing will be done. The observer will be * notified when we are done so shutdown sequence can continue. */ mountShutdownLatch.countDown(); Slog.i(TAG, "Unmount completed: " + path + ", result code: " + StorageResultCode.OperationSucceeded); } } } }