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

Commit 1325500a authored by Chi Zhang's avatar Chi Zhang Committed by Android (Google) Code Review
Browse files

Merge "Add radio_state to telephony.proto" into sc-dev

parents bfff58e1 fddc6116
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -853,6 +853,9 @@ message TelephonyEvent {

    // Signal strength
    SIGNAL_STRENGTH = 23;

    // Radio state change event
    RADIO_STATE_CHANGED = 24;
  }

  enum ApnType {
@@ -901,6 +904,20 @@ message TelephonyEvent {
    NETWORK_VALIDATION_STATE_PASSED = 3;
  }

  enum RadioState {
    /** Radio state is unknown or invalid. */
    RADIO_STATE_UNKNOWN = 0;

    /** Radio is explicitly off (e.g. airplane mode). */
    RADIO_STATE_OFF = 1;

    /** Radio is on. */
    RADIO_STATE_ON = 2;

    /** Radio power unavailable (eg, modem resetting or not booted). */
    RADIO_STATE_UNAVAILABLE = 3;
  }

  message DataSwitch {
    enum Reason {
      /** Data switch caused by unknown reason. */
@@ -1845,6 +1862,9 @@ message TelephonyEvent {
  //  (datapol.semantic_type) = ST_SOFTWARE_ID,
  //  (datapol.qualifier) = { is_public: true }
  //]

  // Radio state for the given phone_id
  optional RadioState radio_state = 29;
}

message ActiveSubscriptionInfo {
+6 −2
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
import android.telephony.AccessNetworkConstants;
import android.telephony.Annotation.RadioPowerState;
import android.telephony.BarringInfo;
import android.telephony.CarrierConfigManager;
import android.telephony.CellIdentity;
@@ -97,6 +98,7 @@ import com.android.internal.telephony.gsm.SuppServiceNotification;
import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
import com.android.internal.telephony.imsphone.ImsPhoneMmiCode;
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.telephony.metrics.VoiceCallSessionStats;
import com.android.internal.telephony.test.SimulatedRadioControl;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
@@ -2772,8 +2774,10 @@ public class GsmCdmaPhone extends Phone {
    }

    private void handleRadioPowerStateChange() {
        Rlog.d(LOG_TAG, "handleRadioPowerStateChange, state= " + mCi.getRadioState());
        mNotifier.notifyRadioPowerStateChanged(this, mCi.getRadioState());
        @RadioPowerState int newState = mCi.getRadioState();
        Rlog.d(LOG_TAG, "handleRadioPowerStateChange, state= " + newState);
        mNotifier.notifyRadioPowerStateChanged(this, newState);
        TelephonyMetrics.getInstance().writeRadioState(mPhoneId, newState);
    }

    @Override
+7 −0
Original line number Diff line number Diff line
@@ -226,4 +226,11 @@ public class TelephonyEventBuilder {
        mEvent.networkCapabilities = networkCapabilities;
        return this;
    }

    /** Set radio state. */
    public TelephonyEventBuilder setRadioState(int radioState) {
        mEvent.type = TelephonyEvent.Type.RADIO_STATE_CHANGED;
        mEvent.radioState = radioState;
        return this;
    }
}
+40 −23
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.os.SystemClock;
import android.os.SystemProperties;
import android.provider.Telephony.Sms.Intents;
import android.telephony.AccessNetworkConstants;
import android.telephony.Annotation.RadioPowerState;
import android.telephony.CallQuality;
import android.telephony.DisconnectCause;
import android.telephony.NetworkRegistrationInfo;
@@ -109,6 +110,7 @@ import com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent.DataSwi
import com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent.ModemRestart;
import com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent.NetworkCapabilitiesInfo;
import com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent.OnDemandDataSwitch;
import com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent.RadioState;
import com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent.RilDeactivateDataCall;
import com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent.RilDeactivateDataCall.DeactivateReason;
import com.android.internal.telephony.nano.TelephonyProto.TelephonyEvent.RilSetupDataCall;
@@ -183,8 +185,7 @@ public class TelephonyMetrics {
    private final SparseArray<TelephonyServiceState> mLastServiceState = new SparseArray<>();

    /**
     * Last ims capabilities. This is for injecting the base of a new log or a new call/sms
     * session
     * Last ims capabilities. This is for injecting the base of a new log or a new call/sms session
     */
    private final SparseArray<ImsCapabilities> mLastImsCapabilities = new SparseArray<>();

@@ -194,19 +195,16 @@ public class TelephonyMetrics {
     */
    private final SparseArray<ImsConnectionState> mLastImsConnectionState = new SparseArray<>();

    /**
     * Last settings state. This is for deduping same settings event logged.
     */
    /** Last settings state. This is for deduping same settings event logged. */
    private final SparseArray<TelephonySettings> mLastSettings = new SparseArray<>();

    /**
     * Last sim state, indexed by phone id.
     */
    /** Last sim state, indexed by phone id. */
    private final SparseArray<Integer> mLastSimState = new SparseArray<>();

    /**
     * Last active subscription information, indexed by phone id.
     */
    /** Last radio state, indexed by phone id. */
    private final SparseArray<Integer> mLastRadioState = new SparseArray<>();

    /** Last active subscription information, indexed by phone id. */
    private final SparseArray<ActiveSubscriptionInfo> mLastActiveSubscriptionInfos =
            new SparseArray<>();

@@ -218,26 +216,18 @@ public class TelephonyMetrics {
     */
    private int mLastEnabledModemBitmap = (1 << TelephonyManager.getDefault().getPhoneCount()) - 1;

    /**
     * Last carrier id matching.
     */
    /** Last carrier id matching. */
    private final SparseArray<CarrierIdMatching> mLastCarrierId = new SparseArray<>();

    /**
     * Last NetworkCapabilitiesInfo, indexed by phone id.
     */
    /** Last NetworkCapabilitiesInfo, indexed by phone id. */
    private final SparseArray<NetworkCapabilitiesInfo> mLastNetworkCapabilitiesInfos =
            new SparseArray<>();

    /**
     * Last RilDataCall Events (indexed by cid), indexed by phone id
     */
    /** Last RilDataCall Events (indexed by cid), indexed by phone id */
    private final SparseArray<SparseArray<RilDataCall>> mLastRilDataCallEvents =
            new SparseArray<>();

    /**
     * List of Tx and Rx Bandwidth estimation stats maps
     */
    /** List of Tx and Rx Bandwidth estimation stats maps */
    private final List<Map<String, BwEstimationStats>> mBwEstStatsMapList = new ArrayList<>(
            Arrays.asList(new ArrayMap<>(), new ArrayMap<>()));

@@ -749,6 +739,12 @@ public class TelephonyMetrics {
            }
        }

        for (int i = 0; i < mLastRadioState.size(); i++) {
            final int key = mLastRadioState.keyAt(i);
            TelephonyEvent event = new TelephonyEventBuilder(mStartElapsedTimeMs, key)
                    .setRadioState(mLastRadioState.get(key)).build();
            addTelephonyEvent(event);
        }
    }

    /**
@@ -2710,6 +2706,27 @@ public class TelephonyMetrics {
        addTelephonyEvent(event);
    }

    /** Write radio state changed event */
    public void writeRadioState(int phoneId, @RadioPowerState int state) {
        int radioState = convertRadioState(state);
        TelephonyEvent event = new TelephonyEventBuilder(phoneId).setRadioState(radioState).build();
        mLastRadioState.put(phoneId, radioState);
        addTelephonyEvent(event);
    }

    private static int convertRadioState(@RadioPowerState int state) {
        switch (state) {
            case TelephonyManager.RADIO_POWER_OFF:
                return RadioState.RADIO_STATE_OFF;
            case TelephonyManager.RADIO_POWER_ON:
                return RadioState.RADIO_STATE_ON;
            case TelephonyManager.RADIO_POWER_UNAVAILABLE:
                return RadioState.RADIO_STATE_UNAVAILABLE;
            default:
                return RadioState.RADIO_STATE_UNKNOWN;
        }
    }

    /**
     * Convert SMS format
     */