summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ying Xu <yinxu@google.com> 2017-05-16 23:04:39 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2017-05-16 23:04:42 +0000
commit0727abc423bb8ff265534f54daa4df9df7b61ee3 (patch)
tree4b92bc250f258170d05fbf0cdc9786c4a3f5bcdc
parent11780f1ad3f831d36655723ab07c28db821c3fe1 (diff)
parent84c9e01f10bd5987bd9a401db9e0d46400f88540 (diff)
Merge "Add the new RIL requests and NetworkScanResult."
-rw-r--r--telephony/java/com/android/internal/telephony/NetworkScanResult.java129
-rw-r--r--telephony/java/com/android/internal/telephony/RILConstants.java3
2 files changed, 132 insertions, 0 deletions
diff --git a/telephony/java/com/android/internal/telephony/NetworkScanResult.java b/telephony/java/com/android/internal/telephony/NetworkScanResult.java
new file mode 100644
index 000000000000..0099961190e1
--- /dev/null
+++ b/telephony/java/com/android/internal/telephony/NetworkScanResult.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2017 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 com.android.internal.telephony;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.telephony.CellInfo;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Defines the incremental network scan result.
+ *
+ * This class contains the network scan results. When the user starts a new scan, multiple
+ * NetworkScanResult may be returned, containing either the scan result or error. When the user
+ * stops an ongoing scan, only one NetworkScanResult will be returned to indicate either the scan
+ * is now complete or there is some error stopping it.
+ * @hide
+ */
+public final class NetworkScanResult implements Parcelable {
+
+ // Contains only part of the scan result and more are coming.
+ public static final int SCAN_STATUS_PARTIAL = 0;
+
+ // Contains the last part of the scan result and the scan is now complete.
+ public static final int SCAN_STATUS_COMPLETE = 1;
+
+ // The status of the scan, only valid when scanError = SUCCESS.
+ public int scanStatus;
+
+ /**
+ * The error code of the scan
+ *
+ * This is the error code returned from the RIL, see {@link RILConstants} for more details
+ */
+ public int scanError;
+
+ // The scan results, only valid when scanError = SUCCESS.
+ public List<CellInfo> networkInfos;
+
+ /**
+ * Creates a new NetworkScanResult with scanStatus, scanError and networkInfos
+ *
+ * @param scanStatus The status of the scan.
+ * @param scanError The error code of the scan.
+ * @param networkInfos List of the CellInfo.
+ */
+ public NetworkScanResult(int scanStatus, int scanError, List<CellInfo> networkInfos) {
+ this.scanStatus = scanStatus;
+ this.scanError = scanError;
+ this.networkInfos = networkInfos;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(scanStatus);
+ dest.writeInt(scanError);
+ CellInfo[] ci = networkInfos.toArray(new CellInfo[networkInfos.size()]);
+ dest.writeParcelableArray(ci, flags);
+ }
+
+ private NetworkScanResult(Parcel in) {
+ scanStatus = in.readInt();
+ scanError = in.readInt();
+ CellInfo[] ci = (CellInfo[]) in.readParcelableArray(
+ Object.class.getClassLoader(),
+ CellInfo.class);
+ networkInfos = Arrays.asList(ci);
+ }
+
+ @Override
+ public boolean equals (Object o) {
+ NetworkScanResult nsr;
+
+ try {
+ nsr = (NetworkScanResult) o;
+ } catch (ClassCastException ex) {
+ return false;
+ }
+
+ if (o == null) {
+ return false;
+ }
+
+ return (scanStatus == nsr.scanStatus
+ && scanError == nsr.scanError
+ && networkInfos.equals(nsr.networkInfos));
+ }
+
+ @Override
+ public int hashCode () {
+ return ((scanStatus * 31)
+ + (scanError * 23)
+ + (networkInfos.hashCode() * 37));
+ }
+
+ public static final Creator<NetworkScanResult> CREATOR =
+ new Creator<NetworkScanResult>() {
+ @Override
+ public NetworkScanResult createFromParcel(Parcel in) {
+ return new NetworkScanResult(in);
+ }
+
+ @Override
+ public NetworkScanResult[] newArray(int size) {
+ return new NetworkScanResult[size];
+ }
+ };
+}
diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java
index e50901f7eadc..e2d25b8e352c 100644
--- a/telephony/java/com/android/internal/telephony/RILConstants.java
+++ b/telephony/java/com/android/internal/telephony/RILConstants.java
@@ -415,6 +415,8 @@ cat include/telephony/ril.h | \
int RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER = 139;
int RIL_REQUEST_SET_SIM_CARD_POWER = 140;
int RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION = 141;
+ int RIL_REQUEST_START_NETWORK_SCAN = 142;
+ int RIL_REQUEST_STOP_NETWORK_SCAN = 143;
int RIL_RESPONSE_ACKNOWLEDGEMENT = 800;
@@ -468,4 +470,5 @@ cat include/telephony/ril.h | \
int RIL_UNSOL_PCO_DATA = 1046;
int RIL_UNSOL_MODEM_RESTART = 1047;
int RIL_UNSOL_CARRIER_INFO_IMSI_ENCRYPTION = 1048;
+ int RIL_UNSOL_NETWORK_SCAN_RESULT = 1049;
}