Skip to content

Commit

Permalink
Merge "qt_dev: Fix ContentSuggestions service connection" into qt-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
perumaalgoog authored and Android (Google) Code Review committed Jun 17, 2019
2 parents 4f3e0aa + bcedb60 commit 1ed4ce0
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected boolean updateLocked(boolean disabled) {

@GuardedBy("mLock")
void provideContextImageLocked(int taskId, @NonNull Bundle imageContextRequestExtras) {
RemoteContentSuggestionsService service = getRemoteServiceLocked();
RemoteContentSuggestionsService service = ensureRemoteServiceLocked();
if (service != null) {
ActivityManager.TaskSnapshot snapshot =
mActivityTaskManagerInternal.getTaskSnapshotNoRestore(taskId, false);
Expand All @@ -118,7 +118,7 @@ void provideContextImageLocked(int taskId, @NonNull Bundle imageContextRequestEx
void suggestContentSelectionsLocked(
@NonNull SelectionsRequest selectionsRequest,
@NonNull ISelectionsCallback selectionsCallback) {
RemoteContentSuggestionsService service = getRemoteServiceLocked();
RemoteContentSuggestionsService service = ensureRemoteServiceLocked();
if (service != null) {
service.suggestContentSelections(selectionsRequest, selectionsCallback);
}
Expand All @@ -128,15 +128,15 @@ void suggestContentSelectionsLocked(
void classifyContentSelectionsLocked(
@NonNull ClassificationsRequest classificationsRequest,
@NonNull IClassificationsCallback callback) {
RemoteContentSuggestionsService service = getRemoteServiceLocked();
RemoteContentSuggestionsService service = ensureRemoteServiceLocked();
if (service != null) {
service.classifyContentSelections(classificationsRequest, callback);
}
}

@GuardedBy("mLock")
void notifyInteractionLocked(@NonNull String requestId, @NonNull Bundle bundle) {
RemoteContentSuggestionsService service = getRemoteServiceLocked();
RemoteContentSuggestionsService service = ensureRemoteServiceLocked();
if (service != null) {
service.notifyInteraction(requestId, bundle);
}
Expand All @@ -153,12 +153,12 @@ private void updateRemoteServiceLocked() {

@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;
}
Expand All @@ -170,8 +170,8 @@ private RemoteContentSuggestionsService getRemoteServiceLocked() {
@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);
}
Expand Down

0 comments on commit 1ed4ce0

Please sign in to comment.