use of android.os.storage.VolumeInfo in project platform_frameworks_base by android.
the class MountService method mount.
@Override
public void mount(String volId) {
enforcePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS);
waitForReady();
final VolumeInfo vol = findVolumeByIdOrThrow(volId);
if (isMountDisallowed(vol)) {
throw new SecurityException("Mounting " + volId + " restricted by policy");
}
try {
mConnector.execute("volume", "mount", vol.id, vol.mountFlags, vol.mountUserId);
} catch (NativeDaemonConnectorException e) {
throw e.rethrowAsParcelableException();
}
}
use of android.os.storage.VolumeInfo in project platform_frameworks_base by android.
the class StorageNotification method updateMissingPrivateVolumes.
private void updateMissingPrivateVolumes() {
final List<VolumeRecord> recs = mStorageManager.getVolumeRecords();
for (VolumeRecord rec : recs) {
if (rec.getType() != VolumeInfo.TYPE_PRIVATE)
continue;
final String fsUuid = rec.getFsUuid();
final VolumeInfo info = mStorageManager.findVolumeByUuid(fsUuid);
if ((info != null && info.isMountedWritable()) || rec.isSnoozed()) {
// Yay, private volume is here, or user snoozed
mNotificationManager.cancelAsUser(fsUuid, PRIVATE_ID, UserHandle.ALL);
} else {
// Boo, annoy the user to reinsert the private volume
final CharSequence title = mContext.getString(R.string.ext_media_missing_title, rec.getNickname());
final CharSequence text = mContext.getString(R.string.ext_media_missing_message);
Notification.Builder builder = new Notification.Builder(mContext).setSmallIcon(R.drawable.ic_sd_card_48dp).setColor(mContext.getColor(R.color.system_notification_accent_color)).setContentTitle(title).setContentText(text).setContentIntent(buildForgetPendingIntent(rec)).setStyle(new Notification.BigTextStyle().bigText(text)).setVisibility(Notification.VISIBILITY_PUBLIC).setLocalOnly(true).setCategory(Notification.CATEGORY_SYSTEM).setDeleteIntent(buildSnoozeIntent(fsUuid));
SystemUI.overrideNotificationAppName(mContext, builder);
mNotificationManager.notifyAsUser(fsUuid, PRIVATE_ID, builder.build(), UserHandle.ALL);
}
}
}
use of android.os.storage.VolumeInfo in project platform_frameworks_base by android.
the class StorageNotification method onMoveFinished.
private void onMoveFinished(MoveInfo move, int status) {
if (move.packageName != null) {
// We currently ignore finished app moves; just clear the last
// published progress
mNotificationManager.cancelAsUser(move.packageName, MOVE_ID, UserHandle.ALL);
return;
}
final VolumeInfo privateVol = mContext.getPackageManager().getPrimaryStorageCurrentVolume();
final String descrip = mStorageManager.getBestVolumeDescription(privateVol);
final CharSequence title;
final CharSequence text;
if (status == PackageManager.MOVE_SUCCEEDED) {
title = mContext.getString(R.string.ext_media_move_success_title);
text = mContext.getString(R.string.ext_media_move_success_message, descrip);
} else {
title = mContext.getString(R.string.ext_media_move_failure_title);
text = mContext.getString(R.string.ext_media_move_failure_message);
}
// Jump back into the wizard flow if we moved to a real disk
final PendingIntent intent;
if (privateVol != null && privateVol.getDisk() != null) {
intent = buildWizardReadyPendingIntent(privateVol.getDisk());
} else if (privateVol != null) {
intent = buildVolumeSettingsPendingIntent(privateVol);
} else {
intent = null;
}
Notification.Builder builder = new Notification.Builder(mContext).setSmallIcon(R.drawable.ic_sd_card_48dp).setColor(mContext.getColor(R.color.system_notification_accent_color)).setContentTitle(title).setContentText(text).setContentIntent(intent).setStyle(new Notification.BigTextStyle().bigText(text)).setVisibility(Notification.VISIBILITY_PUBLIC).setLocalOnly(true).setCategory(Notification.CATEGORY_SYSTEM).setPriority(Notification.PRIORITY_LOW).setAutoCancel(true);
SystemUI.overrideNotificationAppName(mContext, builder);
mNotificationManager.notifyAsUser(move.packageName, MOVE_ID, builder.build(), UserHandle.ALL);
}
use of android.os.storage.VolumeInfo in project platform_frameworks_base by android.
the class StorageNotification method start.
@Override
public void start() {
mNotificationManager = mContext.getSystemService(NotificationManager.class);
mStorageManager = mContext.getSystemService(StorageManager.class);
mStorageManager.registerListener(mListener);
mContext.registerReceiver(mSnoozeReceiver, new IntentFilter(ACTION_SNOOZE_VOLUME), android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS, null);
mContext.registerReceiver(mFinishReceiver, new IntentFilter(ACTION_FINISH_WIZARD), android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS, null);
// Kick current state into place
final List<DiskInfo> disks = mStorageManager.getDisks();
for (DiskInfo disk : disks) {
onDiskScannedInternal(disk, disk.volumeCount);
}
final List<VolumeInfo> vols = mStorageManager.getVolumes();
for (VolumeInfo vol : vols) {
onVolumeStateChangedInternal(vol);
}
mContext.getPackageManager().registerMoveCallback(mMoveCallback, new Handler());
updateMissingPrivateVolumes();
}
use of android.os.storage.VolumeInfo in project platform_frameworks_base by android.
the class PackageManagerService method destroyUserData.
/**
* Destroy storage areas for given user on all mounted devices.
*/
void destroyUserData(int userId, int flags) {
synchronized (mInstallLock) {
final StorageManager storage = mContext.getSystemService(StorageManager.class);
for (VolumeInfo vol : storage.getWritablePrivateVolumes()) {
final String volumeUuid = vol.getFsUuid();
destroyUserDataLI(volumeUuid, userId, flags);
}
}
}
Aggregations