Pierre Imai | 55618be | 2016-02-19 15:25:54 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.net.metrics; |
| 18 | |
Hugo Benichi | 4b6dfc2 | 2016-04-15 12:15:47 +0900 | [diff] [blame] | 19 | import android.annotation.SystemApi; |
Pierre Imai | 55618be | 2016-02-19 15:25:54 +0900 | [diff] [blame] | 20 | import android.os.Parcel; |
| 21 | import android.os.Parcelable; |
| 22 | |
Pierre Imai | bc9cc50 | 2016-03-29 14:50:51 +0900 | [diff] [blame] | 23 | /** |
| 24 | * {@hide} |
| 25 | */ |
Hugo Benichi | 4b6dfc2 | 2016-04-15 12:15:47 +0900 | [diff] [blame] | 26 | @SystemApi |
Hugo Benichi | 627b424 | 2016-04-15 16:56:28 +0900 | [diff] [blame] | 27 | public final class CaptivePortalStateChangeEvent extends IpConnectivityEvent implements Parcelable { |
| 28 | public static final int NETWORK_MONITOR_CONNECTED = 0; |
Pierre Imai | 55618be | 2016-02-19 15:25:54 +0900 | [diff] [blame] | 29 | public static final int NETWORK_MONITOR_DISCONNECTED = 1; |
Hugo Benichi | 627b424 | 2016-04-15 16:56:28 +0900 | [diff] [blame] | 30 | public static final int NETWORK_MONITOR_VALIDATED = 2; |
| 31 | |
| 32 | public final int state; |
Pierre Imai | 55618be | 2016-02-19 15:25:54 +0900 | [diff] [blame] | 33 | |
| 34 | public CaptivePortalStateChangeEvent(int state) { |
Hugo Benichi | 627b424 | 2016-04-15 16:56:28 +0900 | [diff] [blame] | 35 | this.state = state; |
Pierre Imai | 55618be | 2016-02-19 15:25:54 +0900 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | public CaptivePortalStateChangeEvent(Parcel in) { |
Hugo Benichi | 627b424 | 2016-04-15 16:56:28 +0900 | [diff] [blame] | 39 | state = in.readInt(); |
Pierre Imai | 55618be | 2016-02-19 15:25:54 +0900 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | public void writeToParcel(Parcel out, int flags) { |
Hugo Benichi | 627b424 | 2016-04-15 16:56:28 +0900 | [diff] [blame] | 43 | out.writeInt(state); |
| 44 | } |
| 45 | |
| 46 | public int describeContents() { |
| 47 | return 0; |
Pierre Imai | 55618be | 2016-02-19 15:25:54 +0900 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | public static final Parcelable.Creator<CaptivePortalStateChangeEvent> CREATOR |
| 51 | = new Parcelable.Creator<CaptivePortalStateChangeEvent>() { |
| 52 | public CaptivePortalStateChangeEvent createFromParcel(Parcel in) { |
| 53 | return new CaptivePortalStateChangeEvent(in); |
| 54 | } |
| 55 | |
| 56 | public CaptivePortalStateChangeEvent[] newArray(int size) { |
| 57 | return new CaptivePortalStateChangeEvent[size]; |
| 58 | } |
| 59 | }; |
| 60 | |
| 61 | public static void logEvent(int state) { |
Hugo Benichi | 627b424 | 2016-04-15 16:56:28 +0900 | [diff] [blame] | 62 | logEvent(IPCE_NETMON_STATE_CHANGE, new CaptivePortalStateChangeEvent(state)); |
Pierre Imai | 55618be | 2016-02-19 15:25:54 +0900 | [diff] [blame] | 63 | } |
| 64 | }; |