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

Commit 24cddced authored by Shuo Qian's avatar Shuo Qian Committed by Gerrit Code Review
Browse files

Merge "Introduce Emergency number functions APIs"

parents d605b5ab 5ac293f0
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -42494,6 +42494,7 @@ package android.telephony {
    field public static final int LISTEN_CELL_LOCATION = 16; // 0x10
    field public static final int LISTEN_DATA_ACTIVITY = 128; // 0x80
    field public static final int LISTEN_DATA_CONNECTION_STATE = 64; // 0x40
    field public static final int LISTEN_EMERGENCY_NUMBER_LIST = 16777216; // 0x1000000
    field public static final int LISTEN_MESSAGE_WAITING_INDICATOR = 4; // 0x4
    field public static final int LISTEN_NONE = 0; // 0x0
    field public static final int LISTEN_SERVICE_STATE = 1; // 0x1
@@ -42805,6 +42806,8 @@ package android.telephony {
    method public int getCallState();
    method public android.os.PersistableBundle getCarrierConfig();
    method public deprecated android.telephony.CellLocation getCellLocation();
    method public java.util.Map<java.lang.Integer, java.util.List<android.telephony.emergency.EmergencyNumber>> getCurrentEmergencyNumberList();
    method public java.util.Map<java.lang.Integer, java.util.List<android.telephony.emergency.EmergencyNumber>> getCurrentEmergencyNumberList(int);
    method public int getDataActivity();
    method public int getDataNetworkType();
    method public int getDataState();
@@ -42858,6 +42861,7 @@ package android.telephony {
    method public java.lang.String iccTransmitApduBasicChannel(int, int, int, int, int, java.lang.String);
    method public java.lang.String iccTransmitApduLogicalChannel(int, int, int, int, int, int, java.lang.String);
    method public boolean isConcurrentVoiceAndDataSupported();
    method public boolean isCurrentEmergencyNumber(java.lang.String);
    method public boolean isDataEnabled();
    method public boolean isDataRoamingEnabled();
    method public boolean isHearingAidCompatibilitySupported();
+8 −0
Original line number Diff line number Diff line
@@ -301,6 +301,14 @@ public class PhoneStateListener {
    @SystemApi
    public static final int LISTEN_RADIO_POWER_STATE_CHANGED               = 0x00800000;

    /**
     * Listen for changes to emergency number list based on all active subscriptions.
     *
     * <p>Requires permission {@link android.Manifest.permission#READ_PHONE_STATE} or the calling
     * app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges}).
     */
    public static final int LISTEN_EMERGENCY_NUMBER_LIST                   = 0x01000000;

    /*
     * Subscription used to listen to the phone state changes
     * @hide
+115 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static com.android.internal.util.Preconditions.checkNotNull;

import android.Manifest;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
@@ -57,6 +58,8 @@ import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telephony.VisualVoicemailService.VisualVoicemailTask;
import android.telephony.emergency.EmergencyNumber;
import android.telephony.emergency.EmergencyNumber.EmergencyServiceCategories;
import android.telephony.ims.aidl.IImsConfig;
import android.telephony.ims.aidl.IImsMmTelFeature;
import android.telephony.ims.aidl.IImsRcsFeature;
@@ -86,6 +89,7 @@ import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -9047,4 +9051,115 @@ public class TelephonyManager {
        }
    }

    /**
     * Get the emergency number list based on current locale, sim, default, modem and network.
     *
     * <p>The emergency number {@link EmergencyNumber} with higher display priority is located at
     * the smaller index in the returned list.
     *
     * <p>The subscriptions which the returned list would be based on, are all the active
     * subscriptions, no matter which subscription could be used to create TelephonyManager.
     *
     * <p>Requires permission {@link android.Manifest.permission#READ_PHONE_STATE} or the calling
     * app has carrier privileges (see {@link #hasCarrierPrivileges}).
     *
     * @return Map including the key as the active subscription ID (Note: if there is no active
     * subscription, the key is {@link SubscriptionManager#DEFAULT_SUBSCRIPTION_ID}) and the value
     * as the list of {@link EmergencyNumber}; null if this information is not available.
     */
    @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
    @Nullable
    public Map<Integer, List<EmergencyNumber>> getCurrentEmergencyNumberList() {
        try {
            ITelephony telephony = getITelephony();
            if (telephony == null) {
                return null;
            }
            return telephony.getCurrentEmergencyNumberList(mContext.getOpPackageName());
        } catch (RemoteException ex) {
            Log.e(TAG, "getCurrentEmergencyNumberList RemoteException", ex);
        }
        return null;
    }

    /**
     * Get the per-category emergency number list based on current locale, sim, default, modem
     * and network.
     *
     * <p>The emergency number {@link EmergencyNumber} with higher display priority is located at
     * the smaller index in the returned list.
     *
     * <p>The subscriptions which the returned list would be based on, are all the active
     * subscriptions, no matter which subscription could be used to create TelephonyManager.
     *
     * <p>Requires permission {@link android.Manifest.permission#READ_PHONE_STATE} or the calling
     * app has carrier privileges (see {@link #hasCarrierPrivileges}).
     *
     * @param categories the emergency service categories which are the bitwise-OR combination of
     * the following constants:
     * <ol>
     * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED} </li>
     * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_POLICE} </li>
     * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_AMBULANCE} </li>
     * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_FIRE_BRIGADE} </li>
     * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_MARINE_GUARD} </li>
     * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_MOUNTAIN_RESCUE} </li>
     * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_MIEC} </li>
     * <li>{@link EmergencyNumber#EMERGENCY_SERVICE_CATEGORY_AIEC} </li>
     * </ol>
     * @return Map including the key as the active subscription ID (Note: if there is no active
     * subscription, the key is {@link SubscriptionManager#DEFAULT_SUBSCRIPTION_ID}) and the value
     * as the list of {@link EmergencyNumber}; null if this information is not available.
     */
    @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
    @Nullable
    public Map<Integer, List<EmergencyNumber>> getCurrentEmergencyNumberList(
            @EmergencyServiceCategories int categories) {
        try {
            ITelephony telephony = getITelephony();
            if (telephony == null) {
                return null;
            }
            Map<Integer, List<EmergencyNumber>> numberMap = telephony
                    .getCurrentEmergencyNumberList(mContext.getOpPackageName());
            if (numberMap != null) {
                for (Integer subscriptionId : numberMap.keySet()) {
                    List<EmergencyNumber> numberList = numberMap.get(subscriptionId);
                    for (EmergencyNumber number : numberList) {
                        if (!number.isInEmergencyServiceCategories(categories)) {
                            numberList.remove(number);
                        }
                    }
                }
            }
            return numberMap;
        } catch (RemoteException ex) {
            Log.e(TAG, "getCurrentEmergencyNumberList with Categories RemoteException", ex);
        }
        return null;
    }

    /**
     * Checks if the supplied number is an emergency number based on current locale, sim, default,
     * modem and network.
     *
     * <p>The subscriptions which the identification would be based on, are all the active
     * subscriptions, no matter which subscription could be used to create TelephonyManager.
     *
     * @param number - the number to look up
     * @return {@code true} if the given number is an emergency number based on current locale,
     * sim, modem and network; {@code false} otherwise.
     */
    public boolean isCurrentEmergencyNumber(@NonNull String number) {
        try {
            ITelephony telephony = getITelephony();
            if (telephony == null) {
                return false;
            }
            return telephony.isCurrentEmergencyNumber(number);
        } catch (RemoteException ex) {
            Log.e(TAG, "isCurrentEmergencyNumber RemoteException", ex);
        }
        return false;
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import com.android.internal.telephony.CellNetworkScanResult;
import com.android.internal.telephony.OperatorInfo;

import java.util.List;
import java.util.Map;

import android.telephony.UiccSlotInfo;

@@ -1633,6 +1634,16 @@ interface ITelephony {
     */
    boolean isTtyOverVolteEnabled(int subId);

    /**
     * Return the emergency number list from all the active subscriptions.
     */
    Map getCurrentEmergencyNumberList(String callingPackage);

    /**
     * Identify if the number is emergency number, based on all the active subscriptions.
     */
    boolean isCurrentEmergencyNumber(String number);

    /**
     * Return a list of certs in hex string from loaded carrier privileges access rules.
     */