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

Commit 4bbee19c authored by Fang Yunong's avatar Fang Yunong Committed by Linux Build Service Account
Browse files

Settings: add enhanced Wi-Fi Calling menu

Add enhanced Wifi calling menu and display wifi call status
message received from WFC service.

Change-Id: I3bf46a8f452f5c886aeb75dd31d2aca04ce671f4
CRs-Fixed: 1039278
parent 98c6323c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@ LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := \
        $(call all-java-files-under, src) \
        src/com/android/settings/EventLogTags.logtags
LOCAL_SRC_FILES += src/org/codeaurora/wfcservice/IWFCService.aidl \
                   src/org/codeaurora/wfcservice/IWFCServiceCB.aidl

LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res \
    frameworks/support/v7/preference/res \
+4 −0
Original line number Diff line number Diff line
@@ -74,4 +74,8 @@
    <bool name="config_regional_account_check_dialog_enable">false</bool>
    <!-- Tethering & Mobile HotSpots display summary on Tmoblie -->
    <bool name="config_tethering_settings_display_summary_Tmobile">false</bool>
    <!-- Config to enable/disable wifi call notification -->
    <bool name="config_regional_wifi_calling_notificaion_enable">false</bool>
    <bool name="wifi_call_enhanced_setting">false</bool>

</resources>
+12 −0
Original line number Diff line number Diff line
@@ -34,6 +34,18 @@
        settings:keywords="@string/keywords_wifi_calling"
        android:fragment="com.android.settings.WifiCallingSettings" />

    <PreferenceScreen
        android:key="wifi_calling_enhanced_settings"
        android:title="@string/wifi_calling_settings_title"
        android:summaryOff="@null"
        android:summaryOn="@null"
        android:persistent="false">
        <intent
            android:action="android.intent.action.MAIN"
            android:targetPackage="com.qualcomm.qti.wfcservice"
            android:targetClass="com.qualcomm.qti.wfcservice.WifiCallingEnhancedSettings" />
    </PreferenceScreen>

    <com.android.settingslib.RestrictedPreference
        android:fragment="com.android.settings.nfc.AndroidBeam"
        android:key="android_beam_settings"
+103 −6
Original line number Diff line number Diff line
@@ -57,6 +57,12 @@ import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedPreference;
import org.codeaurora.wfcservice.IWFCService;
import org.codeaurora.wfcservice.IWFCServiceCB;

import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;

import java.util.ArrayList;
import java.util.Arrays;
@@ -64,6 +70,7 @@ import java.util.List;

public class WirelessSettings extends SettingsPreferenceFragment implements Indexable {
    private static final String TAG = "WirelessSettings";
    private static final boolean DEBUG = true;

    private static final String KEY_TOGGLE_AIRPLANE = "toggle_airplane";
    private static final String KEY_TOGGLE_NFC = "toggle_nfc";
@@ -75,6 +82,7 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
    private static final String KEY_MOBILE_NETWORK_SETTINGS = "mobile_network_settings";
    private static final String KEY_MANAGE_MOBILE_PLAN = "manage_mobile_plan";
    private static final String KEY_WFC_SETTINGS = "wifi_calling_settings";
    private static final String KEY_WFC_ENHANCED_SETTINGS = "wifi_calling_enhanced_settings";

    public static final String EXIT_ECM_RESULT = "exit_ecm_result";
    public static final int REQUEST_CODE_EXIT_ECM = 1;
@@ -95,6 +103,69 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
    private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage";

    private PreferenceScreen mButtonWfc;
    private boolean mEnhancedWFCSettingsEnabled = false;

    private IWFCService mWFCService;
    private ServiceConnection mConnection = new ServiceConnection() {

        public void onServiceConnected(ComponentName className, IBinder service) {
            Log.i(TAG, "AIDLExample connect service");
            mWFCService = IWFCService.Stub.asInterface(service);
            try {
                mWFCService.registerCallback(mCallback);
            } catch (RemoteException re) {
            }
        }

        public void onServiceDisconnected(ComponentName className) {
            Log.i(TAG, " AIDLExample disconnect service");
            mWFCService = null;
        }
    };

