summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPerumaal S <perumaal@google.com>2019-06-14 15:34:07 -0700
committerPerumaal Shanmugam <perumaal@google.com>2019-06-17 16:40:43 +0000
commitbcedb60f4cc23908b505f3ea648a1eb065f2d78e (patch)
tree1570159021cf7d0741be17a39ba0f27f6195a632
parent2aa255a74656e448b28b1f258d25bed18f2d6396 (diff)
qt_dev: Fix ContentSuggestions service connection
Issue: When the RemoteContentSuggestionsService dies (due to package manager update or clear data), the ContentSuggestionsPerUserService (system) does not restart and uses an old zombie instance. Fix: Reset the instance upon onServiceDied in the system service. Test: Verified that stopping/clear-data/package-update of Device Personalization Services (which implements ContentSuggestionsService) multiple-times and then Overview long-press actually works. Also verified that if the Remote Service crashes, we don't keep reconnecting infinitely. Fixes: 120865921 Fixes: 130420008 Change-Id: I80197ec1cb446ddb5f1865a4b75beb18b48d2e9e
-rw-r--r--services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsPerUserService.java14
1 files changed, 7 insertions, 7 deletions
diff --git a/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsPerUserService.java b/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsPerUserService.java
index 770931179c5e..bae453d6a7b6 100644
--- a/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsPerUserService.java
+++ b/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsPerUserService.java
@@ -95,7 +95,7 @@ public final class ContentSuggestionsPerUserService extends
@GuardedBy("mLock")
void provideContextImageLocked(int taskId, @NonNull Bundle imageContextRequestExtras) {
- RemoteContentSuggestionsService service = getRemoteServiceLocked();
+ RemoteContentSuggestionsService service = ensureRemoteServiceLocked();
if (service != null) {
ActivityManager.TaskSnapshot snapshot =
mActivityTaskManagerInternal.getTaskSnapshot(taskId, false);
@@ -118,7 +118,7 @@ public final class ContentSuggestionsPerUserService extends
void suggestContentSelectionsLocked(
@NonNull SelectionsRequest selectionsRequest,
@NonNull ISelectionsCallback selectionsCallback) {
- RemoteContentSuggestionsService service = getRemoteServiceLocked();
+ RemoteContentSuggestionsService service = ensureRemoteServiceLocked();
if (service != null) {
service.suggestContentSelections(selectionsRequest, selectionsCallback);
}
@@ -128,7 +128,7 @@ public final class ContentSuggestionsPerUserService extends
void classifyContentSelectionsLocked(
@NonNull ClassificationsRequest classificationsRequest,
@NonNull IClassificationsCallback callback) {
- RemoteContentSuggestionsService service = getRemoteServiceLocked();
+ RemoteContentSuggestionsService service = ensureRemoteServiceLocked();
if (service != null) {
service.classifyContentSelections(classificationsRequest, callback);
}
@@ -136,7 +136,7 @@ public final class ContentSuggestionsPerUserService extends
@GuardedBy("mLock")
void notifyInteractionLocked(@NonNull String requestId, @NonNull Bundle bundle) {
- RemoteContentSuggestionsService service = getRemoteServiceLocked();
+ RemoteContentSuggestionsService service = ensureRemoteServiceLocked();
if (service != null) {
service.notifyInteraction(requestId, bundle);
}
@@ -153,12 +153,12 @@ public final class ContentSuggestionsPerUserService extends
@GuardedBy("mLock")
@Nullable
- private RemoteContentSuggestionsService getRemoteServiceLocked() {
+ private RemoteContentSuggestionsService ensureRemoteServiceLocked() {
if (mRemoteService == null) {
final String serviceName = getComponentNameLocked();
if (serviceName == null) {
if (mMaster.verbose) {
- Slog.v(TAG, "getRemoteServiceLocked(): not set");
+ Slog.v(TAG, "ensureRemoteServiceLocked(): not set");
}
return null;
}
@@ -170,8 +170,8 @@ public final class ContentSuggestionsPerUserService extends
@Override
public void onServiceDied(
@NonNull RemoteContentSuggestionsService service) {
- // TODO(b/120865921): properly implement
Slog.w(TAG, "remote content suggestions service died");
+ updateRemoteServiceLocked();
}
}, mMaster.isBindInstantServiceAllowed(), mMaster.verbose);
}