summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorRemi NGUYEN VAN <reminv@google.com>2018-05-22 09:58:19 +0900
committerRemi NGUYEN VAN <reminv@google.com>2018-05-24 12:04:27 +0900
commitd57329d8537add164833a58af436d1d059b08fab (patch)
treec763fc2eaedf86621793f202733a2fdc4347a811 /core/java/android
parent6fa8d06c78d21d455015e19691d5d6f2e6bd258b (diff)
Move CaptivePortalProbeResult to its own file
This is necessary to resolve visibility issues for the next change. Bug: b/79499239 Test: runtest frameworks-net Merged-In: Ia48b32307a51a66f2672d7112f71166dd6db41b1 Merged-In: I5df7ee9f16bc6be4f02353d40a843a383dd4cbd9 (Clean cherry-pick of pi-dev I50bc96afe6ae88c8f58a693f0a4e821f1f9b3299) Change-Id: I3c416c1a91ebfdf914fd528ff8ab73e3eb490562
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/net/captiveportal/CaptivePortalProbeResult.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/core/java/android/net/captiveportal/CaptivePortalProbeResult.java b/core/java/android/net/captiveportal/CaptivePortalProbeResult.java
new file mode 100644
index 000000000000..614c0b8dd17f
--- /dev/null
+++ b/core/java/android/net/captiveportal/CaptivePortalProbeResult.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.captiveportal;
+
+/**
+ * Result of calling isCaptivePortal().
+ * @hide
+ */
+public final class CaptivePortalProbeResult {
+ public static final int SUCCESS_CODE = 204;
+ public static final int FAILED_CODE = 599;
+
+ public static final CaptivePortalProbeResult FAILED = new CaptivePortalProbeResult(FAILED_CODE);
+ public static final CaptivePortalProbeResult SUCCESS =
+ new CaptivePortalProbeResult(SUCCESS_CODE);
+
+ private final int mHttpResponseCode; // HTTP response code returned from Internet probe.
+ public final String redirectUrl; // Redirect destination returned from Internet probe.
+ public final String detectUrl; // URL where a 204 response code indicates
+ // captive portal has been appeased.
+
+ public CaptivePortalProbeResult(int httpResponseCode) {
+ this(httpResponseCode, null, null);
+ }
+
+ public CaptivePortalProbeResult(int httpResponseCode, String redirectUrl, String detectUrl) {
+ mHttpResponseCode = httpResponseCode;
+ this.redirectUrl = redirectUrl;
+ this.detectUrl = detectUrl;
+ }
+
+ public boolean isSuccessful() {
+ return mHttpResponseCode == SUCCESS_CODE;
+ }
+
+ public boolean isPortal() {
+ return !isSuccessful() && (mHttpResponseCode >= 200) && (mHttpResponseCode <= 399);
+ }
+
+ public boolean isFailed() {
+ return !isSuccessful() && !isPortal();
+ }
+}