    private IWFCServiceCB mCallback = new IWFCServiceCB.Stub() {
        public void updateWFCMessage(String s) {
            if (!mEnhancedWFCSettingsEnabled || (s == null)) {
                if(DEBUG) Log.e(TAG, "updateWFCMessage fail.");
                return ;
            }
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    if(DEBUG) Log.d (TAG, "new UI thread.");
                    mButtonWfc.setSummary(s);
                }
            });

        }
    };

    private void updateCallback() {
        Log.i(TAG, "call back from settings is called");
    }

    private void unbindWFCService() {
        if (!mEnhancedWFCSettingsEnabled) {
            return;
        }
        if (mWFCService != null) {
            try {
                Log.d(TAG, "WFCService unbindService");
                mWFCService.unregisterCallback(mCallback);
            } catch (RemoteException e) {
                Log.e(TAG, "WFCService unregister error " + e);
            }
        }

        getActivity().unbindService(mConnection);
        Log.d(TAG, "WFCService unbind error ");
    }

    @Override
    public void onDestroy() {
        unbindWFCService();

        super.onDestroy();
    }

    private static final String VOICE_OVER_LTE = "voice_over_lte";
    private SwitchPreference mVoLtePreference;
@@ -258,7 +329,23 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
        mAirplaneModeEnabler = new AirplaneModeEnabler(activity, mAirplaneModePreference);
        mNfcEnabler = new NfcEnabler(activity, nfc, androidBeam);

        mEnhancedWFCSettingsEnabled = getActivity().getResources().getBoolean(
                    R.bool.wifi_call_enhanced_setting);
        if (mEnhancedWFCSettingsEnabled) {
            mButtonWfc = (PreferenceScreen) findPreference(KEY_WFC_ENHANCED_SETTINGS);
            removePreference(KEY_WFC_SETTINGS);
        } else {
            mButtonWfc = (PreferenceScreen) findPreference(KEY_WFC_SETTINGS);
            removePreference(KEY_WFC_ENHANCED_SETTINGS);
        }

        if (mEnhancedWFCSettingsEnabled) {
            //bind WFC service
            final Intent intentWfc = new Intent();
            intentWfc.setAction("com.qualcomm.qti.wfcservice.IWFCService");
            intentWfc.setPackage("com.qualcomm.qti.wfcservice");
            activity.bindService(intentWfc, mConnection, Context.BIND_AUTO_CREATE);
        }

        String toggleable = Settings.Global.getString(activity.getContentResolver(),
                Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
@@ -381,6 +468,7 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
            getPreferenceScreen().removePreference(mVoLtePreference);
        }
        }

    }

    @Override
@@ -392,15 +480,23 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
            mNfcEnabler.resume();
        }

        // update WFC setting
        // update Wi-Fi Calling setting
        final Context context = getActivity();
        if (ImsManager.isWfcEnabledByPlatform(context)) {
            getPreferenceScreen().addPreference(mButtonWfc);

            if (!mEnhancedWFCSettingsEnabled) {
                mButtonWfc.setSummary(WifiCallingSettings.getWfcModeSummary(
                        context, ImsManager.getWfcMode(context)));
            } else {
            removePreference(KEY_WFC_SETTINGS);
                if (!ImsManager.isWfcEnabledByUser(context)) {
                    mButtonWfc.setSummary(R.string.disabled);
                } else {
                    mButtonWfc.setSummary(SystemProperties.get("sys.wificall.status.msg"));
                }
            }
        } else {
            log("WFC not supported. Remove WFC menu");
            if (mButtonWfc != null) getPreferenceScreen().removePreference(mButtonWfc);
        }
    }

@@ -518,4 +614,5 @@ public class WirelessSettings extends SettingsPreferenceFragment implements Inde
                return result;
            }
        };

}
+39 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2016, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * * Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following
 * disclaimer in the documentation and/or other materials provided
 * with the distribution.
 * * Neither the name of The Linux Foundation nor the names of its
 * contributors may be used to endorse or promote products derived
 * from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 **/
package org.codeaurora.wfcservice;
import org.codeaurora.wfcservice.IWFCServiceCB;

/**
 * WFC service interface.
 */
interface IWFCService {
    void registerCallback(IWFCServiceCB cb);
    void unregisterCallback(IWFCServiceCB cb);
}
Loading