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

Commit 07921b72 authored by Yue Liang's avatar Yue Liang Committed by Gerrit - the friendly Code Review server
Browse files

Fix HotSpot first-use-help bug.

Rootcause:
When pop-up dialog for wizards user setup AP, if user click CANCEL,
HotSpot preference will display error.

Logic:
Above situation, shell be pop-up again, until user setup AP as successful or leave.

Change-Id: I4cf00df1fa0abb42d66f21d1aa57612ad5e23369
CRs-Fixed: 1070422
parent 6ef072e3
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -96,6 +96,8 @@ public class TetherSettings extends RestrictedSettingsFragment
    private static final String ACTION_HOTSPOT_CONFIGURE_RRSPONSE =
            "Hotspot_PreConfigure_Response";

    private static final String INTENT_EXTRA_NEED_SHOW_HELP_LATER = "needShowHelpLater";

    private static final int DIALOG_AP_SETTINGS = 1;

    private static final String TAG = "TetheringSettings";
@@ -155,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() {
@@ -280,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);
@@ -616,10 +637,12 @@ public class TetherSettings extends RestrictedSettingsFragment
            if(enableWifiApSettingsExt && showNoSimCardDialog(getPrefContext())) {
                ((HotspotPreference)preference).setChecked(false);
                return false;
            } else if(enableWifiApSettingsExt && isNeedShowHelp(getPrefContext())) {
            } else if(enableWifiApSettingsExt &&
                (isNeedShowHelp(getPrefContext()) || !mHaveWifiApConfig)) {
                Intent intent = new Intent();
                intent.setAction(ACTION_HOTSPOT_PRE_CONFIGURE);
                intent.setPackage("com.qualcomm.qti.extsettings");
                intent.putExtra(INTENT_EXTRA_NEED_SHOW_HELP_LATER, true);
                getPrefContext().startActivity(intent);
                ((HotspotPreference)preference).setChecked(false);
                return false;