Merge "Include data scheme when registering for package_* broadcasts." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
606626e020
@@ -216,12 +216,17 @@ public class BlobStoreManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void registerReceivers() {
|
private void registerReceivers() {
|
||||||
final IntentFilter intentFilter = new IntentFilter();
|
final IntentFilter packageChangedFilter = new IntentFilter();
|
||||||
intentFilter.addAction(Intent.ACTION_PACKAGE_FULLY_REMOVED);
|
packageChangedFilter.addAction(Intent.ACTION_PACKAGE_FULLY_REMOVED);
|
||||||
intentFilter.addAction(Intent.ACTION_PACKAGE_DATA_CLEARED);
|
packageChangedFilter.addAction(Intent.ACTION_PACKAGE_DATA_CLEARED);
|
||||||
intentFilter.addAction(Intent.ACTION_USER_REMOVED);
|
packageChangedFilter.addDataScheme("package");
|
||||||
mContext.registerReceiverAsUser(new PackageChangedReceiver(), UserHandle.ALL,
|
mContext.registerReceiverAsUser(new PackageChangedReceiver(), UserHandle.ALL,
|
||||||
intentFilter, null, mHandler);
|
packageChangedFilter, null, mHandler);
|
||||||
|
|
||||||
|
final IntentFilter userActionFilter = new IntentFilter();
|
||||||
|
userActionFilter.addAction(Intent.ACTION_USER_REMOVED);
|
||||||
|
mContext.registerReceiverAsUser(new UserActionReceiver(), UserHandle.ALL,
|
||||||
|
userActionFilter, null, mHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GuardedBy("mBlobsLock")
|
@GuardedBy("mBlobsLock")
|
||||||
@@ -769,40 +774,34 @@ public class BlobStoreManagerService extends SystemService {
|
|||||||
// Clean up any pending sessions
|
// Clean up any pending sessions
|
||||||
final LongSparseArray<BlobStoreSession> userSessions =
|
final LongSparseArray<BlobStoreSession> userSessions =
|
||||||
getUserSessionsLocked(UserHandle.getUserId(uid));
|
getUserSessionsLocked(UserHandle.getUserId(uid));
|
||||||
final ArrayList<Integer> indicesToRemove = new ArrayList<>();
|
userSessions.removeIf((sessionId, blobStoreSession) -> {
|
||||||
for (int i = 0, count = userSessions.size(); i < count; ++i) {
|
if (blobStoreSession.getOwnerUid() == uid
|
||||||
final BlobStoreSession session = userSessions.valueAt(i);
|
&& blobStoreSession.getOwnerPackageName().equals(packageName)) {
|
||||||
if (session.getOwnerUid() == uid
|
blobStoreSession.getSessionFile().delete();
|
||||||
&& session.getOwnerPackageName().equals(packageName)) {
|
mActiveBlobIds.remove(blobStoreSession.getSessionId());
|
||||||
session.getSessionFile().delete();
|
return true;
|
||||||
mActiveBlobIds.remove(session.getSessionId());
|
|
||||||
indicesToRemove.add(i);
|
|
||||||
}
|
}
|
||||||
}
|
return false;
|
||||||
for (int i = 0, count = indicesToRemove.size(); i < count; ++i) {
|
});
|
||||||
userSessions.removeAt(indicesToRemove.get(i));
|
|
||||||
}
|
|
||||||
writeBlobSessionsAsync();
|
writeBlobSessionsAsync();
|
||||||
|
|
||||||
// Remove the package from the committer and leasee list
|
// Remove the package from the committer and leasee list
|
||||||
final ArrayMap<BlobHandle, BlobMetadata> userBlobs =
|
final ArrayMap<BlobHandle, BlobMetadata> userBlobs =
|
||||||
getUserBlobsLocked(UserHandle.getUserId(uid));
|
getUserBlobsLocked(UserHandle.getUserId(uid));
|
||||||
indicesToRemove.clear();
|
userBlobs.entrySet().removeIf(entry -> {
|
||||||
for (int i = 0, count = userBlobs.size(); i < count; ++i) {
|
final BlobMetadata blobMetadata = entry.getValue();
|
||||||
final BlobMetadata blobMetadata = userBlobs.valueAt(i);
|
|
||||||
blobMetadata.removeCommitter(packageName, uid);
|
blobMetadata.removeCommitter(packageName, uid);
|
||||||
blobMetadata.removeLeasee(packageName, uid);
|
blobMetadata.removeLeasee(packageName, uid);
|
||||||
// Delete the blob if it doesn't have any active leases.
|
// Delete the blob if it doesn't have any active leases.
|
||||||
if (!blobMetadata.hasLeases()) {
|
if (!blobMetadata.hasLeases()) {
|
||||||
blobMetadata.getBlobFile().delete();
|
blobMetadata.getBlobFile().delete();
|
||||||
mActiveBlobIds.remove(blobMetadata.getBlobId());
|
mActiveBlobIds.remove(blobMetadata.getBlobId());
|
||||||
indicesToRemove.add(i);
|
return true;
|
||||||
}
|
}
|
||||||
}
|
return false;
|
||||||
for (int i = 0, count = indicesToRemove.size(); i < count; ++i) {
|
});
|
||||||
userBlobs.removeAt(indicesToRemove.get(i));
|
|
||||||
}
|
|
||||||
writeBlobsInfoAsync();
|
writeBlobsInfoAsync();
|
||||||
|
|
||||||
if (LOGV) {
|
if (LOGV) {
|
||||||
Slog.v(TAG, "Removed blobs data associated with pkg="
|
Slog.v(TAG, "Removed blobs data associated with pkg="
|
||||||
+ packageName + ", uid=" + uid);
|
+ packageName + ", uid=" + uid);
|
||||||
@@ -1103,6 +1102,19 @@ public class BlobStoreManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
handlePackageRemoved(packageName, uid);
|
handlePackageRemoved(packageName, uid);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
Slog.wtf(TAG, "Received unknown intent: " + intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UserActionReceiver extends BroadcastReceiver {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (LOGV) {
|
||||||
|
Slog.v(TAG, "Received: " + intent);
|
||||||
|
}
|
||||||
|
switch (intent.getAction()) {
|
||||||
case Intent.ACTION_USER_REMOVED:
|
case Intent.ACTION_USER_REMOVED:
|
||||||
final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
|
final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
|
||||||
USER_NULL);
|
USER_NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user