Merge "Add BlobStoreManager.releaseAllLeases()." into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b771b2215a
@@ -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
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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()
|
||||||
@@ -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)));
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
@@ -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();
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user