use of android.os.storage.IMountService in project android_frameworks_base by AOSPA.
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 AOSPA.
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 AOSPA.
the class LockPatternUtils method setVisiblePasswordEnabled.
/**
* Set whether the visible password is enabled for cryptkeeper screen.
*/
public void setVisiblePasswordEnabled(boolean enabled, int 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.PASSWORD_VISIBLE_KEY, enabled ? "1" : "0");
} catch (RemoteException e) {
Log.e(TAG, "Error changing password visible state", e);
}
}
use of android.os.storage.IMountService in project android_frameworks_base by AOSPA.
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 XobotOS by xamarin.
the class Environment method getPrimaryVolume.
private static StorageVolume getPrimaryVolume() {
if (mPrimaryVolume == null) {
synchronized (mLock) {
if (mPrimaryVolume == null) {
try {
IMountService mountService = IMountService.Stub.asInterface(ServiceManager.getService("mount"));
Parcelable[] volumes = mountService.getVolumeList();
mPrimaryVolume = (StorageVolume) volumes[0];
} catch (Exception e) {
Log.e(TAG, "couldn't talk to MountService", e);
}
}
}
}
return mPrimaryVolume;
}
Aggregations