use of android.os.storage.StorageVolume in project android_frameworks_base by ParanoidAndroid.
the class MountService method isUsbMassStorageEnabled.
public boolean isUsbMassStorageEnabled() {
waitForReady();
final StorageVolume primary = getPrimaryPhysicalVolume();
if (primary != null) {
return doGetVolumeShared(primary.getPath(), "ums");
} else {
return false;
}
}
use of android.os.storage.StorageVolume in project android_frameworks_base by ParanoidAndroid.
the class MountService method dump.
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
pw.println("Permission Denial: can't dump ActivityManager from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid() + " without permission " + android.Manifest.permission.DUMP);
return;
}
synchronized (mObbMounts) {
pw.println(" mObbMounts:");
final Iterator<Entry<IBinder, List<ObbState>>> binders = mObbMounts.entrySet().iterator();
while (binders.hasNext()) {
Entry<IBinder, List<ObbState>> e = binders.next();
pw.print(" Key=");
pw.println(e.getKey().toString());
final List<ObbState> obbStates = e.getValue();
for (final ObbState obbState : obbStates) {
pw.print(" ");
pw.println(obbState.toString());
}
}
pw.println("");
pw.println(" mObbPathToStateMap:");
final Iterator<Entry<String, ObbState>> maps = mObbPathToStateMap.entrySet().iterator();
while (maps.hasNext()) {
final Entry<String, ObbState> e = maps.next();
pw.print(" ");
pw.print(e.getKey());
pw.print(" -> ");
pw.println(e.getValue().toString());
}
}
pw.println("");
synchronized (mVolumesLock) {
pw.println(" mVolumes:");
final int N = mVolumes.size();
for (int i = 0; i < N; i++) {
final StorageVolume v = mVolumes.get(i);
pw.print(" ");
pw.println(v.toString());
}
}
pw.println();
pw.println(" mConnection:");
mConnector.dump(fd, pw, args);
}
use of android.os.storage.StorageVolume in project android_frameworks_base by ParanoidAndroid.
the class MountService method onDaemonConnected.
/**
* Callback from NativeDaemonConnector
*/
public void onDaemonConnected() {
/*
* Since we'll be calling back into the NativeDaemonConnector,
* we need to do our work in a new thread.
*/
new Thread("MountService#onDaemonConnected") {
@Override
public void run() {
/**
* Determine media state and UMS detection status
*/
try {
final String[] vols = NativeDaemonEvent.filterMessageList(mConnector.executeForList("volume", "list"), VoldResponseCode.VolumeListResult);
for (String volstr : vols) {
String[] tok = volstr.split(" ");
// FMT: <label> <mountpoint> <state>
String path = tok[1];
String state = Environment.MEDIA_REMOVED;
final StorageVolume volume;
synchronized (mVolumesLock) {
volume = mVolumesByPath.get(path);
}
int st = Integer.parseInt(tok[2]);
if (st == VolumeState.NoMedia) {
state = Environment.MEDIA_REMOVED;
} else if (st == VolumeState.Idle) {
state = Environment.MEDIA_UNMOUNTED;
} else if (st == VolumeState.Mounted) {
state = Environment.MEDIA_MOUNTED;
Slog.i(TAG, "Media already mounted on daemon connection");
} else if (st == VolumeState.Shared) {
state = Environment.MEDIA_SHARED;
Slog.i(TAG, "Media shared on daemon connection");
} else {
throw new Exception(String.format("Unexpected state %d", st));
}
if (state != null) {
if (DEBUG_EVENTS)
Slog.i(TAG, "Updating valid state " + state);
updatePublicVolumeState(volume, state);
}
}
} catch (Exception e) {
Slog.e(TAG, "Error processing initial volume state", e);
final StorageVolume primary = getPrimaryPhysicalVolume();
if (primary != null) {
updatePublicVolumeState(primary, Environment.MEDIA_REMOVED);
}
}
/*
* Now that we've done our initialization, release
* the hounds!
*/
mConnectedSignal.countDown();
// Let package manager load internal ASECs.
mPms.scanAvailableAsecs();
// Notify people waiting for ASECs to be scanned that it's done.
mAsecsScanned.countDown();
}
}.start();
}
use of android.os.storage.StorageVolume in project android_frameworks_base by ParanoidAndroid.
the class MountService method getVolumeList.
@Override
public StorageVolume[] getVolumeList() {
final int callingUserId = UserHandle.getCallingUserId();
final boolean accessAll = (mContext.checkPermission(android.Manifest.permission.ACCESS_ALL_EXTERNAL_STORAGE, Binder.getCallingPid(), Binder.getCallingUid()) == PERMISSION_GRANTED);
synchronized (mVolumesLock) {
final ArrayList<StorageVolume> filtered = Lists.newArrayList();
for (StorageVolume volume : mVolumes) {
final UserHandle owner = volume.getOwner();
final boolean ownerMatch = owner == null || owner.getIdentifier() == callingUserId;
if (accessAll || ownerMatch) {
filtered.add(volume);
}
}
return filtered.toArray(new StorageVolume[filtered.size()]);
}
}
use of android.os.storage.StorageVolume in project android_frameworks_base by ParanoidAndroid.
the class MountService method handleSystemReady.
private void handleSystemReady() {
// Snapshot current volume states since it's not safe to call into vold
// while holding locks.
final HashMap<String, String> snapshot;
synchronized (mVolumesLock) {
snapshot = new HashMap<String, String>(mVolumeStates);
}
for (Map.Entry<String, String> entry : snapshot.entrySet()) {
final String path = entry.getKey();
final String state = entry.getValue();
if (state.equals(Environment.MEDIA_UNMOUNTED)) {
int rc = doMountVolume(path);
if (rc != StorageResultCode.OperationSucceeded) {
Slog.e(TAG, String.format("Boot-time mount failed (%d)", rc));
}
} else if (state.equals(Environment.MEDIA_SHARED)) {
/*
* Bootstrap UMS enabled state since vold indicates
* the volume is shared (runtime restart while ums enabled)
*/
notifyVolumeStateChange(null, path, VolumeState.NoMedia, VolumeState.Shared);
}
}
// Push mounted state for all emulated storage
synchronized (mVolumesLock) {
for (StorageVolume volume : mVolumes) {
if (volume.isEmulated()) {
updatePublicVolumeState(volume, Environment.MEDIA_MOUNTED);
}
}
}
/*
* If UMS was connected on boot, send the connected event
* now that we're up.
*/
if (mSendUmsConnectedOnBoot) {
sendUmsIntent(true);
mSendUmsConnectedOnBoot = false;
}
}
Aggregations