use of android.os.storage.VolumeInfo in project android_frameworks_base by crdroidandroid.
the class StorageNotification method buildWizardMigratePendingIntent.
private PendingIntent buildWizardMigratePendingIntent(MoveInfo move) {
final Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings.deviceinfo.StorageWizardMigrateProgress");
intent.putExtra(PackageManager.EXTRA_MOVE_ID, move.moveId);
final VolumeInfo vol = mStorageManager.findVolumeByQualifiedUuid(move.volumeUuid);
if (vol != null) {
intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, vol.getId());
}
return PendingIntent.getActivityAsUser(mContext, move.moveId, intent, PendingIntent.FLAG_CANCEL_CURRENT, null, UserHandle.CURRENT);
}
use of android.os.storage.VolumeInfo in project android_frameworks_base by crdroidandroid.
the class AppCollectorTest method testOneValidApp.
@Test
public void testOneValidApp() throws Exception {
addApplication("com.test.app", "testuuid");
VolumeInfo volume = new VolumeInfo("testuuid", 0, null, null);
volume.fsUuid = "testuuid";
AppCollector collector = new AppCollector(mContext, volume);
PackageStats stats = new PackageStats("com.test.app");
// Set up this to handle the asynchronous call to the PackageManager. This returns the
// package info for the specified package.
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) {
try {
((IPackageStatsObserver.Stub) invocation.getArguments()[2]).onGetStatsCompleted(stats, true);
} catch (Exception e) {
// We fail instead of just letting the exception fly because throwing
// out of the callback like this on the background thread causes the test
// runner to crash, rather than reporting the failure.
fail();
}
return null;
}
}).when(mPm).getPackageSizeInfoAsUser(eq("com.test.app"), eq(0), any());
// Because getPackageStats is a blocking call, we block execution of the test until the
// call finishes. In order to finish the call, we need the above answer to execute.
List<PackageStats> myStats = new ArrayList<>();
CountDownLatch latch = new CountDownLatch(1);
new Thread(new Runnable() {
@Override
public void run() {
myStats.addAll(collector.getPackageStats(TIMEOUT));
latch.countDown();
}
}).start();
latch.await();
assertThat(myStats).containsExactly(stats);
}
use of android.os.storage.VolumeInfo in project android_frameworks_base by crdroidandroid.
the class AppCollectorTest method testMultipleUsersOneApp.
@Test
public void testMultipleUsersOneApp() throws Exception {
addApplication("com.test.app", "testuuid");
ApplicationInfo otherUsersApp = new ApplicationInfo();
otherUsersApp.packageName = "com.test.app";
otherUsersApp.volumeUuid = "testuuid";
otherUsersApp.uid = 1;
mUsers.add(new UserInfo(1, "", 0));
VolumeInfo volume = new VolumeInfo("testuuid", 0, null, null);
volume.fsUuid = "testuuid";
AppCollector collector = new AppCollector(mContext, volume);
PackageStats stats = new PackageStats("com.test.app");
PackageStats otherStats = new PackageStats("com.test.app");
otherStats.userHandle = 1;
// Set up this to handle the asynchronous call to the PackageManager. This returns the
// package info for our packages.
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) {
try {
((IPackageStatsObserver.Stub) invocation.getArguments()[2]).onGetStatsCompleted(stats, true);
// Now callback for the other uid.
((IPackageStatsObserver.Stub) invocation.getArguments()[2]).onGetStatsCompleted(otherStats, true);
} catch (Exception e) {
// We fail instead of just letting the exception fly because throwing
// out of the callback like this on the background thread causes the test
// runner to crash, rather than reporting the failure.
fail();
}
return null;
}
}).when(mPm).getPackageSizeInfoAsUser(eq("com.test.app"), eq(0), any());
// Because getPackageStats is a blocking call, we block execution of the test until the
// call finishes. In order to finish the call, we need the above answer to execute.
List<PackageStats> myStats = new ArrayList<>();
CountDownLatch latch = new CountDownLatch(1);
new Thread(new Runnable() {
@Override
public void run() {
myStats.addAll(collector.getPackageStats(TIMEOUT));
latch.countDown();
}
}).start();
latch.await();
assertThat(myStats).containsAllOf(stats, otherStats);
}
use of android.os.storage.VolumeInfo in project android_frameworks_base by crdroidandroid.
the class PrivateStorageInfo method getPrivateStorageInfo.
public static PrivateStorageInfo getPrivateStorageInfo(StorageVolumeProvider sm) {
long totalInternalStorage = sm.getPrimaryStorageSize();
long privateFreeBytes = 0;
long privateTotalBytes = 0;
for (VolumeInfo info : sm.getVolumes()) {
final File path = info.getPath();
if (info.getType() != VolumeInfo.TYPE_PRIVATE || path == null) {
continue;
}
privateTotalBytes += getTotalSize(info, totalInternalStorage);
privateFreeBytes += path.getFreeSpace();
}
return new PrivateStorageInfo(privateFreeBytes, privateTotalBytes);
}
use of android.os.storage.VolumeInfo in project android_frameworks_base by crdroidandroid.
the class MountService method dump.
@Override
protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " ", 160);
synchronized (mLock) {
pw.println("Disks:");
pw.increaseIndent();
for (int i = 0; i < mDisks.size(); i++) {
final DiskInfo disk = mDisks.valueAt(i);
disk.dump(pw);
}
pw.decreaseIndent();
pw.println();
pw.println("Volumes:");
pw.increaseIndent();
for (int i = 0; i < mVolumes.size(); i++) {
final VolumeInfo vol = mVolumes.valueAt(i);
if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(vol.id))
continue;
vol.dump(pw);
}
pw.decreaseIndent();
pw.println();
pw.println("Records:");
pw.increaseIndent();
for (int i = 0; i < mRecords.size(); i++) {
final VolumeRecord note = mRecords.valueAt(i);
note.dump(pw);
}
pw.decreaseIndent();
pw.println();
pw.println("Primary storage UUID: " + mPrimaryStorageUuid);
pw.println("Force adoptable: " + mForceAdoptable);
pw.println();
pw.println("Local unlocked users: " + Arrays.toString(mLocalUnlockedUsers));
pw.println("System unlocked users: " + Arrays.toString(mSystemUnlockedUsers));
}
synchronized (mObbMounts) {
pw.println();
pw.println("mObbMounts:");
pw.increaseIndent();
final Iterator<Entry<IBinder, List<ObbState>>> binders = mObbMounts.entrySet().iterator();
while (binders.hasNext()) {
Entry<IBinder, List<ObbState>> e = binders.next();
pw.println(e.getKey() + ":");
pw.increaseIndent();
final List<ObbState> obbStates = e.getValue();
for (final ObbState obbState : obbStates) {
pw.println(obbState);
}
pw.decreaseIndent();
}
pw.decreaseIndent();
pw.println();
pw.println("mObbPathToStateMap:");
pw.increaseIndent();
final Iterator<Entry<String, ObbState>> maps = mObbPathToStateMap.entrySet().iterator();
while (maps.hasNext()) {
final Entry<String, ObbState> e = maps.next();
pw.print(e.getKey());
pw.print(" -> ");
pw.println(e.getValue());
}
pw.decreaseIndent();
}
pw.println();
pw.println("mConnector:");
pw.increaseIndent();
mConnector.dump(fd, pw, args);
pw.decreaseIndent();
pw.println();
pw.println("mCryptConnector:");
pw.increaseIndent();
mCryptConnector.dump(fd, pw, args);
pw.decreaseIndent();
pw.println();
pw.print("Last maintenance: ");
pw.println(TimeUtils.formatForLogging(mLastMaintenance));
}
Aggregations