1/* 2 * Copyright (C) 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 17package android.telephony; 18 19import android.os.Parcel; 20import android.os.Parcelable; 21 22import java.util.Arrays; 23 24/** 25 * Defines a request to peform a network scan. 26 * 27 * This class defines whether the network scan will be performed only once or periodically until 28 * cancelled, when the scan is performed periodically, the time interval is not controlled by the 29 * user but defined by the modem vendor. 30 * @hide 31 */ 32public final class NetworkScanRequest implements Parcelable { 33 34 // Below size limits for RAN/Band/Channel are for pre-treble modems and will be removed later. 35 /** @hide */ 36 public static final int MAX_RADIO_ACCESS_NETWORKS = 8; 37 /** @hide */ 38 public static final int MAX_BANDS = 8; 39 /** @hide */ 40 public static final int MAX_CHANNELS = 32; 41 42 /** Performs the scan only once */ 43 public static final int SCAN_TYPE_ONE_SHOT = 0; 44 /** 45 * Performs the scan periodically until cancelled 46 * 47 * The modem will start new scans periodically, and the interval between two scans is usually 48 * multiple minutes. 49 * */ 50 public static final int SCAN_TYPE_PERIODIC = 1; 51 52 /** Defines the type of the scan. */ 53 public int scanType; 54 55 /** Describes the radio access technologies with bands or channels that need to be scanned. */ 56 public RadioAccessSpecifier[] specifiers; 57 58 /** 59 * Creates a new NetworkScanRequest with scanType and network specifiers 60 * 61 * @param scanType The type of the scan 62 * @param specifiers the radio network with bands / channels to be scanned 63 */ 64 public NetworkScanRequest(int scanType, RadioAccessSpecifier[] specifiers) { 65 this.scanType = scanType; 66 this.specifiers = specifiers; 67 } 68 69 @Override 70 public int describeContents() { 71 return 0; 72 } 73 74 @Override 75 public void writeToParcel(Parcel dest, int flags) { 76 dest.writeInt(scanType); 77 dest.writeParcelableArray(specifiers, flags); 78 } 79 80 private NetworkScanRequest(Parcel in) { 81 scanType = in.readInt(); 82 specifiers = (RadioAccessSpecifier[]) in.readParcelableArray( 83 Object.class.getClassLoader(), 84 RadioAccessSpecifier.class); 85 } 86 87 @Override 88 public boolean equals (Object o) { 89 NetworkScanRequest nsr; 90 91 try { 92 nsr = (NetworkScanRequest) o; 93 } catch (ClassCastException ex) { 94 return false; 95 } 96 97 if (o == null) { 98 return false; 99 } 100 101 return (scanType == nsr.scanType 102 && Arrays.equals(specifiers, nsr.specifiers)); 103 } 104 105 @Override 106 public int hashCode () { 107 return ((scanType * 31) 108 + (Arrays.hashCode(specifiers)) * 37); 109 } 110 111 public static final Creator<NetworkScanRequest> CREATOR = 112 new Creator<NetworkScanRequest>() { 113 @Override 114 public NetworkScanRequest createFromParcel(Parcel in) { 115 return new NetworkScanRequest(in); 116 } 117 118 @Override 119 public NetworkScanRequest[] newArray(int size) { 120 return new NetworkScanRequest[size]; 121 } 122 }; 123} 124