1 /* 2 * Copyright (C) 2020 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.settings.network.ims; 18 19 import android.telephony.ims.ProvisioningManager; 20 import android.telephony.ims.feature.MmTelFeature; 21 import android.telephony.ims.stub.ImsRegistrationImplBase; 22 import android.util.Log; 23 24 /** 25 * An {@link ImsQuery} for accessing IMS provision stat 26 */ 27 public class ImsQueryProvisioningStat implements ImsQuery { 28 29 private static final String LOG_TAG = "QueryPrivisioningStat"; 30 31 private volatile int mSubId; 32 private volatile int mCapability; 33 private volatile int mTech; 34 35 /** 36 * Constructor 37 * @param subId subscription id 38 * @param capability {@link MmTelFeature.MmTelCapabilities#MmTelCapability} 39 * @param tech {@link ImsRegistrationImplBase#ImsRegistrationTech} 40 */ ImsQueryProvisioningStat(int subId, @MmTelFeature.MmTelCapabilities.MmTelCapability int capability, @ImsRegistrationImplBase.ImsRegistrationTech int tech)41 public ImsQueryProvisioningStat(int subId, 42 @MmTelFeature.MmTelCapabilities.MmTelCapability int capability, 43 @ImsRegistrationImplBase.ImsRegistrationTech int tech) { 44 mSubId = subId; 45 mCapability = capability; 46 mTech = tech; 47 } 48 49 /** 50 * Implementation of interface {@link ImsQuery#query()} 51 * 52 * @return result of query 53 */ query()54 public boolean query() { 55 try { 56 final ProvisioningManager privisionManager = 57 ProvisioningManager.createForSubscriptionId(mSubId); 58 return privisionManager.getProvisioningStatusForCapability(mCapability, mTech); 59 } catch (IllegalArgumentException exception) { 60 Log.w(LOG_TAG, "fail to get Provisioning stat. subId=" + mSubId, exception); 61 } 62 return false; 63 } 64 } 65