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

Commit 57f1ebef authored by Arne Coucheron's avatar Arne Coucheron
Browse files

Revert "HotSpot learning after initialize activated"

This reverts commit bcc5e2aa.

Change-Id: I8974b3c1493d44258fe98e5e691582425bdd2e8f
parent b75830bf
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -7833,19 +7833,16 @@
    <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 Wi-Fi hotspot at the First Use</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>
    <string name="turn_off_wifi_dialog_title">Turn off Wi-Fi</string>
    <string name="turn_off_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="learn_usb_dialog_title">USB tethering is activated</string>
    <string name="learn_usb_dialog_title">First Time Notification Use</string>
    <string name="learn_usb_dialog_text">Would you like to learn more about USB Tethering on your phone?</string>
    <string name="mobile_tether_help_dialog_title">Mobile HotSpot Help</string>
    <string name="mobile_usb_help_dialog_text">You can tether your Android device to your computer with a USB cable, to share your device\'s Internet connection with your computer. \n\n1. USB tethering works with Windows Vista, Windows 7, and Linux, the USB drivers for tethering may be needed.\n\n2. If your device has an SD card or USB storage, you can\'t mount it on your computer when USB tethered</string>
    <string name="mobile_hotspot_help_dialog_title">Mobile HotSpot Help</string>
    <string name="mobile_hotspot_help_dialog_text">You can turn your Android device into a portable Wi-Fi hotspot, to share your Android device\'s Internet connection with one or more computers or other devices. \n\n1.When your device is serving as a Wi-Fi hotspot, you can not use your device\'s applications to access the Internet via its Wi-Fi connection (but of course you remain connected to the Internet via your mobile data network). \n\n2.You configure the hotspot with the Wi-Fi hotspot settings</string>
    <string name="wifiap_mobile_hotspot_help">Status</string>
    <string name="dialog_font_warining_title">Information</string>
@@ -7864,8 +7861,6 @@
    <string name="ssid_broadcast_dialog_title">Your HotSpot is not visible now</string>
    <string name="ssid_broadcast_dialog_text">If you switch the Broadcast Network Name (SSID) option off, your phone will not be visible to other devices and will not appear in the list of available Wi-Fi networks. Other devices can still connect to your HotSpot by entering its network name manually.</string>
    <string name="learn_hotspot_dialog_title">Wi-Fi tethering is activated</string>
    <string name="learn_hotspot_dialog_text">Would you like to learn more about wifi Tethering on your phone?</string>
    <!-- Used as title on the automatic storage manager settings. [CHAR LIMIT=60] -->
    <string name="automatic_storage_manager_settings">Manage storage</string>
