Android-x86
Fork

  • R/O
  • HTTP
  • SSH
  • HTTPS

hardware-ril: コミット

hardware/ril


コミットメタ情報

リビジョン964b483df580ef27664669610250318228aac23f (tree)
日時2018-10-06 12:15:57
作者android-build-team Robot <android-build-team-robot@goog...>
コミッターandroid-build-team Robot

ログメッセージ

Snap for 5053079 from 5f438e18ba37089a8ae58fca529ab1cb964e9f81 to pi-qpr2-release

Change-Id: Ie86cd6aae2b1ad9fa68af015827da13623bd1e52

変更サマリ

差分

--- a/include/telephony/ril.h
+++ b/include/telephony/ril.h
@@ -1360,14 +1360,18 @@ typedef struct {
13601360
13611361 typedef struct {
13621362 int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
1363- int mnc; /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
1363+ int mnc; /* 2 or 3-digit Mobile Network Code, 0..999;
1364+ the most significant nibble encodes the number of digits - {2, 3, 0 (unset)};
1365+ INT_MAX if unknown */
13641366 int lac; /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown */
13651367 int cid; /* 16-bit GSM Cell Identity described in TS 27.007, 0..65535, INT_MAX if unknown */
13661368 } RIL_CellIdentityGsm;
13671369
13681370 typedef struct {
13691371 int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
1370- int mnc; /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
1372+ int mnc; /* 2 or 3-digit Mobile Network Code, 0..999;
1373+ the most significant nibble encodes the number of digits - {2, 3, 0 (unset)};
1374+ INT_MAX if unknown */
13711375 int lac; /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown */
13721376 int cid; /* 16-bit GSM Cell Identity described in TS 27.007, 0..65535, INT_MAX if unknown */
13731377 int arfcn; /* 16-bit GSM Absolute RF channel number; this value must be reported */
@@ -1376,7 +1380,9 @@ typedef struct {
13761380
13771381 typedef struct {
13781382 int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
1379- int mnc; /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
1383+ int mnc; /* 2 or 3-digit Mobile Network Code, 0..999;
1384+ the most significant nibble encodes the number of digits - {2, 3, 0 (unset)};
1385+ INT_MAX if unknown */
13801386 int lac; /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown */
13811387 int cid; /* 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, INT_MAX if unknown */
13821388 int psc; /* 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511, INT_MAX if unknown */
@@ -1384,7 +1390,9 @@ typedef struct {
13841390
13851391 typedef struct {
13861392 int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
1387- int mnc; /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
1393+ int mnc; /* 2 or 3-digit Mobile Network Code, 0..999;
1394+ the most significant nibble encodes the number of digits - {2, 3, 0 (unset)};
1395+ INT_MAX if unknown */
13881396 int lac; /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown */
13891397 int cid; /* 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, INT_MAX if unknown */
13901398 int psc; /* 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511; this value must be reported */
@@ -1408,7 +1416,9 @@ typedef struct {
14081416
14091417 typedef struct {
14101418 int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
1411- int mnc; /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
1419+ int mnc; /* 2 or 3-digit Mobile Network Code, 0..999;
1420+ the most significant nibble encodes the number of digits - {2, 3, 0 (unset)};
1421+ INT_MAX if unknown */
14121422 int ci; /* 28-bit Cell Identity described in TS ???, INT_MAX if unknown */
14131423 int pci; /* physical cell id 0..503, INT_MAX if unknown */
14141424 int tac; /* 16-bit tracking area code, INT_MAX if unknown */
@@ -1416,7 +1426,9 @@ typedef struct {
14161426
14171427 typedef struct {
14181428 int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
1419- int mnc; /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
1429+ int mnc; /* 2 or 3-digit Mobile Network Code, 0..999;
1430+ the most significant nibble encodes the number of digits - {2, 3, 0 (unset)};
1431+ INT_MAX if unknown */
14201432 int ci; /* 28-bit Cell Identity described in TS ???, INT_MAX if unknown */
14211433 int pci; /* physical cell id 0..503; this value must be reported */
14221434 int tac; /* 16-bit tracking area code, INT_MAX if unknown */
@@ -1425,7 +1437,9 @@ typedef struct {
14251437
14261438 typedef struct {
14271439 int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
1428- int mnc; /* 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
1440+ int mnc; /* 2 or 3-digit Mobile Network Code, 0..999;
1441+ the most significant nibble encodes the number of digits - {2, 3, 0 (unset)};
1442+ INT_MAX if unknown */
14291443 int lac; /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown */
14301444 int cid; /* 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, INT_MAX if unknown */
14311445 int cpid; /* 8-bit Cell Parameters ID described in TS 25.331, 0..127, INT_MAX if unknown */
--- /dev/null
+++ b/include/telephony/ril_mnc.h
@@ -0,0 +1,149 @@
1+/*
2+ * Copyright (C) 2018 The Android Open Source Project
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+#ifndef RIL_MNC_H
18+#define RIL_MNC_H
19+
20+#include <climits>
21+#include <cstdio>
22+#include <string>
23+
24+namespace ril {
25+namespace util {
26+namespace mnc {
27+
28+/**
29+ * Decode an MNC with an optional length indicator provided in the most-significant nibble.
30+ *
31+ * @param mnc an encoded MNC value; if no encoding is provided, then the string is returned
32+ * as a minimum length string representing the provided integer.
33+ *
34+ * @return string representation of an encoded MNC or an empty string if the MNC is not a valid
35+ * MNC value.
36+ */
37+static inline std::string decode(int mnc) {
38+ if (mnc == INT_MAX || mnc < 0) return "";
39+ unsigned umnc = mnc;
40+ char mncNumDigits = (umnc >> (sizeof(int) * 8 - 4)) & 0xF;
41+
42+ umnc = (umnc << 4) >> 4;
43+ if (umnc > 999) return "";
44+
45+ char mncStr[4] = {0};
46+ switch (mncNumDigits) {
47+ case 0:
48+ // Legacy MNC report hasn't set the number of digits; preserve current
49+ // behavior and make a string of the minimum number of required digits.
50+ return std::to_string(umnc);
51+
52+ case 2:
53+ snprintf(mncStr, sizeof(mncStr), "%03.3u", umnc);
54+ return mncStr + 1;
55+
56+ case 3:
57+ snprintf(mncStr, sizeof(mncStr), "%03.3u", umnc);
58+ return mncStr;
59+
60+ default:
61+ // Error case
62+ return "";
63+ }
64+
65+}
66+
67+/**
68+ * Encode an MNC of the given value and a given number of digits
69+ *
70+ * @param mnc an MNC value 0-999 or INT_MAX if unknown
71+ * @param numDigits the number of MNC digits {2, 3} or 0 if unknown
72+ *
73+ * @return an encoded MNC with embedded length information
74+ */
75+static inline int encode(int mnc, int numDigits) {
76+ if (mnc > 999 || mnc < 0) return INT_MAX;
77+ switch (numDigits) {
78+ case 0: // fall through
79+ case 2: // fall through
80+ case 3:
81+ break;
82+
83+ default:
84+ return INT_MAX;
85+ };
86+
87+ return (numDigits << (sizeof(int) * 8 - 4)) | mnc;
88+}
89+
90+/**
91+ * Encode an MNC of the given value
92+ *
93+ * @param mnc the string representation of the MNC, with the length equal to the length of the
94+ * provided string.
95+ *
96+ * @return an encoded MNC with embedded length information
97+ */
98+static inline int encode(const std::string & mnc) {
99+ return encode(std::stoi(mnc), mnc.length());
100+}
101+
102+// echo -e "#include \"hardware/ril/include/telephony/ril_mnc.h\"\nint main()"\
103+// "{ return ril::util::mnc::test(); }" > ril_test.cpp \
104+// && g++ -o /tmp/ril_test -DTEST_RIL_MNC ril_test.cpp; \
105+// rm ril_test.cpp; /tmp/ril_test && [ $? ] && echo "passed"
106+#ifdef TEST_RIL_MNC
107+static int test() {
108+ const struct mnc_strings { const char * in; const char * out; } mncs[] = {
109+ {"0001",""},
110+ {"9999",""},
111+ {"0",""},
112+ {"9",""},
113+ {"123","123"},
114+ {"000","000"},
115+ {"001","001"},
116+ {"011","011"},
117+ {"111","111"},
118+ {"00","00"},
119+ {"01","01"},
120+ {"11","11"},
121+ {"09","09"},
122+ {"099","099"},
123+ {"999", "999"}};
124+
125+ for (int i=0; i< sizeof(mncs) / sizeof(struct mnc_strings); i++) {
126+ if (decode(encode(mncs[i].in)).compare(mncs[i].out)) return 1;
127+ }
128+
129+ const struct mnc_ints { const int in; const char * out; } legacy_mncs[] = {
130+ {INT_MAX, ""},
131+ {1, "1"},
132+ {11, "11"},
133+ {111, "111"},
134+ {0, "0"},
135+ {9999, ""},
136+ };
137+
138+ for (int i=0; i < sizeof(legacy_mncs) / sizeof(struct mnc_ints); i++) {
139+ if (decode(legacy_mncs[i].in).compare(legacy_mncs[i].out)) return 1;
140+ }
141+
142+ return 0;
143+}
144+#endif
145+
146+}
147+}
148+}
149+#endif /* !defined(RIL_MNC_H) */
--- a/libril/ril_service.cpp
+++ b/libril/ril_service.cpp
@@ -25,6 +25,8 @@
2525
2626 #include <hwbinder/IPCThreadState.h>
2727 #include <hwbinder/ProcessState.h>
28+#include <telephony/ril.h>
29+#include <telephony/ril_mnc.h>
2830 #include <ril_service.h>
2931 #include <hidl/HidlTransportSupport.h>
3032 #include <utils/SystemClock.h>
@@ -3549,7 +3551,7 @@ void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &
35493551 cellIdentity.cellIdentityGsm[0].mcc =
35503552 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
35513553 cellIdentity.cellIdentityGsm[0].mnc =
3552- std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
3554+ ril::util::mnc::decode(rilCellIdentity.cellIdentityGsm.mnc);
35533555 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
35543556 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
35553557 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
@@ -3562,7 +3564,7 @@ void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &
35623564 cellIdentity.cellIdentityWcdma[0].mcc =
35633565 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
35643566 cellIdentity.cellIdentityWcdma[0].mnc =
3565- std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
3567+ ril::util::mnc::decode(rilCellIdentity.cellIdentityWcdma.mnc);
35663568 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
35673569 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
35683570 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
@@ -3586,7 +3588,7 @@ void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &
35863588 cellIdentity.cellIdentityLte[0].mcc =
35873589 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
35883590 cellIdentity.cellIdentityLte[0].mnc =
3589- std::to_string(rilCellIdentity.cellIdentityLte.mnc);
3591+ ril::util::mnc::decode(rilCellIdentity.cellIdentityLte.mnc);
35903592 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
35913593 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
35923594 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
@@ -3599,7 +3601,7 @@ void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &
35993601 cellIdentity.cellIdentityTdscdma[0].mcc =
36003602 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
36013603 cellIdentity.cellIdentityTdscdma[0].mnc =
3602- std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
3604+ ril::util::mnc::decode(rilCellIdentity.cellIdentityTdscdma.mnc);
36033605 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
36043606 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
36053607 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
@@ -7863,7 +7865,7 @@ void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<Ce
78637865 cellInfoGsm->cellIdentityGsm.mcc =
78647866 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
78657867 cellInfoGsm->cellIdentityGsm.mnc =
7866- std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7868+ ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
78677869 cellInfoGsm->cellIdentityGsm.lac =
78687870 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
78697871 cellInfoGsm->cellIdentityGsm.cid =
@@ -7887,7 +7889,7 @@ void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<Ce
78877889 cellInfoWcdma->cellIdentityWcdma.mcc =
78887890 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
78897891 cellInfoWcdma->cellIdentityWcdma.mnc =
7890- std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7892+ ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
78917893 cellInfoWcdma->cellIdentityWcdma.lac =
78927894 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
78937895 cellInfoWcdma->cellIdentityWcdma.cid =
@@ -7935,7 +7937,7 @@ void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<Ce
79357937 cellInfoLte->cellIdentityLte.mcc =
79367938 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
79377939 cellInfoLte->cellIdentityLte.mnc =
7938- std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7940+ ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
79397941 cellInfoLte->cellIdentityLte.ci =
79407942 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
79417943 cellInfoLte->cellIdentityLte.pci =
@@ -7965,7 +7967,8 @@ void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<Ce
79657967 cellInfoTdscdma->cellIdentityTdscdma.mcc =
79667968 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
79677969 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7968- std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
7970+ ril::util::mnc::decode(
7971+ rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
79697972 cellInfoTdscdma->cellIdentityTdscdma.lac =
79707973 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
79717974 cellInfoTdscdma->cellIdentityTdscdma.cid =
旧リポジトリブラウザで表示