[Settings] add VolteQueryImsState for IMS

1. Code refactor
2. Introduce VolteQueryImsState for user enable/disable configuration

Bug: 140542283
Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=Enhanced4gBasePreferenceControllerTest
Test: m RunSettingsRoboTests -j ROBOTEST_FILTER=Enhanced4gLteSliceHelperTest
Change-Id: I9c18c8900ac01909030d9433935650c1581a0fb0
This commit is contained in:
Bonian Chen
2020-01-21 14:04:26 +08:00
parent eb8658a85e
commit bd9a04ceea
5 changed files with 169 additions and 46 deletions

View File

@@ -0,0 +1,58 @@
/*
* Copyright (C) 2020 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 com.android.settings.network.ims;
import android.content.Context;
import android.telephony.SubscriptionManager;
import com.android.ims.ImsManager;
import com.android.settings.network.SubscriptionUtil;
/**
* Controller class for querying Volte status
*/
public class VolteQueryImsState {
private Context mContext;
private int mSubId;
/**
* Constructor
*
* @param context {@code Context}
* @param subId subscription's id
*/
public VolteQueryImsState(Context context, int subId) {
mContext = context;
mSubId = subId;
}
/**
* Get user's configuration
*
* @return true when user's configuration is ON otherwise false.
*/
public boolean isEnabledByUser() {
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
return false;
}
ImsManager imsManager = ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(
mContext, mSubId));
return imsManager.isEnhanced4gLteModeSettingEnabledByUser();
}
}