use of android.os.storage.IMountService in project android_frameworks_base by crdroidandroid.
the class PackageHelper method resizeSdDir.
public static boolean resizeSdDir(long sizeBytes, String cid, String sdEncKey) {
// Round up to nearest MB, plus another MB for filesystem overhead
final int sizeMb = (int) ((sizeBytes + MB_IN_BYTES) / MB_IN_BYTES) + 1;
try {
IMountService mountService = getMountService();
int rc = mountService.resizeSecureContainer(cid, sizeMb, sdEncKey);
if (rc == StorageResultCode.OperationSucceeded) {
return true;
}
} catch (RemoteException e) {
Log.e(TAG, "MountService running?");
}
Log.e(TAG, "Failed to create secure container " + cid);
return false;
}
use of android.os.storage.IMountService in project android_frameworks_base by crdroidandroid.
the class PackageHelperTests method cleanupContainers.
private void cleanupContainers() throws RemoteException {
Log.d(TAG, "cleanUp");
IMountService ms = getMs();
String[] containers = ms.getSecureContainerList();
for (int i = 0; i < containers.length; i++) {
if (containers[i].startsWith(PREFIX)) {
Log.d(TAG, "cleaing up " + containers[i]);
ms.destroySecureContainer(containers[i], true);
}
}
}
use of android.os.storage.IMountService in project android_frameworks_base by crdroidandroid.
the class ContextImpl method ensureExternalDirsExistOrFilter.
/**
* Ensure that given directories exist, trying to create them if missing. If
* unable to create, they are filtered by replacing with {@code null}.
*/
private File[] ensureExternalDirsExistOrFilter(File[] dirs) {
File[] result = new File[dirs.length];
for (int i = 0; i < dirs.length; i++) {
File dir = dirs[i];
if (!dir.exists()) {
if (!dir.mkdirs()) {
// recheck existence in case of cross-process race
if (!dir.exists()) {
// Failing to mkdir() may be okay, since we might not have
// enough permissions; ask vold to create on our behalf.
final IMountService mount = IMountService.Stub.asInterface(ServiceManager.getService("mount"));
try {
final int res = mount.mkdirs(getPackageName(), dir.getAbsolutePath());
if (res != 0) {
Log.w(TAG, "Failed to ensure " + dir + ": " + res);
dir = null;
}
} catch (Exception e) {
Log.w(TAG, "Failed to ensure " + dir + ": " + e);
dir = null;
}
}
}
}
result[i] = dir;
}
return result;
}
use of android.os.storage.IMountService in project android_frameworks_base by crdroidandroid.
the class LockPatternUtils method setVisiblePatternEnabled.
/**
* Set whether the visible pattern is enabled.
*/
public void setVisiblePatternEnabled(boolean enabled, int userId) {
setBoolean(Settings.Secure.LOCK_PATTERN_VISIBLE, enabled, userId);
// Update for crypto if owner
if (userId != UserHandle.USER_SYSTEM) {
return;
}
IBinder service = ServiceManager.getService("mount");
if (service == null) {
Log.e(TAG, "Could not find the mount service to update the user info");
return;
}
IMountService mountService = IMountService.Stub.asInterface(service);
try {
mountService.setField(StorageManager.PATTERN_VISIBLE_KEY, enabled ? "1" : "0");
} catch (RemoteException e) {
Log.e(TAG, "Error changing pattern visible state", e);
}
}
use of android.os.storage.IMountService in project android_frameworks_base by crdroidandroid.
the class LockPatternUtils method updateEncryptionPassword.
/** Update the encryption password if it is enabled **/
private void updateEncryptionPassword(final int type, final String password) {
if (!isDeviceEncryptionEnabled()) {
return;
}
final IBinder service = ServiceManager.getService("mount");
if (service == null) {
Log.e(TAG, "Could not find the mount service to update the encryption password");
return;
}
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... dummy) {
IMountService mountService = IMountService.Stub.asInterface(service);
try {
mountService.changeEncryptionPassword(type, password);
} catch (RemoteException e) {
Log.e(TAG, "Error changing encryption password", e);
}
return null;
}
}.execute();
}
Aggregations