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

Commit 53b95297 authored by Benjamin Löhner's avatar Benjamin Löhner
Browse files

Add getEmergencyAssistancePackageName API to TelephonyManager.

Since the emergency role is basically the app that handles
ACTION_EMERGENCY_ASSISTANCE, it was proposed to add this API
alongside isEmergencyAssistanceEnabled(). This provides privileged
clients (e.g. GmsCore) with a robust way to query the emergency
role holder.

This API calls a new getEmergencyRoleHolder() API in RoleManager.
Both of these APIs are guarded by a common flag in the permissions
namespace.

Bug: 323157319
Test: atest RoleManagerTest
Change-Id: I4302ca53f6a0187f225ad085a7d43cd20a935b3e
parent 1684475d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -15135,6 +15135,7 @@ package android.telephony {
    method @Deprecated public boolean getDataEnabled(int);
    method @Nullable @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public android.content.ComponentName getDefaultRespondViaMessageApplication();
    method @Nullable @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getDeviceSoftwareVersion(int);
    method @FlaggedApi("android.permission.flags.get_emergency_role_holder_api_enabled") @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getEmergencyAssistancePackage();
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean getEmergencyCallbackMode();
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getEmergencyNumberDbVersion();
    method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getIsimDomain();
+8 −0
Original line number Diff line number Diff line
@@ -111,3 +111,11 @@ flag {
    description: "When the flag is off no permissions can be device aware"
    bug: "274852670"
}

flag {
     name: "get_emergency_role_holder_api_enabled"
     is_fixed_read_only: true
     namespace: "permissions"
     description: "Enables the getEmergencyRoleHolder API."
     bug: "323157319"
}
+21 −0
Original line number Diff line number Diff line
@@ -15010,6 +15010,27 @@ public class TelephonyManager {
        return EMERGENCY_ASSISTANCE_ENABLED;
    }
    /**
     * Get the emergency assistance package name.
     *
     * @return the package name of the emergency assistance app.
     * @throws IllegalStateException if emergency assistance is not enabled.
     *
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
    @FlaggedApi(android.permission.flags.Flags.FLAG_GET_EMERGENCY_ROLE_HOLDER_API_ENABLED)
    @NonNull
    @SystemApi
    public String getEmergencyAssistancePackage() {
        if (!isEmergencyAssistanceEnabled()) {
            throw new IllegalStateException("isEmergencyAssistanceEnabled() is false.");
        }
        String emergencyRole = mContext.getSystemService(RoleManager.class)
                .getEmergencyRoleHolder(mContext.getUserId());
        return Objects.requireNonNull(emergencyRole, "Emergency role holder must not be null");
    }
    /**
     * Get the emergency number list based on current locale, sim, default, modem and network.
     *