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

Commit 89514808 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Add the user mobile data state into PhoneStateListener so that...

Merge "Add the user mobile data state into PhoneStateListener so that applications can listen to the change of the user mobile data state."
parents 277c7d24 35a47024
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -40455,6 +40455,7 @@ package android.telephony {
    method public void onServiceStateChanged(android.telephony.ServiceState);
    method public deprecated void onSignalStrengthChanged(int);
    method public void onSignalStrengthsChanged(android.telephony.SignalStrength);
    method public void onUserMobileDataStateChanged(boolean);
    field public static final int LISTEN_CALL_FORWARDING_INDICATOR = 8; // 0x8
    field public static final int LISTEN_CALL_STATE = 32; // 0x20
    field public static final int LISTEN_CELL_INFO = 1024; // 0x400
@@ -40466,6 +40467,7 @@ package android.telephony {
    field public static final int LISTEN_SERVICE_STATE = 1; // 0x1
    field public static final deprecated int LISTEN_SIGNAL_STRENGTH = 2; // 0x2
    field public static final int LISTEN_SIGNAL_STRENGTHS = 256; // 0x100
    field public static final int LISTEN_USER_MOBILE_DATA_STATE = 524288; // 0x80000
  }
  public final class RadioAccessSpecifier implements android.os.Parcelable {
+51 −0
Original line number Diff line number Diff line
@@ -147,6 +147,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {

    private int[] mDataActivationState;

    private boolean[] mUserMobileDataState;

    private SignalStrength[] mSignalStrength;

    private boolean[] mMessageWaiting;
@@ -304,6 +306,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
        mServiceState = new ServiceState[numPhones];
        mVoiceActivationState = new int[numPhones];
        mDataActivationState = new int[numPhones];
        mUserMobileDataState = new boolean[numPhones];
        mSignalStrength = new SignalStrength[numPhones];
        mMessageWaiting = new boolean[numPhones];
        mCallForwarding = new boolean[numPhones];
@@ -320,6 +323,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
            mCallIncomingNumber[i] =  "";
            mServiceState[i] =  new ServiceState();
            mSignalStrength[i] =  new SignalStrength();
            mUserMobileDataState[i] = false;
            mMessageWaiting[i] =  false;
            mCallForwarding[i] =  false;
            mCellLocation[i] = new Bundle();
@@ -656,6 +660,13 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
                            remove(r.binder);
                        }
                    }
                    if ((events & PhoneStateListener.LISTEN_USER_MOBILE_DATA_STATE) != 0) {
                        try {
                            r.callback.onUserMobileDataStateChanged(mUserMobileDataState[phoneId]);
                        } catch (RemoteException ex) {
                            remove(r.binder);
                        }
                    }
                }
            }
        } else {
@@ -1012,6 +1023,33 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
        }
    }

    public void notifyUserMobileDataStateChangedForPhoneId(int phoneId, int subId, boolean state) {
        if (!checkNotifyPermission("notifyUserMobileDataStateChanged()")) {
            return;
        }
        if (VDBG) {
            log("notifyUserMobileDataStateChangedForSubscriberPhoneID: subId=" + phoneId
                    + " state=" + state);
        }
        synchronized (mRecords) {
            if (validatePhoneId(phoneId)) {
                mMessageWaiting[phoneId] = state;
                for (Record r : mRecords) {
                    if (r.matchPhoneStateListenerEvent(
                            PhoneStateListener.LISTEN_USER_MOBILE_DATA_STATE) &&
                            idMatch(r.subId, subId, phoneId)) {
                        try {
                            r.callback.onUserMobileDataStateChanged(state);
                        } catch (RemoteException ex) {
                            mRemoveList.add(r.binder);
                        }
                    }
                }
            }
            handleRemoveListLocked();
        }
    }

    public void notifyCallForwardingChanged(boolean cfi) {
        notifyCallForwardingChangedForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cfi);
    }
