use of android.os.storage.VolumeRecord in project android_frameworks_base by DirtyUnicorns.
the class MountService method readVolumeRecord.
public static VolumeRecord readVolumeRecord(XmlPullParser in) throws IOException {
final int type = readIntAttribute(in, ATTR_TYPE);
final String fsUuid = readStringAttribute(in, ATTR_FS_UUID);
final VolumeRecord meta = new VolumeRecord(type, fsUuid);
meta.partGuid = readStringAttribute(in, ATTR_PART_GUID);
meta.nickname = readStringAttribute(in, ATTR_NICKNAME);
meta.userFlags = readIntAttribute(in, ATTR_USER_FLAGS);
meta.createdMillis = readLongAttribute(in, ATTR_CREATED_MILLIS);
meta.lastTrimMillis = readLongAttribute(in, ATTR_LAST_TRIM_MILLIS);
meta.lastBenchMillis = readLongAttribute(in, ATTR_LAST_BENCH_MILLIS);
return meta;
}
use of android.os.storage.VolumeRecord in project android_frameworks_base by DirtyUnicorns.
the class MountService method setVolumeUserFlags.
@Override
public void setVolumeUserFlags(String fsUuid, int flags, int mask) {
enforcePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS);
waitForReady();
Preconditions.checkNotNull(fsUuid);
synchronized (mLock) {
final VolumeRecord rec = mRecords.get(fsUuid);
if (rec == null)
return;
rec.userFlags = (rec.userFlags & ~mask) | (flags & mask);
mCallbacks.notifyVolumeRecordChanged(rec);
writeSettingsLocked();
}
}
use of android.os.storage.VolumeRecord in project android_frameworks_base by DirtyUnicorns.
the class MountService method forgetAllVolumes.
@Override
public void forgetAllVolumes() {
enforcePermission(android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS);
waitForReady();
synchronized (mLock) {
for (int i = 0; i < mRecords.size(); i++) {
final String fsUuid = mRecords.keyAt(i);
final VolumeRecord rec = mRecords.valueAt(i);
if (!TextUtils.isEmpty(rec.partGuid)) {
mHandler.obtainMessage(H_PARTITION_FORGET, rec.partGuid).sendToTarget();
}
mCallbacks.notifyVolumeForgotten(fsUuid);
}
mRecords.clear();
if (!Objects.equals(StorageManager.UUID_PRIVATE_INTERNAL, mPrimaryStorageUuid)) {
mPrimaryStorageUuid = getDefaultPrimaryStorageUuid();
}
writeSettingsLocked();
mHandler.obtainMessage(H_RESET).sendToTarget();
}
}
use of android.os.storage.VolumeRecord in project android_frameworks_base by AOSPA.
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, SystemMessage.NOTE_STORAGE_PRIVATE, 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, SystemMessage.NOTE_STORAGE_PRIVATE, builder.build(), UserHandle.ALL);
}
}
}
use of android.os.storage.VolumeRecord in project android_frameworks_base by AOSPA.
the class StorageNotification method onVolumeMounted.
private Notification onVolumeMounted(VolumeInfo vol) {
final VolumeRecord rec = mStorageManager.findRecordByUuid(vol.getFsUuid());
final DiskInfo disk = vol.getDisk();
// used to allow snoozing non-adoptable disks too.)
if (rec.isSnoozed() && disk.isAdoptable()) {
return null;
}
if (disk.isAdoptable() && !rec.isInited()) {
final CharSequence title = disk.getDescription();
final CharSequence text = mContext.getString(R.string.ext_media_new_notification_message, disk.getDescription());
final PendingIntent initIntent = buildInitPendingIntent(vol);
return buildNotificationBuilder(vol, title, text).addAction(new Action(R.drawable.ic_settings_24dp, mContext.getString(R.string.ext_media_init_action), initIntent)).addAction(new Action(R.drawable.ic_eject_24dp, mContext.getString(R.string.ext_media_unmount_action), buildUnmountPendingIntent(vol))).setContentIntent(initIntent).setDeleteIntent(buildSnoozeIntent(vol.getFsUuid())).setCategory(Notification.CATEGORY_SYSTEM).build();
} else {
final CharSequence title = disk.getDescription();
final CharSequence text = mContext.getString(R.string.ext_media_ready_notification_message, disk.getDescription());
final PendingIntent browseIntent = buildBrowsePendingIntent(vol);
final Notification.Builder builder = buildNotificationBuilder(vol, title, text).addAction(new Action(R.drawable.ic_folder_24dp, mContext.getString(R.string.ext_media_browse_action), browseIntent)).addAction(new Action(R.drawable.ic_eject_24dp, mContext.getString(R.string.ext_media_unmount_action), buildUnmountPendingIntent(vol))).setContentIntent(browseIntent).setCategory(Notification.CATEGORY_SYSTEM).setPriority(Notification.PRIORITY_LOW);
// Non-adoptable disks can't be snoozed.
if (disk.isAdoptable()) {
builder.setDeleteIntent(buildSnoozeIntent(vol.getFsUuid()));
}
return builder.build();
}
}
Aggregations