Example usage for android.os.storage StorageManager CRYPT_TYPE_DEFAULT

List of usage examples for android.os.storage StorageManager CRYPT_TYPE_DEFAULT

Introduction

In this page you can find the example usage for android.os.storage StorageManager CRYPT_TYPE_DEFAULT.

Prototype

int CRYPT_TYPE_DEFAULT

To view the source code for android.os.storage StorageManager CRYPT_TYPE_DEFAULT.

Click Source Link

Usage

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

public int encryptStorage(int type, String password) {
    if (TextUtils.isEmpty(password) && type != StorageManager.CRYPT_TYPE_DEFAULT) {
        throw new IllegalArgumentException("password cannot be empty");
    }/* w ww  .j ava2 s.c  om*/

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

    waitForReady();

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

    try {
        mConnector.execute("cryptfs", "enablecrypto", "inplace", CRYPTO_TYPES[type],
                new SensitiveArg(toHex(password)));
    } catch (NativeDaemonConnectorException e) {
        // Encryption failed
        return e.getCode();
    }

    return 0;
}