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

Commit fab7839a authored by Chen Xu's avatar Chen Xu Committed by android-build-merger
Browse files

Merge "add version to carrier identification metrics"

am: ddde95c2

Change-Id: I572421f4b4aa9e9d6c3c9dea21a4c264b478749f
parents b4bc8f54 ddde95c2
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -555,17 +555,26 @@ public class CarrierIdentifier extends Handler {

        /*
         * Write Carrier Identification Matching event, logging with the
         * matching score and carrierId to differentiate below cases of metrics:
         * carrierId, gid1 and carrier list version to differentiate below cases of metrics:
         * 1) unknown mccmnc - the Carrier Id provider contains no rule that matches the
         * read mccmnc.
         * 2) the Carrier Id provider contains some rule(s) that match the read mccmnc,
         * but the read gid1 is not matched within the highest-scored rule.
         * 3) successfully found a matched carrier id in the provider.
         * 4) use carrier list version to compare the unknown carrier ratio between each version.
         */
        String gid1ToLog = ((maxScore & CarrierMatchingRule.SCORE_GID1) == 0
                && !TextUtils.isEmpty(subscriptionRule.mGid1)) ? subscriptionRule.mGid1 : null;
        TelephonyMetrics.getInstance().writeCarrierIdMatchingEvent(
                mPhone.getPhoneId(), mCarrierId, gid1ToLog);
                mPhone.getPhoneId(), getCarrierListVersion(), mCarrierId, gid1ToLog);
    }

    private int getCarrierListVersion() {
        final Cursor cursor = mContext.getContentResolver().query(
                Uri.withAppendedPath(Telephony.CarrierIdentification.CONTENT_URI,
                "get_version"), null, null, null);
        cursor.moveToFirst();
        return cursor.getInt(0);
    }

    public int getCarrierId() {
@@ -599,6 +608,7 @@ public class CarrierIdentifier extends Handler {

        ipw.println("mCarrierId: " + mCarrierId);
        ipw.println("mCarrierName: " + mCarrierName);
        ipw.println("version: " + getCarrierListVersion());

        ipw.println("mCarrierMatchingRules on mccmnc: "
                + mTelephonyMgr.getSimOperatorNumericForPhone(mPhone.getPhoneId()));
+3 −1
Original line number Diff line number Diff line
@@ -1721,10 +1721,11 @@ public class TelephonyMetrics {
     * Write carrier identification matching event
     *
     * @param phoneId Phone id
     * @param version Carrier table version
     * @param cid Unique Carrier Id
     * @param gid1 Group id level 1
     */
    public void writeCarrierIdMatchingEvent(int phoneId, int cid, String gid1) {
    public void writeCarrierIdMatchingEvent(int phoneId, int version, int cid, String gid1) {
        final CarrierIdMatching carrierIdMatching = new CarrierIdMatching();
        final CarrierIdMatchingResult carrierIdMatchingResult = new CarrierIdMatchingResult();

@@ -1735,6 +1736,7 @@ public class TelephonyMetrics {
            }
        }

        carrierIdMatching.cidTableVersion = version;
        carrierIdMatching.result = carrierIdMatchingResult;

        TelephonyEvent event = new TelephonyEventBuilder(phoneId).setCarrierIdMatching(
+4 −2
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ public class TelephonyMetricsTest extends TelephonyTest {
    @SmallTest
    public void testWriteCarrierIdMatchingEventWithInvalidMatchingScore() throws Exception {

        mMetrics.writeCarrierIdMatchingEvent(mPhone.getPhoneId(),
        mMetrics.writeCarrierIdMatchingEvent(mPhone.getPhoneId(), 1,
                TelephonyManager.UNKNOWN_CARRIER_ID, "gid1Test");
        TelephonyLog log = buildProto();

@@ -196,6 +196,7 @@ public class TelephonyMetricsTest extends TelephonyTest {
        assertEquals(0, log.smsSessions.length);

        assertEquals(mPhone.getPhoneId(), log.events[0].phoneId);
        assertEquals(1, log.events[0].carrierIdMatching.cidTableVersion);
        assertEquals(TelephonyEvent.Type.CARRIER_ID_MATCHING, log.events[0].type);
        assertTrue(log.events[0].carrierIdMatching.result.gid1.isEmpty());
    }
@@ -205,7 +206,7 @@ public class TelephonyMetricsTest extends TelephonyTest {
    @SmallTest
    public void testWriteCarrierIdMatchingEvent() throws Exception {

        mMetrics.writeCarrierIdMatchingEvent(mPhone.getPhoneId(), 1, "gid1Test");
        mMetrics.writeCarrierIdMatchingEvent(mPhone.getPhoneId(), 1, 1, "gid1Test");
        TelephonyLog log = buildProto();

        assertEquals(1, log.events.length);
@@ -214,6 +215,7 @@ public class TelephonyMetricsTest extends TelephonyTest {

        assertEquals(mPhone.getPhoneId(), log.events[0].phoneId);
        assertEquals(TelephonyEvent.Type.CARRIER_ID_MATCHING, log.events[0].type);
        assertEquals(1, log.events[0].carrierIdMatching.cidTableVersion);
        assertEquals(1, log.events[0].carrierIdMatching.result.carrierId);
        assertEquals("gid1Test", log.events[0].carrierIdMatching.result.gid1);
    }