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

Commit fb922e9b authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge changes from topic "prediction_suggestion_services"

* changes:
  Initial commit of Content Suggestions (overview long press) Manager.
  Adding initial implementation of Prediction client/service API
parents 7c1bbb71 3fb0f258
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -104,6 +104,11 @@ 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",
        "core/java/android/app/role/IRoleManager.aidl",
        "core/java/android/app/role/IRoleManagerCallback.aidl",
@@ -273,6 +278,7 @@ java_defaults {
        "core/java/android/rolecontrollerservice/IRoleControllerService.aidl",
        ":keystore_aidl",
        "core/java/android/security/keymaster/IKeyAttestationApplicationIdProvider.aidl",
        "core/java/android/service/appprediction/IPredictionService.aidl",
        "core/java/android/service/autofill/augmented/IAugmentedAutofillService.aidl",
        "core/java/android/service/autofill/augmented/IFillCallback.aidl",
        "core/java/android/service/autofill/IAutoFillService.aidl",
@@ -282,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",
+183 −0
Original line number Diff line number Diff line
@@ -86,11 +86,13 @@ package android {
    field public static final java.lang.String MANAGE_ACCESSIBILITY = "android.permission.MANAGE_ACCESSIBILITY";
    field public static final java.lang.String MANAGE_ACTIVITY_STACKS = "android.permission.MANAGE_ACTIVITY_STACKS";
    field public static final java.lang.String MANAGE_APP_OPS_RESTRICTIONS = "android.permission.MANAGE_APP_OPS_RESTRICTIONS";
    field public static final java.lang.String MANAGE_APP_PREDICTIONS = "android.permission.MANAGE_APP_PREDICTIONS";
    field public static final java.lang.String MANAGE_APP_TOKENS = "android.permission.MANAGE_APP_TOKENS";
    field public static final java.lang.String MANAGE_AUTO_FILL = "android.permission.MANAGE_AUTO_FILL";
    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";
@@ -869,6 +871,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 {
@@ -877,6 +946,87 @@ package android.app.job {
}
package android.app.prediction {
  public final class AppPredictionContext implements android.os.Parcelable {
    method public int describeContents();
    method public android.os.Bundle getExtras();
    method public java.lang.String getPackageName();
    method public int getPredictedTargetCount();
    method public java.lang.String getUiSurface();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.prediction.AppPredictionContext> CREATOR;
  }
  public static final class AppPredictionContext.Builder {
    method public android.app.prediction.AppPredictionContext build();
    method public android.app.prediction.AppPredictionContext.Builder setExtras(android.os.Bundle);
    method public android.app.prediction.AppPredictionContext.Builder setPredictedTargetCount(int);
    method public android.app.prediction.AppPredictionContext.Builder setUiSurface(java.lang.String);
  }
  public final class AppPredictionManager {
    method public android.app.prediction.AppPredictor createAppPredictionSession(android.app.prediction.AppPredictionContext);
  }
  public final class AppPredictionSessionId implements android.os.Parcelable {
    method public int describeContents();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.prediction.AppPredictionSessionId> CREATOR;
  }
  public final class AppPredictor {
    method public void destroy();
    method public void notifyAppTargetEvent(android.app.prediction.AppTargetEvent);
    method public void notifyLocationShown(java.lang.String, java.util.List<android.app.prediction.AppTargetId>);
    method public void registerPredictionUpdates(java.util.concurrent.Executor, android.app.prediction.AppPredictor.Callback);
    method public void requestPredictionUpdate();
    method public void sortTargets(java.util.List<android.app.prediction.AppTarget>, java.util.concurrent.Executor, java.util.function.Consumer<java.util.List<android.app.prediction.AppTarget>>);
    method public void unregisterPredictionUpdates(android.app.prediction.AppPredictor.Callback);
  }
  public static abstract interface AppPredictor.Callback {
    method public abstract void onTargetsAvailable(java.util.List<android.app.prediction.AppTarget>);
  }
  public final class AppTarget implements android.os.Parcelable {
    method public int describeContents();
    method public java.lang.String getClassName();
    method public android.app.prediction.AppTargetId getId();
    method public java.lang.String getPackageName();
    method public int getRank();
    method public android.content.pm.ShortcutInfo getShortcutInfo();
    method public android.os.UserHandle getUser();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.prediction.AppTarget> CREATOR;
  }
  public final class AppTargetEvent implements android.os.Parcelable {
    method public int describeContents();
    method public int getAction();
    method public java.lang.String getLaunchLocation();
    method public android.app.prediction.AppTarget getTarget();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final int ACTION_DISMISS = 2; // 0x2
    field public static final int ACTION_LAUNCH = 1; // 0x1
    field public static final int ACTION_PIN = 3; // 0x3
    field public static final android.os.Parcelable.Creator<android.app.prediction.AppTargetEvent> CREATOR;
  }
  public static final class AppTargetEvent.Builder {
    ctor public AppTargetEvent.Builder(android.app.prediction.AppTarget, int);
    method public android.app.prediction.AppTargetEvent build();
    method public android.app.prediction.AppTargetEvent.Builder setLaunchLocation(java.lang.String);
  }
  public final class AppTargetId implements android.os.Parcelable {
    method public int describeContents();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.prediction.AppTargetId> CREATOR;
  }
}
package android.app.role {
  public abstract interface OnRoleHoldersChangedListener {
@@ -1063,7 +1213,9 @@ package android.content {
    method public abstract void sendBroadcastAsUser(android.content.Intent, android.os.UserHandle, java.lang.String, android.os.Bundle);
    method public abstract void sendOrderedBroadcast(android.content.Intent, java.lang.String, android.os.Bundle, android.content.BroadcastReceiver, android.os.Handler, int, java.lang.String, android.os.Bundle);
    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";
@@ -5184,6 +5336,24 @@ package android.security.keystore.recovery {
}
package android.service.appprediction {
  public abstract class AppPredictionService extends android.app.Service {
    ctor public AppPredictionService();
    method public abstract void onAppTargetEvent(android.app.prediction.AppPredictionSessionId, android.app.prediction.AppTargetEvent);
    method public final android.os.IBinder onBind(android.content.Intent);
    method public void onCreatePredictionSession(android.app.prediction.AppPredictionContext, android.app.prediction.AppPredictionSessionId);
    method public void onDestroyPredictionSession(android.app.prediction.AppPredictionSessionId);
    method public abstract void onLocationShown(android.app.prediction.AppPredictionSessionId, java.lang.String, java.util.List<android.app.prediction.AppTargetId>);
    method public abstract void onRequestPredictionUpdate(android.app.prediction.AppPredictionSessionId);
    method public abstract void onSortAppTargets(android.app.prediction.AppPredictionSessionId, java.util.List<android.app.prediction.AppTarget>, android.os.CancellationSignal, java.util.function.Consumer<java.util.List<android.app.prediction.AppTarget>>);
    method public void onStartPredictionUpdates();
    method public void onStopPredictionUpdates();
    method public final void updatePredictions(android.app.prediction.AppPredictionSessionId, java.util.List<android.app.prediction.AppTarget>);
  }
}
package android.service.autofill {
  public abstract class AutofillFieldClassificationService extends android.app.Service {
@@ -5312,6 +5482,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 {
+26 −0
Original line number Diff line number Diff line
@@ -21,8 +21,11 @@ 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;
import android.app.role.RoleManager;
import android.app.slice.SliceManager;
import android.app.timedetector.TimeDetector;
@@ -1120,6 +1123,29 @@ final class SystemServiceRegistry {
                return null;
            }});

        registerService(Context.APP_PREDICTION_SERVICE, AppPredictionManager.class,
                new CachedServiceFetcher<AppPredictionManager>() {
            @Override
            public AppPredictionManager createService(ContextImpl ctx)
                    throws ServiceNotFoundException {
                return new AppPredictionManager(ctx);
            }
        });

        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