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

Commit 453baf4b authored by Fang Yunong's avatar Fang Yunong Committed by Linux Build Service Account
Browse files

Fix HotSpot bugs.

1.No notification pop up when the first time
open hotspot.

2.Couldn't pop up message for notify 'Please install
SIM card in order to share your phone' when open
hotsopt without SIM.

3.No check box option "Broadcast network name (SSID).

4.HotSpot setting UI incorrect

Change-Id: I003eb9ae6f0a9bb5cf498fa3f5f51a0fff9fb4e0
CRs-Fixed: 1039259
parent da5646b2
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -74,10 +74,16 @@
    <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>

    <!-- Config to show/hide Collect and diagnostics Preference UI option -->
    <bool name="config_collect_diagnostics_enabled">false</bool>

    <bool name="config_regional_hotspot_show_broadcast_ssid_checkbox">false</bool>
    <bool name="config_regional_hotspot_show_maximum_connection_enable">false</bool>
    <string-array translatable="false" name="carrier_operator_list">
    </string-array>
</resources>
+8 −0
Original line number Diff line number Diff line
@@ -577,6 +577,8 @@
    <string name="cancel">Cancel</string>
    <!-- Button label for generic OK action [CHAR LIMIT=20] -->
    <string name="okay">OK</string>
    <!-- Button label for generic later action [CHAR LIMIT=20] -->
    <string name="later">LATER</string>
    <!-- Button label for generic forget action [CHAR LIMIT=20] -->
    <string name="forget">Forget</string>
    <!-- Button label for generic save action [CHAR LIMIT=20] -->
@@ -7574,6 +7576,12 @@
    <string name="turn_on_wifi_dialog_text">Wi-Fi is turned off when Mobile HotSpot is active. To turn on Wi-Fi, please turn off Mobile HotSpot.</string>
    <string name="dialog_not_show_again">Do not show again</string>
    <string name="tethering_settings_summary">Share your device\'s mobile data connection via USB or a Mobile HotSpot</string>
    <string name="collect_diagnostics_title">Collect Diagnostics</string>
    <string name="collect_diagnostics_summary">Collect diagnostics data for troubleshooting</string>
    <string name="tethering_no_sim_alert_title">No SIM Card</string>
    <string name="tethering_no_sim_card_text">Please install SIM card in order to share your data connection with other devices using Mobile HotSpot or USB tethering for Internet access.</string>
    <string name="tether_settings_launch_title">Mobile HotSpot</string>
    <string name="wifi_tether_first_use_message">Set up Mobile HotSpot at the First Use</string>
</resources>
+71 −8
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.UserHandle;
import android.os.UserManager;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
@@ -58,6 +59,7 @@ import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicReference;

import static android.content.Context.TELEPHONY_SERVICE;
import static android.net.ConnectivityManager.TETHERING_BLUETOOTH;
import static android.net.ConnectivityManager.TETHERING_USB;
import static android.net.ConnectivityManager.TETHERING_WIFI;
@@ -80,7 +82,8 @@ public class TetherSettings extends RestrictedSettingsFragment
    private static final String ACTION_EXTRA_VALUE = "value";
    private static final String SHAREPREFERENCE_DEFAULT_WIFI = "def_wifiap_set";
    private static final String SHAREPREFERENCE_FIFE_NAME = "MY_PERFS";
    private static final String ACTION_HOTSPOT_CONFIGURE = "Hotspot_PreConfigure";
    private static final String KEY_FIRST_LAUNCH_HOTSPOT = "FirstLaunchHotspotTethering";
    private static final String ACTION_HOTSPOT_PRE_CONFIGURE = "Hotspot_PreConfigure";
    private static final String ACTION_HOTSPOT_POST_CONFIGURE = "Hotspot_PostConfigure";
    private static final String CONFIGURE_RESULT = "PreConfigure_result";
    private static final String ACTION_HOTSPOT_CONFIGURE_RRSPONSE =
