use of android.os.Environment.UserEnvironment in project platform_frameworks_base by android.
the class DefaultContainerService method onHandleIntent.
@Override
protected void onHandleIntent(Intent intent) {
if (PackageManager.ACTION_CLEAN_EXTERNAL_STORAGE.equals(intent.getAction())) {
final IPackageManager pm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
PackageCleanItem item = null;
try {
while ((item = pm.nextPackageToClean(item)) != null) {
final UserEnvironment userEnv = new UserEnvironment(item.userId);
eraseFiles(userEnv.buildExternalStorageAppDataDirs(item.packageName));
eraseFiles(userEnv.buildExternalStorageAppMediaDirs(item.packageName));
if (item.andCode) {
eraseFiles(userEnv.buildExternalStorageAppObbDirs(item.packageName));
}
}
} catch (RemoteException e) {
}
}
}
use of android.os.Environment.UserEnvironment in project platform_frameworks_base by android.
the class PackageManagerService method clearExternalStorageDataSync.
private void clearExternalStorageDataSync(String packageName, int userId, boolean allData) {
if (DEFAULT_CONTAINER_PACKAGE.equals(packageName))
return;
final boolean mounted;
if (Environment.isExternalStorageEmulated()) {
mounted = true;
} else {
final String status = Environment.getExternalStorageState();
mounted = status.equals(Environment.MEDIA_MOUNTED) || status.equals(Environment.MEDIA_MOUNTED_READ_ONLY);
}
if (!mounted) {
return;
}
final Intent containerIntent = new Intent().setComponent(DEFAULT_CONTAINER_COMPONENT);
int[] users;
if (userId == UserHandle.USER_ALL) {
users = sUserManager.getUserIds();
} else {
users = new int[] { userId };
}
final ClearStorageConnection conn = new ClearStorageConnection();
if (mContext.bindServiceAsUser(containerIntent, conn, Context.BIND_AUTO_CREATE, UserHandle.SYSTEM)) {
try {
for (int curUser : users) {
long timeout = SystemClock.uptimeMillis() + 5000;
synchronized (conn) {
long now;
while (conn.mContainerService == null && (now = SystemClock.uptimeMillis()) < timeout) {
try {
conn.wait(timeout - now);
} catch (InterruptedException e) {
}
}
}
if (conn.mContainerService == null) {
return;
}
final UserEnvironment userEnv = new UserEnvironment(curUser);
clearDirectory(conn.mContainerService, userEnv.buildExternalStorageAppCacheDirs(packageName));
if (allData) {
clearDirectory(conn.mContainerService, userEnv.buildExternalStorageAppDataDirs(packageName));
clearDirectory(conn.mContainerService, userEnv.buildExternalStorageAppMediaDirs(packageName));
}
}
} finally {
mContext.unbindService(conn);
}
}
}
use of android.os.Environment.UserEnvironment in project android_frameworks_base by DirtyUnicorns.
the class DiskStatsLoggingService method onStartJob.
@Override
public boolean onStartJob(JobParameters params) {
// subsequent runs.
if (!isCharging(this) || !isDumpsysTaskEnabled(getContentResolver())) {
jobFinished(params, true);
return false;
}
VolumeInfo volume = getPackageManager().getPrimaryStorageCurrentVolume();
// volume is null if the primary storage is not yet mounted.
if (volume == null) {
return false;
}
AppCollector collector = new AppCollector(this, volume);
final int userId = UserHandle.myUserId();
UserEnvironment environment = new UserEnvironment(userId);
LogRunnable task = new LogRunnable();
task.setRootDirectory(environment.getExternalStorageDirectory());
task.setDownloadsDirectory(environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS));
task.setSystemSize(FileCollector.getSystemSize(this));
task.setLogOutputFile(new File(DUMPSYS_CACHE_PATH));
task.setAppCollector(collector);
task.setJobService(this, params);
AsyncTask.execute(task);
return true;
}
use of android.os.Environment.UserEnvironment in project android_frameworks_base by DirtyUnicorns.
the class DefaultContainerService method onHandleIntent.
@Override
protected void onHandleIntent(Intent intent) {
if (PackageManager.ACTION_CLEAN_EXTERNAL_STORAGE.equals(intent.getAction())) {
final IPackageManager pm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
PackageCleanItem item = null;
try {
while ((item = pm.nextPackageToClean(item)) != null) {
final UserEnvironment userEnv = new UserEnvironment(item.userId);
eraseFiles(userEnv.buildExternalStorageAppDataDirs(item.packageName));
eraseFiles(userEnv.buildExternalStorageAppMediaDirs(item.packageName));
if (item.andCode) {
eraseFiles(userEnv.buildExternalStorageAppObbDirs(item.packageName));
}
}
} catch (RemoteException e) {
}
}
}
use of android.os.Environment.UserEnvironment in project android_frameworks_base by AOSPA.
the class DefaultContainerService method onHandleIntent.
@Override
protected void onHandleIntent(Intent intent) {
if (PackageManager.ACTION_CLEAN_EXTERNAL_STORAGE.equals(intent.getAction())) {
final IPackageManager pm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
PackageCleanItem item = null;
try {
while ((item = pm.nextPackageToClean(item)) != null) {
final UserEnvironment userEnv = new UserEnvironment(item.userId);
eraseFiles(userEnv.buildExternalStorageAppDataDirs(item.packageName));
eraseFiles(userEnv.buildExternalStorageAppMediaDirs(item.packageName));
if (item.andCode) {
eraseFiles(userEnv.buildExternalStorageAppObbDirs(item.packageName));
}
}
} catch (RemoteException e) {
}
}
}
Aggregations