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

Commit e9f4fe3c authored by Nathan Harold's avatar Nathan Harold Committed by Gerrit Code Review
Browse files

Merge "Make SignalStrength constructor system APIs"

parents 391bc944 f48c0fd4
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -9003,6 +9003,10 @@ package android.telephony {
    field public static final int ROAMING_TYPE_UNKNOWN = 1; // 0x1
  }
  public class SignalStrength implements android.os.Parcelable {
    ctor public SignalStrength(@NonNull android.telephony.SignalStrength);
  }
  public final class SmsCbCmasInfo implements android.os.Parcelable {
    ctor public SmsCbCmasInfo(int, int, int, int, int, int);
    method public int describeContents();
+59 −20
Original line number Diff line number Diff line
@@ -50,6 +50,13 @@ import android.telephony.CallQuality;
import android.telephony.CellIdentity;
import android.telephony.CellInfo;
import android.telephony.CellLocation;
import android.telephony.CellSignalStrength;
import android.telephony.CellSignalStrengthCdma;
import android.telephony.CellSignalStrengthGsm;
import android.telephony.CellSignalStrengthLte;
import android.telephony.CellSignalStrengthNr;
import android.telephony.CellSignalStrengthTdscdma;
import android.telephony.CellSignalStrengthWcdma;
import android.telephony.DataFailCause;
import android.telephony.DisconnectCause;
import android.telephony.LocationAccessPolicy;
@@ -404,7 +411,11 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
        mVoiceActivationState = copyOf(mVoiceActivationState, mNumPhones);
        mDataActivationState = copyOf(mDataActivationState, mNumPhones);
        mUserMobileDataState = copyOf(mUserMobileDataState, mNumPhones);
        if (mSignalStrength != null) {
            mSignalStrength = copyOf(mSignalStrength, mNumPhones);
        } else {
            mSignalStrength = new SignalStrength[mNumPhones];
        }
        mMessageWaiting = copyOf(mMessageWaiting, mNumPhones);
        mCallForwarding = copyOf(mCallForwarding, mNumPhones);
        mCellIdentity = copyOf(mCellIdentity, mNumPhones);
@@ -438,7 +449,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
            mDataActivationState[i] = TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN;
            mCallIncomingNumber[i] =  "";
            mServiceState[i] =  new ServiceState();
            mSignalStrength[i] =  new SignalStrength();
            mSignalStrength[i] =  null;
            mUserMobileDataState[i] = false;
            mMessageWaiting[i] =  false;
            mCallForwarding[i] =  false;
@@ -522,7 +533,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
            mDataActivationState[i] = TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN;
            mCallIncomingNumber[i] =  "";
            mServiceState[i] =  new ServiceState();
            mSignalStrength[i] =  new SignalStrength();
            mSignalStrength[i] =  null;
            mUserMobileDataState[i] = false;
            mMessageWaiting[i] =  false;
            mCallForwarding[i] =  false;
@@ -799,10 +810,12 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                    }
                    if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
                        try {
                            if (mSignalStrength[phoneId] != null) {
                                int gsmSignalStrength = mSignalStrength[phoneId]
                                        .getGsmSignalStrength();
                                r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
                                        : gsmSignalStrength));
                            }
                        } catch (RemoteException ex) {
                            remove(r.binder);
                        }
@@ -859,7 +872,9 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                    }
                    if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
                        try {
                            if (mSignalStrength[phoneId] != null) {
                                r.callback.onSignalStrengthsChanged(mSignalStrength[phoneId]);
                            }
                        } catch (RemoteException ex) {
                            remove(r.binder);
                        }
@@ -2204,13 +2219,32 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {

        Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED);
        Bundle data = new Bundle();
        signalStrength.fillInNotifierBundle(data);
        fillInSignalStrengthNotifierBundle(signalStrength, data);
        intent.putExtras(data);
        intent.putExtra(PHONE_CONSTANTS_SUBSCRIPTION_KEY, subId);
        intent.putExtra(PHONE_CONSTANTS_SLOT_KEY, phoneId);
        mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
    }

    private void fillInSignalStrengthNotifierBundle(SignalStrength signalStrength, Bundle bundle) {
        List<CellSignalStrength> cellSignalStrengths = signalStrength.getCellSignalStrengths();
        for (CellSignalStrength cellSignalStrength : cellSignalStrengths) {
            if (cellSignalStrength instanceof CellSignalStrengthLte) {
                bundle.putParcelable("Lte", (CellSignalStrengthLte) cellSignalStrength);
            } else if (cellSignalStrength instanceof CellSignalStrengthCdma) {
                bundle.putParcelable("Cdma", (CellSignalStrengthCdma) cellSignalStrength);
            } else if (cellSignalStrength instanceof CellSignalStrengthGsm) {
                bundle.putParcelable("Gsm", (CellSignalStrengthGsm) cellSignalStrength);
            } else if (cellSignalStrength instanceof CellSignalStrengthWcdma) {
                bundle.putParcelable("Wcdma", (CellSignalStrengthWcdma) cellSignalStrength);
            } else if (cellSignalStrength instanceof CellSignalStrengthTdscdma) {
                bundle.putParcelable("Tdscdma", (CellSignalStrengthTdscdma) cellSignalStrength);
            } else if (cellSignalStrength instanceof CellSignalStrengthNr) {
                bundle.putParcelable("Nr", (CellSignalStrengthNr) cellSignalStrength);
            }
        }
    }

    /**
     * Broadcasts an intent notifying apps of a phone state change. {@code subId} can be
     * a valid subId, in which case this function fires a subId-specific intent, or it
@@ -2519,11 +2553,14 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {

        if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
            try {
                if (mSignalStrength[phoneId] != null) {
                    SignalStrength signalStrength = mSignalStrength[phoneId];
                    if (DBG) {
                    log("checkPossibleMissNotify: onSignalStrengthsChanged SS=" + signalStrength);
                        log("checkPossibleMissNotify: onSignalStrengthsChanged SS="
                                + signalStrength);
                    }
                    r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
                }
            } catch (RemoteException ex) {
                mRemoveList.add(r.binder);
            }
@@ -2531,14 +2568,16 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {

        if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
            try {
                if (mSignalStrength[phoneId] != null) {
                    int gsmSignalStrength = mSignalStrength[phoneId]
                            .getGsmSignalStrength();
                    if (DBG) {
                    log("checkPossibleMissNotify: onSignalStrengthChanged SS=" +
                            gsmSignalStrength);
                        log("checkPossibleMissNotify: onSignalStrengthChanged SS="
                                + gsmSignalStrength);
                    }
                    r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
                            : gsmSignalStrength));
                }
            } catch (RemoteException ex) {
                mRemoveList.add(r.binder);
            }
+3 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.telephony;
import com.android.telephony.Rlog;

import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.Build;
import android.os.Bundle;
@@ -277,8 +278,8 @@ public class SignalStrength implements Parcelable {
     *
     * @hide
     */
    @UnsupportedAppUsage
    public SignalStrength(SignalStrength s) {
    @SystemApi
    public SignalStrength(@NonNull SignalStrength s) {
        copyFrom(s);
    }