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

Commit 84bced49 authored by SongFerngWang's avatar SongFerngWang
Browse files

The phone didn't reload the allowed Network Type

Reload the allowed Network after device insert SIM card.
Change the behavior of notifyAllowedNetworkTypesChanged.
Log print String representation of the allowed network types.
Bug: 180903931
Bug: 179814490
Test: atest cts/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java#testSetAllowedNetworkTypesForReason_moreReason
atest cts/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java#testSetAllowedNetworkTypesForReason
atest android.telephony.cts.TelephonyCallbackTest

Change-Id: Icfffea3c74ecf6938455d841da9d6175f6aa07de
Merged-In: Icfffea3c74ecf6938455d841da9d6175f6aa07de
parent 3ccc2738
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -10017,7 +10017,7 @@ package android.telephony {
  }
  }
  public static interface TelephonyCallback.AllowedNetworkTypesListener {
  public static interface TelephonyCallback.AllowedNetworkTypesListener {
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void onAllowedNetworkTypesChanged(@NonNull java.util.Map<java.lang.Integer,java.lang.Long>);
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void onAllowedNetworkTypesChanged(int, long);
  }
  }
  public static interface TelephonyCallback.CallAttributesListener {
  public static interface TelephonyCallback.CallAttributesListener {
+1 −1
Original line number Original line Diff line number Diff line
@@ -1577,7 +1577,7 @@ public class PhoneStateListener {
            // default implementation empty
            // default implementation empty
        }
        }


        public void onAllowedNetworkTypesChanged(Map allowedNetworkTypesList) {
        public void onAllowedNetworkTypesChanged(int reason, long allowedNetworkType) {
            // default implementation empty
            // default implementation empty
        }
        }


+21 −19
Original line number Original line Diff line number Diff line
@@ -544,9 +544,6 @@ public class TelephonyCallback {
    /**
    /**
     * Event for changes to allowed network list based on all active subscriptions.
     * Event for changes to allowed network 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}).
     *
     * @hide
     * @hide
     * @see AllowedNetworkTypesListener#onAllowedNetworkTypesChanged
     * @see AllowedNetworkTypesListener#onAllowedNetworkTypesChanged
     */
     */
@@ -1287,30 +1284,34 @@ public class TelephonyCallback {
    public interface AllowedNetworkTypesListener {
    public interface AllowedNetworkTypesListener {
        /**
        /**
         * Callback invoked when the current allowed network type list has changed on the
         * Callback invoked when the current allowed network type list has changed on the
         * registered subscription.
         * registered subscription for a specified reason.
         * Note, the registered subscription is associated with {@link TelephonyManager} object
         * Note, the registered subscription is associated with {@link TelephonyManager} object
         * on which
         * on which {@link TelephonyManager#registerTelephonyCallback(Executor, TelephonyCallback)}
         * {@link TelephonyManager#registerTelephonyCallback(Executor, TelephonyCallback)}
         * was called.
         * was called.
         * If this TelephonyManager object was created with
         * If this TelephonyManager object was created with
         * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the
         * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the
         * given subscription ID. Otherwise, this callback applies to
         * given subscription ID. Otherwise, this callback applies to
         * {@link SubscriptionManager#getDefaultSubscriptionId()}.
         * {@link SubscriptionManager#getDefaultSubscriptionId()}.
         *
         *
         * @param allowedNetworkTypesList Map associating all allowed network type reasons
         * @param reason an allowed network type reasons.
         * ({@link TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_USER},
         * @see TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_USER
         * {@link TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_POWER},
         * @see TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_POWER
         * {@link TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_CARRIER}, and
         * @see TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_CARRIER
         * {@link TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G}) with reason's allowed
         * @see TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G
         * network type values.
         *
         * @param allowedNetworkType an allowed network type bitmask value. (for example,
         * the long bitmask value is {{@link TelephonyManager#NETWORK_TYPE_BITMASK_NR}|
         * {@link TelephonyManager#NETWORK_TYPE_BITMASK_LTE}})
         *
         * For example:
         * For example:
         * map{{TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_USER, long type value},
         * If the latest allowed network type is changed by user, then the system
         *     {TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_POWER, long type value},
         * notifies the {@link TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_USER} and
         *     {TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_CARRIER, long type value},
         * long type value}.
         *     {TelephonyManager#ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G, long type value}}
         */
         */
        @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
        @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
        void onAllowedNetworkTypesChanged(@NonNull Map<Integer, Long> allowedNetworkTypesList);
        void onAllowedNetworkTypesChanged(
                @TelephonyManager.AllowedNetworkTypesReason int reason,
                @TelephonyManager.NetworkTypeBitMask long allowedNetworkType);
    }
    }


    /**
    /**
@@ -1741,14 +1742,15 @@ public class TelephonyCallback {
                            enabled, reason)));
                            enabled, reason)));
        }
        }


        public void onAllowedNetworkTypesChanged(Map allowedNetworkTypesList) {
        public void onAllowedNetworkTypesChanged(int reason, long allowedNetworkType) {
            AllowedNetworkTypesListener listener =
            AllowedNetworkTypesListener listener =
                    (AllowedNetworkTypesListener) mTelephonyCallbackWeakRef.get();
                    (AllowedNetworkTypesListener) mTelephonyCallbackWeakRef.get();
            if (listener == null) return;
            if (listener == null) return;


            Binder.withCleanCallingIdentity(
            Binder.withCleanCallingIdentity(
                    () -> mExecutor.execute(
                    () -> mExecutor.execute(
                            () -> listener.onAllowedNetworkTypesChanged(allowedNetworkTypesList)));
                            () -> listener.onAllowedNetworkTypesChanged(reason,
                                    allowedNetworkType)));
        }
        }


        public void onLinkCapacityEstimateChanged(
        public void onLinkCapacityEstimateChanged(
+9 −7
Original line number Original line Diff line number Diff line
@@ -825,16 +825,18 @@ public class TelephonyRegistryManager {
    }
    }


    /**
    /**
     * Notify emergency number list changed on certain subscription.
     * Notify the allowed network types has changed for a specific subscription and the specific
     *
     * reason.
     * @param slotIndex for which emergency number list changed. Can be derived from subId except
     * @param slotIndex for which allowed network types changed.
     * when subId is invalid.
     * @param subId for which allowed network types changed.
     * @param subId for which emergency number list changed.
     * @param reason an allowed network type reasons.
     * @param allowedNetworkType an allowed network type bitmask value.
     */
     */
    public void notifyAllowedNetworkTypesChanged(int slotIndex, int subId,
    public void notifyAllowedNetworkTypesChanged(int slotIndex, int subId,
            Map<Integer, Long> allowedNetworkTypeList) {
            int reason, long allowedNetworkType) {
        try {
        try {
            sRegistry.notifyAllowedNetworkTypesChanged(slotIndex, subId, allowedNetworkTypeList);
            sRegistry.notifyAllowedNetworkTypesChanged(slotIndex, subId, reason,
                    allowedNetworkType);
        } catch (RemoteException ex) {
        } catch (RemoteException ex) {
            // system process is dead
            // system process is dead
        }
        }
+1 −1
Original line number Original line Diff line number Diff line
@@ -72,6 +72,6 @@ oneway interface IPhoneStateListener {
    void onBarringInfoChanged(in BarringInfo barringInfo);
    void onBarringInfoChanged(in BarringInfo barringInfo);
    void onPhysicalChannelConfigChanged(in List<PhysicalChannelConfig> configs);
    void onPhysicalChannelConfigChanged(in List<PhysicalChannelConfig> configs);
    void onDataEnabledChanged(boolean enabled, int reason);
    void onDataEnabledChanged(boolean enabled, int reason);
    void onAllowedNetworkTypesChanged(in Map allowedNetworkTypeList);
    void onAllowedNetworkTypesChanged(in int reason, in long allowedNetworkType);
    void onLinkCapacityEstimateChanged(in List<LinkCapacityEstimate> linkCapacityEstimateList);
    void onLinkCapacityEstimateChanged(in List<LinkCapacityEstimate> linkCapacityEstimateList);
}
}
Loading