+20 −15
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ public class TetherSettings extends RestrictedSettingsFragment
    private boolean mUsbEnable = false;
    private WifiManager mWifiStatusManager;
    private boolean mIsWifiEnabled = false;
    private boolean mHaveWifiApConfig = false;

    @Override
    protected int getMetricsCategory() {
@@ -282,6 +283,24 @@ public class TetherSettings extends RestrictedSettingsFragment
                Context.WIFI_SERVICE);
    }

    @Override
    public void onResume() {
        super.onResume();
        if(mWifiManager != null) {
            WifiConfiguration config = mWifiManager.getWifiApConfiguration();
            boolean isNotNoneSecurity = config.getAuthType() > WifiConfiguration.KeyMgmt.NONE;
            // WifiConfiguration.KeyMgmt be used to management schemes,
            // WifiConfiguration.preSharedKey for use with WPA-PSK, it's password,
            // if preSharedKey is empty, the WifiConfiguration need to set password.
            if(isNotNoneSecurity) {
                mHaveWifiApConfig = config.preSharedKey != null &&
                    !config.preSharedKey.isEmpty();
            } else {
                mHaveWifiApConfig = true;
            }
        }
    }

    @Override
    public void onDestroy() {
        mDataSaverBackend.remListener(this);
@@ -609,20 +628,6 @@ public class TetherSettings extends RestrictedSettingsFragment
                == TelephonyManager.SIM_STATE_READY);
    }

    private boolean checkWifiApConfig() {
        WifiConfiguration config = mWifiManager.getWifiApConfiguration();
        boolean isNotNoneSecurity = config.getAuthType() > WifiConfiguration.KeyMgmt.NONE;
        // WifiConfiguration.KeyMgmt be used to management schemes,
        // WifiConfiguration.preSharedKey for use with WPA-PSK, it's password,
        // if preSharedKey is empty, the WifiConfiguration need to set password.
        if(isNotNoneSecurity) {
            return config.preSharedKey != null &&
                !config.preSharedKey.isEmpty();
        } else {
            return true;
        }
    }

    @Override
    public boolean onPreferenceChange(Preference preference, Object value) {
        boolean enable = (Boolean) value;
@@ -633,7 +638,7 @@ public class TetherSettings extends RestrictedSettingsFragment
                ((HotspotPreference)preference).setChecked(false);
                return false;
            } else if(enableWifiApSettingsExt &&
                (isNeedShowHelp(getPrefContext()) || !checkWifiApConfig())) {
                (isNeedShowHelp(getPrefContext()) || !mHaveWifiApConfig)) {
                Intent intent = new Intent();
                intent.setAction(ACTION_HOTSPOT_PRE_CONFIGURE);
                intent.setPackage("com.qualcomm.qti.extsettings");
+2 −57
Original line number Diff line number Diff line
@@ -16,14 +16,10 @@

package com.android.settings.wifi;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.DialogInterface;
import android.net.ConnectivityManager;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
@@ -32,12 +28,10 @@ import android.os.UserHandle;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import com.android.settings.HotspotPreference;
import com.android.settings.TetherSettings;
import com.android.settings.R;
import com.android.settings.datausage.DataSaverBackend;
import com.android.settingslib.TetherUtil;
import android.app.AlertDialog;
import android.app.Dialog;

import java.util.ArrayList;

public class WifiApEnabler {
@@ -54,8 +48,6 @@ public class WifiApEnabler {
    private boolean mEnabling = false;
    private static final String ACTION_HOTSPOT_POST_CONFIGURE = "Hotspot_PostConfigure";
    private static final String ACTION_EXTRA = "choice";
    private static final String KEY_FIRST_HOTSPOT_ACTIVATED = "FirstHotspotActivated";
    private static final String MY_PREF_FILE = "MY_PERFS";
    public static final int TETHERING_WIFI      = 0;

    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@@ -172,52 +164,6 @@ public class WifiApEnabler {
        }
    }

    private void showWifiTetheringLearning(final Context ctx) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
        builder.setTitle(ctx.getResources().getString(R.string.mobile_hotspot_help_dialog_title));
        builder.setMessage(ctx.getResources().getString(R.string.mobile_hotspot_help_dialog_text));
        builder.setPositiveButton(ctx.getResources().getString(R.string.yes), null);
        builder.setCancelable(false);
        builder.show();
    }


    private void showWifiTetheringActivatedDialog(final Context ctx) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
        builder.setTitle(ctx.getResources().getString(R.string.learn_hotspot_dialog_title));
        builder.setMessage(ctx.getResources().getString(R.string.learn_hotspot_dialog_text));
        builder.setPositiveButton(ctx.getResources().getString(R.string.yes),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        showWifiTetheringLearning(ctx);
                    }
                });
        builder.setNegativeButton(ctx.getResources().getString(R.string.skip_label), null);
        builder.setCancelable(false);
        builder.show();
    }

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

    private void showActivatedDialog(final Context ctx) {
        if (ctx.getResources().getBoolean(R.bool.config_hotspot_need_show_activated_dialog)
                && isNeedShowActivated(ctx)) {
            showWifiTetheringActivatedDialog(ctx);
        }
    }

    private void handleWifiApStateChanged(int state, int reason) {
        boolean enableWifiApSettingsExt = mContext.getResources().getBoolean(
                R.bool.show_wifi_hotspot_settings);
@@ -237,7 +183,6 @@ public class WifiApEnabler {
                    hSwitch.setChecked(true);
                    /* Doesnt need the airplane check */
                    hSwitch.setEnabled(!mDataSaverBackend.isDataSaverEnabled());
                    showActivatedDialog(mContext);
                    break;
                case WifiManager.WIFI_AP_STATE_DISABLING:
                    hSwitch.setSummary(R.string.wifi_tether_stopping);