Search in sources :

Example 36 with SensitiveArg

use of com.android.server.NativeDaemonConnector.SensitiveArg in project android_frameworks_base by ResurrectionRemix.

the class MountService method changeEncryptionPassword.

/** Set the password for encrypting the master key.
     *  @param type One of the CRYPTO_TYPE_XXX consts defined in StorageManager.
     *  @param password The password to set.
     */
public int changeEncryptionPassword(int type, String password) {
    mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER, "no permission to access the crypt keeper");
    waitForReady();
    if (DEBUG_EVENTS) {
        Slog.i(TAG, "changing encryption password...");
    }
    ILockSettings lockSettings = ILockSettings.Stub.asInterface(ServiceManager.getService("lock_settings"));
    String currentPassword = "default_password";
    try {
        currentPassword = lockSettings.getPassword();
    } catch (RemoteException e) {
        Slog.e(TAG, "Couldn't get password" + e);
    }
    try {
        NativeDaemonEvent event = mCryptConnector.execute("cryptfs", "changepw", CRYPTO_TYPES[type], new SensitiveArg(currentPassword), new SensitiveArg(password));
        try {
            lockSettings.sanitizePassword();
        } catch (RemoteException e) {
            Slog.e(TAG, "Couldn't sanitize password" + e);
        }
        return Integer.parseInt(event.getMessage());
    } catch (NativeDaemonConnectorException e) {
        // Encryption failed
        return e.getCode();
    }
}
Also used : ILockSettings(com.android.internal.widget.ILockSettings) SensitiveArg(com.android.server.NativeDaemonConnector.SensitiveArg) RemoteException(android.os.RemoteException)

Example 37 with SensitiveArg

use of com.android.server.NativeDaemonConnector.SensitiveArg in project android_frameworks_base by ResurrectionRemix.

the class MountService method resizeSecureContainer.

@Override
public int resizeSecureContainer(String id, int sizeMb, String key) {
    enforcePermission(android.Manifest.permission.ASEC_CREATE);
    waitForReady();
    warnOnNotMounted();
    int rc = StorageResultCode.OperationSucceeded;
    try {
        mConnector.execute("asec", "resize", id, sizeMb, new SensitiveArg(key));
    } catch (NativeDaemonConnectorException e) {
        rc = StorageResultCode.OperationFailedInternalError;
    }
    return rc;
}
Also used : SensitiveArg(com.android.server.NativeDaemonConnector.SensitiveArg)

Example 38 with SensitiveArg

use of com.android.server.NativeDaemonConnector.SensitiveArg in project android_frameworks_base by ResurrectionRemix.

the class NetworkManagementService method setAccessPoint.

@Override
public void setAccessPoint(WifiConfiguration wifiConfig, String wlanIface) {
    mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
    Object[] args;
    String logMsg = "startAccessPoint Error setting up softap";
    try {
        if (wifiConfig == null) {
            args = new Object[] { "set", wlanIface };
        } else {
            // TODO: understand why this is set to "6" instead of
            // Integer.toString(wifiConfig.apChannel) as in startAccessPoint
            // TODO: should startAccessPoint call this instead of repeating code?
            args = new Object[] { "set", wlanIface, wifiConfig.SSID, "broadcast", "6", getSecurityType(wifiConfig), new SensitiveArg(wifiConfig.preSharedKey) };
        }
        executeOrLogWithMessage(SOFT_AP_COMMAND, args, NetdResponseCode.SoftapStatusResult, SOFT_AP_COMMAND_SUCCESS, logMsg);
    } catch (NativeDaemonConnectorException e) {
        throw e.rethrowAsParcelableException();
    }
}
Also used : SensitiveArg(com.android.server.NativeDaemonConnector.SensitiveArg)

Example 39 with SensitiveArg

use of com.android.server.NativeDaemonConnector.SensitiveArg in project android_frameworks_base by crdroidandroid.

the class MountService method createSecureContainer.

public int createSecureContainer(String id, int sizeMb, String fstype, String key, int ownerUid, boolean external) {
    enforcePermission(android.Manifest.permission.ASEC_CREATE);
    waitForReady();
    warnOnNotMounted();
    int rc = StorageResultCode.OperationSucceeded;
    try {
        mConnector.execute("asec", "create", id, sizeMb, fstype, new SensitiveArg(key), ownerUid, external ? "1" : "0");
    } catch (NativeDaemonConnectorException e) {
        rc = StorageResultCode.OperationFailedInternalError;
    }
    if (rc == StorageResultCode.OperationSucceeded) {
        synchronized (mAsecMountSet) {
            mAsecMountSet.add(id);
        }
    }
    return rc;
}
Also used : SensitiveArg(com.android.server.NativeDaemonConnector.SensitiveArg)

Example 40 with SensitiveArg

use of com.android.server.NativeDaemonConnector.SensitiveArg in project android_frameworks_base by crdroidandroid.

the class MountService method encryptStorageExtended.

private int encryptStorageExtended(int type, String password, boolean wipe) {
    if (TextUtils.isEmpty(password) && type != StorageManager.CRYPT_TYPE_DEFAULT) {
        throw new IllegalArgumentException("password cannot be empty");
    }
    mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER, "no permission to access the crypt keeper");
    waitForReady();
    if (DEBUG_EVENTS) {
        Slog.i(TAG, "encrypting storage...");
    }
    try {
        if (type == StorageManager.CRYPT_TYPE_DEFAULT) {
            mCryptConnector.execute("cryptfs", "enablecrypto", wipe ? "wipe" : "inplace", CRYPTO_TYPES[type]);
        } else {
            mCryptConnector.execute("cryptfs", "enablecrypto", wipe ? "wipe" : "inplace", CRYPTO_TYPES[type], new SensitiveArg(password));
        }
    } catch (NativeDaemonConnectorException e) {
        // Encryption failed
        return e.getCode();
    }
    return 0;
}
Also used : SensitiveArg(com.android.server.NativeDaemonConnector.SensitiveArg)

Aggregations

SensitiveArg (com.android.server.NativeDaemonConnector.SensitiveArg)42 RemoteException (android.os.RemoteException)3 ILockSettings (com.android.internal.widget.ILockSettings)3