Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d311e06c authored by Abodunrinwa Toki's avatar Abodunrinwa Toki Committed by Android (Google) Code Review
Browse files

Merge "Ensure userId is set in TCEvent."

parents d8435c57 1480ed10
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -409,6 +409,15 @@ public final class SelectionEvent implements Parcelable {
        return mPackageName;
    }

    /**
     * Sets the id of this event's user.
     * <p>
     * Package-private for SystemTextClassifier's use.
     */
    void setUserId(@UserIdInt int userId) {
        mUserId = userId;
    }

    /**
     * Returns the id of this event's user.
     * @hide
+7 −0
Original line number Diff line number Diff line
@@ -151,6 +151,7 @@ public final class SystemTextClassifier implements TextClassifier {
        Utils.checkMainThread();

        try {
            event.setUserId(mUserId);
            mManagerService.onSelectionEvent(mSessionId, event);
        } catch (RemoteException e) {
            Log.e(LOG_TAG, "Error reporting selection event.", e);
@@ -163,6 +164,12 @@ public final class SystemTextClassifier implements TextClassifier {
        Utils.checkMainThread();

        try {
            final TextClassificationContext tcContext = event.getEventContext() == null
                    ? new TextClassificationContext.Builder(mPackageName, WIDGET_TYPE_UNKNOWN)
                            .build()
                    : event.getEventContext();
            tcContext.setUserId(mUserId);
            event.setEventContext(tcContext);
            mManagerService.onTextClassifierEvent(mSessionId, event);
        } catch (RemoteException e) {
            Log.e(LOG_TAG, "Error reporting textclassifier event.", e);
+10 −1
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ public abstract class TextClassifierEvent implements Parcelable {
    @Nullable
    private final String[] mEntityTypes;
    @Nullable
    private final TextClassificationContext mEventContext;
    private TextClassificationContext mEventContext;
    @Nullable
    private final String mResultId;
    private final int mEventIndex;
@@ -288,6 +288,15 @@ public abstract class TextClassifierEvent implements Parcelable {
        return mEventContext;
    }

    /**
     * Sets the event context.
     * <p>
     * Package-private for SystemTextClassifier's use.
     */
    void setEventContext(@Nullable TextClassificationContext eventContext) {
        mEventContext = eventContext;
    }

    /**
     * Returns the id of the text classifier result related to this event.
     */
+2 −2
Original line number Diff line number Diff line
@@ -457,12 +457,12 @@ public final class TextClassificationManagerService extends ITextClassifierServi
            Preconditions.checkArgument(userId != UserHandle.USER_NULL, "Null userId");
            final int callingUserId = UserHandle.getCallingUserId();
            if (callingUserId != userId) {
                context.enforceCallingPermission(
                context.enforceCallingOrSelfPermission(
                        android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
                        "Invalid userId. UserId=" + userId + ", CallingUserId=" + callingUserId);
            }
        } catch (Exception e) {
            throw new RemoteException("Invalid request", e,
            throw new RemoteException("Invalid request: " + e.getMessage(), e,
                    /* enableSuppression */ true, /* writableStackTrace */ true);
        }
    }