Loading telephony/java/android/telephony/NetworkScan.java 0 → 100644 +83 −0 Original line number Diff line number Diff line /* * 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.content.Context; import android.os.RemoteException; import android.os.ServiceManager; import android.util.Log; import com.android.internal.telephony.ITelephony; /** * Allows applications to request the system to perform a network scan. * * The caller of {@link #requestNetworkScan(NetworkScanRequest, NetworkScanCallback)} will * receive a NetworkScan which contains the callback method to stop the scan requested. * @hide */ public class NetworkScan { public static final String TAG = "NetworkScan"; public static final int SUCCESS = 0; public static final int ERROR_INVALID_SCAN = 1; public static final int ERROR_UNSUPPORTED = 2; public static final int ERROR_INTERRUPTED = 3; public static final int ERROR_CANCELLED = 4; private final int mScanId; private final int mSubId; /** * Stops the network scan * * This is the callback method to stop an ongoing scan. When user requests a new scan, * a NetworkScan object will be returned, and the user can stop the scan by calling this * method. */ public void stop() throws RemoteException { try { ITelephony telephony = getITelephony(); if (telephony != null) { telephony.stopNetworkScan(mSubId, mScanId); } else { throw new RemoteException("Failed to get the ITelephony instance."); } } catch (RemoteException ex) { Rlog.e(TAG, "stopNetworkScan RemoteException", ex); throw new RemoteException("Failed to stop the network scan with id " + mScanId); } } /** * Creates a new NetworkScan with scanId * * @param scanId The id of the scan * @param subId the id of the subscription * @hide */ public NetworkScan(int scanId, int subId) { mScanId = scanId; mSubId = subId; } private ITelephony getITelephony() { return ITelephony.Stub.asInterface( ServiceManager.getService(Context.TELEPHONY_SERVICE)); } } telephony/java/android/telephony/NetworkScanRequest.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * 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; parcelable NetworkScanRequest; telephony/java/android/telephony/NetworkScanRequest.java 0 → 100644 +115 −0 Original line number Diff line number Diff line /* * 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; /** * Defines a request to peform a network scan. * * This class defines whether the network scan will be performed only once or periodically until * cancelled, when the scan is performed periodically, the time interval is not controlled by the * user but defined by the modem vendor. * @hide */ public final class NetworkScanRequest implements Parcelable { /** Performs the scan only once */ public static final int SCAN_TYPE_ONE_SHOT = 0; /** * Performs the scan periodically until cancelled * * The modem will start new scans periodically, and the interval between two scans is usually * multiple minutes. * */ public static final int SCAN_TYPE_PERIODIC = 1; /** Defines the type of the scan. */ public int scanType; /** Describes the radio access technologies with bands or channels that need to be scanned. */ public RadioAccessSpecifier[] specifiers; /** * Creates a new NetworkScanRequest with scanType and network specifiers * * @param scanType The type of the scan * @param specifiers the radio network with bands / channels to be scanned */ public NetworkScanRequest(int scanType, RadioAccessSpecifier[] specifiers) { this.scanType = scanType; this.specifiers = specifiers; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(scanType); dest.writeParcelableArray(specifiers, flags); } private NetworkScanRequest(Parcel in) { scanType = in.readInt(); specifiers = (RadioAccessSpecifier[]) in.readParcelableArray( Object.class.getClassLoader(), RadioAccessSpecifier.class); } @Override public boolean equals (Object o) { NetworkScanRequest nsr; try { nsr = (NetworkScanRequest) o; } catch (ClassCastException ex) { return false; } if (o == null) { return false; } return (scanType == nsr.scanType && Arrays.equals(specifiers, nsr.specifiers)); } @Override public int hashCode () { return ((scanType * 31) + (Arrays.hashCode(specifiers)) * 37); } public static final Creator<NetworkScanRequest> CREATOR = new Creator<NetworkScanRequest>() { @Override public NetworkScanRequest createFromParcel(Parcel in) { return new NetworkScanRequest(in); } @Override public NetworkScanRequest[] newArray(int size) { return new NetworkScanRequest[size]; } }; } telephony/java/android/telephony/RadioAccessSpecifier.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * 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; parcelable RadioAccessSpecifier; telephony/java/android/telephony/RadioAccessSpecifier.java 0 → 100644 +129 −0 Original line number Diff line number Diff line /* * 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); } } Loading
telephony/java/android/telephony/NetworkScan.java 0 → 100644 +83 −0 Original line number Diff line number Diff line /* * 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.content.Context; import android.os.RemoteException; import android.os.ServiceManager; import android.util.Log; import com.android.internal.telephony.ITelephony; /** * Allows applications to request the system to perform a network scan. * * The caller of {@link #requestNetworkScan(NetworkScanRequest, NetworkScanCallback)} will * receive a NetworkScan which contains the callback method to stop the scan requested. * @hide */ public class NetworkScan { public static final String TAG = "NetworkScan"; public static final int SUCCESS = 0; public static final int ERROR_INVALID_SCAN = 1; public static final int ERROR_UNSUPPORTED = 2; public static final int ERROR_INTERRUPTED = 3; public static final int ERROR_CANCELLED = 4; private final int mScanId; private final int mSubId; /** * Stops the network scan * * This is the callback method to stop an ongoing scan. When user requests a new scan, * a NetworkScan object will be returned, and the user can stop the scan by calling this * method. */ public void stop() throws RemoteException { try { ITelephony telephony = getITelephony(); if (telephony != null) { telephony.stopNetworkScan(mSubId, mScanId); } else { throw new RemoteException("Failed to get the ITelephony instance."); } } catch (RemoteException ex) { Rlog.e(TAG, "stopNetworkScan RemoteException", ex); throw new RemoteException("Failed to stop the network scan with id " + mScanId); } } /** * Creates a new NetworkScan with scanId * * @param scanId The id of the scan * @param subId the id of the subscription * @hide */ public NetworkScan(int scanId, int subId) { mScanId = scanId; mSubId = subId; } private ITelephony getITelephony() { return ITelephony.Stub.asInterface( ServiceManager.getService(Context.TELEPHONY_SERVICE)); } }
telephony/java/android/telephony/NetworkScanRequest.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * 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; parcelable NetworkScanRequest;
telephony/java/android/telephony/NetworkScanRequest.java 0 → 100644 +115 −0 Original line number Diff line number Diff line /* * 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; /** * Defines a request to peform a network scan. * * This class defines whether the network scan will be performed only once or periodically until * cancelled, when the scan is performed periodically, the time interval is not controlled by the * user but defined by the modem vendor. * @hide */ public final class NetworkScanRequest implements Parcelable { /** Performs the scan only once */ public static final int SCAN_TYPE_ONE_SHOT = 0; /** * Performs the scan periodically until cancelled * * The modem will start new scans periodically, and the interval between two scans is usually * multiple minutes. * */ public static final int SCAN_TYPE_PERIODIC = 1; /** Defines the type of the scan. */ public int scanType; /** Describes the radio access technologies with bands or channels that need to be scanned. */ public RadioAccessSpecifier[] specifiers; /** * Creates a new NetworkScanRequest with scanType and network specifiers * * @param scanType The type of the scan * @param specifiers the radio network with bands / channels to be scanned */ public NetworkScanRequest(int scanType, RadioAccessSpecifier[] specifiers) { this.scanType = scanType; this.specifiers = specifiers; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(scanType); dest.writeParcelableArray(specifiers, flags); } private NetworkScanRequest(Parcel in) { scanType = in.readInt(); specifiers = (RadioAccessSpecifier[]) in.readParcelableArray( Object.class.getClassLoader(), RadioAccessSpecifier.class); } @Override public boolean equals (Object o) { NetworkScanRequest nsr; try { nsr = (NetworkScanRequest) o; } catch (ClassCastException ex) { return false; } if (o == null) { return false; } return (scanType == nsr.scanType && Arrays.equals(specifiers, nsr.specifiers)); } @Override public int hashCode () { return ((scanType * 31) + (Arrays.hashCode(specifiers)) * 37); } public static final Creator<NetworkScanRequest> CREATOR = new Creator<NetworkScanRequest>() { @Override public NetworkScanRequest createFromParcel(Parcel in) { return new NetworkScanRequest(in); } @Override public NetworkScanRequest[] newArray(int size) { return new NetworkScanRequest[size]; } }; }
telephony/java/android/telephony/RadioAccessSpecifier.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * 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; parcelable RadioAccessSpecifier;
telephony/java/android/telephony/RadioAccessSpecifier.java 0 → 100644 +129 −0 Original line number Diff line number Diff line /* * 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); } }