Example usage for android.content Intent ACTION_MEDIA_NOFS

List of usage examples for android.content Intent ACTION_MEDIA_NOFS

Introduction

In this page you can find the example usage for android.content Intent ACTION_MEDIA_NOFS.

Prototype

String ACTION_MEDIA_NOFS

To view the source code for android.content Intent ACTION_MEDIA_NOFS.

Click Source Link

Document

Broadcast Action: External media is present, but is using an incompatible fs (or is blank) The path to the mount point for the checking media is contained in the Intent.mData field.

Usage

From source file:com.loloof64.android.chess_position_manager.MainActivity.java

@Override
protected void onResume() {
    super.onResume();

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_MEDIA_REMOVED);
    filter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL);
    filter.addAction(Intent.ACTION_MEDIA_EJECT);
    filter.addAction(Intent.ACTION_MEDIA_NOFS);
    filter.addAction(Intent.ACTION_MEDIA_SHARED);
    filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
    registerReceiver(mStorageReceiver, filter);
}

From source file:com.android.server.MountService.java

private int doMountVolume(String path) {
    int rc = StorageResultCode.OperationSucceeded;

    final StorageVolume volume;
    synchronized (mVolumesLock) {
        volume = mVolumesByPath.get(path);
    }/*  w  w  w .  ja v a 2s.  c o m*/

    if (!volume.isEmulated() && hasUserRestriction(UserManager.DISALLOW_MOUNT_PHYSICAL_MEDIA)) {
        Slog.w(TAG, "User has restriction DISALLOW_MOUNT_PHYSICAL_MEDIA; cannot mount volume.");
        return StorageResultCode.OperationFailedInternalError;
    }

    if (DEBUG_EVENTS)
        Slog.i(TAG, "doMountVolume: Mouting " + path);
    try {
        mConnector.execute("volume", "mount", path);
    } catch (NativeDaemonConnectorException e) {
        /*
         * Mount failed for some reason
         */
        String action = null;
        int code = e.getCode();
        if (code == VoldResponseCode.OpFailedNoMedia) {
            /*
             * Attempt to mount but no media inserted
             */
            rc = StorageResultCode.OperationFailedNoMedia;
        } else if (code == VoldResponseCode.OpFailedMediaBlank) {
            if (DEBUG_EVENTS)
                Slog.i(TAG, " updating volume state :: media nofs");
            /*
             * Media is blank or does not contain a supported filesystem
             */
            updatePublicVolumeState(volume, Environment.MEDIA_NOFS);
            action = Intent.ACTION_MEDIA_NOFS;
            rc = StorageResultCode.OperationFailedMediaBlank;
        } else if (code == VoldResponseCode.OpFailedMediaCorrupt) {
            if (DEBUG_EVENTS)
                Slog.i(TAG, "updating volume state media corrupt");
            /*
             * Volume consistency check failed
             */
            updatePublicVolumeState(volume, Environment.MEDIA_UNMOUNTABLE);
            action = Intent.ACTION_MEDIA_UNMOUNTABLE;
            rc = StorageResultCode.OperationFailedMediaCorrupt;
        } else {
            rc = StorageResultCode.OperationFailedInternalError;
        }

        /*
         * Send broadcast intent (if required for the failure)
         */
        if (action != null) {
            sendStorageIntent(action, volume, UserHandle.ALL);
        }
    }

    return rc;
}