1 /* 2 * Copyright (C) 2019 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 android.telephony.ims; 18 19 import android.annotation.NonNull; 20 import android.annotation.SdkConstant; 21 import android.annotation.SuppressLint; 22 import android.annotation.SystemService; 23 import android.content.Context; 24 import android.telephony.SubscriptionManager; 25 26 /** 27 * Provides access to information about Telephony IMS services on the device. 28 */ 29 @SystemService(Context.TELEPHONY_IMS_SERVICE) 30 public class ImsManager { 31 32 private Context mContext; 33 34 /** 35 * <p>Broadcast Action: Indicates that a previously allowed IMS operation was rejected by the 36 * network due to the network returning a "forbidden" response. This may be due to a 37 * provisioning change from the network. 38 * May include the {@link SubscriptionManager#EXTRA_SUBSCRIPTION_INDEX} extra to also specify 39 * which subscription the operation was rejected for. 40 * <p class="note"> 41 * Carrier applications may listen to this broadcast to be notified of possible IMS provisioning 42 * issues. 43 * @hide 44 */ 45 // Moved from TelephonyIntents, need to keep backwards compatibility with OEM apps that have 46 // this value hard-coded in BroadcastReceiver. 47 @SuppressLint("ActionValue") 48 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION) 49 public static final String ACTION_FORBIDDEN_NO_SERVICE_AUTHORIZATION = 50 "com.android.internal.intent.action.ACTION_FORBIDDEN_NO_SERVICE_AUTHORIZATION"; 51 52 /** 53 * An intent action indicating that IMS registration for WiFi calling has resulted in an error. 54 * Contains error information that should be displayed to the user. 55 * <p> 56 * This intent will contain the following extra key/value pairs: 57 * {@link #EXTRA_WFC_REGISTRATION_FAILURE_TITLE} 58 * and {@link #EXTRA_WFC_REGISTRATION_FAILURE_MESSAGE}, which contain carrier specific 59 * error information that should be displayed to the user. 60 * <p> 61 * Usage: This intent is sent as an ordered broadcast. If the settings application is going 62 * to show the error information specified to the user, it should respond to 63 * {@link android.content.BroadcastReceiver#setResultCode(int)} with 64 * {@link android.app.Activity#RESULT_CANCELED}, which will signal to the framework that the 65 * event was handled. If the framework does not receive a response to the ordered broadcast, 66 * it will then show a notification to the user indicating that there was a registration 67 * failure. 68 */ 69 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION) 70 public static final String ACTION_WFC_IMS_REGISTRATION_ERROR = 71 "android.telephony.ims.action.WFC_IMS_REGISTRATION_ERROR"; 72 73 /** 74 * An extra key corresponding to a {@link CharSequence} value which contains the carrier 75 * specific title to be displayed as part of the message shown to the user when there is an 76 * error registering for WiFi calling. 77 */ 78 public static final String EXTRA_WFC_REGISTRATION_FAILURE_TITLE = 79 "android.telephony.ims.extra.WFC_REGISTRATION_FAILURE_TITLE"; 80 81 /** 82 * An extra key corresponding to a {@link CharSequence} value which contains the carrier 83 * specific message to be displayed as part of the message shown to the user when there is an 84 * error registering for WiFi calling. 85 */ 86 public static final String EXTRA_WFC_REGISTRATION_FAILURE_MESSAGE = 87 "android.telephony.ims.extra.WFC_REGISTRATION_FAILURE_MESSAGE"; 88 89 /** 90 * Use {@link Context#getSystemService(String)} to get an instance of this class. 91 * @hide 92 */ ImsManager(@onNull Context context)93 public ImsManager(@NonNull Context context) { 94 mContext = context; 95 } 96 97 /** 98 * Create an instance of ImsRcsManager for the subscription id specified. 99 * 100 * @param subscriptionId The ID of the subscription that this ImsRcsManager will use. 101 * @throws IllegalArgumentException if the subscription is invalid. 102 * @return a ImsRcsManager instance with the specific subscription ID. 103 */ 104 @NonNull getImsRcsManager(int subscriptionId)105 public ImsRcsManager getImsRcsManager(int subscriptionId) { 106 if (!SubscriptionManager.isValidSubscriptionId(subscriptionId)) { 107 throw new IllegalArgumentException("Invalid subscription ID: " + subscriptionId); 108 } 109 110 return new ImsRcsManager(mContext, subscriptionId); 111 } 112 113 /** 114 * Create an instance of ImsMmTelManager for the subscription id specified. 115 * 116 * @param subscriptionId The ID of the subscription that this ImsMmTelManager will use. 117 * @throws IllegalArgumentException if the subscription is invalid. 118 * @return a ImsMmTelManager instance with the specific subscription ID. 119 */ 120 @NonNull getImsMmTelManager(int subscriptionId)121 public ImsMmTelManager getImsMmTelManager(int subscriptionId) { 122 if (!SubscriptionManager.isValidSubscriptionId(subscriptionId)) { 123 throw new IllegalArgumentException("Invalid subscription ID: " + subscriptionId); 124 } 125 126 return new ImsMmTelManager(subscriptionId); 127 } 128 } 129