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

Commit fd2d0130 authored by Wink Saville's avatar Wink Saville
Browse files

Add PhoneStateListener.onOtaspChanged.

Bug: 3102320
Change-Id: I46e8d33a4ed80e5e074e92135653d57598d4c865
parent 6b21cdeb
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -103,6 +103,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {

    private int mDataConnectionNetworkType;

    private int mOtaspMode;

    static final int PHONE_STATE_PERMISSION_MASK =
                PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR |
                PhoneStateListener.LISTEN_CALL_STATE |
@@ -225,6 +227,13 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
                            remove(r.binder);
                        }
                    }
                    if ((events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) {
                        try {
                            r.callback.onOtaspChanged(mOtaspMode);
                        } catch (RemoteException ex) {
                            remove(r.binder);
                        }
                    }
                }
            }
        } else {
@@ -467,6 +476,25 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
        }
    }

    public void notifyOtaspChanged(int otaspMode) {
        if (!checkNotifyPermission("notifyOtaspChanged()" )) {
            return;
        }
        synchronized (mRecords) {
            mOtaspMode = otaspMode;
            for (Record r : mRecords) {
                if ((r.events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) {
                    try {
                        r.callback.onOtaspChanged(otaspMode);
                    } catch (RemoteException ex) {
                        mRemoveList.add(r.binder);
                    }
                }
            }
            handleRemoveListLocked();
        }
    }

    @Override
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
+31 −0
Original line number Diff line number Diff line
@@ -148,6 +148,14 @@ public class PhoneStateListener {
     */
    public static final int LISTEN_SIGNAL_STRENGTHS                         = 0x00000100;

    /**
     * Listen for changes to OTASP mode.
     *
     * @see #onOtaspChanged
     * @hide
     */
    public static final int LISTEN_OTASP_CHANGED                            = 0x00000200;

    public PhoneStateListener() {
    }

@@ -252,6 +260,21 @@ public class PhoneStateListener {
        // default implementation empty
    }


    /**
     * The Over The Air Service Provisioning (OTASP) has changed. Requires
     * the READ_PHONE_STATE permission.
     * @param otaspMode is integer <code>OTASP_UNKNOWN=1<code>
     *   means the value is currently unknown and the system should wait until
     *   <code>OTASP_NEEDED=2<code> or <code>OTASP_NOT_NEEDED=3<code> is received before
     *   making the decisision to perform OTASP or not.
     *
     * @hide
     */
    public void onOtaspChanged(int otaspMode) {
        // default implementation empty
    }

    /**
     * The callback methods need to be called on the handler thread where
     * this object was created.  If the binder did that for us it'd be nice.
@@ -292,9 +315,14 @@ public class PhoneStateListener {
        public void onDataActivity(int direction) {
            Message.obtain(mHandler, LISTEN_DATA_ACTIVITY, direction, 0, null).sendToTarget();
        }

        public void onSignalStrengthsChanged(SignalStrength signalStrength) {
            Message.obtain(mHandler, LISTEN_SIGNAL_STRENGTHS, 0, 0, signalStrength).sendToTarget();
        }

        public void onOtaspChanged(int otaspMode) {
            Message.obtain(mHandler, LISTEN_OTASP_CHANGED, otaspMode, 0).sendToTarget();
        }
    };

    Handler mHandler = new Handler() {
@@ -329,6 +357,9 @@ public class PhoneStateListener {
                case LISTEN_SIGNAL_STRENGTHS:
                    PhoneStateListener.this.onSignalStrengthsChanged((SignalStrength)msg.obj);
                    break;
                case LISTEN_OTASP_CHANGED:
                    PhoneStateListener.this.onOtaspChanged(msg.arg1);
                    break;
            }
        }
    };
+8 −0
Original line number Diff line number Diff line
@@ -148,6 +148,14 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
        }
    }

    public void notifyOtaspChanged(Phone sender, int otaspMode) {
        try {
            mRegistry.notifyOtaspChanged(otaspMode);
        } catch (RemoteException ex) {
            // system process is dead
        }
    }

    private void log(String s) {
        Log.d(LOG_TAG, "[PhoneNotifier] " + s);
    }
+1 −0
Original line number Diff line number Diff line
@@ -32,5 +32,6 @@ oneway interface IPhoneStateListener {
    void onDataConnectionStateChanged(int state, int networkType);
    void onDataActivity(int direction);
    void onSignalStrengthsChanged(in SignalStrength signalStrength);
    void onOtaspChanged(in int otaspMode);
}
+1 −0
Original line number Diff line number Diff line
@@ -38,4 +38,5 @@ interface ITelephonyRegistry {
            in LinkCapabilities linkCapabilities, int networkType);
    void notifyDataConnectionFailed(String reason, String apnType);
    void notifyCellLocation(in Bundle cellLocation);
    void notifyOtaspChanged(in int otaspMode);
}
Loading