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

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

Merge "Notify CellLocation whenever ACTION_USER_SWITCHED"

parents d3cb1715 9a218feb
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -60,7 +60,6 @@ interface ITelephonyRegistry {
    void notifyDataConnectionForSubscriber(
    void notifyDataConnectionForSubscriber(
            int phoneId, int subId, in PreciseDataConnectionState preciseState);
            int phoneId, int subId, in PreciseDataConnectionState preciseState);
    // Uses CellIdentity which is Parcelable here; will convert to CellLocation in client.
    // Uses CellIdentity which is Parcelable here; will convert to CellLocation in client.
    void notifyCellLocation(in CellIdentity cellLocation);
    void notifyCellLocationForSubscriber(in int subId, in CellIdentity cellLocation);
    void notifyCellLocationForSubscriber(in int subId, in CellIdentity cellLocation);
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    void notifyCellInfo(in List<CellInfo> cellInfo);
    void notifyCellInfo(in List<CellInfo> cellInfo);
+17 −12
Original line number Original line Diff line number Diff line
@@ -402,10 +402,15 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
            switch (msg.what) {
            switch (msg.what) {
                case MSG_USER_SWITCHED: {
                case MSG_USER_SWITCHED: {
                    if (VDBG) log("MSG_USER_SWITCHED userId=" + msg.arg1);
                    if (VDBG) log("MSG_USER_SWITCHED userId=" + msg.arg1);
                    int numPhones = getTelephonyManager().getPhoneCount();
                    int numPhones = getTelephonyManager().getActiveModemCount();
                    for (int sub = 0; sub < numPhones; sub++) {
                    for (int phoneId = 0; phoneId < numPhones; phoneId++) {
                        TelephonyRegistry.this.notifyCellLocationForSubscriber(sub,
                        int[] subIds = SubscriptionManager.getSubId(phoneId);
                                mCellIdentity[sub]);
                        int subId =
                                (subIds != null) && (subIds.length > 0)
                                        ? subIds[0]
                                        : SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
                        TelephonyRegistry.this.notifyCellLocationForSubscriber(
                                subId, mCellIdentity[phoneId], true /* hasUserSwitched */);
                    }
                    }
                    break;
                    break;
                }
                }
@@ -1879,20 +1884,20 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
    }
    }


    @Override
    @Override
    public void notifyCellLocation(CellIdentity cellLocation) {
    public void notifyCellLocationForSubscriber(int subId, CellIdentity cellIdentity) {
        notifyCellLocationForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellLocation);
        notifyCellLocationForSubscriber(subId, cellIdentity, false /* hasUserSwitched */);
    }
    }


    @Override
    private void notifyCellLocationForSubscriber(int subId, CellIdentity cellIdentity,
    public void notifyCellLocationForSubscriber(int subId, CellIdentity cellIdentity) {
            boolean hasUserSwitched) {
        log("notifyCellLocationForSubscriber: subId=" + subId
        log("notifyCellLocationForSubscriber: subId=" + subId + " cellIdentity=" + cellIdentity);
                + " cellIdentity=" + cellIdentity);
        if (!checkNotifyPermission("notifyCellLocation()")) {
        if (!checkNotifyPermission("notifyCellLocation()")) {
            return;
            return;
        }
        }
        int phoneId = getPhoneIdFromSubId(subId);
        int phoneId = getPhoneIdFromSubId(subId);
        synchronized (mRecords) {
        synchronized (mRecords) {
            if (validatePhoneId(phoneId) && !Objects.equals(cellIdentity, mCellIdentity[phoneId])) {
            if (validatePhoneId(phoneId)
                    && (hasUserSwitched || !Objects.equals(cellIdentity, mCellIdentity[phoneId]))) {
                mCellIdentity[phoneId] = cellIdentity;
                mCellIdentity[phoneId] = cellIdentity;
                for (Record r : mRecords) {
                for (Record r : mRecords) {
                    if (validateEventAndUserLocked(
                    if (validateEventAndUserLocked(
@@ -2553,7 +2558,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
            final int recordCount = mRecords.size();
            final int recordCount = mRecords.size();
            pw.println("last known state:");
            pw.println("last known state:");
            pw.increaseIndent();
            pw.increaseIndent();
            for (int i = 0; i < getTelephonyManager().getPhoneCount(); i++) {
            for (int i = 0; i < getTelephonyManager().getActiveModemCount(); i++) {
                pw.println("Phone Id=" + i);
                pw.println("Phone Id=" + i);
                pw.increaseIndent();
                pw.increaseIndent();
                pw.println("mCallState=" + mCallState[i]);
                pw.println("mCallState=" + mCallState[i]);