Loading cmds/pm/src/com/android/commands/pm/Pm.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -1473,7 +1473,7 @@ public final class Pm { ClearDataObserver obs = new ClearDataObserver(); ClearDataObserver obs = new ClearDataObserver(); try { try { mPm.freeStorageAndNotify(volumeUuid, sizeVal, mPm.freeStorageAndNotify(volumeUuid, sizeVal, StorageManager.FLAG_ALLOCATE_DEFY_RESERVED, obs); StorageManager.FLAG_ALLOCATE_DEFY_ALL_RESERVED, obs); synchronized (obs) { synchronized (obs) { while (!obs.finished) { while (!obs.finished) { try { try { Loading core/java/android/app/AppOpsManager.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -1947,4 +1947,13 @@ public class AppOpsManager { public void finishOp(int op) { public void finishOp(int op) { finishOp(op, Process.myUid(), mContext.getOpPackageName()); finishOp(op, Process.myUid(), mContext.getOpPackageName()); } } /** @hide */ public boolean isOperationActive(int code, int uid, String packageName) { try { return mService.isOperationActive(code, uid, packageName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } } core/java/android/os/storage/IStorageManager.aidl +2 −2 Original line number Original line Diff line number Diff line Loading @@ -293,7 +293,7 @@ interface IStorageManager { ParcelFileDescriptor openProxyFileDescriptor(int mountPointId, int fileId, int mode) = 74; ParcelFileDescriptor openProxyFileDescriptor(int mountPointId, int fileId, int mode) = 74; long getCacheQuotaBytes(String volumeUuid, int uid) = 75; long getCacheQuotaBytes(String volumeUuid, int uid) = 75; long getCacheSizeBytes(String volumeUuid, int uid) = 76; long getCacheSizeBytes(String volumeUuid, int uid) = 76; long getAllocatableBytes(String volumeUuid, int flags) = 77; long getAllocatableBytes(String volumeUuid, int flags, String callingPackage) = 77; void allocateBytes(String volumeUuid, long bytes, int flags) = 78; void allocateBytes(String volumeUuid, long bytes, int flags, String callingPackage) = 78; void secdiscard(in String path) = 79; void secdiscard(in String path) = 79; } } core/java/android/os/storage/StorageManager.java +28 −8 Original line number Original line Diff line number Diff line Loading @@ -1174,7 +1174,7 @@ public class StorageManager { * * * @hide * @hide */ */ public long getStorageCacheBytes(File path) { public long getStorageCacheBytes(File path, @AllocateFlags int flags) { final long cachePercent = Settings.Global.getInt(mResolver, final long cachePercent = Settings.Global.getInt(mResolver, Settings.Global.SYS_STORAGE_CACHE_PERCENTAGE, DEFAULT_CACHE_PERCENTAGE); Settings.Global.SYS_STORAGE_CACHE_PERCENTAGE, DEFAULT_CACHE_PERCENTAGE); final long cacheBytes = (path.getTotalSpace() * cachePercent) / 100; final long cacheBytes = (path.getTotalSpace() * cachePercent) / 100; Loading @@ -1182,7 +1182,16 @@ public class StorageManager { final long maxCacheBytes = Settings.Global.getLong(mResolver, final long maxCacheBytes = Settings.Global.getLong(mResolver, Settings.Global.SYS_STORAGE_CACHE_MAX_BYTES, DEFAULT_CACHE_MAX_BYTES); Settings.Global.SYS_STORAGE_CACHE_MAX_BYTES, DEFAULT_CACHE_MAX_BYTES); return Math.min(cacheBytes, maxCacheBytes); final long result = Math.min(cacheBytes, maxCacheBytes); if ((flags & StorageManager.FLAG_ALLOCATE_AGGRESSIVE) != 0) { return 0; } else if ((flags & StorageManager.FLAG_ALLOCATE_DEFY_ALL_RESERVED) != 0) { return 0; } else if ((flags & StorageManager.FLAG_ALLOCATE_DEFY_HALF_RESERVED) != 0) { return result / 2; } else { return result; } } } /** /** Loading Loading @@ -1628,17 +1637,26 @@ public class StorageManager { public static final int FLAG_ALLOCATE_AGGRESSIVE = 1 << 0; public static final int FLAG_ALLOCATE_AGGRESSIVE = 1 << 0; /** /** * Flag indicating that a disk space allocation request should defy any * Flag indicating that a disk space allocation request should be allowed to * reserved disk space. * clear up to all reserved disk space. * * @hide */ public static final int FLAG_ALLOCATE_DEFY_ALL_RESERVED = 1 << 1; /** * Flag indicating that a disk space allocation request should be allowed to * clear up to half of all reserved disk space. * * * @hide * @hide */ */ public static final int FLAG_ALLOCATE_DEFY_RESERVED = 1 << 1; public static final int FLAG_ALLOCATE_DEFY_HALF_RESERVED = 1 << 2; /** @hide */ /** @hide */ @IntDef(flag = true, value = { @IntDef(flag = true, value = { FLAG_ALLOCATE_AGGRESSIVE, FLAG_ALLOCATE_AGGRESSIVE, FLAG_ALLOCATE_DEFY_RESERVED, FLAG_ALLOCATE_DEFY_ALL_RESERVED, FLAG_ALLOCATE_DEFY_HALF_RESERVED, }) }) @Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE) public @interface AllocateFlags {} public @interface AllocateFlags {} Loading Loading @@ -1688,7 +1706,8 @@ public class StorageManager { public long getAllocatableBytes(@NonNull UUID storageUuid, public long getAllocatableBytes(@NonNull UUID storageUuid, @RequiresPermission @AllocateFlags int flags) throws IOException { @RequiresPermission @AllocateFlags int flags) throws IOException { try { try { return mStorageManager.getAllocatableBytes(convert(storageUuid), flags); return mStorageManager.getAllocatableBytes(convert(storageUuid), flags, mContext.getOpPackageName()); } catch (ParcelableException e) { } catch (ParcelableException e) { e.maybeRethrow(IOException.class); e.maybeRethrow(IOException.class); throw new RuntimeException(e); throw new RuntimeException(e); Loading Loading @@ -1738,7 +1757,8 @@ public class StorageManager { public void allocateBytes(@NonNull UUID storageUuid, @BytesLong long bytes, public void allocateBytes(@NonNull UUID storageUuid, @BytesLong long bytes, @RequiresPermission @AllocateFlags int flags) throws IOException { @RequiresPermission @AllocateFlags int flags) throws IOException { try { try { mStorageManager.allocateBytes(convert(storageUuid), bytes, flags); mStorageManager.allocateBytes(convert(storageUuid), bytes, flags, mContext.getOpPackageName()); } catch (ParcelableException e) { } catch (ParcelableException e) { e.maybeRethrow(IOException.class); e.maybeRethrow(IOException.class); } catch (RemoteException e) { } catch (RemoteException e) { Loading core/java/com/android/internal/app/IAppOpsService.aidl +2 −0 Original line number Original line Diff line number Diff line Loading @@ -48,4 +48,6 @@ interface IAppOpsService { void setUserRestrictions(in Bundle restrictions, IBinder token, int userHandle); void setUserRestrictions(in Bundle restrictions, IBinder token, int userHandle); void setUserRestriction(int code, boolean restricted, IBinder token, int userHandle, in String[] exceptionPackages); void setUserRestriction(int code, boolean restricted, IBinder token, int userHandle, in String[] exceptionPackages); void removeUser(int userHandle); void removeUser(int userHandle); boolean isOperationActive(int code, int uid, String packageName); } } Loading
cmds/pm/src/com/android/commands/pm/Pm.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -1473,7 +1473,7 @@ public final class Pm { ClearDataObserver obs = new ClearDataObserver(); ClearDataObserver obs = new ClearDataObserver(); try { try { mPm.freeStorageAndNotify(volumeUuid, sizeVal, mPm.freeStorageAndNotify(volumeUuid, sizeVal, StorageManager.FLAG_ALLOCATE_DEFY_RESERVED, obs); StorageManager.FLAG_ALLOCATE_DEFY_ALL_RESERVED, obs); synchronized (obs) { synchronized (obs) { while (!obs.finished) { while (!obs.finished) { try { try { Loading
core/java/android/app/AppOpsManager.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -1947,4 +1947,13 @@ public class AppOpsManager { public void finishOp(int op) { public void finishOp(int op) { finishOp(op, Process.myUid(), mContext.getOpPackageName()); finishOp(op, Process.myUid(), mContext.getOpPackageName()); } } /** @hide */ public boolean isOperationActive(int code, int uid, String packageName) { try { return mService.isOperationActive(code, uid, packageName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } } }
core/java/android/os/storage/IStorageManager.aidl +2 −2 Original line number Original line Diff line number Diff line Loading @@ -293,7 +293,7 @@ interface IStorageManager { ParcelFileDescriptor openProxyFileDescriptor(int mountPointId, int fileId, int mode) = 74; ParcelFileDescriptor openProxyFileDescriptor(int mountPointId, int fileId, int mode) = 74; long getCacheQuotaBytes(String volumeUuid, int uid) = 75; long getCacheQuotaBytes(String volumeUuid, int uid) = 75; long getCacheSizeBytes(String volumeUuid, int uid) = 76; long getCacheSizeBytes(String volumeUuid, int uid) = 76; long getAllocatableBytes(String volumeUuid, int flags) = 77; long getAllocatableBytes(String volumeUuid, int flags, String callingPackage) = 77; void allocateBytes(String volumeUuid, long bytes, int flags) = 78; void allocateBytes(String volumeUuid, long bytes, int flags, String callingPackage) = 78; void secdiscard(in String path) = 79; void secdiscard(in String path) = 79; } }
core/java/android/os/storage/StorageManager.java +28 −8 Original line number Original line Diff line number Diff line Loading @@ -1174,7 +1174,7 @@ public class StorageManager { * * * @hide * @hide */ */ public long getStorageCacheBytes(File path) { public long getStorageCacheBytes(File path, @AllocateFlags int flags) { final long cachePercent = Settings.Global.getInt(mResolver, final long cachePercent = Settings.Global.getInt(mResolver, Settings.Global.SYS_STORAGE_CACHE_PERCENTAGE, DEFAULT_CACHE_PERCENTAGE); Settings.Global.SYS_STORAGE_CACHE_PERCENTAGE, DEFAULT_CACHE_PERCENTAGE); final long cacheBytes = (path.getTotalSpace() * cachePercent) / 100; final long cacheBytes = (path.getTotalSpace() * cachePercent) / 100; Loading @@ -1182,7 +1182,16 @@ public class StorageManager { final long maxCacheBytes = Settings.Global.getLong(mResolver, final long maxCacheBytes = Settings.Global.getLong(mResolver, Settings.Global.SYS_STORAGE_CACHE_MAX_BYTES, DEFAULT_CACHE_MAX_BYTES); Settings.Global.SYS_STORAGE_CACHE_MAX_BYTES, DEFAULT_CACHE_MAX_BYTES); return Math.min(cacheBytes, maxCacheBytes); final long result = Math.min(cacheBytes, maxCacheBytes); if ((flags & StorageManager.FLAG_ALLOCATE_AGGRESSIVE) != 0) { return 0; } else if ((flags & StorageManager.FLAG_ALLOCATE_DEFY_ALL_RESERVED) != 0) { return 0; } else if ((flags & StorageManager.FLAG_ALLOCATE_DEFY_HALF_RESERVED) != 0) { return result / 2; } else { return result; } } } /** /** Loading Loading @@ -1628,17 +1637,26 @@ public class StorageManager { public static final int FLAG_ALLOCATE_AGGRESSIVE = 1 << 0; public static final int FLAG_ALLOCATE_AGGRESSIVE = 1 << 0; /** /** * Flag indicating that a disk space allocation request should defy any * Flag indicating that a disk space allocation request should be allowed to * reserved disk space. * clear up to all reserved disk space. * * @hide */ public static final int FLAG_ALLOCATE_DEFY_ALL_RESERVED = 1 << 1; /** * Flag indicating that a disk space allocation request should be allowed to * clear up to half of all reserved disk space. * * * @hide * @hide */ */ public static final int FLAG_ALLOCATE_DEFY_RESERVED = 1 << 1; public static final int FLAG_ALLOCATE_DEFY_HALF_RESERVED = 1 << 2; /** @hide */ /** @hide */ @IntDef(flag = true, value = { @IntDef(flag = true, value = { FLAG_ALLOCATE_AGGRESSIVE, FLAG_ALLOCATE_AGGRESSIVE, FLAG_ALLOCATE_DEFY_RESERVED, FLAG_ALLOCATE_DEFY_ALL_RESERVED, FLAG_ALLOCATE_DEFY_HALF_RESERVED, }) }) @Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE) public @interface AllocateFlags {} public @interface AllocateFlags {} Loading Loading @@ -1688,7 +1706,8 @@ public class StorageManager { public long getAllocatableBytes(@NonNull UUID storageUuid, public long getAllocatableBytes(@NonNull UUID storageUuid, @RequiresPermission @AllocateFlags int flags) throws IOException { @RequiresPermission @AllocateFlags int flags) throws IOException { try { try { return mStorageManager.getAllocatableBytes(convert(storageUuid), flags); return mStorageManager.getAllocatableBytes(convert(storageUuid), flags, mContext.getOpPackageName()); } catch (ParcelableException e) { } catch (ParcelableException e) { e.maybeRethrow(IOException.class); e.maybeRethrow(IOException.class); throw new RuntimeException(e); throw new RuntimeException(e); Loading Loading @@ -1738,7 +1757,8 @@ public class StorageManager { public void allocateBytes(@NonNull UUID storageUuid, @BytesLong long bytes, public void allocateBytes(@NonNull UUID storageUuid, @BytesLong long bytes, @RequiresPermission @AllocateFlags int flags) throws IOException { @RequiresPermission @AllocateFlags int flags) throws IOException { try { try { mStorageManager.allocateBytes(convert(storageUuid), bytes, flags); mStorageManager.allocateBytes(convert(storageUuid), bytes, flags, mContext.getOpPackageName()); } catch (ParcelableException e) { } catch (ParcelableException e) { e.maybeRethrow(IOException.class); e.maybeRethrow(IOException.class); } catch (RemoteException e) { } catch (RemoteException e) { Loading
core/java/com/android/internal/app/IAppOpsService.aidl +2 −0 Original line number Original line Diff line number Diff line Loading @@ -48,4 +48,6 @@ interface IAppOpsService { void setUserRestrictions(in Bundle restrictions, IBinder token, int userHandle); void setUserRestrictions(in Bundle restrictions, IBinder token, int userHandle); void setUserRestriction(int code, boolean restricted, IBinder token, int userHandle, in String[] exceptionPackages); void setUserRestriction(int code, boolean restricted, IBinder token, int userHandle, in String[] exceptionPackages); void removeUser(int userHandle); void removeUser(int userHandle); boolean isOperationActive(int code, int uid, String packageName); } }