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

Commit 3fca0f85 authored by Shuo Qian's avatar Shuo Qian Committed by Gerrit Code Review
Browse files

Merge "Add Emergency Number metrics for Q"

parents 14364026 9d5949bb
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
@@ -642,6 +642,38 @@ message RilDataCall {
  }
}

message EmergencyNumberInfo {
  // Dialing address
  optional string address = 1 /* [
    (datapol.semantic_type) = ST_PHONE_NUMBER,
    (datapol.qualifier) = {is_public: true}
  ] */;

  // Country code string (lowercase character) in ISO 3166 format
  optional string country_iso = 2 /* [(datapol.semantic_type) = ST_LOCATION] */;

  // Mobile Network Code
  optional string mnc = 3 /* [(datapol.semantic_type) = ST_LOCATION] */;

  // Bitmask of emergency service categories
  optional int32 service_categories_bitmask = 4;

  // Emergency Uniform Resources Names (URN)
  // Reference: https://tools.ietf.org/html/rfc5031
  repeated string urns = 5;

  // Bitmask of the sources
  optional int32 number_sources_bitmask = 6;

  // Emergency call routing information.
  // Emergency call routing is a flag to tell how modem handles the calling with
  // emergency numbers. For example, 110 in India, modem needs to handle/route
  // it like a normal call. There are only two possible options for emergency
  // call routing: emergency call routing vs normal call routing. It is usually
  // a country or carrier requirement.
  optional int32 routing = 7;
}

