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

Commit 725b329d authored by Nathalie Ruano's avatar Nathalie Ruano Committed by Jack Yu
Browse files

Added changes to support new phone number telephony module in TelephonyServiceManager

The changes add new TelephonyServicesInitializer to initialize and
register the service.

Test: presubmit

Bug: b/418868405 Bug: b/412560144

Flag: com.android.internal.telephony.flags.enable_phone_number_parsing_api
Change-Id: I2dd17d564e1bd0570328c4a828eeedf06bc36d0f
parent 58b7d28a
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -473,6 +473,15 @@ package android.os {
    method @FlaggedApi("android.permission.flags.enhanced_confirmation_mode_apis_enabled") @NonNull @RequiresPermission(android.Manifest.permission.MANAGE_ENHANCED_CONFIRMATION_STATES) public java.util.Set<android.content.pm.SignedPackage> getEnhancedConfirmationTrustedPackages();
  }

  @FlaggedApi("com.android.internal.telephony.flags.enable_phone_number_parsing_api") public class TelephonyServiceManager {
    method @NonNull public android.os.TelephonyServiceManager.ServiceRegisterer getPhoneNumberServiceRegisterer();
  }

  public static final class TelephonyServiceManager.ServiceRegisterer {
    method @Nullable public android.os.IBinder get();
    method public void publishBinderService(@NonNull android.os.IBinder);
  }

  public final class Trace {
    method public static void asyncTraceBegin(long, @NonNull String, int);
    method public static void asyncTraceEnd(long, @NonNull String, int);
@@ -620,6 +629,12 @@ package android.telephony {
    method public void removeSubscriptionInfoRecord(@NonNull String, int);
  }

  @FlaggedApi("com.android.internal.telephony.flags.enable_phone_number_parsing_api") public class TelephonyFrameworkInitializer {
    method @Nullable public static android.os.TelephonyServiceManager getTelephonyServiceManager();
    method public static void registerServiceWrappers();
    method public static void setTelephonyServiceManager(@NonNull android.os.TelephonyServiceManager);
  }

  public class TelephonyManager {
    method @NonNull public static int[] getAllNetworkTypes();
    method @FlaggedApi("android.os.mainline_vcn_platform_api") @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.Set<java.lang.String> getPackagesWithCarrierPrivileges();
+61 −1
Original line number Diff line number Diff line
@@ -15,8 +15,14 @@
 */
package android.os;

import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;

import static com.android.internal.telephony.flags.Flags.FLAG_ENABLE_PHONE_NUMBER_PARSING_API;

import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.content.Context;

/**
@@ -27,7 +33,10 @@ import android.content.Context;
 *
 * @hide
 */
@SystemApi(client = MODULE_LIBRARIES)
@FlaggedApi(FLAG_ENABLE_PHONE_NUMBER_PARSING_API)
public class TelephonyServiceManager {

    /**
     * @hide
     */
@@ -48,17 +57,34 @@ public class TelephonyServiceManager {
        }

        /**
         * Register a system server binding object for a service.
         * Publish the service so it is accessible to other services and apps.
         *
         * @param service the service object
         *
         * @hide
         *
         */
        // TODO: Replaced all callers to use publishBinderService().
        public void register(@NonNull IBinder service) {
            ServiceManager.addService(mServiceName, service);
        }

        /**
         * Publish the service so it is accessible to other services and apps.
         *
         * @param service the service object
         */
        public void publishBinderService(@NonNull IBinder service) {
            ServiceManager.addService(mServiceName, service);
        }

        /**
         * Get the system server binding object for a service.
         *
         * <p>This blocks until the service instance is ready,
         * or a timeout happens, in which case it returns null.
         *
         * @return The binder object, or null if the service is not found or a timeout occurs.
         */
        @Nullable
        public IBinder get() {
@@ -70,6 +96,8 @@ public class TelephonyServiceManager {
         *
         * <p>This blocks until the service instance is ready,
         * or a timeout happens, in which case it throws {@link ServiceNotFoundException}.
         *
         * @hide
         */
        @NonNull
        public IBinder getOrThrow() throws ServiceNotFoundException {
@@ -83,6 +111,8 @@ public class TelephonyServiceManager {
        /**
         * Get the system server binding object for a service. If the specified service is
         * not available, it returns null.
         *
         * @hide
         */
        @Nullable
        public IBinder tryGet() {
@@ -109,6 +139,8 @@ public class TelephonyServiceManager {

    /**
     * Returns {@link ServiceRegisterer} for the "telephony" service.
     *
     * @hide
     */
    @NonNull
    public ServiceRegisterer getTelephonyServiceRegisterer() {
@@ -117,6 +149,8 @@ public class TelephonyServiceManager {

    /**
     * Returns {@link ServiceRegisterer} for the telephony IMS service.
     *
     * @hide
     */
    @NonNull
    public ServiceRegisterer getTelephonyImsServiceRegisterer() {
@@ -125,6 +159,8 @@ public class TelephonyServiceManager {

    /**
     * Returns {@link ServiceRegisterer} for the telephony RCS message service.
     *
     * @hide
     */
    @NonNull
    public ServiceRegisterer getTelephonyRcsMessageServiceRegisterer() {
@@ -133,6 +169,8 @@ public class TelephonyServiceManager {

    /**
     * Returns {@link ServiceRegisterer} for the subscription service.
     *
     * @hide
     */
    @NonNull
    public ServiceRegisterer getSubscriptionServiceRegisterer() {
@@ -141,6 +179,8 @@ public class TelephonyServiceManager {

    /**
     * Returns {@link ServiceRegisterer} for the phone sub service.
     *
     * @hide
     */
    @NonNull
    public ServiceRegisterer getPhoneSubServiceRegisterer() {
@@ -149,6 +189,8 @@ public class TelephonyServiceManager {

    /**
     * Returns {@link ServiceRegisterer} for the opportunistic network service.
     *
     * @hide
     */
    @NonNull
    public ServiceRegisterer getOpportunisticNetworkServiceRegisterer() {
@@ -157,6 +199,8 @@ public class TelephonyServiceManager {

    /**
     * Returns {@link ServiceRegisterer} for the carrier config service.
     *
     * @hide
     */
    @NonNull
    public ServiceRegisterer getCarrierConfigServiceRegisterer() {
@@ -165,6 +209,8 @@ public class TelephonyServiceManager {

    /**
     * Returns {@link ServiceRegisterer} for the "SMS" service.
     *
     * @hide
     */
    @NonNull
    public ServiceRegisterer getSmsServiceRegisterer() {
@@ -173,6 +219,8 @@ public class TelephonyServiceManager {

    /**
     * Returns {@link ServiceRegisterer} for the eUICC controller service.
     *
     * @hide
     */
    @NonNull
    public ServiceRegisterer getEuiccControllerService() {
@@ -181,6 +229,8 @@ public class TelephonyServiceManager {

    /**
     * Returns {@link ServiceRegisterer} for the eUICC card controller service.
     *
     * @hide
     */
    @NonNull
    public ServiceRegisterer getEuiccCardControllerServiceRegisterer() {
@@ -189,9 +239,19 @@ public class TelephonyServiceManager {

    /**
     * Returns {@link ServiceRegisterer} for the ICC phone book service.
     *
     * @hide
     */
    @NonNull
    public ServiceRegisterer getIccPhoneBookServiceRegisterer() {
        return new ServiceRegisterer("simphonebook");
    }

    /**
     * Returns {@link ServiceRegisterer} for the Phone Number Service.
     */
    @NonNull
    public ServiceRegisterer getPhoneNumberServiceRegisterer() {
        return new ServiceRegisterer(Context.TELEPHONY_PHONE_NUMBER_SERVICE);
    }
}
+23 −2
Original line number Diff line number Diff line
@@ -16,7 +16,12 @@

package android.telephony;

import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;

import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.app.SystemServiceRegistry;
import android.compat.Compatibility;
import android.compat.annotation.ChangeId;
@@ -31,14 +36,16 @@ import android.telephony.euicc.EuiccManager;
import android.telephony.ims.ImsManager;
import android.telephony.satellite.SatelliteManager;

import com.android.internal.telephony.flags.Flags;
import com.android.internal.util.Preconditions;


/**
 * Class for performing registration for all telephony services.
 *
 * @hide
 */
@SystemApi(client = MODULE_LIBRARIES)
@FlaggedApi(Flags.FLAG_ENABLE_PHONE_NUMBER_PARSING_API)
public class TelephonyFrameworkInitializer {

    private TelephonyFrameworkInitializer() {
@@ -143,9 +150,23 @@ public class TelephonyFrameworkInitializer {
                context -> hasSystemFeature(context, PackageManager.FEATURE_TELEPHONY_SATELLITE)
                        ? new SatelliteManager(context) : null
        );

        // TODO: Do the following after mainline is released to the release branch.
        /*if (Flags.enablePhoneNumberParsingApi()) {
            TelephonyServicesInitializer.registerServiceWrappers();
        }*/
    }

    /** @hide */
    /**
     * Retrieves an instance of {@link TelephonyServiceManager} that allows the telephony mainline
     * module to register/obtain telephony binder services.
     *
     * @return instance of {@link TelephonyServiceManager}
     *
     * @hide
     */
    @SystemApi(client = MODULE_LIBRARIES)
    @Nullable
    public static TelephonyServiceManager getTelephonyServiceManager() {
        return sTelephonyServiceManager;
    }