diff options
author | Zak Cohen <zakcohen@google.com> | 2019-03-08 12:59:01 -0800 |
---|---|---|
committer | Zak Cohen <zakcohen@google.com> | 2019-03-14 14:44:56 -0700 |
commit | 4834e9f02cae8188604af82dbdb8c83882cd1984 (patch) | |
tree | 0e6d9f86c1345d15accbfde2bd76f39907eaee6a /services/contentsuggestions | |
parent | 7c8b15414177bccc5e84366d0a045c013f2c4831 (diff) |
ContentSuggestionsManager - API updates.
Adds isEnabled for the manager.
Manager also requires a user for construction, this is the user for
query for suggestions, not the calling user.
Bug: 125912329
Test: compile and CTS
Change-Id: I07145681fdf792965fee868b65f31d2978df7599
Diffstat (limited to 'services/contentsuggestions')
-rw-r--r-- | services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java b/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java index 69b4672213c4..55a062187bb1 100644 --- a/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java +++ b/services/contentsuggestions/java/com/android/server/contentsuggestions/ContentSuggestionsManagerService.java @@ -35,6 +35,7 @@ import android.os.UserHandle; import android.os.UserManager; import android.util.Slog; +import com.android.internal.os.IResultReceiver; import com.android.server.LocalServices; import com.android.server.infra.AbstractMasterSystemService; import com.android.server.infra.FrameworkResourcesServiceNameResolver; @@ -114,13 +115,14 @@ public class ContentSuggestionsManagerService extends private class ContentSuggestionsManagerStub extends IContentSuggestionsManager.Stub { @Override - public void provideContextImage(int taskId, @NonNull Bundle imageContextRequestExtras) { + public void provideContextImage( + int userId, + int taskId, + @NonNull Bundle imageContextRequestExtras) { if (imageContextRequestExtras == null) { throw new IllegalArgumentException("Expected non-null imageContextRequestExtras"); } - - final int userId = UserHandle.getCallingUserId(); - enforceCallerIsRecents(userId, "provideContextImage"); + enforceCallerIsRecents(UserHandle.getCallingUserId(), "provideContextImage"); synchronized (mLock) { final ContentSuggestionsPerUserService service = getServiceForUserLocked(userId); @@ -136,10 +138,10 @@ public class ContentSuggestionsManagerService extends @Override public void suggestContentSelections( + int userId, @NonNull SelectionsRequest selectionsRequest, @NonNull ISelectionsCallback selectionsCallback) { - final int userId = UserHandle.getCallingUserId(); - enforceCallerIsRecents(userId, "suggestContentSelections"); + enforceCallerIsRecents(UserHandle.getCallingUserId(), "suggestContentSelections"); synchronized (mLock) { final ContentSuggestionsPerUserService service = getServiceForUserLocked(userId); @@ -155,10 +157,10 @@ public class ContentSuggestionsManagerService extends @Override public void classifyContentSelections( + int userId, @NonNull ClassificationsRequest classificationsRequest, @NonNull IClassificationsCallback callback) { - final int userId = UserHandle.getCallingUserId(); - enforceCallerIsRecents(userId, "classifyContentSelections"); + enforceCallerIsRecents(UserHandle.getCallingUserId(), "classifyContentSelections"); synchronized (mLock) { final ContentSuggestionsPerUserService service = getServiceForUserLocked(userId); @@ -173,9 +175,9 @@ public class ContentSuggestionsManagerService extends } @Override - public void notifyInteraction(@NonNull String requestId, @NonNull Bundle bundle) { - final int userId = UserHandle.getCallingUserId(); - enforceCallerIsRecents(userId, "notifyInteraction"); + public void notifyInteraction( + int userId, @NonNull String requestId, @NonNull Bundle bundle) { + enforceCallerIsRecents(UserHandle.getCallingUserId(), "notifyInteraction"); synchronized (mLock) { final ContentSuggestionsPerUserService service = getServiceForUserLocked(userId); @@ -189,6 +191,18 @@ public class ContentSuggestionsManagerService extends } } + @Override + public void isEnabled(int userId, @NonNull IResultReceiver receiver) + throws RemoteException { + enforceCallerIsRecents(UserHandle.getCallingUserId(), "isEnabled"); + + boolean isDisabled; + synchronized (mLock) { + isDisabled = isDisabledLocked(userId); + } + receiver.send(isDisabled ? 0 : 1, null); + } + public void onShellCommand(@Nullable FileDescriptor in, @Nullable FileDescriptor out, @Nullable FileDescriptor err, @NonNull String[] args, @Nullable ShellCallback callback, |