@@ -180,7 +183,8 @@ public class TetherSettings extends RestrictedSettingsFragment

        mCreateNetwork = findPreference(WIFI_AP_SSID_AND_SECURITY);

        boolean enableWifiApSettingsExt = getResources().getBoolean(R.bool.show_wifi_hotspot_settings);
        boolean enableWifiApSettingsExt = getResources().
                         getBoolean(R.bool.show_wifi_hotspot_settings);
        boolean isWifiApEnabled = getResources().getBoolean(R.bool.hide_wifi_hotspot);
        checkDefaultValue(getActivity());
        if (enableWifiApSettingsExt) {
@@ -188,10 +192,19 @@ public class TetherSettings extends RestrictedSettingsFragment
                    (HotspotPreference) findPreference(ENABLE_WIFI_AP_EXT);
            getPreferenceScreen().removePreference(findPreference(ENABLE_WIFI_AP));
            getPreferenceScreen().removePreference(mCreateNetwork);
            mEnableWifiAp.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
                public boolean onPreferenceClick(Preference preference) {
                    Intent intent = new Intent();
                    if(isNeedShowHelp(getActivity())) {
                        intent.setAction(ACTION_HOTSPOT_PRE_CONFIGURE);
                    } else {
                        intent.setAction("com.qti.ap.settings");
                    }
                    intent.setPackage("com.qualcomm.qti.extsettings");
                    mEnableWifiAp.setIntent(intent);
                    return false;
                }
            });
        } else {
            mEnableWifiAp =
                    (SwitchPreference) findPreference(ENABLE_WIFI_AP);
@@ -547,12 +560,50 @@ public class TetherSettings extends RestrictedSettingsFragment
        }
    }

    private boolean showNoSimCardDialog(Context ctx) {
        TelephonyManager tm = (TelephonyManager) ctx.getSystemService(TELEPHONY_SERVICE);
        if (!isSimCardReady(tm)) {
            AlertDialog.Builder alert = new AlertDialog.Builder(ctx);
            alert.setTitle(ctx.getResources().getString(R.string.tethering_no_sim_alert_title));
            alert.setMessage(ctx.getResources().getString(R.string.tethering_no_sim_card_text));
            alert.setPositiveButton(ctx.getResources().getString(R.string.okay),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
            alert.show();
            return true;
        }
        return false;
    }

    private boolean isSimCardReady(
            TelephonyManager telephonyManager) {
        return (telephonyManager.getSimState()
                == TelephonyManager.SIM_STATE_READY);
    }

    @Override
    public boolean onPreferenceChange(Preference preference, Object value) {
        boolean enable = (Boolean) value;

        boolean enableWifiApSettingsExt = getResources().
                         getBoolean(R.bool.show_wifi_hotspot_settings);
        if (enable) {
            if(enableWifiApSettingsExt && showNoSimCardDialog(getPrefContext())) {
                ((HotspotPreference)preference).setChecked(false);
                return false;
            } else if(enableWifiApSettingsExt && isNeedShowHelp(getPrefContext())) {
                Intent intent = new Intent();
                intent.setAction(ACTION_HOTSPOT_PRE_CONFIGURE);
                intent.setPackage("com.qualcomm.qti.extsettings");
                getPrefContext().startActivity(intent);
                ((HotspotPreference)preference).setChecked(false);
                return false;
            } else {
                startTethering(TETHERING_WIFI);
            }
        } else {
            mCm.stopTethering(TETHERING_WIFI);
        }
@@ -652,6 +703,18 @@ public class TetherSettings extends RestrictedSettingsFragment
        return R.string.help_url_tether;
    }

    private boolean isNeedShowHelp(final Context ctx) {
        SharedPreferences sharedPreferences = ctx.getSharedPreferences(
                SHAREPREFERENCE_FIFE_NAME, Activity.MODE_PRIVATE);
        Editor editor = sharedPreferences.edit();
        boolean isFirstUse = sharedPreferences.getBoolean(KEY_FIRST_LAUNCH_HOTSPOT, true);
        if (isFirstUse) {
            editor.putBoolean(KEY_FIRST_LAUNCH_HOTSPOT, false);
            editor.commit();
        }
        return isFirstUse;
    }

    private void checkDefaultValue(Context ctx) {
        boolean def_ssid = ctx.getResources().getBoolean(
                R.bool.hotspot_default_ssid_with_imei_enable);