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

Commit fbbb158d authored by Winson Chung's avatar Winson Chung
Browse files

Add mechanism to send assist data to a IntelligenceService

- Proxy requested assist data from swipe up through the the
  IntelligenceServiceManager to AiAi for each activity that we receive
  assist data for (the AssistDataReceiver to be removed later once AiAi
  implements the new IntelligenceService interface).

Bug: 117268952
Test: Build dummy intelligence service, ensure that we get capture event
      on swipe up.

Change-Id: Iec29792932d30e94a702bd5079711c6615d0738a
parent d8059a2a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -4907,6 +4907,7 @@ package android.service.intelligence {

  public abstract class IntelligenceService extends android.app.Service {
    ctor public IntelligenceService();
    method public void onActivitySnapshot(android.service.intelligence.InteractionSessionId, android.service.intelligence.SnapshotData);
    method public abstract void onContentCaptureEvent(android.service.intelligence.InteractionSessionId, java.util.List<android.view.intelligence.ContentCaptureEvent>);
    method public void onCreateInteractionSession(android.service.intelligence.InteractionContext, android.service.intelligence.InteractionSessionId);
    method public void onDestroyInteractionSession(android.service.intelligence.InteractionSessionId);
@@ -4931,6 +4932,15 @@ package android.service.intelligence {
    field public static final android.os.Parcelable.Creator<android.service.intelligence.InteractionSessionId> CREATOR;
  }

  public final class SnapshotData implements android.os.Parcelable {
    method public int describeContents();
    method public android.app.assist.AssistContent getAssistContent();
    method public android.os.Bundle getAssistData();
    method public android.app.assist.AssistStructure getAssistStructure();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.service.intelligence.SnapshotData> CREATOR;
  }

}

package android.service.notification {
+4 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.service.intelligence;

import android.service.intelligence.InteractionSessionId;
import android.service.intelligence.InteractionContext;
import android.service.intelligence.SnapshotData;

import android.view.intelligence.ContentCaptureEvent;

@@ -36,4 +37,7 @@ oneway interface IIntelligenceService {

    void onContentCaptureEvents(in InteractionSessionId sessionId,
                                in List<ContentCaptureEvent> events);

    void onActivitySnapshot(in InteractionSessionId sessionId,
                            in SnapshotData snapshotData);
}
+19 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ public abstract class IntelligenceService extends Service {
                                IntelligenceService.this, sessionId));
            }
        }

        @Override
        public void onContentCaptureEvents(InteractionSessionId sessionId,
                List<ContentCaptureEvent> events) {
@@ -78,6 +79,14 @@ public abstract class IntelligenceService extends Service {
                            IntelligenceService.this, sessionId, events));

        }

        @Override
        public void onActivitySnapshot(InteractionSessionId sessionId,
                SnapshotData snapshotData) {
            mHandler.sendMessage(
                    obtainMessage(IntelligenceService::onActivitySnapshot,
                            IntelligenceService.this, sessionId, snapshotData));
        }
    };

    @CallSuper
@@ -117,6 +126,16 @@ public abstract class IntelligenceService extends Service {
    public abstract void onContentCaptureEvent(@NonNull InteractionSessionId sessionId,
            @NonNull List<ContentCaptureEvent> events);

    /**
     * Notifies the service of {@link IntelligenceSnapshotData snapshot data} associated with a
     * session.
     *
     * @param sessionId the session's Id
     * @param snapshotData the data
     */
    public void onActivitySnapshot(@NonNull InteractionSessionId sessionId,
            @NonNull SnapshotData snapshotData) {}

    /**
     * Destroys the interaction session.
     *
+19 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2018, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.service.intelligence;

parcelable SnapshotData;
+104 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.service.intelligence;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.app.assist.AssistContent;
import android.app.assist.AssistStructure;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * A container class for data taken from a snapshot of an activity.
 *
 * @hide
 */
@SystemApi
public final class SnapshotData implements Parcelable {

    private final @NonNull Bundle mAssistData;
    private final @NonNull AssistStructure mAssistStructure;
    private final @Nullable AssistContent mAssistContent;

    /**
     * Creates a new instance.
     *
     * @hide
     */
    public SnapshotData(@NonNull Bundle assistData, @NonNull AssistStructure assistStructure,
            @Nullable AssistContent assistContent) {
        mAssistData = assistData;
        mAssistStructure = assistStructure;
        mAssistContent = assistContent;
    }

    SnapshotData(@NonNull Parcel parcel) {
        mAssistData = parcel.readBundle();
        mAssistStructure = parcel.readParcelable(null);
        mAssistContent = parcel.readParcelable(null);
    }

    /**
     * Returns the assist data for this snapshot.
     */
    public Bundle getAssistData() {
        return mAssistData;
    }

    /**
     * Returns the assist structure for this snapshot.
     */
    public AssistStructure getAssistStructure() {
        return mAssistStructure;
    }

    /**
     * Returns the assist context for this snapshot.
     */
    public AssistContent getAssistContent() {
        return mAssistContent;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(@NonNull Parcel parcel, int flags) {
        parcel.writeBundle(mAssistData);
        parcel.writeParcelable(mAssistStructure, flags);
        parcel.writeParcelable(mAssistContent, flags);
    }

    public static final Creator<SnapshotData> CREATOR =
            new Creator<SnapshotData>() {

        @Override
        public SnapshotData createFromParcel(@NonNull Parcel parcel) {
            return new SnapshotData(parcel);
        }

        @Override
        public SnapshotData[] newArray(int size) {
            return new SnapshotData[size];
        }
    };
}
Loading