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

Commit 55e2379c authored by sqian's avatar sqian Committed by android-build-merger
Browse files

Merge "Add mccmnc into local telephony proto and metrics" am: aa3b7d02

am: dc99b31a

Change-Id: Ibb5913b548eab12dc4af976d7d980f70274e3d43
parents 6cbc3335 dc99b31a
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -794,6 +794,10 @@ message TelephonyEvent {
    // Group id level 1. Logged only if gid1 is configured from subscription
    // Group id level 1. Logged only if gid1 is configured from subscription
    // but its matching rule is unknown
    // but its matching rule is unknown
    optional string gid1 = 2;
    optional string gid1 = 2;

    // MCC and MNC that map to this carrier. Logged only if mccmnc is configured
    // from subscription but its matching rule is unknown
    optional string mccmnc = 3;
  }
  }


  // Time when event happened on device, in milliseconds since epoch
  // Time when event happened on device, in milliseconds since epoch
+5 −2
Original line number Original line Diff line number Diff line
@@ -575,10 +575,13 @@ public class CarrierIdentifier extends Handler {
         * 3) successfully found a matched carrier id in the provider.
         * 3) successfully found a matched carrier id in the provider.
         * 4) use carrier list version to compare the unknown carrier ratio between each version.
         * 4) use carrier list version to compare the unknown carrier ratio between each version.
         */
         */
        String gid1ToLog = ((maxScore & CarrierMatchingRule.SCORE_GID1) == 0
        String unknownGid1ToLog = ((maxScore & CarrierMatchingRule.SCORE_GID1) == 0
                && !TextUtils.isEmpty(subscriptionRule.mGid1)) ? subscriptionRule.mGid1 : null;
                && !TextUtils.isEmpty(subscriptionRule.mGid1)) ? subscriptionRule.mGid1 : null;
        String unknownMccmncToLog = (maxScore == CarrierMatchingRule.SCORE_INVALID
                && !TextUtils.isEmpty(subscriptionRule.mMccMnc)) ? subscriptionRule.mMccMnc : null;
        TelephonyMetrics.getInstance().writeCarrierIdMatchingEvent(
        TelephonyMetrics.getInstance().writeCarrierIdMatchingEvent(
                mPhone.getPhoneId(), getCarrierListVersion(), mCarrierId, gid1ToLog);
                mPhone.getPhoneId(), getCarrierListVersion(), mCarrierId,
                unknownMccmncToLog, unknownGid1ToLog);
    }
    }


    private int getCarrierListVersion() {
    private int getCarrierListVersion() {
+5 −1
Original line number Original line Diff line number Diff line
@@ -1754,9 +1754,11 @@ public class TelephonyMetrics {
     * @param phoneId Phone id
     * @param phoneId Phone id
     * @param version Carrier table version
     * @param version Carrier table version
     * @param cid Unique Carrier Id
     * @param cid Unique Carrier Id
     * @param mccmnc MCC and MNC that map to this carrier
     * @param gid1 Group id level 1
     * @param gid1 Group id level 1
     */
     */
    public void writeCarrierIdMatchingEvent(int phoneId, int version, int cid, String gid1) {
    public void writeCarrierIdMatchingEvent(int phoneId, int version, int cid,
                                            String mccmnc, String gid1) {
        final CarrierIdMatching carrierIdMatching = new CarrierIdMatching();
        final CarrierIdMatching carrierIdMatching = new CarrierIdMatching();
        final CarrierIdMatchingResult carrierIdMatchingResult = new CarrierIdMatchingResult();
        final CarrierIdMatchingResult carrierIdMatchingResult = new CarrierIdMatchingResult();


@@ -1765,6 +1767,8 @@ public class TelephonyMetrics {
            if (gid1 != null) {
            if (gid1 != null) {
                carrierIdMatchingResult.gid1 = gid1;
                carrierIdMatchingResult.gid1 = gid1;
            }
            }
        } else {
            carrierIdMatchingResult.mccmnc = mccmnc;
        }
        }


        carrierIdMatching.cidTableVersion = version;
        carrierIdMatching.cidTableVersion = version;
+4 −2
Original line number Original line Diff line number Diff line
@@ -188,7 +188,7 @@ public class TelephonyMetricsTest extends TelephonyTest {
    public void testWriteCarrierIdMatchingEventWithInvalidMatchingScore() throws Exception {
    public void testWriteCarrierIdMatchingEventWithInvalidMatchingScore() throws Exception {


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


        assertEquals(1, log.events.length);
        assertEquals(1, log.events.length);
@@ -198,6 +198,7 @@ public class TelephonyMetricsTest extends TelephonyTest {
        assertEquals(mPhone.getPhoneId(), log.events[0].phoneId);
        assertEquals(mPhone.getPhoneId(), log.events[0].phoneId);
        assertEquals(1, log.events[0].carrierIdMatching.cidTableVersion);
        assertEquals(1, log.events[0].carrierIdMatching.cidTableVersion);
        assertEquals(TelephonyEvent.Type.CARRIER_ID_MATCHING, log.events[0].type);
        assertEquals(TelephonyEvent.Type.CARRIER_ID_MATCHING, log.events[0].type);
        assertEquals("mccmncTest", log.events[0].carrierIdMatching.result.mccmnc);
        assertTrue(log.events[0].carrierIdMatching.result.gid1.isEmpty());
        assertTrue(log.events[0].carrierIdMatching.result.gid1.isEmpty());
    }
    }


@@ -206,7 +207,7 @@ public class TelephonyMetricsTest extends TelephonyTest {
    @SmallTest
    @SmallTest
    public void testWriteCarrierIdMatchingEvent() throws Exception {
    public void testWriteCarrierIdMatchingEvent() throws Exception {


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


        assertEquals(1, log.events.length);
        assertEquals(1, log.events.length);
@@ -217,6 +218,7 @@ public class TelephonyMetricsTest extends TelephonyTest {
        assertEquals(TelephonyEvent.Type.CARRIER_ID_MATCHING, log.events[0].type);
        assertEquals(TelephonyEvent.Type.CARRIER_ID_MATCHING, log.events[0].type);
        assertEquals(1, log.events[0].carrierIdMatching.cidTableVersion);
        assertEquals(1, log.events[0].carrierIdMatching.cidTableVersion);
        assertEquals(1, log.events[0].carrierIdMatching.result.carrierId);
        assertEquals(1, log.events[0].carrierIdMatching.result.carrierId);
        assertTrue(log.events[0].carrierIdMatching.result.mccmnc.isEmpty());
        assertEquals("gid1Test", log.events[0].carrierIdMatching.result.gid1);
        assertEquals("gid1Test", log.events[0].carrierIdMatching.result.gid1);
    }
    }