summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrandon McAnsh <brandon.mcansh@gmail.com>2015-06-27 16:41:39 -0400
committerBrandon McAnsh <brandon.mcansh@gmail.com>2015-07-13 13:52:21 -0400
commiteff742708f953bf9d732fd3c709a254576ad9177 (patch)
tree1f5c5594acc1567293b4b7f97b18336bbaa9cfb1 /src
parent79f63d23c1ada28d3d3d5fe48714d0c12f19b16a (diff)
downloadpackages_apps_SetupWizard-eff742708f953bf9d732fd3c709a254576ad9177.zip
packages_apps_SetupWizard-eff742708f953bf9d732fd3c709a254576ad9177.tar.gz
packages_apps_SetupWizard-eff742708f953bf9d732fd3c709a254576ad9177.tar.bz2
WifiSetup: Pass the correct componentName and data for captivePortal
* CaptivePortal expects the networkid, which was not being passed on via the intent * Also use the correct componentName to bring up the sign in page Change-Id: I83d80dc3ec026d7a5a5d4b8bf4cf577214a13da4 Signed-off-by: Brandon McAnsh <brandon.mcansh@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java b/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java
index 63a9a0e..49385b9 100644
--- a/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java
@@ -19,9 +19,11 @@ package com.cyanogenmod.setupwizard.setup;
import android.app.Activity;
import android.app.ActivityOptions;
import android.app.FragmentManager;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
+import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings;
@@ -38,6 +40,7 @@ import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Random;
public class WifiSetupPage extends SetupPage {
@@ -46,9 +49,6 @@ public class WifiSetupPage extends SetupPage {
private static final String DEFAULT_SERVER = "clients3.google.com";
private static final int CAPTIVE_PORTAL_SOCKET_TIMEOUT_MS = 10000;
- private static final String CAPTIVE_PORTAL_LOGIN_ACTION
- = "android.net.action.captive_portal_login";
-
private LoadingFragment mLoadingFragment;
private URL mCaptivePortalUrl;
@@ -57,6 +57,8 @@ public class WifiSetupPage extends SetupPage {
private final Handler mHandler = new Handler();
+ private String mResponseToken;
+
private Runnable mFinishCaptivePortalCheckRunnable = new Runnable() {
@Override
public void run() {
@@ -64,7 +66,12 @@ public class WifiSetupPage extends SetupPage {
try {
int netId = ConnectivityManager.from(mContext)
.getNetworkForType(ConnectivityManager.TYPE_WIFI).netId;
- Intent intent = new Intent(CAPTIVE_PORTAL_LOGIN_ACTION);
+ mResponseToken = String.valueOf(new Random().nextLong());
+ Intent intent = new Intent();
+ intent.setData(Uri.fromParts("netid", Integer.toString(netId),
+ mResponseToken));
+ intent.setComponent(new ComponentName("com.android.captiveportallogin",
+ "com.android.captiveportallogin.CaptivePortalLoginActivity"));
intent.putExtra(Intent.EXTRA_TEXT, String.valueOf(netId));
intent.putExtra("status_bar_color",
mContext.getResources().getColor(R.color.primary_dark));
@@ -163,16 +170,24 @@ public class WifiSetupPage extends SetupPage {
getCallbacks().onNextPage();
}
} else if (requestCode == SetupWizardApp.REQUEST_CODE_SETUP_CAPTIVE_PORTAL) {
- if (resultCode == Activity.RESULT_CANCELED) {
+ String token = data.getStringExtra("response_token");
+ if (token != null && !token.equals(mResponseToken)) {
SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
SetupStats.Action.EXTERNAL_PAGE_RESULT,
- SetupStats.Label.CAPTIVE_PORTAL_LOGIN, "canceled");
+ SetupStats.Label.CAPTIVE_PORTAL_LOGIN, "token_mismatch");
launchWifiSetup();
} else {
- SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
- SetupStats.Action.EXTERNAL_PAGE_RESULT,
- SetupStats.Label.CAPTIVE_PORTAL_LOGIN, "success");
- getCallbacks().onNextPage();
+ if (resultCode == Activity.RESULT_CANCELED) {
+ SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
+ SetupStats.Action.EXTERNAL_PAGE_RESULT,
+ SetupStats.Label.CAPTIVE_PORTAL_LOGIN, "canceled");
+ launchWifiSetup();
+ } else {
+ SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
+ SetupStats.Action.EXTERNAL_PAGE_RESULT,
+ SetupStats.Label.CAPTIVE_PORTAL_LOGIN, "success");
+ getCallbacks().onNextPage();
+ }
}
} else {
return false;