Loading src/com/android/settings/network/ims/ImsQueryWfcUserSetting.java 0 → 100644 +46 −0 Original line number Diff line number Diff line /* * 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.telephony.ims.ImsMmTelManager; /** * An {@code ImsQuery} for accessing IMS WFC enabled settings from user */ public class ImsQueryWfcUserSetting extends ImsDirectQueryImpl { /** * Constructor * @param subId subscription id */ public ImsQueryWfcUserSetting(int subId) { mSubId = subId; } private volatile int mSubId; /** * Query running within a {@code Callable} * * @return result of query */ public Boolean call() { final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(mSubId); return imsMmTelManager.isVoWiFiSettingEnabled(); } } src/com/android/settings/network/ims/WifiCallingQueryImsState.java +10 −5 Original line number Diff line number Diff line Loading @@ -19,8 +19,7 @@ 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; import androidx.annotation.VisibleForTesting; /** * Controller class for querying Wifi calling status Loading @@ -41,6 +40,14 @@ public class WifiCallingQueryImsState extends ImsQueryController { mSubId = subId; } /** * Implementation of ImsQueryController#isEnabledByUser(int subId) */ @VisibleForTesting ImsDirectQuery isEnabledByUser(int subId) { return new ImsQueryWfcUserSetting(subId); } /** * Get allowance status for user to alter configuration * Loading @@ -64,8 +71,6 @@ public class WifiCallingQueryImsState extends ImsQueryController { if (!SubscriptionManager.isValidSubscriptionId(mSubId)) { return false; } ImsManager imsManager = ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId( mContext, mSubId)); return imsManager.isWfcEnabledByUser(); return isEnabledByUser(mSubId).directQuery(); } } src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java +3 −2 Original line number Diff line number Diff line Loading @@ -115,7 +115,8 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment @Override public void onCallStateChanged(int state, String incomingNumber) { final SettingsActivity activity = (SettingsActivity) getActivity(); final boolean isNonTtyOrTtyOnVolteEnabled = mImsManager.isNonTtyOrTtyOnVolteEnabled(); final boolean isNonTtyOrTtyOnVolteEnabled = queryImsState(WifiCallingSettingsForSub.this.mSubId).isAllowUserControl(); final boolean isWfcEnabled = mSwitchBar.isChecked() && isNonTtyOrTtyOnVolteEnabled; boolean isCallStateIdle = Loading Loading @@ -403,7 +404,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment // NOTE: Buttons will be enabled/disabled in mPhoneStateListener final WifiCallingQueryImsState queryIms = queryImsState(mSubId); final boolean wfcEnabled = queryIms.isEnabledByUser() && mImsManager.isNonTtyOrTtyOnVolteEnabled(); && queryIms.isAllowUserControl(); mSwitch.setChecked(wfcEnabled); final int wfcMode = mImsMmTelManager.getVoWiFiModeSetting(); final int wfcRoamingMode = mImsMmTelManager.getVoWiFiRoamingModeSetting(); Loading src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java +21 −27 Original line number Diff line number Diff line Loading @@ -148,8 +148,7 @@ public class WifiCallingSliceHelper { return null; } try { final boolean isWifiCallingEnabled = isWifiCallingEnabled(imsManager); final boolean isWifiCallingEnabled = isWifiCallingEnabled(); final Intent activationAppIntent = getWifiCallingCarrierActivityIntent(subId); Loading @@ -166,17 +165,12 @@ public class WifiCallingSliceHelper { sliceUri, getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY)); } return getWifiCallingSlice(sliceUri, isWifiCallingEnabled, subId); } catch (InterruptedException | TimeoutException | ExecutionException e) { Log.e(TAG, "Unable to read the current WiFi calling status", e); return null; } } private boolean isWifiCallingEnabled(ImsManager imsManager) throws InterruptedException, ExecutionException, TimeoutException { private boolean isWifiCallingEnabled() { final int subId = getDefaultVoiceSubId(); return queryImsState(subId).isEnabledByUser() && imsManager.isNonTtyOrTtyOnVolteEnabled(); && queryImsState(subId).isAllowUserControl(); } /** Loading Loading @@ -247,7 +241,7 @@ public class WifiCallingSliceHelper { boolean isWifiCallingEnabled = false; int wfcMode = -1; try { isWifiCallingEnabled = isWifiCallingEnabled(imsManager); isWifiCallingEnabled = isWifiCallingEnabled(); wfcMode = getWfcMode(imsMmTelManager); } catch (InterruptedException | ExecutionException | TimeoutException e) { Log.e(TAG, "Unable to get wifi calling preferred mode", e); Loading Loading @@ -392,7 +386,7 @@ public class WifiCallingSliceHelper { if (imsManager.isWfcEnabledByPlatform() && isWfcProvisionedOnDevice(subId)) { final boolean currentValue = queryImsState(subId).isEnabledByUser() && imsManager.isNonTtyOrTtyOnVolteEnabled(); && queryImsState(subId).isAllowUserControl(); final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE, currentValue); final Intent activationAppIntent = Loading Loading @@ -436,7 +430,7 @@ public class WifiCallingSliceHelper { && imsManager.isWfcEnabledByPlatform() && isWfcProvisionedOnDevice(subId) && queryImsState(subId).isEnabledByUser() && imsManager.isNonTtyOrTtyOnVolteEnabled()) { && queryImsState(subId).isAllowUserControl()) { // Change the preference only when wifi calling is enabled // And when wifi calling preference is editable for the current carrier final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId); Loading Loading
src/com/android/settings/network/ims/ImsQueryWfcUserSetting.java 0 → 100644 +46 −0 Original line number Diff line number Diff line /* * 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.telephony.ims.ImsMmTelManager; /** * An {@code ImsQuery} for accessing IMS WFC enabled settings from user */ public class ImsQueryWfcUserSetting extends ImsDirectQueryImpl { /** * Constructor * @param subId subscription id */ public ImsQueryWfcUserSetting(int subId) { mSubId = subId; } private volatile int mSubId; /** * Query running within a {@code Callable} * * @return result of query */ public Boolean call() { final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(mSubId); return imsMmTelManager.isVoWiFiSettingEnabled(); } }
src/com/android/settings/network/ims/WifiCallingQueryImsState.java +10 −5 Original line number Diff line number Diff line Loading @@ -19,8 +19,7 @@ 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; import androidx.annotation.VisibleForTesting; /** * Controller class for querying Wifi calling status Loading @@ -41,6 +40,14 @@ public class WifiCallingQueryImsState extends ImsQueryController { mSubId = subId; } /** * Implementation of ImsQueryController#isEnabledByUser(int subId) */ @VisibleForTesting ImsDirectQuery isEnabledByUser(int subId) { return new ImsQueryWfcUserSetting(subId); } /** * Get allowance status for user to alter configuration * Loading @@ -64,8 +71,6 @@ public class WifiCallingQueryImsState extends ImsQueryController { if (!SubscriptionManager.isValidSubscriptionId(mSubId)) { return false; } ImsManager imsManager = ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId( mContext, mSubId)); return imsManager.isWfcEnabledByUser(); return isEnabledByUser(mSubId).directQuery(); } }
src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java +3 −2 Original line number Diff line number Diff line Loading @@ -115,7 +115,8 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment @Override public void onCallStateChanged(int state, String incomingNumber) { final SettingsActivity activity = (SettingsActivity) getActivity(); final boolean isNonTtyOrTtyOnVolteEnabled = mImsManager.isNonTtyOrTtyOnVolteEnabled(); final boolean isNonTtyOrTtyOnVolteEnabled = queryImsState(WifiCallingSettingsForSub.this.mSubId).isAllowUserControl(); final boolean isWfcEnabled = mSwitchBar.isChecked() && isNonTtyOrTtyOnVolteEnabled; boolean isCallStateIdle = Loading Loading @@ -403,7 +404,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment // NOTE: Buttons will be enabled/disabled in mPhoneStateListener final WifiCallingQueryImsState queryIms = queryImsState(mSubId); final boolean wfcEnabled = queryIms.isEnabledByUser() && mImsManager.isNonTtyOrTtyOnVolteEnabled(); && queryIms.isAllowUserControl(); mSwitch.setChecked(wfcEnabled); final int wfcMode = mImsMmTelManager.getVoWiFiModeSetting(); final int wfcRoamingMode = mImsMmTelManager.getVoWiFiRoamingModeSetting(); Loading
src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java +21 −27 Original line number Diff line number Diff line Loading @@ -148,8 +148,7 @@ public class WifiCallingSliceHelper { return null; } try { final boolean isWifiCallingEnabled = isWifiCallingEnabled(imsManager); final boolean isWifiCallingEnabled = isWifiCallingEnabled(); final Intent activationAppIntent = getWifiCallingCarrierActivityIntent(subId); Loading @@ -166,17 +165,12 @@ public class WifiCallingSliceHelper { sliceUri, getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY)); } return getWifiCallingSlice(sliceUri, isWifiCallingEnabled, subId); } catch (InterruptedException | TimeoutException | ExecutionException e) { Log.e(TAG, "Unable to read the current WiFi calling status", e); return null; } } private boolean isWifiCallingEnabled(ImsManager imsManager) throws InterruptedException, ExecutionException, TimeoutException { private boolean isWifiCallingEnabled() { final int subId = getDefaultVoiceSubId(); return queryImsState(subId).isEnabledByUser() && imsManager.isNonTtyOrTtyOnVolteEnabled(); && queryImsState(subId).isAllowUserControl(); } /** Loading Loading @@ -247,7 +241,7 @@ public class WifiCallingSliceHelper { boolean isWifiCallingEnabled = false; int wfcMode = -1; try { isWifiCallingEnabled = isWifiCallingEnabled(imsManager); isWifiCallingEnabled = isWifiCallingEnabled(); wfcMode = getWfcMode(imsMmTelManager); } catch (InterruptedException | ExecutionException | TimeoutException e) { Log.e(TAG, "Unable to get wifi calling preferred mode", e); Loading Loading @@ -392,7 +386,7 @@ public class WifiCallingSliceHelper { if (imsManager.isWfcEnabledByPlatform() && isWfcProvisionedOnDevice(subId)) { final boolean currentValue = queryImsState(subId).isEnabledByUser() && imsManager.isNonTtyOrTtyOnVolteEnabled(); && queryImsState(subId).isAllowUserControl(); final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE, currentValue); final Intent activationAppIntent = Loading Loading @@ -436,7 +430,7 @@ public class WifiCallingSliceHelper { && imsManager.isWfcEnabledByPlatform() && isWfcProvisionedOnDevice(subId) && queryImsState(subId).isEnabledByUser() && imsManager.isNonTtyOrTtyOnVolteEnabled()) { && queryImsState(subId).isAllowUserControl()) { // Change the preference only when wifi calling is enabled // And when wifi calling preference is editable for the current carrier final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId); Loading