@@ -1374,6 +1412,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
                pw.println("mServiceState=" + mServiceState[i]);
                pw.println("mVoiceActivationState= " + mVoiceActivationState[i]);
                pw.println("mDataActivationState= " + mDataActivationState[i]);
                pw.println("mUserMobileDataState= " + mUserMobileDataState[i]);
                pw.println("mSignalStrength=" + mSignalStrength[i]);
                pw.println("mMessageWaiting=" + mMessageWaiting[i]);
                pw.println("mCallForwarding=" + mCallForwarding[i]);
@@ -1755,6 +1794,18 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
            }
        }

        if ((events & PhoneStateListener.LISTEN_USER_MOBILE_DATA_STATE) != 0) {
            try {
                if (VDBG) {
                    log("checkPossibleMissNotify: onUserMobileDataStateChanged phoneId="
                            + phoneId + " umds=" + mUserMobileDataState[phoneId]);
                }
                r.callback.onUserMobileDataStateChanged(mUserMobileDataState[phoneId]);
            } catch (RemoteException ex) {
                mRemoveList.add(r.binder);
            }
        }

        if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
            try {
                if (VDBG) {
+22 −0
Original line number Diff line number Diff line
@@ -244,6 +244,13 @@ public class PhoneStateListener {
     */
    public static final int LISTEN_DATA_ACTIVATION_STATE                   = 0x00040000;

    /**
     *  Listen for changes to the user mobile data state
     *
     *  @see #onUserMobileDataStateChanged
     */
    public static final int LISTEN_USER_MOBILE_DATA_STATE                  = 0x00080000;

     /*
     * Subscription used to listen to the phone state changes
     * @hide
@@ -349,6 +356,9 @@ public class PhoneStateListener {
                    case LISTEN_DATA_ACTIVATION_STATE:
                        PhoneStateListener.this.onDataActivationStateChanged((int)msg.obj);
                        break;
                    case LISTEN_USER_MOBILE_DATA_STATE:
                        PhoneStateListener.this.onUserMobileDataStateChanged((boolean)msg.obj);
                        break;
                    case LISTEN_CARRIER_NETWORK_CHANGE:
                        PhoneStateListener.this.onCarrierNetworkChange((boolean)msg.obj);
                        break;
@@ -542,6 +552,14 @@ public class PhoneStateListener {

    }

    /**
     * Callback invoked when the user mobile data state has changed
     * @param enabled indicates whether the current user mobile data state is enabled or disabled.
     */
    public void onUserMobileDataStateChanged(boolean enabled) {
        // default implementation empty
    }

    /**
     * Callback invoked when telephony has received notice from a carrier
     * app that a network action that could result in connectivity loss
@@ -654,6 +672,10 @@ public class PhoneStateListener {
            send(LISTEN_DATA_ACTIVATION_STATE, 0, 0, activationState);
        }

        public void onUserMobileDataStateChanged(boolean enabled) {
            send(LISTEN_USER_MOBILE_DATA_STATE, 0, 0, enabled);
        }

        public void onCarrierNetworkChange(boolean active) {
            send(LISTEN_CARRIER_NETWORK_CHANGE, 0, 0, active);
        }
+1 −0
Original line number Diff line number Diff line
@@ -46,5 +46,6 @@ oneway interface IPhoneStateListener {
    void onVoiceActivationStateChanged(int activationState);
    void onDataActivationStateChanged(int activationState);
    void onCarrierNetworkChange(in boolean active);
    void onUserMobileDataStateChanged(in boolean enabled);
}
+1 −0
Original line number Diff line number Diff line
@@ -69,4 +69,5 @@ interface ITelephonyRegistry {
            int activationState, int activationType);
    void notifySubscriptionInfoChanged();
    void notifyCarrierNetworkChange(in boolean active);
    void notifyUserMobileDataStateChangedForPhoneId(in int phoneId, in int subId, in boolean state);
}