Loading services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java +3 −0 Original line number Diff line number Diff line Loading @@ -870,6 +870,9 @@ public class CompanionDeviceManagerService extends SystemService { // Removing the association. mAssociationStore.removeAssociation(associationId); // Remove all the system data transfer requests for the association. mSystemDataTransferRequestStore.removeRequestsByAssociationId(userId, associationId); final List<AssociationInfo> otherAssociations = mAssociationStore.getAssociationsForPackage(userId, packageName); Loading services/companion/java/com/android/server/companion/datatransfer/SystemDataTransferRequestStore.java +18 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,6 @@ public class SystemDataTransferRequestStore { private static final String XML_TAG_REQUESTS = "requests"; private static final String XML_TAG_REQUEST = "request"; private static final String XML_TAG_LIST = "list"; private static final String XML_ATTR_ASSOCIATION_ID = "association_id"; private static final String XML_ATTR_DATA_TYPE = "data_type"; Loading Loading @@ -122,6 +121,7 @@ public class SystemDataTransferRequestStore { } void writeRequest(@UserIdInt int userId, SystemDataTransferRequest request) { Slog.i(LOG_TAG, "Writing request=" + request + " to store."); ArrayList<SystemDataTransferRequest> cachedRequests; synchronized (mLock) { // Write to cache Loading @@ -133,6 +133,23 @@ public class SystemDataTransferRequestStore { mExecutor.execute(() -> writeRequestsToStore(userId, cachedRequests)); } /** * Remove requests by association id. userId must be the one which owns the associationId. */ public void removeRequestsByAssociationId(@UserIdInt int userId, int associationId) { Slog.i(LOG_TAG, "Removing system data transfer requests for userId=" + userId + ", associationId=" + associationId); ArrayList<SystemDataTransferRequest> cachedRequests; synchronized (mLock) { // Remove requests from cache cachedRequests = readRequestsFromCache(userId); cachedRequests.removeIf(request -> request.getAssociationId() == associationId); mCachedPerUser.set(userId, cachedRequests); } // Remove requests from store mExecutor.execute(() -> writeRequestsToStore(userId, cachedRequests)); } @GuardedBy("mLock") private ArrayList<SystemDataTransferRequest> readRequestsFromCache(@UserIdInt int userId) { ArrayList<SystemDataTransferRequest> cachedRequests = mCachedPerUser.get(userId); Loading Loading
services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java +3 −0 Original line number Diff line number Diff line Loading @@ -870,6 +870,9 @@ public class CompanionDeviceManagerService extends SystemService { // Removing the association. mAssociationStore.removeAssociation(associationId); // Remove all the system data transfer requests for the association. mSystemDataTransferRequestStore.removeRequestsByAssociationId(userId, associationId); final List<AssociationInfo> otherAssociations = mAssociationStore.getAssociationsForPackage(userId, packageName); Loading
services/companion/java/com/android/server/companion/datatransfer/SystemDataTransferRequestStore.java +18 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,6 @@ public class SystemDataTransferRequestStore { private static final String XML_TAG_REQUESTS = "requests"; private static final String XML_TAG_REQUEST = "request"; private static final String XML_TAG_LIST = "list"; private static final String XML_ATTR_ASSOCIATION_ID = "association_id"; private static final String XML_ATTR_DATA_TYPE = "data_type"; Loading Loading @@ -122,6 +121,7 @@ public class SystemDataTransferRequestStore { } void writeRequest(@UserIdInt int userId, SystemDataTransferRequest request) { Slog.i(LOG_TAG, "Writing request=" + request + " to store."); ArrayList<SystemDataTransferRequest> cachedRequests; synchronized (mLock) { // Write to cache Loading @@ -133,6 +133,23 @@ public class SystemDataTransferRequestStore { mExecutor.execute(() -> writeRequestsToStore(userId, cachedRequests)); } /** * Remove requests by association id. userId must be the one which owns the associationId. */ public void removeRequestsByAssociationId(@UserIdInt int userId, int associationId) { Slog.i(LOG_TAG, "Removing system data transfer requests for userId=" + userId + ", associationId=" + associationId); ArrayList<SystemDataTransferRequest> cachedRequests; synchronized (mLock) { // Remove requests from cache cachedRequests = readRequestsFromCache(userId); cachedRequests.removeIf(request -> request.getAssociationId() == associationId); mCachedPerUser.set(userId, cachedRequests); } // Remove requests from store mExecutor.execute(() -> writeRequestsToStore(userId, cachedRequests)); } @GuardedBy("mLock") private ArrayList<SystemDataTransferRequest> readRequestsFromCache(@UserIdInt int userId) { ArrayList<SystemDataTransferRequest> cachedRequests = mCachedPerUser.get(userId); Loading