use of com.android.server.NativeDaemonConnector.SensitiveArg in project android_frameworks_base by ParanoidAndroid.
the class MountService method encryptStorage.
public int encryptStorage(String password) {
if (TextUtils.isEmpty(password)) {
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 {
mConnector.execute("cryptfs", "enablecrypto", "inplace", new SensitiveArg(password));
} catch (NativeDaemonConnectorException e) {
// Encryption failed
return e.getCode();
}
return 0;
}
use of com.android.server.NativeDaemonConnector.SensitiveArg in project android_frameworks_base by ParanoidAndroid.
the class MountService method mountSecureContainer.
public int mountSecureContainer(String id, String key, int ownerUid) {
validatePermission(android.Manifest.permission.ASEC_MOUNT_UNMOUNT);
waitForReady();
warnOnNotMounted();
synchronized (mAsecMountSet) {
if (mAsecMountSet.contains(id)) {
return StorageResultCode.OperationFailedStorageMounted;
}
}
int rc = StorageResultCode.OperationSucceeded;
try {
mConnector.execute("asec", "mount", id, new SensitiveArg(key), ownerUid);
} catch (NativeDaemonConnectorException e) {
int code = e.getCode();
if (code != VoldResponseCode.OpFailedStorageBusy) {
rc = StorageResultCode.OperationFailedInternalError;
}
}
if (rc == StorageResultCode.OperationSucceeded) {
synchronized (mAsecMountSet) {
mAsecMountSet.add(id);
}
}
return rc;
}
use of com.android.server.NativeDaemonConnector.SensitiveArg in project android_frameworks_base by ParanoidAndroid.
the class NativeDaemonConnectorTest method testSensitiveArgs.
public void testSensitiveArgs() throws Exception {
final StringBuilder rawBuilder = new StringBuilder();
final StringBuilder logBuilder = new StringBuilder();
rawBuilder.setLength(0);
logBuilder.setLength(0);
makeCommand(rawBuilder, logBuilder, 1, "foo", "bar", "baz");
assertEquals("1 foo bar baz\0", rawBuilder.toString());
assertEquals("1 foo bar baz", logBuilder.toString());
rawBuilder.setLength(0);
logBuilder.setLength(0);
makeCommand(rawBuilder, logBuilder, 1, "foo", new SensitiveArg("bar"), "baz");
assertEquals("1 foo bar baz\0", rawBuilder.toString());
assertEquals("1 foo [scrubbed] baz", logBuilder.toString());
rawBuilder.setLength(0);
logBuilder.setLength(0);
makeCommand(rawBuilder, logBuilder, 1, "foo", new SensitiveArg("foo bar"), "baz baz", new SensitiveArg("wat"));
assertEquals("1 foo \"foo bar\" \"baz baz\" wat\0", rawBuilder.toString());
assertEquals("1 foo [scrubbed] \"baz baz\" [scrubbed]", logBuilder.toString());
}
use of com.android.server.NativeDaemonConnector.SensitiveArg in project platform_frameworks_base by android.
the class MountService method encryptStorage.
public int encryptStorage(int type, String password) {
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", "inplace", CRYPTO_TYPES[type]);
} else {
mCryptConnector.execute("cryptfs", "enablecrypto", "inplace", CRYPTO_TYPES[type], new SensitiveArg(password));
}
} catch (NativeDaemonConnectorException e) {
// Encryption failed
return e.getCode();
}
return 0;
}
use of com.android.server.NativeDaemonConnector.SensitiveArg in project platform_frameworks_base by android.
the class MountService method mountSecureContainer.
public int mountSecureContainer(String id, String key, int ownerUid, boolean readOnly) {
enforcePermission(android.Manifest.permission.ASEC_MOUNT_UNMOUNT);
waitForReady();
warnOnNotMounted();
synchronized (mAsecMountSet) {
if (mAsecMountSet.contains(id)) {
return StorageResultCode.OperationFailedStorageMounted;
}
}
int rc = StorageResultCode.OperationSucceeded;
try {
mConnector.execute("asec", "mount", id, new SensitiveArg(key), ownerUid, readOnly ? "ro" : "rw");
} catch (NativeDaemonConnectorException e) {
int code = e.getCode();
if (code != VoldResponseCode.OpFailedStorageBusy) {
rc = StorageResultCode.OperationFailedInternalError;
}
}
if (rc == StorageResultCode.OperationSucceeded) {
synchronized (mAsecMountSet) {
mAsecMountSet.add(id);
}
}
return rc;
}
Aggregations