Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8aac4052 authored by yinxu's avatar yinxu
Browse files

Address the API review comments.

This is a clean cherry-pick from:
https://android-review.git.corp.google.com/c/platform/frameworks/base/+/632313

Bug:73750871
Test: Unit Test
Change-Id: I8ebb617c819c7604957b3c086098ef5074d70f78
Merged-in: I8ebb617c819c7604957b3c086098ef5074d70f78
(cherry picked from commit 1abe9b18)
parent 1c6e3ba6
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -42093,11 +42093,9 @@ package android.telecom {
package android.telephony {
  public final class AccessNetworkConstants {
    ctor public AccessNetworkConstants();
  }
  public static final class AccessNetworkConstants.AccessNetworkType {
    ctor public AccessNetworkConstants.AccessNetworkType();
    field public static final int CDMA2000 = 4; // 0x4
    field public static final int EUTRAN = 3; // 0x3
    field public static final int GERAN = 1; // 0x1
@@ -42107,7 +42105,6 @@ package android.telephony {
  }
  public static final class AccessNetworkConstants.EutranBand {
    ctor public AccessNetworkConstants.EutranBand();
    field public static final int BAND_1 = 1; // 0x1
    field public static final int BAND_10 = 10; // 0xa
    field public static final int BAND_11 = 11; // 0xb
@@ -42159,7 +42156,6 @@ package android.telephony {
  }
  public static final class AccessNetworkConstants.GeranBand {
    ctor public AccessNetworkConstants.GeranBand();
    field public static final int BAND_450 = 3; // 0x3
    field public static final int BAND_480 = 4; // 0x4
    field public static final int BAND_710 = 5; // 0x5
@@ -42177,7 +42173,6 @@ package android.telephony {
  }
  public static final class AccessNetworkConstants.UtranBand {
    ctor public AccessNetworkConstants.UtranBand();
    field public static final int BAND_1 = 1; // 0x1
    field public static final int BAND_10 = 10; // 0xa
    field public static final int BAND_11 = 11; // 0xb
@@ -42618,7 +42613,8 @@ package android.telephony {
  }
  public class NetworkScan {
    method public void stop() throws android.os.RemoteException;
    method public deprecated void stop() throws android.os.RemoteException;
    method public void stopScan();
    field public static final int ERROR_INTERRUPTED = 10002; // 0x2712
    field public static final int ERROR_INVALID_SCAN = 2; // 0x2
    field public static final int ERROR_INVALID_SCANID = 10001; // 0x2711
@@ -43083,7 +43079,8 @@ package android.telephony {
    method public boolean isVoicemailVibrationEnabled(android.telecom.PhoneAccountHandle);
    method public boolean isWorldPhone();
    method public void listen(android.telephony.PhoneStateListener, int);
    method public android.telephony.NetworkScan requestNetworkScan(android.telephony.NetworkScanRequest, android.telephony.TelephonyScanManager.NetworkScanCallback);
    method public android.telephony.NetworkScan requestNetworkScan(android.telephony.NetworkScanRequest, java.util.concurrent.Executor, android.telephony.TelephonyScanManager.NetworkScanCallback);
    method public deprecated android.telephony.NetworkScan requestNetworkScan(android.telephony.NetworkScanRequest, android.telephony.TelephonyScanManager.NetworkScanCallback);
    method public void sendDialerSpecialCode(java.lang.String);
    method public java.lang.String sendEnvelopeWithStatus(java.lang.String);
    method public void sendUssdRequest(java.lang.String, android.telephony.TelephonyManager.UssdResponseCallback, android.os.Handler);
+0 −1
Original line number Diff line number Diff line
@@ -4986,7 +4986,6 @@ package android.telecom {
package android.telephony {

  public static final class AccessNetworkConstants.TransportType {
    ctor public AccessNetworkConstants.TransportType();
    field public static final int WLAN = 2; // 0x2
    field public static final int WWAN = 1; // 0x1
  }
+21 −0
Original line number Diff line number Diff line
@@ -30,6 +30,9 @@ public final class AccessNetworkConstants {
        public static final int EUTRAN = 3;
        public static final int CDMA2000 = 4;
        public static final int IWLAN = 5;

        /** @hide */
        private AccessNetworkType() {};
    }

    /**
@@ -42,6 +45,9 @@ public final class AccessNetworkConstants {
        public static final int WWAN = 1;
        /** Wireless Local Area Networks (i.e. Wifi) */
        public static final int WLAN = 2;

        /** @hide */
        private TransportType() {};
    }

    /**
@@ -63,6 +69,9 @@ public final class AccessNetworkConstants {
        public static final int BAND_DCS1800 = 12;
        public static final int BAND_PCS1900 = 13;
        public static final int BAND_ER900 = 14;

        /** @hide */
        private GeranBand() {};
    }

    /**
@@ -92,6 +101,9 @@ public final class AccessNetworkConstants {
        /** band 23, 24 are reserved */
        public static final int BAND_25 = 25;
        public static final int BAND_26 = 26;

        /** @hide */
        private UtranBand() {};
    }

    /**
@@ -147,6 +159,9 @@ public final class AccessNetworkConstants {
        public static final int BAND_66 = 66;
        public static final int BAND_68 = 68;
        public static final int BAND_70 = 70;

        /** @hide */
        private EutranBand() {};
    }

    /**
@@ -179,5 +194,11 @@ public final class AccessNetworkConstants {
        public static final int BAND_19 = 20;
        public static final int BAND_20 = 21;
        public static final int BAND_21 = 22;

        /** @hide */
        private CdmaBands() {};
    }

    /** @hide */
    private AccessNetworkConstants() {};
}
+19 −9
Original line number Diff line number Diff line
@@ -29,9 +29,9 @@ import java.lang.annotation.RetentionPolicy;

/**
 * The caller of
 * {@link TelephonyManager#requestNetworkScan(NetworkScanRequest, NetworkScanCallback)}
 * {@link TelephonyManager#requestNetworkScan(NetworkScanRequest, Executor, NetworkScanCallback)}
 * will receive an instance of {@link NetworkScan}, which contains a callback method
 * {@link #stop()} for stopping the in-progress scan.
 * {@link #stopScan()} for stopping the in-progress scan.
 */
public class NetworkScan {

@@ -106,16 +106,26 @@ public class NetworkScan {
     * Use this method to stop an ongoing scan. When user requests a new scan, a {@link NetworkScan}
     * object will be returned, and the user can stop the scan by calling this method.
     */
    public void stop() throws RemoteException {
        try {
    public void stopScan() {
        ITelephony telephony = getITelephony();
            if (telephony != null) {
                telephony.stopNetworkScan(mSubId, mScanId);
            } else {
                throw new RemoteException("Failed to get the ITelephony instance.");
        if (telephony == null) {
            Rlog.e(TAG, "Failed to get the ITelephony instance.");
            throw new RuntimeException("Failed to get the ITelephony instance.");
        }
        try {
            telephony.stopNetworkScan(mSubId, mScanId);
        } catch (RemoteException ex) {
            Rlog.e(TAG, "stopNetworkScan  RemoteException", ex);
            ex.rethrowAsRuntimeException();
        }
    }

    /** @deprecated Use {@link #stopScan()} */
    @Deprecated
    public void stop() throws RemoteException {
        try {
            stopScan();
        } catch (RuntimeException ex) {
            throw new RemoteException("Failed to stop the network scan with id " + mScanId);
        }
    }
+19 −3
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkStats;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.BatteryStats;
import android.os.Bundle;
import android.os.Handler;
@@ -74,6 +75,7 @@ import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@@ -5394,21 +5396,35 @@ public class TelephonyManager {
     * <p>
     * Requires Permission:
     *   {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}
     * Or the calling app has carrier privileges. @see #hasCarrierPrivileges
     * Or the calling app has carrier privileges. @see #hasCarrierPrivileges()
     *
     * @param request Contains all the RAT with bands/channels that need to be scanned.
     * @param executor The executor through which the callback should be invoked.
     * @param callback Returns network scan results or errors.
     * @return A NetworkScan obj which contains a callback which can be used to stop the scan.
     */
    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    public NetworkScan requestNetworkScan(
            NetworkScanRequest request, TelephonyScanManager.NetworkScanCallback callback) {
            NetworkScanRequest request, Executor executor,
            TelephonyScanManager.NetworkScanCallback callback) {
        synchronized (this) {
            if (mTelephonyScanManager == null) {
                mTelephonyScanManager = new TelephonyScanManager();
            }
        }
        return mTelephonyScanManager.requestNetworkScan(getSubId(), request, callback);
        return mTelephonyScanManager.requestNetworkScan(getSubId(), request, executor, callback);
    }

    /**
     * @deprecated
     * Use {@link
     * #requestNetworkScan(NetworkScanRequest, Executor, TelephonyScanManager.NetworkScanCallback)}
     */
    @Deprecated
    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    public NetworkScan requestNetworkScan(
        NetworkScanRequest request, TelephonyScanManager.NetworkScanCallback callback) {
        return requestNetworkScan(request, AsyncTask.THREAD_POOL_EXECUTOR, callback);
    }

    /**
Loading