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

Commit 3fb0f258 authored by Winson Chung's avatar Winson Chung
Browse files

Initial commit of Content Suggestions (overview long press) Manager.

Test: compile
Bug: 120865921
Change-Id: I9f8310112bedc883406f0f50a99041f542036fd9
parent 54e91344
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -104,6 +104,9 @@ java_defaults {
        "core/java/android/app/backup/IRestoreObserver.aidl",
        "core/java/android/app/backup/IRestoreSession.aidl",
        "core/java/android/app/backup/ISelectBackupTransportCallback.aidl",
        "core/java/android/app/contentsuggestions/IClassificationsCallback.aidl",
        "core/java/android/app/contentsuggestions/IContentSuggestionsManager.aidl",
        "core/java/android/app/contentsuggestions/ISelectionsCallback.aidl",
        "core/java/android/app/prediction/IPredictionCallback.aidl",
        "core/java/android/app/prediction/IPredictionManager.aidl",
        "core/java/android/app/role/IOnRoleHoldersChangedListener.aidl",
@@ -285,6 +288,7 @@ java_defaults {
        "core/java/android/service/carrier/ICarrierService.aidl",
        "core/java/android/service/carrier/ICarrierMessagingCallback.aidl",
        "core/java/android/service/carrier/ICarrierMessagingService.aidl",
        "core/java/android/service/contentsuggestions/IContentSuggestionsService.aidl",
        "core/java/android/service/euicc/IDeleteSubscriptionCallback.aidl",
        "core/java/android/service/euicc/IDownloadSubscriptionCallback.aidl",
        "core/java/android/service/euicc/IEraseSubscriptionsCallback.aidl",
+82 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ package android {
    field public static final java.lang.String MANAGE_CARRIER_OEM_UNLOCK_STATE = "android.permission.MANAGE_CARRIER_OEM_UNLOCK_STATE";
    field public static final java.lang.String MANAGE_CA_CERTIFICATES = "android.permission.MANAGE_CA_CERTIFICATES";
    field public static final java.lang.String MANAGE_CONTENT_CAPTURE = "android.permission.MANAGE_CONTENT_CAPTURE";
    field public static final java.lang.String MANAGE_CONTENT_SUGGESTIONS = "android.permission.MANAGE_CONTENT_SUGGESTIONS";
    field public static final java.lang.String MANAGE_DEBUGGING = "android.permission.MANAGE_DEBUGGING";
    field public static final java.lang.String MANAGE_DEVICE_ADMINS = "android.permission.MANAGE_DEVICE_ADMINS";
    field public static final java.lang.String MANAGE_IPSEC_TUNNELS = "android.permission.MANAGE_IPSEC_TUNNELS";
@@ -849,6 +850,73 @@ package android.app.backup {

}

package android.app.contentsuggestions {

  public final class ClassificationsRequest implements android.os.Parcelable {
    method public int describeContents();
    method public android.os.Bundle getExtras();
    method public java.util.List<android.app.contentsuggestions.ContentSelection> getSelections();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.contentsuggestions.ClassificationsRequest> CREATOR;
  }

  public static final class ClassificationsRequest.Builder {
    ctor public ClassificationsRequest.Builder(java.util.List<android.app.contentsuggestions.ContentSelection>);
    method public android.app.contentsuggestions.ClassificationsRequest build();
    method public android.app.contentsuggestions.ClassificationsRequest.Builder setExtras(android.os.Bundle);
  }

  public final class ContentClassification implements android.os.Parcelable {
    ctor public ContentClassification(java.lang.String, android.os.Bundle);
    method public int describeContents();
    method public android.os.Bundle getExtras();
    method public java.lang.String getId();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.contentsuggestions.ContentClassification> CREATOR;
  }

  public final class ContentSelection implements android.os.Parcelable {
    ctor public ContentSelection(java.lang.String, android.os.Bundle);
    method public int describeContents();
    method public android.os.Bundle getExtras();
    method public java.lang.String getId();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.contentsuggestions.ContentSelection> CREATOR;
  }

  public final class ContentSuggestionsManager {
    method public void classifyContentSelections(android.app.contentsuggestions.ClassificationsRequest, java.util.concurrent.Executor, android.app.contentsuggestions.ContentSuggestionsManager.ClassificationsCallback);
    method public void notifyInteraction(java.lang.String, android.os.Bundle);
    method public void provideContextImage(int, android.os.Bundle);
    method public void suggestContentSelections(android.app.contentsuggestions.SelectionsRequest, java.util.concurrent.Executor, android.app.contentsuggestions.ContentSuggestionsManager.SelectionsCallback);
  }

  public static abstract interface ContentSuggestionsManager.ClassificationsCallback {
    method public abstract void onContentClassificationsAvailable(int, java.util.List<android.app.contentsuggestions.ContentClassification>);
  }

  public static abstract interface ContentSuggestionsManager.SelectionsCallback {
    method public abstract void onContentSelectionsAvailable(int, java.util.List<android.app.contentsuggestions.ContentSelection>);
  }

  public final class SelectionsRequest implements android.os.Parcelable {
    method public int describeContents();
    method public android.os.Bundle getExtras();
    method public android.graphics.Point getInterestPoint();
    method public int getTaskId();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.contentsuggestions.SelectionsRequest> CREATOR;
  }

  public static final class SelectionsRequest.Builder {
    ctor public SelectionsRequest.Builder(int);
    method public android.app.contentsuggestions.SelectionsRequest build();
    method public android.app.contentsuggestions.SelectionsRequest.Builder setExtras(android.os.Bundle);
    method public android.app.contentsuggestions.SelectionsRequest.Builder setInterestPoint(android.graphics.Point);
  }

}

package android.app.job {

  public abstract class JobScheduler {
@@ -1126,6 +1194,7 @@ package android.content {
    method public void startActivityAsUser(android.content.Intent, android.os.UserHandle);
    field public static final java.lang.String APP_PREDICTION_SERVICE = "app_prediction";
    field public static final java.lang.String BACKUP_SERVICE = "backup";
    field public static final java.lang.String CONTENT_SUGGESTIONS_SERVICE = "content_suggestions";
    field public static final java.lang.String CONTEXTHUB_SERVICE = "contexthub";
    field public static final java.lang.String EUICC_CARD_SERVICE = "euicc_card";
    field public static final java.lang.String HDMI_CONTROL_SERVICE = "hdmi_control";
@@ -5374,6 +5443,19 @@ package android.service.contentcapture {

}

package android.service.contentsuggestions {

  public abstract class ContentSuggestionsService extends android.app.Service {
    ctor public ContentSuggestionsService();
    method public abstract void classifyContentSelections(android.app.contentsuggestions.ClassificationsRequest, android.app.contentsuggestions.ContentSuggestionsManager.ClassificationsCallback);
    method public abstract void notifyInteraction(java.lang.String, android.os.Bundle);
    method public abstract void processContextImage(int, android.graphics.Bitmap, android.os.Bundle);
    method public abstract void suggestContentSelections(android.app.contentsuggestions.SelectionsRequest, android.app.contentsuggestions.ContentSuggestionsManager.SelectionsCallback);
    field public static final java.lang.String SERVICE_INTERFACE = "android.service.contentsuggestions.ContentSuggestionsService";
  }

}

package android.service.euicc {

  public final class DownloadSubscriptionResult implements android.os.Parcelable {
+16 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.accounts.IAccountManager;
import android.app.ContextImpl.ServiceInitializationState;
import android.app.admin.DevicePolicyManager;
import android.app.admin.IDevicePolicyManager;
import android.app.contentsuggestions.ContentSuggestionsManager;
import android.app.contentsuggestions.IContentSuggestionsManager;
import android.app.job.IJobScheduler;
import android.app.job.JobScheduler;
import android.app.prediction.AppPredictionManager;
@@ -1105,6 +1107,20 @@ final class SystemServiceRegistry {
            }
        });

        registerService(Context.CONTENT_SUGGESTIONS_SERVICE,
                ContentSuggestionsManager.class,
                new CachedServiceFetcher<ContentSuggestionsManager>() {
                    @Override
                    public ContentSuggestionsManager createService(ContextImpl ctx) {
                        // No throw as this is an optional service
                        IBinder b = ServiceManager.getService(
                                Context.CONTENT_SUGGESTIONS_SERVICE);
                        IContentSuggestionsManager service =
                                IContentSuggestionsManager.Stub.asInterface(b);
                        return new ContentSuggestionsManager(service);
                    }
                });

        registerService(Context.VR_SERVICE, VrManager.class, new CachedServiceFetcher<VrManager>() {
            @Override
            public VrManager createService(ContextImpl ctx) throws ServiceNotFoundException {
+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.app.contentsuggestions;

parcelable ClassificationsRequest;
+113 −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.app.contentsuggestions;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.List;

/**
 * @hide
 */
@SystemApi
public final class ClassificationsRequest implements Parcelable {
    @NonNull
    private final List<ContentSelection> mSelections;
    @Nullable
    private final Bundle mExtras;

    private ClassificationsRequest(@NonNull List<ContentSelection> selections,
            @Nullable Bundle extras) {
        mSelections = selections;
        mExtras = extras;
    }

    /**
     * Return request selections.
     */
    public List<ContentSelection> getSelections() {
        return mSelections;
    }

    /**
     * Return the request extras.
     */
    public Bundle getExtras() {
        return mExtras;
    }

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

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeTypedList(mSelections);
        dest.writeBundle(mExtras);
    }

    public static final Creator<ClassificationsRequest> CREATOR =
            new Creator<ClassificationsRequest>() {
        @Override
        public ClassificationsRequest createFromParcel(Parcel source) {
            return new ClassificationsRequest(
                    source.createTypedArrayList(ContentSelection.CREATOR),
                    source.readBundle());
        }

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

    /**
     * A builder for classifications request events.
     * @hide
     */
    @SystemApi
    public static final class Builder {

        private final List<ContentSelection> mSelections;
        private Bundle mExtras;

        public Builder(@NonNull List<ContentSelection> selections) {
            mSelections = selections;
        }

        /**
         * Sets the request extras.
         */
        public Builder setExtras(@NonNull Bundle extras) {
            mExtras = extras;
            return this;
        }

        /**
         * Builds a new request instance.
         */
        public ClassificationsRequest build() {
            return new ClassificationsRequest(mSelections, mExtras);
        }
    }
}
Loading