Example usage for android.util Slog e

List of usage examples for android.util Slog e

Introduction

In this page you can find the example usage for android.util Slog e.

Prototype

@UnsupportedAppUsage
    public static int e(String tag, String msg, Throwable tr) 

Source Link

Usage

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

private void doShareUnshareVolume(String path, String method, boolean enable) {
    // TODO: Add support for multiple share methods
    if (!method.equals("ums")) {
        throw new IllegalArgumentException(String.format("Method %s not supported", method));
    }/*from  w ww .  j av  a 2  s.  c  o  m*/

    try {
        mConnector.execute("volume", enable ? "share" : "unshare", path, method);
    } catch (NativeDaemonConnectorException e) {
        Slog.e(TAG, "Failed to share/unshare", e);
    }
}

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

/**
 * Callback from NativeDaemonConnector/*from  w w  w .ja va  2 s  . c  o  m*/
 */
public void onDaemonConnected() {
    /*
     * Since we'll be calling back into the NativeDaemonConnector,
     * we need to do our work in a new thread.
     */
    new Thread("MountService#onDaemonConnected") {
        @Override
        public void run() {
            /**
             * Determine media state and UMS detection status
             */
            try {
                final String[] vols = NativeDaemonEvent.filterMessageList(
                        mConnector.executeForList("volume", "list", "broadcast"),
                        VoldResponseCode.VolumeListResult);
                for (String volstr : vols) {
                    String[] tok = volstr.split(" ");
                    // FMT: <label> <mountpoint> <state>
                    String path = tok[1];
                    String state = Environment.MEDIA_REMOVED;

                    final StorageVolume volume;
                    synchronized (mVolumesLock) {
                        volume = mVolumesByPath.get(path);
                    }

                    int st = Integer.parseInt(tok[2]);
                    if (st == VolumeState.NoMedia) {
                        state = Environment.MEDIA_REMOVED;
                    } else if (st == VolumeState.Idle) {
                        state = Environment.MEDIA_UNMOUNTED;
                    } else if (st == VolumeState.Mounted) {
                        state = Environment.MEDIA_MOUNTED;
                        Slog.i(TAG, "Media already mounted on daemon connection");
                    } else if (st == VolumeState.Shared) {
                        state = Environment.MEDIA_SHARED;
                        Slog.i(TAG, "Media shared on daemon connection");
                    } else {
                        throw new Exception(String.format("Unexpected state %d", st));
                    }

                    if (state != null) {
                        if (DEBUG_EVENTS)
                            Slog.i(TAG, "Updating valid state " + state);
                        updatePublicVolumeState(volume, state);
                    }
                }
            } catch (Exception e) {
                Slog.e(TAG, "Error processing initial volume state", e);
                final StorageVolume primary = getPrimaryPhysicalVolume();
                if (primary != null) {
                    updatePublicVolumeState(primary, Environment.MEDIA_REMOVED);
                }
            }

            /*
             * Now that we've done our initialization, release
             * the hounds!
             */
            mConnectedSignal.countDown();

            // On an encrypted device we can't see system properties yet, so pull
            // the system locale out of the mount service.
            if ("".equals(SystemProperties.get("vold.encrypt_progress"))) {
                copyLocaleFromMountService();
            }

            // Let package manager load internal ASECs.
            mPms.scanAvailableAsecs();

            // Notify people waiting for ASECs to be scanned that it's done.
            mAsecsScanned.countDown();
        }
    }.start();
}

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

private void copyLocaleFromMountService() {
    String systemLocale;/*from  w w w .ja v a  2  s .c o m*/
    try {
        systemLocale = getField(StorageManager.SYSTEM_LOCALE_KEY);
    } catch (RemoteException e) {
        return;
    }
    if (TextUtils.isEmpty(systemLocale)) {
        return;
    }

    Slog.d(TAG, "Got locale " + systemLocale + " from mount service");
    Locale locale = Locale.forLanguageTag(systemLocale);
    Configuration config = new Configuration();
    config.setLocale(locale);
    try {
        ActivityManagerNative.getDefault().updateConfiguration(config);
    } catch (RemoteException e) {
        Slog.e(TAG, "Error setting system locale from mount service", e);
    }

    // Temporary workaround for http://b/17945169.
    Slog.d(TAG, "Setting system properties to " + systemLocale + " from mount service");
    SystemProperties.set("persist.sys.language", locale.getLanguage());
    SystemProperties.set("persist.sys.country", locale.getCountry());
}

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

/**
 * Callback from NativeDaemonConnector//from w  w w  .  j  av  a 2 s . c  o m
 */
