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

Commit f874f0d3 authored by Arne Coucheron's avatar Arne Coucheron
Browse files

Revert "Fix HotSpot bugs."

This reverts commit 453baf4b.

Change-Id: I0811ea3de2e96914fcac8b07fe5b81628a2f3b38
parent 3065e506
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -80,11 +80,7 @@
    <!-- 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>
    <bool name="tethering_need_show_activated">false</bool>
    <string-array translatable="false" name="carrier_operator_list">
    </string-array>
    <bool name="config_regional_security_show_password_enable">false</bool>
    <bool name="config_hotspot_need_show_activated_dialog">false</bool>

+0 −6
Original line number Diff line number Diff line
@@ -583,8 +583,6 @@
    <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] -->
@@ -7830,10 +7828,6 @@
    <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>
    <string name="lte_data_and_voice_calling_enabled">LTE data and Voice Calling (IMS/VoLTE) service enabled </string>
    <string name="lte_data_service_enabled">LTE data service enabled </string>
+8 −71
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ 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;
@@ -59,7 +58,6 @@ 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;
@@ -82,8 +80,7 @@ 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 KEY_FIRST_LAUNCH_HOTSPOT = "FirstLaunchHotspotTethering";
    private static final String ACTION_HOTSPOT_PRE_CONFIGURE = "Hotspot_PreConfigure";
    private static final String ACTION_HOTSPOT_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 =
@@ -183,8 +180,7 @@ 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) {
@@ -192,19 +188,10 @@ 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);
@@ -560,50 +547,12 @@ 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);
        }
@@ -706,18 +655,6 @@ 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);