Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b053cd63 authored by Bonian Chen's avatar Bonian Chen Committed by Android (Google) Code Review
Browse files

Merge "[Settings] replace isNonTtyOrTtyOnVolteEnabled() and isWfcEnabledByUser() in WFC"

parents 77b86b1e c4413a85
Loading
Loading
Loading
Loading
+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();
    }
}
+10 −5
Original line number Diff line number Diff line
@@ -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
@@ -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
     *
@@ -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();
    }
}
+3 −2
Original line number Diff line number Diff line
@@ -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 =
@@ -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();
+21 −27
Original line number Diff line number Diff line
@@ -148,8 +148,7 @@ public class WifiCallingSliceHelper {
            return null;
        }

        try {
            final boolean isWifiCallingEnabled = isWifiCallingEnabled(imsManager);
        final boolean isWifiCallingEnabled = isWifiCallingEnabled();
        final Intent activationAppIntent =
                getWifiCallingCarrierActivityIntent(subId);

@@ -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();
    }

    /**
@@ -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);
@@ -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 =
@@ -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);