message TelephonyEvent {

  enum Type {
@@ -710,6 +742,9 @@ message TelephonyEvent {

    // Enabled modem change event.
    ENABLED_MODEM_CHANGED = 20;

    // Emergency Number update event (Device HAL >= 1.4).
    EMERGENCY_NUMBER_REPORT = 21;
  }

  enum ApnType {
@@ -1649,6 +1684,9 @@ message TelephonyEvent {
  // The modem state represent by a bitmap, the i-th bit(LSB) indicates the i-th modem
  // state (0 - disabled, 1 - enabled).
  optional int32 enabled_modem_bitmap = 24;

  // Updated Emergency Call info.
  optional EmergencyNumberInfo updated_emergency_number = 25;
}

message ActiveSubscriptionInfo {
@@ -1952,6 +1990,12 @@ message TelephonyCallSession {
      // Detailed cause code for CS Call failures
      // frameworks/base/telephony/java/android/telephony/PreciseDisconnectCause.java
      optional int32 precise_disconnect_cause = 6;

      // Indicate if the call is an emergency call
      optional bool is_emergency_call = 7;

      // Indicate the emergency call information dialed from the CS call
      optional EmergencyNumberInfo emergency_number_info = 8;
    }

    // Single Radio Voice Call Continuity(SRVCC) progress state
@@ -2173,6 +2217,11 @@ message TelephonyCallSession {
    // Uplink call quality summary at the end of a call
    optional CallQualitySummary call_quality_summary_ul = 25;

    // Indicate if it is IMS emergency call
    optional bool is_ims_emergency_call = 26;

    // Emergency call info
    optional EmergencyNumberInfo ims_emergency_number_info = 27;
  }

  // Time when call has started, in minutes since epoch,
+27 −7
Original line number Diff line number Diff line
@@ -1091,8 +1091,10 @@ public class GsmCdmaCallTracker extends CallTracker {
                newUnknownConnectionCdma = null;
            }
        }

        if (locallyDisconnectedConnections.size() > 0) {
            mMetrics.writeRilCallList(mPhone.getPhoneId(), locallyDisconnectedConnections);
            mMetrics.writeRilCallList(mPhone.getPhoneId(), locallyDisconnectedConnections,
                    getNetworkCountryIso());
        }

        /* Disconnect any pending Handover connections */
@@ -1163,7 +1165,7 @@ public class GsmCdmaCallTracker extends CallTracker {
        for (GsmCdmaConnection conn : connections) {
            if (conn != null) activeConnections.add(conn);
        }
        mMetrics.writeRilCallList(mPhone.getPhoneId(), activeConnections);
        mMetrics.writeRilCallList(mPhone.getPhoneId(), activeConnections, getNetworkCountryIso());
    }

    private void handleRadioNotAvailable() {
@@ -1236,7 +1238,8 @@ public class GsmCdmaCallTracker extends CallTracker {
            return;
        } else {
            try {
                mMetrics.writeRilHangup(mPhone.getPhoneId(), conn, conn.getGsmCdmaIndex());
                mMetrics.writeRilHangup(mPhone.getPhoneId(), conn, conn.getGsmCdmaIndex(),
                        getNetworkCountryIso());
                mCi.hangupConnection (conn.getGsmCdmaIndex(), obtainCompleteMessage());
            } catch (CallStateException ex) {
                // Ignore "connection not found"
@@ -1331,7 +1334,7 @@ public class GsmCdmaCallTracker extends CallTracker {
            } catch (CallStateException ex) {
                call_index = -1;
            }
            mMetrics.writeRilHangup(mPhone.getPhoneId(), cn, call_index);
            mMetrics.writeRilHangup(mPhone.getPhoneId(), cn, call_index, getNetworkCountryIso());
        }
        if (VDBG) Rlog.v(LOG_TAG, "logHangupEvent logged " + count + " Connections ");
    }
@@ -1353,7 +1356,8 @@ public class GsmCdmaCallTracker extends CallTracker {
        for (int i = 0; i < count; i++) {
            GsmCdmaConnection cn = (GsmCdmaConnection)call.mConnections.get(i);
            if (!cn.mDisconnected && cn.getGsmCdmaIndex() == index) {
                mMetrics.writeRilHangup(mPhone.getPhoneId(), cn, cn.getGsmCdmaIndex());
                mMetrics.writeRilHangup(mPhone.getPhoneId(), cn, cn.getGsmCdmaIndex(),
                        getNetworkCountryIso());
                mCi.hangupConnection(index, obtainCompleteMessage());
                return;
            }
@@ -1368,7 +1372,8 @@ public class GsmCdmaCallTracker extends CallTracker {
            for (int i = 0; i < count; i++) {
                GsmCdmaConnection cn = (GsmCdmaConnection)call.mConnections.get(i);
                if (!cn.mDisconnected) {
                    mMetrics.writeRilHangup(mPhone.getPhoneId(), cn, cn.getGsmCdmaIndex());
                    mMetrics.writeRilHangup(mPhone.getPhoneId(), cn, cn.getGsmCdmaIndex(),
                            getNetworkCountryIso());
                    mCi.hangupConnection(cn.getGsmCdmaIndex(), obtainCompleteMessage());
                }
            }
@@ -1551,7 +1556,8 @@ public class GsmCdmaCallTracker extends CallTracker {
                updatePhoneState();

                mPhone.notifyPreciseCallStateChanged();
                mMetrics.writeRilCallList(mPhone.getPhoneId(), mDroppedDuringPoll);
                mMetrics.writeRilCallList(mPhone.getPhoneId(), mDroppedDuringPoll,
                        getNetworkCountryIso());
                mDroppedDuringPoll.clear();
            break;

@@ -1797,6 +1803,20 @@ public class GsmCdmaCallTracker extends CallTracker {
                MAX_CONNECTIONS_PER_CALL_CDMA;
    }

    private String getNetworkCountryIso() {
        String countryIso = "";
        if (mPhone != null) {
            ServiceStateTracker sst = mPhone.getServiceStateTracker();
            if (sst != null) {
                LocaleTracker lt = sst.getLocaleTracker();
                if (lt != null) {
                    countryIso = lt.getCurrentCountry();
                }
            }
        }
        return countryIso;
    }

    /**
     * Called to force the call tracker to cleanup any stale calls.  Does this by triggering
     * {@code GET_CURRENT_CALLS} on the RIL.
+16 −2
Original line number Diff line number Diff line
@@ -43,10 +43,13 @@ import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.ServiceStateTracker;
import com.android.internal.telephony.SubscriptionController;
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.util.IndentingPrintWriter;
import com.android.phone.ecc.nano.ProtobufEccData;
import com.android.phone.ecc.nano.ProtobufEccData.EccInfo;

import libcore.io.IoUtils;

import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileDescriptor;
@@ -58,8 +61,6 @@ import java.util.Collections;
import java.util.List;
import java.util.zip.GZIPInputStream;

import libcore.io.IoUtils;

/**
 * Emergency Number Tracker that handles update of emergency number list from RIL and emergency
 * number database. This is multi-sim based and each Phone has a EmergencyNumberTracker.
@@ -358,6 +359,7 @@ public class EmergencyNumberTracker extends Handler {
        if (!emergencyNumberListRadio.equals(mEmergencyNumberListFromRadio)) {
            try {
                EmergencyNumber.mergeSameNumbersInEmergencyNumberList(emergencyNumberListRadio);
                writeUpdatedEmergencyNumberListMetrics(emergencyNumberListRadio);
                mEmergencyNumberListFromRadio = emergencyNumberListRadio;
                if (!DBG) {
                    mEmergencyNumberListRadioLocalLog.log("updateRadioEmergencyNumberList:"
@@ -382,6 +384,7 @@ public class EmergencyNumberTracker extends Handler {

        mCountryIso = countryIso.toLowerCase();
        cacheEmergencyDatabaseByCountry(countryIso);
        writeUpdatedEmergencyNumberListMetrics(mEmergencyNumberListFromDatabase);
        if (!DBG) {
            mEmergencyNumberListDatabaseLocalLog.log(
                    "updateEmergencyNumberListDatabaseAndNotify:"
@@ -835,6 +838,17 @@ public class EmergencyNumberTracker extends Handler {
        Rlog.e(TAG, str);
    }

    private void writeUpdatedEmergencyNumberListMetrics(
            List<EmergencyNumber> updatedEmergencyNumberList) {
        if (updatedEmergencyNumberList == null) {
            return;
        }
        for (EmergencyNumber num : updatedEmergencyNumberList) {
            TelephonyMetrics.getInstance().writeEmergencyNumberUpdateEvent(
                    mPhone.getPhoneId(), num);
        }
    }

    /**
     * Dump Emergency Number List info in the tracking
     *
+18 −1
Original line number Diff line number Diff line
@@ -92,9 +92,11 @@ import com.android.internal.telephony.CallTracker;
import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.Connection;
import com.android.internal.telephony.LocaleTracker;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.PhoneInternalInterface;
import com.android.internal.telephony.ServiceStateTracker;
import com.android.internal.telephony.SubscriptionController;
import com.android.internal.telephony.TelephonyProperties;
import com.android.internal.telephony.dataconnection.DataEnabledSettings;
@@ -2344,7 +2346,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {

            String callId = imsCall.getSession().getCallId();
            mMetrics.writeOnImsCallTerminated(mPhone.getPhoneId(), imsCall.getCallSession(),
                    reasonInfo, mCallQualityMetrics.get(callId));
                    reasonInfo, mCallQualityMetrics.get(callId), conn.getEmergencyNumberInfo(),
                    getNetworkCountryIso());
            pruneCallQualityMetricsHistory();
            mPhone.notifyImsReason(reasonInfo);

@@ -4196,6 +4199,20 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        mAlwaysPlayRemoteHoldTone = shouldPlayRemoteHoldTone;
    }

    private String getNetworkCountryIso() {
        String countryIso = "";
        if (mPhone != null) {
            ServiceStateTracker sst = mPhone.getServiceStateTracker();
            if (sst != null) {
                LocaleTracker lt = sst.getLocaleTracker();
                if (lt != null) {
                    countryIso = lt.getCurrentCountry();
                }
            }
        }
        return countryIso;
    }

    public ImsPhone getPhone() {
        return mPhone;
    }
+14 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.telephony.metrics;

import com.android.internal.telephony.nano.TelephonyProto.EmergencyNumberInfo;
import com.android.internal.telephony.nano.TelephonyProto.ImsCapabilities;
import com.android.internal.telephony.nano.TelephonyProto.ImsConnectionState;
import com.android.internal.telephony.nano.TelephonyProto.ImsReasonInfo;
@@ -156,4 +157,17 @@ public class CallSessionEventBuilder {
        mEvent.callQualitySummaryUl = callQualitySummary;
        return this;
    }

    /** Set if the Ims call is emergency. */
    public CallSessionEventBuilder setIsImsEmergencyCall(boolean isImsEmergencyCall) {
        mEvent.isImsEmergencyCall = isImsEmergencyCall;
        return this;
    }

    /** Set the Ims emergency call information. */
    public CallSessionEventBuilder setImsEmergencyNumberInfo(
            EmergencyNumberInfo imsEmergencyNumberInfo) {
        mEvent.imsEmergencyNumberInfo = imsEmergencyNumberInfo;
        return this;
    }
}
Loading