This CL includes the new Java API that supports async network scans.
Applications could get faster network scan results with this new API.
The long-term goal is to support Subsecond Switching which is separate
from what this CL is doing.
Bug: 30954762
Test: Unit test, run runtest -x NetworkScanRequestTest.java
Change-Id: I78cadaf838dee8439fe7417ef39f689990bf5705
(cherry picked from commit fdfb6f4d2f)
130 lines
3.7 KiB
Java
130 lines
3.7 KiB
Java
/*
|
|
* 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 android.telephony;
|
|
|
|
import android.os.Parcel;
|
|
import android.os.Parcelable;
|
|
|
|
import java.util.Arrays;
|
|
|
|
/**
|
|
* Describes a particular radio access network to be scanned.
|
|
*
|
|
* The scan can be performed on either bands or channels for a specific radio access network type.
|
|
* @hide
|
|
*/
|
|
public final class RadioAccessSpecifier implements Parcelable {
|
|
|
|
/**
|
|
* The radio access network that needs to be scanned
|
|
*
|
|
* See {@link RadioNetworkConstants.RadioAccessNetworks} for details.
|
|
*/
|
|
public int radioAccessNetwork;
|
|
|
|
/**
|
|
* The frequency bands that need to be scanned
|
|
*
|
|
* bands must be used together with radioAccessNetwork
|
|
*
|
|
* See {@link RadioNetworkConstants} for details.
|
|
*/
|
|
public int[] bands;
|
|
|
|
/**
|
|
* The frequency channels that need to be scanned
|
|
*
|
|
* channels must be used together with radioAccessNetwork
|
|
*
|
|
* See {@link RadioNetworkConstants.RadioAccessNetworks} for details.
|
|
*/
|
|
public int[] channels;
|
|
|
|
/**
|
|
* Creates a new RadioAccessSpecifier with radio network, bands and channels
|
|
*
|
|
* The user must specify the radio network type, and at least specify either of frequency
|
|
* bands or channels.
|
|
*
|
|
* @param ran The type of the radio access network
|
|
* @param bands the frequency bands to be scanned
|
|
* @param channels the frequency bands to be scanned
|
|
*/
|
|
public RadioAccessSpecifier(int ran, int[] bands, int[] channels) {
|
|
this.radioAccessNetwork = ran;
|
|
this.bands = bands;
|
|
this.channels = channels;
|
|
}
|
|
|
|
public static final Parcelable.Creator<RadioAccessSpecifier> CREATOR =
|
|
new Parcelable.Creator<RadioAccessSpecifier> (){
|
|
@Override
|
|
public RadioAccessSpecifier createFromParcel(Parcel in) {
|
|
return new RadioAccessSpecifier(in);
|
|
}
|
|
|
|
@Override
|
|
public RadioAccessSpecifier[] newArray(int size) {
|
|
return new RadioAccessSpecifier[size];
|
|
}
|
|
};
|
|
|
|
@Override
|
|
public int describeContents() {
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
public void writeToParcel(Parcel dest, int flags) {
|
|
dest.writeInt(radioAccessNetwork);
|
|
dest.writeIntArray(bands);
|
|
dest.writeIntArray(channels);
|
|
}
|
|
|
|
private RadioAccessSpecifier(Parcel in) {
|
|
radioAccessNetwork = in.readInt();
|
|
bands = in.createIntArray();
|
|
channels = in.createIntArray();
|
|
}
|
|
|
|
@Override
|
|
public boolean equals (Object o) {
|
|
RadioAccessSpecifier ras;
|
|
|
|
try {
|
|
ras = (RadioAccessSpecifier) o;
|
|
} catch (ClassCastException ex) {
|
|
return false;
|
|
}
|
|
|
|
if (o == null) {
|
|
return false;
|
|
}
|
|
|
|
return (radioAccessNetwork == ras.radioAccessNetwork
|
|
&& Arrays.equals(bands, ras.bands)
|
|
&& Arrays.equals(channels, ras.channels));
|
|
}
|
|
|
|
@Override
|
|
public int hashCode () {
|
|
return ((radioAccessNetwork * 31)
|
|
+ (Arrays.hashCode(bands) * 37)
|
|
+ (Arrays.hashCode(channels)) * 39);
|
|
}
|
|
}
|