public boolean onEvent(int code, String raw, String[] cooked) {
    if (DEBUG_EVENTS) {
        StringBuilder builder = new StringBuilder();
        builder.append("onEvent::");
        builder.append(" raw= " + raw);
        if (cooked != null) {
            builder.append(" cooked = ");
            for (String str : cooked) {
                builder.append(" " + str);
            }
        }
        Slog.i(TAG, builder.toString());
    }
    if (code == VoldResponseCode.VolumeStateChange) {
        /*
         * One of the volumes we're managing has changed state.
         * Format: "NNN Volume <label> <path> state changed
         * from <old_#> (<old_str>) to <new_#> (<new_str>)"
         */
        notifyVolumeStateChange(cooked[2], cooked[3], Integer.parseInt(cooked[7]),
                Integer.parseInt(cooked[10]));
    } else if (code == VoldResponseCode.VolumeUuidChange) {
        // Format: nnn <label> <path> <uuid>
        final String path = cooked[2];
        final String uuid = (cooked.length > 3) ? cooked[3] : null;

        final StorageVolume vol = mVolumesByPath.get(path);
        if (vol != null) {
            vol.setUuid(uuid);
        }

    } else if (code == VoldResponseCode.VolumeUserLabelChange) {
        // Format: nnn <label> <path> <label>
        final String path = cooked[2];
        final String userLabel = (cooked.length > 3) ? cooked[3] : null;

        final StorageVolume vol = mVolumesByPath.get(path);
        if (vol != null) {
            vol.setUserLabel(userLabel);
        }

    } else if ((code == VoldResponseCode.VolumeDiskInserted) || (code == VoldResponseCode.VolumeDiskRemoved)
            || (code == VoldResponseCode.VolumeBadRemoval)) {
        // FMT: NNN Volume <label> <mountpoint> disk inserted (<major>:<minor>)
        // FMT: NNN Volume <label> <mountpoint> disk removed (<major>:<minor>)
        // FMT: NNN Volume <label> <mountpoint> bad removal (<major>:<minor>)
        String action = null;
        final String label = cooked[2];
        final String path = cooked[3];
        int major = -1;
        int minor = -1;

        try {
            String devComp = cooked[6].substring(1, cooked[6].length() - 1);
            String[] devTok = devComp.split(":");
            major = Integer.parseInt(devTok[0]);
            minor = Integer.parseInt(devTok[1]);
        } catch (Exception ex) {
            Slog.e(TAG, "Failed to parse major/minor", ex);
        }

        final StorageVolume volume;
        final String state;
        synchronized (mVolumesLock) {
            volume = mVolumesByPath.get(path);
            state = mVolumeStates.get(path);
        }

        if (code == VoldResponseCode.VolumeDiskInserted) {
            new Thread("MountService#VolumeDiskInserted") {
                @Override
                public void run() {
                    try {
                        int rc;
                        if ((rc = doMountVolume(path)) != StorageResultCode.OperationSucceeded) {
                            Slog.w(TAG, String.format("Insertion mount failed (%d)", rc));
                        }
                    } catch (Exception ex) {
                        Slog.w(TAG, "Failed to mount media on insertion", ex);
                    }
                }
            }.start();
        } else if (code == VoldResponseCode.VolumeDiskRemoved) {
            /*
             * This event gets trumped if we're already in BAD_REMOVAL state
             */
            if (getVolumeState(path).equals(Environment.MEDIA_BAD_REMOVAL)) {
                return true;
            }
            /* Send the media unmounted event first */
            if (DEBUG_EVENTS)
                Slog.i(TAG, "Sending unmounted event first");
            updatePublicVolumeState(volume, Environment.MEDIA_UNMOUNTED);
            sendStorageIntent(Intent.ACTION_MEDIA_UNMOUNTED, volume, UserHandle.ALL);

            if (DEBUG_EVENTS)
                Slog.i(TAG, "Sending media removed");
            updatePublicVolumeState(volume, Environment.MEDIA_REMOVED);
            action = Intent.ACTION_MEDIA_REMOVED;
        } else if (code == VoldResponseCode.VolumeBadRemoval) {
            if (DEBUG_EVENTS)
                Slog.i(TAG, "Sending unmounted event first");
            /* 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, "Sending media bad removal");
            updatePublicVolumeState(volume, Environment.MEDIA_BAD_REMOVAL);
            action = Intent.ACTION_MEDIA_BAD_REMOVAL;
        } else if (code == VoldResponseCode.FstrimCompleted) {
            EventLogTags.writeFstrimFinish(SystemClock.elapsedRealtime());
        } else {
            Slog.e(TAG, String.format("Unknown code {%d}", code));
        }

        if (action != null) {
            sendStorageIntent(action, volume, UserHandle.ALL);
        }
    } else {
        return false;
    }

    return true;
}

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)) {
                /*/*w ww .  j  a v  a2 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);
            }
        }
    }
}

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

@Override
public int decryptStorage(String password) {
    if (TextUtils.isEmpty(password)) {
        throw new IllegalArgumentException("password cannot be empty");
    }//w  ww . ja va 2 s. co m

    mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER,
            "no permission to access the crypt keeper");

    waitForReady();

    if (DEBUG_EVENTS) {
        Slog.i(TAG, "decrypting storage...");
    }

    final NativeDaemonEvent event;
    try {
        event = mConnector.execute("cryptfs", "checkpw", new SensitiveArg(toHex(password)));

        final int code = Integer.parseInt(event.getMessage());
        if (code == 0) {
            // Decrypt was successful. Post a delayed message before restarting in order
            // to let the UI to clear itself
            mHandler.postDelayed(new Runnable() {
                public void run() {
                    try {
                        mConnector.execute("cryptfs", "restart");
                    } catch (NativeDaemonConnectorException e) {
                        Slog.e(TAG, "problem executing in background", e);
                    }
                }
            }, 1000); // 1 second
        }

        return code;
    } catch (NativeDaemonConnectorException e) {
        // Decryption failed
        return e.getCode();
    }
}