Loading apex/blobstore/framework/java/android/app/blob/BlobStoreManager.java +16 −0 Original line number Original line Diff line number Diff line Loading @@ -506,6 +506,22 @@ public class BlobStoreManager { } } } } /** * Release all the leases which are currently held by the caller. * * @hide */ public void releaseAllLeases() throws Exception { try { mService.releaseAllLeases(mContext.getOpPackageName()); } catch (ParcelableException e) { e.maybeRethrow(IOException.class); throw new RuntimeException(e); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** /** * Return the remaining quota size for acquiring a lease (in bytes) which indicates the * Return the remaining quota size for acquiring a lease (in bytes) which indicates the * remaining amount of data that an app can acquire a lease on before the System starts * remaining amount of data that an app can acquire a lease on before the System starts Loading apex/blobstore/framework/java/android/app/blob/IBlobStoreManager.aidl +1 −0 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ interface IBlobStoreManager { void acquireLease(in BlobHandle handle, int descriptionResId, in CharSequence description, void acquireLease(in BlobHandle handle, int descriptionResId, in CharSequence description, long leaseTimeoutMillis, in String packageName); long leaseTimeoutMillis, in String packageName); void releaseLease(in BlobHandle handle, in String packageName); void releaseLease(in BlobHandle handle, in String packageName); void releaseAllLeases(in String packageName); long getRemainingLeaseQuotaBytes(String packageName); long getRemainingLeaseQuotaBytes(String packageName); void waitForIdle(in RemoteCallback callback); void waitForIdle(in RemoteCallback callback); Loading apex/blobstore/service/java/com/android/server/blob/BlobStoreManagerService.java +36 −6 Original line number Original line Diff line number Diff line Loading @@ -554,6 +554,21 @@ public class BlobStoreManagerService extends SystemService { } } } } private void releaseAllLeasesInternal(int callingUid, String callingPackage) { synchronized (mBlobsLock) { // Remove the package from the leasee list mBlobsMap.forEach((blobHandle, blobMetadata) -> { blobMetadata.removeLeasee(callingPackage, callingUid); }); writeBlobsInfoAsync(); if (LOGV) { Slog.v(TAG, "Release all leases associated with pkg=" + callingPackage + ", uid=" + callingUid); } } } private long getRemainingLeaseQuotaBytesInternal(int callingUid, String callingPackage) { private long getRemainingLeaseQuotaBytesInternal(int callingUid, String callingPackage) { synchronized (mBlobsLock) { synchronized (mBlobsLock) { final long remainingQuota = BlobStoreConfig.getAppDataBytesLimit() final long remainingQuota = BlobStoreConfig.getAppDataBytesLimit() Loading Loading @@ -1376,7 +1391,7 @@ public class BlobStoreManagerService extends SystemService { } } } } private boolean isAllowedBlobAccess(int uid, String packageName) { private boolean isAllowedBlobStoreAccess(int uid, String packageName) { return (!Process.isSdkSandboxUid(uid) && !Process.isIsolated(uid) return (!Process.isSdkSandboxUid(uid) && !Process.isIsolated(uid) && !mPackageManagerInternal.isInstantApp(packageName, UserHandle.getUserId(uid))); && !mPackageManagerInternal.isInstantApp(packageName, UserHandle.getUserId(uid))); } } Loading Loading @@ -1442,7 +1457,7 @@ public class BlobStoreManagerService extends SystemService { final int callingUid = Binder.getCallingUid(); final int callingUid = Binder.getCallingUid(); verifyCallingPackage(callingUid, packageName); verifyCallingPackage(callingUid, packageName); if (!isAllowedBlobAccess(callingUid, packageName)) { if (!isAllowedBlobStoreAccess(callingUid, packageName)) { throw new SecurityException("Caller not allowed to create session; " throw new SecurityException("Caller not allowed to create session; " + "callingUid=" + callingUid + ", callingPackage=" + packageName); + "callingUid=" + callingUid + ", callingPackage=" + packageName); } } Loading Loading @@ -1491,7 +1506,7 @@ public class BlobStoreManagerService extends SystemService { final int callingUid = Binder.getCallingUid(); final int callingUid = Binder.getCallingUid(); verifyCallingPackage(callingUid, packageName); verifyCallingPackage(callingUid, packageName); if (!isAllowedBlobAccess(callingUid, packageName)) { if (!isAllowedBlobStoreAccess(callingUid, packageName)) { throw new SecurityException("Caller not allowed to open blob; " throw new SecurityException("Caller not allowed to open blob; " + "callingUid=" + callingUid + ", callingPackage=" + packageName); + "callingUid=" + callingUid + ", callingPackage=" + packageName); } } Loading Loading @@ -1522,7 +1537,7 @@ public class BlobStoreManagerService extends SystemService { final int callingUid = Binder.getCallingUid(); final int callingUid = Binder.getCallingUid(); verifyCallingPackage(callingUid, packageName); verifyCallingPackage(callingUid, packageName); if (!isAllowedBlobAccess(callingUid, packageName)) { if (!isAllowedBlobStoreAccess(callingUid, packageName)) { throw new SecurityException("Caller not allowed to open blob; " throw new SecurityException("Caller not allowed to open blob; " + "callingUid=" + callingUid + ", callingPackage=" + packageName); + "callingUid=" + callingUid + ", callingPackage=" + packageName); } } Loading @@ -1546,7 +1561,7 @@ public class BlobStoreManagerService extends SystemService { final int callingUid = Binder.getCallingUid(); final int callingUid = Binder.getCallingUid(); verifyCallingPackage(callingUid, packageName); verifyCallingPackage(callingUid, packageName); if (!isAllowedBlobAccess(callingUid, packageName)) { if (!isAllowedBlobStoreAccess(callingUid, packageName)) { throw new SecurityException("Caller not allowed to open blob; " throw new SecurityException("Caller not allowed to open blob; " + "callingUid=" + callingUid + ", callingPackage=" + packageName); + "callingUid=" + callingUid + ", callingPackage=" + packageName); } } Loading @@ -1554,6 +1569,21 @@ public class BlobStoreManagerService extends SystemService { releaseLeaseInternal(blobHandle, callingUid, packageName); releaseLeaseInternal(blobHandle, callingUid, packageName); } } @Override public void releaseAllLeases(@NonNull String packageName) { Objects.requireNonNull(packageName, "packageName must not be null"); final int callingUid = Binder.getCallingUid(); verifyCallingPackage(callingUid, packageName); if (!isAllowedBlobStoreAccess(callingUid, packageName)) { throw new SecurityException("Caller not allowed to open blob; " + "callingUid=" + callingUid + ", callingPackage=" + packageName); } releaseAllLeasesInternal(callingUid, packageName); } @Override @Override public long getRemainingLeaseQuotaBytes(@NonNull String packageName) { public long getRemainingLeaseQuotaBytes(@NonNull String packageName) { final int callingUid = Binder.getCallingUid(); final int callingUid = Binder.getCallingUid(); Loading Loading @@ -1629,7 +1659,7 @@ public class BlobStoreManagerService extends SystemService { final int callingUid = Binder.getCallingUid(); final int callingUid = Binder.getCallingUid(); verifyCallingPackage(callingUid, packageName); verifyCallingPackage(callingUid, packageName); if (!isAllowedBlobAccess(callingUid, packageName)) { if (!isAllowedBlobStoreAccess(callingUid, packageName)) { throw new SecurityException("Caller not allowed to open blob; " throw new SecurityException("Caller not allowed to open blob; " + "callingUid=" + callingUid + ", callingPackage=" + packageName); + "callingUid=" + callingUid + ", callingPackage=" + packageName); } } Loading Loading
apex/blobstore/framework/java/android/app/blob/BlobStoreManager.java +16 −0 Original line number Original line Diff line number Diff line Loading @@ -506,6 +506,22 @@ public class BlobStoreManager { } } } } /** * Release all the leases which are currently held by the caller. * * @hide */ public void releaseAllLeases() throws Exception { try { mService.releaseAllLeases(mContext.getOpPackageName()); } catch (ParcelableException e) { e.maybeRethrow(IOException.class); throw new RuntimeException(e); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** /** * Return the remaining quota size for acquiring a lease (in bytes) which indicates the * Return the remaining quota size for acquiring a lease (in bytes) which indicates the * remaining amount of data that an app can acquire a lease on before the System starts * remaining amount of data that an app can acquire a lease on before the System starts Loading
apex/blobstore/framework/java/android/app/blob/IBlobStoreManager.aidl +1 −0 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ interface IBlobStoreManager { void acquireLease(in BlobHandle handle, int descriptionResId, in CharSequence description, void acquireLease(in BlobHandle handle, int descriptionResId, in CharSequence description, long leaseTimeoutMillis, in String packageName); long leaseTimeoutMillis, in String packageName); void releaseLease(in BlobHandle handle, in String packageName); void releaseLease(in BlobHandle handle, in String packageName); void releaseAllLeases(in String packageName); long getRemainingLeaseQuotaBytes(String packageName); long getRemainingLeaseQuotaBytes(String packageName); void waitForIdle(in RemoteCallback callback); void waitForIdle(in RemoteCallback callback); Loading
apex/blobstore/service/java/com/android/server/blob/BlobStoreManagerService.java +36 −6 Original line number Original line Diff line number Diff line Loading @@ -554,6 +554,21 @@ public class BlobStoreManagerService extends SystemService { } } } } private void releaseAllLeasesInternal(int callingUid, String callingPackage) { synchronized (mBlobsLock) { // Remove the package from the leasee list mBlobsMap.forEach((blobHandle, blobMetadata) -> { blobMetadata.removeLeasee(callingPackage, callingUid); }); writeBlobsInfoAsync(); if (LOGV) { Slog.v(TAG, "Release all leases associated with pkg=" + callingPackage + ", uid=" + callingUid); } } } private long getRemainingLeaseQuotaBytesInternal(int callingUid, String callingPackage) { private long getRemainingLeaseQuotaBytesInternal(int callingUid, String callingPackage) { synchronized (mBlobsLock) { synchronized (mBlobsLock) { final long remainingQuota = BlobStoreConfig.getAppDataBytesLimit() final long remainingQuota = BlobStoreConfig.getAppDataBytesLimit() Loading Loading @@ -1376,7 +1391,7 @@ public class BlobStoreManagerService extends SystemService { } } } } private boolean isAllowedBlobAccess(int uid, String packageName) { private boolean isAllowedBlobStoreAccess(int uid, String packageName) { return (!Process.isSdkSandboxUid(uid) && !Process.isIsolated(uid) return (!Process.isSdkSandboxUid(uid) && !Process.isIsolated(uid) && !mPackageManagerInternal.isInstantApp(packageName, UserHandle.getUserId(uid))); && !mPackageManagerInternal.isInstantApp(packageName, UserHandle.getUserId(uid))); } } Loading Loading @@ -1442,7 +1457,7 @@ public class BlobStoreManagerService extends SystemService { final int callingUid = Binder.getCallingUid(); final int callingUid = Binder.getCallingUid(); verifyCallingPackage(callingUid, packageName); verifyCallingPackage(callingUid, packageName); if (!isAllowedBlobAccess(callingUid, packageName)) { if (!isAllowedBlobStoreAccess(callingUid, packageName)) { throw new SecurityException("Caller not allowed to create session; " throw new SecurityException("Caller not allowed to create session; " + "callingUid=" + callingUid + ", callingPackage=" + packageName); + "callingUid=" + callingUid + ", callingPackage=" + packageName); } } Loading Loading @@ -1491,7 +1506,7 @@ public class BlobStoreManagerService extends SystemService { final int callingUid = Binder.getCallingUid(); final int callingUid = Binder.getCallingUid(); verifyCallingPackage(callingUid, packageName); verifyCallingPackage(callingUid, packageName); if (!isAllowedBlobAccess(callingUid, packageName)) { if (!isAllowedBlobStoreAccess(callingUid, packageName)) { throw new SecurityException("Caller not allowed to open blob; " throw new SecurityException("Caller not allowed to open blob; " + "callingUid=" + callingUid + ", callingPackage=" + packageName); + "callingUid=" + callingUid + ", callingPackage=" + packageName); } } Loading Loading @@ -1522,7 +1537,7 @@ public class BlobStoreManagerService extends SystemService { final int callingUid = Binder.getCallingUid(); final int callingUid = Binder.getCallingUid(); verifyCallingPackage(callingUid, packageName); verifyCallingPackage(callingUid, packageName); if (!isAllowedBlobAccess(callingUid, packageName)) { if (!isAllowedBlobStoreAccess(callingUid, packageName)) { throw new SecurityException("Caller not allowed to open blob; " throw new SecurityException("Caller not allowed to open blob; " + "callingUid=" + callingUid + ", callingPackage=" + packageName); + "callingUid=" + callingUid + ", callingPackage=" + packageName); } } Loading @@ -1546,7 +1561,7 @@ public class BlobStoreManagerService extends SystemService { final int callingUid = Binder.getCallingUid(); final int callingUid = Binder.getCallingUid(); verifyCallingPackage(callingUid, packageName); verifyCallingPackage(callingUid, packageName); if (!isAllowedBlobAccess(callingUid, packageName)) { if (!isAllowedBlobStoreAccess(callingUid, packageName)) { throw new SecurityException("Caller not allowed to open blob; " throw new SecurityException("Caller not allowed to open blob; " + "callingUid=" + callingUid + ", callingPackage=" + packageName); + "callingUid=" + callingUid + ", callingPackage=" + packageName); } } Loading @@ -1554,6 +1569,21 @@ public class BlobStoreManagerService extends SystemService { releaseLeaseInternal(blobHandle, callingUid, packageName); releaseLeaseInternal(blobHandle, callingUid, packageName); } } @Override public void releaseAllLeases(@NonNull String packageName) { Objects.requireNonNull(packageName, "packageName must not be null"); final int callingUid = Binder.getCallingUid(); verifyCallingPackage(callingUid, packageName); if (!isAllowedBlobStoreAccess(callingUid, packageName)) { throw new SecurityException("Caller not allowed to open blob; " + "callingUid=" + callingUid + ", callingPackage=" + packageName); } releaseAllLeasesInternal(callingUid, packageName); } @Override @Override public long getRemainingLeaseQuotaBytes(@NonNull String packageName) { public long getRemainingLeaseQuotaBytes(@NonNull String packageName) { final int callingUid = Binder.getCallingUid(); final int callingUid = Binder.getCallingUid(); Loading Loading @@ -1629,7 +1659,7 @@ public class BlobStoreManagerService extends SystemService { final int callingUid = Binder.getCallingUid(); final int callingUid = Binder.getCallingUid(); verifyCallingPackage(callingUid, packageName); verifyCallingPackage(callingUid, packageName); if (!isAllowedBlobAccess(callingUid, packageName)) { if (!isAllowedBlobStoreAccess(callingUid, packageName)) { throw new SecurityException("Caller not allowed to open blob; " throw new SecurityException("Caller not allowed to open blob; " + "callingUid=" + callingUid + ", callingPackage=" + packageName); + "callingUid=" + callingUid + ", callingPackage=" + packageName); } } Loading