1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.internal.telephony; 18 19 import android.telephony.AvailableNetworkInfo; 20 21 import com.android.internal.telephony.ISetOpportunisticDataCallback; 22 import com.android.internal.telephony.IUpdateAvailableNetworksCallback; 23 24 interface IOns { 25 26 /** 27 * Enable or disable Opportunistic Network service. 28 * 29 * This method should be called to enable or disable 30 * OpportunisticNetwork service on the device. 31 * 32 * <p> 33 * Requires Permission: 34 * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} 35 * Or the calling app has carrier privileges. @see #hasCarrierPrivileges 36 * 37 * @param enable enable(True) or disable(False) 38 * @param callingPackage caller's package name 39 * @return returns true if successfully set. 40 */ setEnable(boolean enable, String callingPackage)41 boolean setEnable(boolean enable, String callingPackage); 42 43 /** 44 * is Opportunistic Network service enabled 45 * 46 * This method should be called to determine if the Opportunistic Network service is enabled 47 * 48 * <p> 49 * Requires Permission: 50 * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} 51 * Or the calling app has carrier privileges. @see #hasCarrierPrivileges 52 * 53 * @param callingPackage caller's package name 54 */ isEnabled(String callingPackage)55 boolean isEnabled(String callingPackage); 56 57 /** 58 * Set preferred opportunistic data subscription id. 59 * 60 * <p>Requires that the calling app has carrier privileges on both primary and 61 * secondary subscriptions (see 62 * {@link #hasCarrierPrivileges}), or has permission 63 * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}. 64 * 65 * @param subId which opportunistic subscription 66 * {@link SubscriptionManager#getOpportunisticSubscriptions} is preferred for cellular data. 67 * Pass {@link SubscriptionManager#DEFAULT_SUBSCRIPTION_ID} to unset the preference 68 * @param needValidation whether validation is needed before switch happens. 69 * @param callback callback upon request completion. 70 * @param callingPackage caller's package name 71 * 72 */ setPreferredDataSubscriptionId(int subId, boolean needValidation, ISetOpportunisticDataCallback callbackStub, String callingPackage)73 void setPreferredDataSubscriptionId(int subId, boolean needValidation, 74 ISetOpportunisticDataCallback callbackStub, String callingPackage); 75 76 /** 77 * Get preferred opportunistic data subscription Id 78 * 79 * <p>Requires that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}), 80 * or has permission {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}. 81 * @return subId preferred opportunistic subscription id or 82 * {@link SubscriptionManager#DEFAULT_SUBSCRIPTION_ID} if there are no preferred 83 * subscription id 84 * 85 */ getPreferredDataSubscriptionId(String callingPackage, String callingFeatureId)86 int getPreferredDataSubscriptionId(String callingPackage, String callingFeatureId); 87 88 /** 89 * Update availability of a list of networks in the current location. 90 * 91 * This api should be called if the caller is aware of the availability of a network 92 * at the current location. This information will be used by OpportunisticNetwork service 93 * to decide to attach to the network. If an empty list is passed, 94 * it is assumed that no network is available. 95 * Requires that the calling app has carrier privileges on both primary and 96 * secondary subscriptions (see 97 * {@link #hasCarrierPrivileges}), or has permission 98 * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}. 99 * @param availableNetworks is a list of available network information. 100 * @param callingPackage caller's package name 101 * @param callback callback upon request completion. 102 * 103 */ updateAvailableNetworks(in List<AvailableNetworkInfo> availableNetworks, IUpdateAvailableNetworksCallback callbackStub, String callingPackage)104 void updateAvailableNetworks(in List<AvailableNetworkInfo> availableNetworks, 105 IUpdateAvailableNetworksCallback callbackStub, String callingPackage); 106 } 107