Merge "Fixes an issue in shortcut persistence." into sc-dev

This commit is contained in:
Pinyao Ting
2021-03-31 17:48:17 +00:00
committed by Android (Google) Code Review
2 changed files with 18 additions and 1 deletions

View File

@@ -2419,6 +2419,20 @@ class ShortcutPackage extends ShortcutPackageItem {
}
}
void closeAppSearchSession() {
synchronized (mLock) {
if (mAppSearchSession != null) {
final long callingIdentity = Binder.clearCallingIdentity();
try {
mAppSearchSession.close();
} finally {
Binder.restoreCallingIdentity(callingIdentity);
}
}
mAppSearchSession = null;
}
}
@NonNull
private AndroidFuture<AppSearchSession> setupSchema(
@NonNull final AppSearchSession session) {

View File

@@ -1050,7 +1050,10 @@ public class ShortcutService extends IShortcutService.Stub {
file.failWrite(os);
}
getUserShortcutsLocked(userId).logSharingShortcutStats(mMetricsLogger);
final ShortcutUser user = getUserShortcutsLocked(userId);
// Close AppSearchSession to flush pending changes.
user.forAllPackages(ShortcutPackage::closeAppSearchSession);
user.logSharingShortcutStats(mMetricsLogger);
}
@GuardedBy("mLock")