chen xu | 6df8a41 | 2019-03-10 21:27:31 -0700 | [diff] [blame] | 1 | ====== carrier_list.textpb ====== |
| 2 | |
| 3 | DO NOT MANUALLY EDIT THIS FILE |
| 4 | |
| 5 | This file is the textpb verion of carrier_list.pb files under assets/, for readability purpose only. |
| 6 | |
| 7 | This file is not build into pb, thus modification of this file won't take any effect. |
| 8 | |
| 9 | ===== carrier_list.pb ===== |
| 10 | DO NOT MANUALLY EDIT THIS FILE |
| 11 | |
| 12 | This file defines carrier id and should be single versioned. |
calvinpan | a214322 | 2020-06-23 16:04:07 +0800 | [diff] [blame] | 13 | |
| 14 | ===== How to test carrier id locally ===== |
| 15 | |
| 16 | If you want to make change locally during testing, currently there are two ways: |
| 17 | |
| 18 | 1. Modify carrierIdentification.db database by SQL command |
| 19 | |
| 20 | For example (Insert MCCMNC '12345' and gid1 'test' to carrier id 20000): |
| 21 | ``` |
| 22 | $ adb shell |
| 23 | device:/ $ su |
| 24 | device:/ # DB='/data/user_de/0/com.android.providers.telephony/databases/carrierIdentification.db' |
| 25 | device:/ # sqlite3 $DB "INSERT INTO carrier_id(mccmnc, gid1, carrier_id, carrier_name) VALUES (12345, 'test', 20000, 'test_carrier')" |
| 26 | device:/ # reboot |
| 27 | ``` |
| 28 | |
| 29 | 2. Override carrier_list.pb |
| 30 | |
| 31 | - Modify carrier_list.textpb directly (Note: You should also bump the version |
| 32 | number to let TelephonyProvider reload the carrier_list.pb) |
| 33 | - Generate class file by using the carrier id proto(TelephonyProvider/proto/src/carrierId.proto) |
| 34 | (See https://developers.google.com/protocol-buffers/docs/overview#generating) |
| 35 | - Create a converter by using TextFormat tool to convert textpb to pb |
| 36 | (Text Format: https://developers.google.com/protocol-buffers/docs/reference/java/com/google/protobuf/TextFormat) |
| 37 | - Rename file to carrier_list_test.pb and push the output file to |
| 38 | /data/user_de/0/com.android.providers.telephony/files/carrier_list_test.pb |
| 39 | - Reboot the device |
| 40 | |
| 41 | Converter example: |
| 42 | ``` |
| 43 | #!/usr/bin/env python3 |
| 44 | from google.protobuf import text_format |
| 45 | |
| 46 | # Generated by: protoc -I=./ --python_out=./ ./carrierId.proto |
| 47 | from carrierId_pb2 import CarrierList |
| 48 | |
| 49 | def main(): |
| 50 | with open("carrier_list.textpb", "r") as rd: |
| 51 | carrierList = CarrierList() |
| 52 | text_format.Merge(rd.read(), carrierList) |
| 53 | |
| 54 | with open("carrier_list.pb", "wb") as wf: |
| 55 | wf.write(carrierList.SerializeToString()) |
| 56 | |
| 57 | if __name__ == '__main__': |
| 58 | main() |
| 59 | ``` |