summaryrefslogtreecommitdiffstats
path: root/packages/CaptivePortalLogin/src
diff options
context:
space:
mode:
authorcretin45 <cretin45@gmail.com>2015-02-19 12:50:15 -0800
committerSteve Kondik <steve@cyngn.com>2015-10-26 16:09:11 -0700
commitdf9b55b5ae330020563a98d55a4ad55fee430958 (patch)
tree3f1d4ce6c311ca11396dfa8a53699c1be80b0ad4 /packages/CaptivePortalLogin/src
parent8056a919eceea9fe51601530023147e42da37c31 (diff)
downloadframeworks_base-df9b55b5ae330020563a98d55a4ad55fee430958.zip
frameworks_base-df9b55b5ae330020563a98d55a4ad55fee430958.tar.gz
frameworks_base-df9b55b5ae330020563a98d55a4ad55fee430958.tar.bz2
CaptivePortalLogin: Add functionality for SetupWizard
Change-Id: I9ccb7ee5e8882acfaa6afc5cd9efa9211058ed60
Diffstat (limited to 'packages/CaptivePortalLogin/src')
-rw-r--r--packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
index 0fe5509..ba77891 100644
--- a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
+++ b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
@@ -22,6 +22,7 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.CaptivePortal;
+import android.graphics.drawable.ColorDrawable;
import android.net.ConnectivityManager;
import android.net.ConnectivityManager.NetworkCallback;
import android.net.Network;
@@ -32,6 +33,7 @@ import android.net.Uri;
import android.net.http.SslError;
import android.os.Bundle;
import android.provider.Settings;
+import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
import android.util.TypedValue;
@@ -57,6 +59,10 @@ import java.util.Random;
public class CaptivePortalLoginActivity extends Activity {
private static final String TAG = "CaptivePortalLogin";
private static final String DEFAULT_SERVER = "connectivitycheck.gstatic.com";
+
+ private static final String EXTRA_STATUS_BAR_COLOR = "status_bar_color";
+ private static final String EXTRA_ACTION_BAR_COLOR = "action_bar_color";
+
private static final int SOCKET_TIMEOUT_MS = 10000;
private enum Result { DISMISSED, UNWANTED, WANTED_AS_IS };
@@ -81,11 +87,26 @@ public class CaptivePortalLoginActivity extends Activity {
} catch (MalformedURLException e) {
// System misconfigured, bail out in a way that at least provides network access.
Log.e(TAG, "Invalid captive portal URL, server=" + server);
+ setResult(Activity.RESULT_CANCELED);
done(Result.WANTED_AS_IS);
}
mNetwork = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_NETWORK);
mCaptivePortal = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL);
+ final Intent intent = getIntent();
+ if (intent.hasExtra(EXTRA_STATUS_BAR_COLOR)) {
+ int color = intent.getIntExtra(EXTRA_STATUS_BAR_COLOR, -1);
+ if (color != -1) {
+ getWindow().setStatusBarColor(color);
+ }
+ }
+ if (intent.hasExtra(EXTRA_ACTION_BAR_COLOR)) {
+ int color = intent.getIntExtra(EXTRA_ACTION_BAR_COLOR, -1);
+ if (color != -1) {
+ getActionBar().setBackgroundDrawable(new ColorDrawable(color));
+ }
+ }
+
// Also initializes proxy system properties.
mCm.bindProcessToNetwork(mNetwork);
@@ -165,6 +186,7 @@ public class CaptivePortalLoginActivity extends Activity {
mCaptivePortal.useNetwork();
break;
}
+ setResult(Activity.RESULT_OK);
finish();
}
@@ -298,6 +320,11 @@ public class CaptivePortalLoginActivity extends Activity {
} else if (mPagesLoaded == 2) {
// Prevent going back to empty first page.
view.clearHistory();
+ } else {
+ if (TextUtils.isEmpty(view.getUrl()) || view.getUrl().contains("text/html")) {
+ setResult(Activity.RESULT_CANCELED);
+ finish();
+ }
}
testForCaptivePortal();
}