/* * Copyright (C) 2017 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.resolver; import android.annotation.SdkConstant; import android.annotation.SystemApi; import android.app.Service; import android.content.ComponentName; import android.content.Intent; import android.os.IBinder; import android.os.Handler; import android.os.HandlerThread; import android.os.RemoteException; import android.service.resolver.ResolverTarget; import android.util.Log; import java.util.List; import java.util.Map; /** * A service to rank apps according to usage stats of apps, when the system is resolving targets for * an Intent. * *
To extend this class, you must declare the service in your manifest file with the * {@link android.Manifest.permission#BIND_RESOLVER_RANKER_SERVICE} permission, and include an * intent filter with the {@link #SERVICE_INTERFACE} action. For example:
** <service android:name=".MyResolverRankerService" * android:exported="true" * android:priority="100" * android:permission="android.permission.BIND_RESOLVER_RANKER_SERVICE"> * <intent-filter> * <action android:name="android.service.resolver.ResolverRankerService" /> * </intent-filter> * </service> ** @hide */ @SystemApi public abstract class ResolverRankerService extends Service { private static final String TAG = "ResolverRankerService"; private static final boolean DEBUG = false; /** * The Intent action that a service must respond to. Add it to the intent filter of the service * in its manifest. */ @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION) public static final String SERVICE_INTERFACE = "android.service.resolver.ResolverRankerService"; /** * The permission that a service must hold. If the service does not hold the permission, the * system will skip that service. */ public static final String HOLD_PERMISSION = "android.permission.PROVIDE_RESOLVER_RANKER_SERVICE"; /** * The permission that a service must require to ensure that only Android system can bind to it. * If this permission is not enforced in the AndroidManifest of the service, the system will * skip that service. */ public static final String BIND_PERMISSION = "android.permission.BIND_RESOLVER_RANKER_SERVICE"; private ResolverRankerServiceWrapper mWrapper = null; /** * Called by the system to retrieve a list of probabilities to rank apps/options. To implement * it, set selectProbability of each input {@link ResolverTarget}. The higher the * selectProbability is, the more likely the {@link ResolverTarget} will be selected by the * user. Override this function to provide prediction results. * * @param targets a list of {@link ResolverTarget}, for the list of apps to be ranked. * * @throws Exception when the prediction task fails. */ public void onPredictSharingProbabilities(final List