Close AppSearchImpl in handling user removed broadcast.
Flushing takes a few ms, it seems like a pretty good trade off compared
to keeping an icing instance in memory forever.
Bug: 179390369
Test: presubmit
Change-Id: Ic0493137dc8c33d44bd074bbd9ca4ae442049513
diff --git a/service/java/com/android/server/appsearch/AppSearchManagerService.java b/service/java/com/android/server/appsearch/AppSearchManagerService.java
index 0709ff5..4721d77 100644
--- a/service/java/com/android/server/appsearch/AppSearchManagerService.java
+++ b/service/java/com/android/server/appsearch/AppSearchManagerService.java
@@ -179,7 +179,7 @@
*/
private void handleUserRemoved(@NonNull UserHandle userHandle) {
try {
- mImplInstanceManager.removeAppSearchImplForUser(userHandle);
+ mImplInstanceManager.closeAndRemoveAppSearchImplForUser(userHandle);
mLoggerInstanceManager.removePlatformLoggerForUser(userHandle);
Log.i(TAG, "Removed AppSearchImpl instance for: " + userHandle);
} catch (Throwable t) {
diff --git a/service/java/com/android/server/appsearch/ImplInstanceManager.java b/service/java/com/android/server/appsearch/ImplInstanceManager.java
index 0775272..e7845d5 100644
--- a/service/java/com/android/server/appsearch/ImplInstanceManager.java
+++ b/service/java/com/android/server/appsearch/ImplInstanceManager.java
@@ -104,25 +104,6 @@
}
/**
- * Remove an instance of {@link AppSearchImpl} for the given user.
- *
- * <p>This method should only be called if {@link AppSearchManagerService} receives an
- * ACTION_USER_REMOVED, which the instance of given user should be removed.
- *
- * <p>If the user is removed, the "credential encrypted" system directory where icing lives will
- * be auto-deleted. So we shouldn't worry about persist data or close the AppSearchImpl.
- *
- * @param userHandle The multi-user user handle of the user that need to be removed.
- */
- public void removeAppSearchImplForUser(@NonNull UserHandle userHandle) {
- Objects.requireNonNull(userHandle);
- synchronized (mInstancesLocked) {
- // no need to close and persist data to disk since we are removing them now.
- mInstancesLocked.remove(userHandle);
- }
- }
-
- /**
* Close and remove an instance of {@link AppSearchImpl} for the given user.
*
* <p>All mutation apply to this {@link AppSearchImpl} will be persisted to disk.