• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 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 com.android.internal.telephony.dataconnection;
18 
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 
22 /**
23  * This class serves to pass around the parameters of Keepalive session
24  * status within the telephony framework.
25  *
26  * {@hide}
27  */
28 public class KeepaliveStatus implements Parcelable {
29     private static final String LOG_TAG = "KeepaliveStatus";
30 
31     /** This should match the HAL Radio::1_1::KeepaliveStatusCode */
32     public static final int STATUS_ACTIVE = 0;
33     public static final int STATUS_INACTIVE = 1;
34     public static final int STATUS_PENDING = 2;
35 
36     public static final int ERROR_NONE = 0;
37     public static final int ERROR_UNSUPPORTED = 1;
38     public static final int ERROR_NO_RESOURCES = 2;
39     public static final int ERROR_UNKNOWN = 3;
40 
41     public static final int INVALID_HANDLE = Integer.MAX_VALUE;
42 
43     /** An opaque value that identifies this Keepalive status to the modem */
44     public final int sessionHandle;
45 
46     /**
47      * A status code indicating whether this Keepalive session is
48      * active, inactive, or pending activation
49      */
50     public final int statusCode;
51 
52     /** An error code indicating a lower layer failure, if any */
53     public final int errorCode;
54 
KeepaliveStatus(int error)55     public KeepaliveStatus(int error) {
56         sessionHandle = INVALID_HANDLE;
57         statusCode = STATUS_INACTIVE;
58         errorCode = error;
59     }
60 
KeepaliveStatus(int handle, int code)61     public KeepaliveStatus(int handle, int code) {
62         sessionHandle = handle;
63         statusCode = code;
64         errorCode = ERROR_NONE;
65     }
66 
67 
68     @Override
toString()69     public String toString() {
70         return String.format("{errorCode=%d, sessionHandle=%d, statusCode=%d}",
71                 errorCode, sessionHandle, statusCode);
72     }
73 
74     // Parcelable Implementation
75     @Override
describeContents()76     public int describeContents() {
77         return 0;
78     }
79 
80     @Override
writeToParcel(Parcel dest, int flags)81     public void writeToParcel(Parcel dest, int flags) {
82         dest.writeInt(errorCode);
83         dest.writeInt(sessionHandle);
84         dest.writeInt(statusCode);
85     }
86 
KeepaliveStatus(Parcel p)87     private KeepaliveStatus(Parcel p) {
88         errorCode = p.readInt();
89         sessionHandle = p.readInt();
90         statusCode = p.readInt();
91     }
92 
93     public static final Parcelable.Creator<KeepaliveStatus> CREATOR =
94             new Parcelable.Creator<KeepaliveStatus>() {
95                 @Override
96                 public KeepaliveStatus createFromParcel(Parcel source) {
97                     return new KeepaliveStatus(source);
98                 }
99 
100                 @Override
101                 public KeepaliveStatus[] newArray(int size) {
102                     return new KeepaliveStatus[size];
103                 }
104             };
105 }
106