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

Commit e4e5dabe authored by Jack Yu's avatar Jack Yu
Browse files

Fixed that telephony registry service reference incorrectly assigned

The reference to telephony registry service was assigned
prior telephony registry service was ready. Fixed by
casting the binder every time when we use it.

Test: Manual
Bug: 65593241
Merged-In: Ib234cdfd93130f7af44ef79271b106fffb8ebad5
Change-Id: Ib234cdfd93130f7af44ef79271b106fffb8ebad5
(cherry picked from commit 66420e25)
parent a7bf2a21
Loading
Loading
Loading
Loading
+12 −11
Original line number Original line Diff line number Diff line
@@ -106,8 +106,6 @@ public class TelephonyManager {
    public static final String MODEM_ACTIVITY_RESULT_KEY =
    public static final String MODEM_ACTIVITY_RESULT_KEY =
            BatteryStats.RESULT_RECEIVER_CONTROLLER_KEY;
            BatteryStats.RESULT_RECEIVER_CONTROLLER_KEY;


    private static ITelephonyRegistry sRegistry;

    /**
    /**
     * The allowed states of Wi-Fi calling.
     * The allowed states of Wi-Fi calling.
     *
     *
@@ -178,11 +176,6 @@ public class TelephonyManager {
            mContext = context;
            mContext = context;
        }
        }
        mSubscriptionManager = SubscriptionManager.from(mContext);
        mSubscriptionManager = SubscriptionManager.from(mContext);

        if (sRegistry == null) {
            sRegistry = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService(
                    "telephony.registry"));
        }
    }
    }


    /** @hide */
    /** @hide */
@@ -3453,6 +3446,10 @@ public class TelephonyManager {
        return ITelecomService.Stub.asInterface(ServiceManager.getService(Context.TELECOM_SERVICE));
        return ITelecomService.Stub.asInterface(ServiceManager.getService(Context.TELECOM_SERVICE));
    }
    }


    private ITelephonyRegistry getTelephonyRegistry() {
        return ITelephonyRegistry.Stub.asInterface(ServiceManager.getService("telephony.registry"));
    }

    //
    //
    //
    //
    // PhoneStateListener
    // PhoneStateListener
@@ -3492,12 +3489,16 @@ public class TelephonyManager {
            if (listener.mSubId == null) {
            if (listener.mSubId == null) {
                listener.mSubId = mSubId;
                listener.mSubId = mSubId;
            }
            }
            sRegistry.listenForSubscriber(listener.mSubId, getOpPackageName(),

            ITelephonyRegistry registry = getTelephonyRegistry();
            if (registry != null) {
                registry.listenForSubscriber(listener.mSubId, getOpPackageName(),
                        listener.callback, events, notifyNow);
                        listener.callback, events, notifyNow);
            } else {
                Rlog.w(TAG, "telephony registry not ready.");
            }
        } catch (RemoteException ex) {
        } catch (RemoteException ex) {
            // system process dead
            // system process dead
        } catch (NullPointerException ex) {
            // system process dead
        }
        }
    }
    }