carriersettings-extractor: Workaround for skip_464xlat field extraction

TelephonyProvider expects an int, not a string.
One would think bypassing the enum_type check and using the numbers
directly would be enough, but google stores the values in protobuf
different than what TelephonyProvider expects (0,1,2 vs -1,0,1).

References:
https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/refs/tags/android-13.0.0_r3/src/com/android/providers/telephony/TelephonyProvider.java#2473
https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-13.0.0_r3/core/java/android/provider/Telephony.java#3399
https://android.googlesource.com/platform/tools/carrier_settings/+/refs/tags/android-13.0.0_r3/proto/carrier_settings.proto#138
https://android.googlesource.com/platform/tools/carrier_settings/+/refs/tags/android-13.0.0_r3/python/update_apn.py#169

Change-Id: I920f8b9cd2638f40f90e22638b8cb67e11b898a8
This commit is contained in:
Michael Bestas 2022-08-25 03:39:55 +03:00
parent 570dc1db81
commit f9e44898fd
No known key found for this signature in database
GPG Key ID: F2D6C348F85577F5
1 changed files with 3 additions and 1 deletions

View File

@ -233,7 +233,9 @@ def main():
if self.apn.HasField(field):
enum_type = self.apn.DESCRIPTOR.fields_by_name[field].enum_type
value = getattr(self.apn, field)
if enum_type is None:
if key == 'skip_464xlat':
self.attributes[key] = str(value - 1)
elif enum_type is None:
if isinstance(value, bool):
self.attributes[key] = str(value).lower()
else: