[{"data":1,"prerenderedAt":2358},["ShallowReactive",2],{"post-logbook_en-\u002Flogbook\u002Fxiaomi-apn-firmware":3,"post-siblings-logbook_en-\u002Flogbook\u002Fxiaomi-apn-firmware":2356},{"id":4,"title":5,"body":6,"cover":2337,"coverAlt":2338,"coverCaption":2339,"date":2340,"description":2341,"draft":2342,"extension":2343,"meta":2344,"navigation":1195,"path":2345,"readingTime":1089,"seo":2346,"stem":2347,"tags":2348,"track":2354,"__hash__":2355},"logbook_en\u002Flogbook\u002Fxiaomi-apn-firmware.md","My grandfather's phone and the vanishing APN: reverse engineering Xiaomi firmware with AI",{"type":7,"value":8,"toc":2311},"minimark",[9,13,16,24,27,32,101,110,113,117,201,208,211,230,232,236,243,336,366,369,371,375,382,430,455,556,559,712,719,724,727,752,769,799,801,805,869,904,911,917,1093,1100,1243,1247,1260,1263,1271,1273,1279,1286,1292,1295,1371,1381,1385,1388,1419,1426,1428,1432,1548,1574,1655,1659,1666,1792,1807,1809,1813,1816,1979,2050,2109,2118,2120,2124,2188,2194,2196,2200,2230,2232,2236,2243,2246,2248,2252,2285,2288,2290,2307],[10,11,12],"p",{},"For two months, my grandfather's phone kept deleting its own mobile internet.",[10,14,15],{},"He doesn't ask much of a phone: WhatsApp, his banking app, government services, maps and family photos. But turning on Wi-Fi, going through Airplane Mode or rebooting his Redmi A3 was enough to make the settings for his regional carrier disappear, leaving him without mobile data until someone entered everything again. If all you want is to talk to your family, there's no such thing as a telephony bug. There's just the phone that stopped working again.",[10,17,18,19,23],{},"We swapped the SIM for a brand-new one, and nothing changed. I removed Xiaomi's telemetry and the provisioning packages, and nothing changed. So I treated the phone the way I treat a production system failing for no clear reason: I plugged it into my Mac, wrote a diagnostic prompt targeting Android's telephony and RIL layers, and let Claude investigate over ",[20,21,22],"code",{},"adb",".",[10,25,26],{},"The full path to the cause is below, with real logs and bytecode. The success criterion was never technical, though: it was my grandfather using his phone in peace again.",[28,29,31],"h2",{"id":30},"tldr","TL;DR",[33,34,35,47,73,91],"ul",{},[36,37,38,42,43,46],"li",{},[39,40,41],"strong",{},"Symptom:"," on my grandfather's Redmi A3 running HyperOS (Android 16), the APN manually configured for a regional MVNO ",[39,44,45],{},"vanished"," whenever the radio reconnected: turning on Wi-Fi, toggling Airplane Mode or rebooting. This went on for two months.",[36,48,49,52,53,56,57,60,61,64,65,68,69,72],{},[39,50,51],{},"Cause:"," a rule Xiaomi added to the ",[20,54,55],{},"DataProfileManager"," in ",[20,58,59],{},"telephony-common.jar",". When an internet request finds no APN, it calls ",[20,62,63],{},"content:\u002F\u002Ftelephony\u002Fcarriers\u002Frestore"," and reloads the factory table. ",[39,66,67],{},"Satellite"," internet requests from Google apps never find an APN, so the rule fired and wiped the user's APN. Since the carrier isn't in ",[20,70,71],{},"apns-conf.xml",", nothing replaced it.",[36,74,75,78,79,82,83,86,87,90],{},[39,76,77],{},"Fix:"," the rule is skipped when ",[20,80,81],{},"isInstalledCtsApps()"," returns ",[20,84,85],{},"true",". An empty 8,538-byte APK, with no code and no permissions, whose package name contains ",[20,88,89],{},"android.telephony.cts",", triggers that exception.",[36,92,93,96,97,100],{},[39,94,95],{},"Validation:"," 92 satellite requests without an APN during the test, ",[39,98,99],{},"0"," restores, and the APN still present after every cycle and after a reboot.",[102,103,104],"blockquote",{},[10,105,106,107,23],{},"A new phone would have solved it. I wanted to know ",[39,108,109],{},"why",[111,112],"hr",{},[28,114,116],{"id":115},"_1-the-symptom","1. The symptom",[118,119,120,133],"table",{},[121,122,123],"thead",{},[124,125,126,130],"tr",{},[127,128,129],"th",{},"Item",[127,131,132],{},"Value",[134,135,136,152,163,179,191],"tbody",{},[124,137,138,142],{},[139,140,141],"td",{},"Device",[139,143,144,145,148,149],{},"Xiaomi Redmi A3 (2024), codename ",[20,146,147],{},"blue",", model ",[20,150,151],{},"2312CRNCCL",[124,153,154,157],{},[139,155,156],{},"SoC \u002F RIL",[139,158,159,160],{},"MediaTek Helio G36, ",[20,161,162],{},"mtkfusionrild",[124,164,165,168],{},[139,166,167],{},"System",[139,169,170,171,174,175,178],{},"HyperOS ",[20,172,173],{},"V816.0.10.0.WGRMIXM",", Android 16, ",[20,176,177],{},"user"," build (no root)",[124,180,181,184],{},[139,182,183],{},"SIM",[139,185,186,187,190],{},"Regional MVNO, MCC\u002FMNC ",[39,188,189],{},"724-18",", registered on TIM's network (724-04)",[124,192,193,196],{},[139,194,195],{},"APN",[139,197,198],{},[20,199,200],{},"solucao.br",[10,202,203,204,207],{},"The pattern never changed. The APN was added in Settings and mobile data came back. Turning on Wi-Fi, toggling Airplane Mode or rebooting was enough for the APN to ",[39,205,206],{},"disappear"," from the list as the radio reconnected. With the same SIM, a Samsung phone worked with no configuration at all.",[10,209,210],{},"Before the investigation, these had already been tried without success:",[33,212,213,216,223],{},[36,214,215],{},"a brand-new SIM from the same carrier;",[36,217,218,219,222],{},"every parameter combination: MVNO type (SPN\u002FIMSI), APN type ",[20,220,221],{},"default,supl"," and forced roaming;",[36,224,225,226,229],{},"debloating with UAD-NG, including disabling the OMA provisioning service (",[20,227,228],{},"com.wdstechnology.android.kryten","), the most obvious suspect.",[111,231],{},[28,233,235],{"id":234},"_2-method-ai-in-the-terminal-no-shortcuts","2. Method: AI in the terminal, no shortcuts",[10,237,238,239,242],{},"The whole investigation ran in a ",[39,240,241],{},"Claude Code"," session with the phone connected over USB. No reverse-engineering plugin or skill was used, only what was already installed on the Mac:",[118,244,245,255],{},[121,246,247],{},[124,248,249,252],{},[127,250,251],{},"Tool",[127,253,254],{},"Use",[134,256,257,287,301,317],{},[124,258,259,263],{},[139,260,261],{},[20,262,22],{},[139,264,265,268,269,268,272,268,275,268,278,268,281,268,284],{},[20,266,267],{},"logcat",", ",[20,270,271],{},"content query\u002Finsert",[20,273,274],{},"dumpsys",[20,276,277],{},"pm",[20,279,280],{},"cmd",[20,282,283],{},"pull",[20,285,286],{},"install",[124,288,289,295],{},[139,290,291,294],{},[20,292,293],{},"dexdump"," (build-tools 36.1)",[139,296,297,298],{},"Disassemble the framework's ",[20,299,300],{},"classes.dex",[124,302,303,314],{},[139,304,305,268,308,268,311],{},[20,306,307],{},"aapt2",[20,309,310],{},"zipalign",[20,312,313],{},"apksigner",[139,315,316],{},"Build, align and sign the guard APK",[124,318,319,333],{},[139,320,321,268,324,268,327,268,330],{},[20,322,323],{},"grep",[20,325,326],{},"awk",[20,328,329],{},"strings",[20,331,332],{},"unzip",[139,334,335],{},"Filter ~34k log lines and ~1M lines of bytecode",[10,337,338,268,341,344,345,348,349,352,353,268,356,268,359,362,363,23],{},[20,339,340],{},"jadx",[20,342,343],{},"baksmali"," and ",[20,346,347],{},"apktool"," ",[39,350,351],{},"weren't installed",", so the analysis was done directly on Dalvik bytecode (",[20,354,355],{},"invoke-virtual",[20,357,358],{},"if-nez",[20,360,361],{},"const-string","), with no decompiled Java. That's one of the places where AI speeds things up the most: reading bytecode register by register is slow for a human and trivial for a model, ",[39,364,365],{},"as long as every conclusion is checked against the dump",[10,367,368],{},"What worked was a clear split of roles. The model proposes the hypothesis and the next command, I decide whether it makes sense, and the log or the dump confirms or kills it.",[111,370],{},[28,372,374],{"id":373},"_3-the-evidence-the-log-at-the-moment-of-deletion","3. The evidence: the log at the moment of deletion",[10,376,377,378,381],{},"The logcat buffer is only 256 KB, so the log has to be saved ",[39,379,380],{},"right after"," the problem:",[383,384,389],"pre",{"className":385,"code":386,"language":387,"meta":388,"style":388},"language-bash shiki shiki-themes github-light github-dark","adb logcat -b all -d -v threadtime,uid > logs\u002Fpre_existing.log   # 33,984 lines\n","bash","",[20,390,391],{"__ignoreMap":388},[392,393,396,399,403,407,410,413,416,419,423,426],"span",{"class":394,"line":395},"line",1,[392,397,22],{"class":398},"sScJk",[392,400,402],{"class":401},"sZZnC"," logcat",[392,404,406],{"class":405},"sj4cs"," -b",[392,408,409],{"class":401}," all",[392,411,412],{"class":405}," -d",[392,414,415],{"class":405}," -v",[392,417,418],{"class":401}," threadtime,uid",[392,420,422],{"class":421},"szBVR"," >",[392,424,425],{"class":401}," logs\u002Fpre_existing.log",[392,427,429],{"class":428},"sJ8bj","   # 33,984 lines\n",[10,431,432,433,436,437,440,441,444,445,268,448,344,451,454],{},"The search started from the user side: the ",[20,434,435],{},"ApnEditor"," activity led to the URI ",[20,438,439],{},"carriers\u002F5142",", the newly created APN. With the PID of ",[20,442,443],{},"com.android.phone"," (1969) in hand, the ",[20,446,447],{},"DPM-0",[20,449,450],{},"DNC-0",[20,452,453],{},"MtkDPM"," tags told the story:",[118,456,457,467],{},[121,458,459],{},[124,460,461,464],{},[127,462,463],{},"Time",[127,465,466],{},"Event",[134,468,469,481,501,519,530,542],{},[124,470,471,474],{},[139,472,473],{},"09:35:38",[139,475,476,477,480],{},"The APN is saved (",[20,478,479],{},"_id 5142",")",[124,482,483,486],{},[139,484,485],{},"09:36:03",[139,487,488,489,492,493,496,497,500],{},"HyperOS's ",[39,490,491],{},"edit"," APN screen crashes (",[20,494,495],{},"NullPointerException"," at ",[20,498,499],{},"ApnEditor.java:459","). That's a different bug, and it deletes nothing",[124,502,503,506],{},[139,504,505],{},"09:36:49",[139,507,508,511,512,515,516],{},[20,509,510],{},"CARRIER_CONFIG_CHANGED",": the DPM loads ",[20,513,514],{},"solucao.br … USER_EDITED"," as the attach profile. ",[39,517,518],{},"The APN still exists",[124,520,521,524],{},[139,522,523],{},"09:37:41",[139,525,526,527],{},"Airplane Mode on; internet ",[20,528,529],{},"CONNECTED → DISCONNECTED",[124,531,532,535],{},[139,533,534],{},"09:37:43.680",[139,536,537],{},[39,538,539],{},[20,540,541],{},"restore apns since apn list is empty",[124,543,544,547],{},[139,545,546],{},"09:37:47",[139,548,549,552,553],{},[20,550,551],{},"Update data profiles due to APN db updated",". The preferred profile becomes ",[20,554,555],{},"null",[10,557,558],{},"The real lines:",[383,560,564],{"className":561,"code":562,"language":563,"meta":388,"style":388},"language-log shiki shiki-themes github-light github-dark","11-05 09:37:42.293 radio  1969  1969 D DNC-0   : onDataNetworkDisconnected: [DataNetwork: DN-103-C, solucao.br, state=null], cause=LOST_CONNECTION(0x10004)(65540), tearDownReason=AIRPLANE_MODE_ON\n11-05 09:37:43.667 radio  1969  1969 D DPM-0   : canHandleDefault(apnSetting) isCanHandleDefault=false\n11-05 09:37:43.680 radio  1969  9316 D DPM-0   : restore apns since apn list is empty\n11-05 09:37:47.268 radio  1969  1969 D DPM-0   : Update data profiles due to APN db updated.\n11-05 09:37:47.293 radio  1969  1969 D DPM-0   : Changed preferred data profile to null\n","log",[20,565,566,620,645,667,688],{"__ignoreMap":388},[392,567,568,571,574,578,581,584,587,589,592,595,598,600,603,605,608,611,614,617],{"class":394,"line":395},[392,569,570],{"class":405},"11-05",[392,572,573],{"class":428}," 09:37:42.293",[392,575,577],{"class":576},"sVt8B"," radio  ",[392,579,580],{"class":405},"1969",[392,582,583],{"class":405},"  1969",[392,585,586],{"class":576}," D DNC-",[392,588,99],{"class":405},[392,590,591],{"class":576},"   : onDataNetworkDisconnected: [DataNetwork: DN-",[392,593,594],{"class":405},"103",[392,596,597],{"class":576},"-C, ",[392,599,200],{"class":405},[392,601,602],{"class":576},", state=",[392,604,555],{"class":405},[392,606,607],{"class":576},"], cause=LOST_CONNECTION(",[392,609,610],{"class":405},"0x10004",[392,612,613],{"class":576},")(",[392,615,616],{"class":405},"65540",[392,618,619],{"class":576},"), tearDownReason=AIRPLANE_MODE_ON\n",[392,621,623,625,628,630,632,634,637,639,642],{"class":394,"line":622},2,[392,624,570],{"class":405},[392,626,627],{"class":428}," 09:37:43.667",[392,629,577],{"class":576},[392,631,580],{"class":405},[392,633,583],{"class":405},[392,635,636],{"class":576}," D DPM-",[392,638,99],{"class":405},[392,640,641],{"class":576},"   : canHandleDefault(apnSetting) isCanHandleDefault=",[392,643,644],{"class":405},"false\n",[392,646,648,650,653,655,657,660,662,664],{"class":394,"line":647},3,[392,649,570],{"class":405},[392,651,652],{"class":428}," 09:37:43.680",[392,654,577],{"class":576},[392,656,580],{"class":405},[392,658,659],{"class":405},"  9316",[392,661,636],{"class":576},[392,663,99],{"class":405},[392,665,666],{"class":576},"   : restore apns since apn list is empty\n",[392,668,670,672,675,677,679,681,683,685],{"class":394,"line":669},4,[392,671,570],{"class":405},[392,673,674],{"class":428}," 09:37:47.268",[392,676,577],{"class":576},[392,678,580],{"class":405},[392,680,583],{"class":405},[392,682,636],{"class":576},[392,684,99],{"class":405},[392,686,687],{"class":576},"   : Update data profiles due to APN db updated.\n",[392,689,691,693,696,698,700,702,704,706,709],{"class":394,"line":690},5,[392,692,570],{"class":405},[392,694,695],{"class":428}," 09:37:47.293",[392,697,577],{"class":576},[392,699,580],{"class":405},[392,701,583],{"class":405},[392,703,636],{"class":576},[392,705,99],{"class":405},[392,707,708],{"class":576},"   : Changed preferred data profile to ",[392,710,711],{"class":405},"null\n",[10,713,714,715,718],{},"Look at the fourth column of the restore line. Every other line runs on the main thread (1969), but the restore runs on ",[39,716,717],{},"thread 9316",", created on demand just for that. Someone wrote code to wipe the table on purpose, on a separate thread.",[720,721,723],"h3",{"id":722},"the-trigger-satellite-internet","The trigger: satellite internet",[10,725,726],{},"Right before each restore, the log filled up with network requests no APN could satisfy:",[383,728,730],{"className":561,"code":729,"language":563,"meta":388,"style":388},"D DPM-0 : Can't find any data profile that can satisfy [NetworkRequest [ REQUEST id=16, [ Transports: SATELLITE Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN&NOT_VCN_MANAGED ...\n",[20,731,732],{"__ignoreMap":388},[392,733,734,738,741,743,746,749],{"class":394,"line":395},[392,735,737],{"class":736},"s4XuR","D",[392,739,740],{"class":576}," DPM-",[392,742,99],{"class":405},[392,744,745],{"class":576}," : Can't find any data profile that can satisfy [NetworkRequest [ REQUEST id=",[392,747,748],{"class":405},"16",[392,750,751],{"class":576},", [ Transports: SATELLITE Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN&NOT_VCN_MANAGED ...\n",[10,753,754,755,760,761,764,765,768],{},"Google apps (Messages, GMS, Maps) keep internet requests with a ",[39,756,757],{},[20,758,759],{},"SATELLITE"," transport. The APN created in Settings gets ",[20,762,763],{},"infrastructure_bitmask=1",", meaning ",[39,766,767],{},"cellular only",", so it never satisfies those requests. What was left to find out was why \"no APN for satellite\" ended up as \"delete every APN\".",[10,770,771,774,775,778,779,268,782,268,785,788,789,791,792,795,796,23],{},[39,772,773],{},"Ruled out at this point:"," the OMA service (",[20,776,777],{},"kryten","), ",[20,780,781],{},"com.miui.daemon",[20,783,784],{},"CarrierConfigLoader",[20,786,787],{},"carrierdefaultapp"," and any third-party app. The culprit lived inside ",[20,790,443],{}," (UID 1001, ",[20,793,794],{},"radio","), in ",[20,797,798],{},"com.android.internal.telephony.data.DataProfileManager",[111,800],{},[28,802,804],{"id":803},"_4-down-to-the-bytecode","4. Down to the bytecode",[383,806,808],{"className":385,"code":807,"language":387,"meta":388,"style":388},"adb pull \u002Fsystem\u002Fframework\u002Ftelephony-common.jar fw\u002F\nadb pull \u002Fsystem\u002Fframework\u002Fmediatek-telephony-common.jar fw\u002F\nunzip -o fw\u002Ftelephony-common.jar classes.dex -d fw\u002Fx_telephony-common.jar\u002F\ndexdump -d fw\u002Fx_telephony-common.jar\u002Fclasses.dex > fw\u002Ftc_dexdump.txt   # 1,033,486 lines\n",[20,809,810,823,834,852],{"__ignoreMap":388},[392,811,812,814,817,820],{"class":394,"line":395},[392,813,22],{"class":398},[392,815,816],{"class":401}," pull",[392,818,819],{"class":401}," \u002Fsystem\u002Fframework\u002Ftelephony-common.jar",[392,821,822],{"class":401}," fw\u002F\n",[392,824,825,827,829,832],{"class":394,"line":622},[392,826,22],{"class":398},[392,828,816],{"class":401},[392,830,831],{"class":401}," \u002Fsystem\u002Fframework\u002Fmediatek-telephony-common.jar",[392,833,822],{"class":401},[392,835,836,838,841,844,847,849],{"class":394,"line":647},[392,837,332],{"class":398},[392,839,840],{"class":405}," -o",[392,842,843],{"class":401}," fw\u002Ftelephony-common.jar",[392,845,846],{"class":401}," classes.dex",[392,848,412],{"class":405},[392,850,851],{"class":401}," fw\u002Fx_telephony-common.jar\u002F\n",[392,853,854,856,858,861,863,866],{"class":394,"line":669},[392,855,293],{"class":398},[392,857,412],{"class":405},[392,859,860],{"class":401}," fw\u002Fx_telephony-common.jar\u002Fclasses.dex",[392,862,422],{"class":421},[392,864,865],{"class":401}," fw\u002Ftc_dexdump.txt",[392,867,868],{"class":428},"   # 1,033,486 lines\n",[10,870,871,872,875,876,879,880,883,884,886,887,268,889,344,892,895,896,899,900,903],{},"One attempt was dropped along the way: the ",[20,873,874],{},"boot-*.vdex"," files (",[20,877,878],{},"vdex027"," format) don't contain dex, so they had no useful code. The ",[20,881,882],{},".jar"," files do. With ",[20,885,329],{},", the anchors ",[20,888,541],{},[20,890,891],{},"restoreDefaultApnsIfNeeded",[20,893,894],{},"canHandleDefault"," showed up in ",[20,897,898],{},"telephony-common",", which ",[39,901,902],{},"Xiaomi modified"," relative to AOSP.",[10,905,906,907,910],{},"From those, using ",[20,908,909],{},"grep -n"," on the dump, seven methods were read. This is the reconstructed logic:",[720,912,914],{"id":913},"getdataprofilefornetworkrequest",[20,915,916],{},"getDataProfileForNetworkRequest(...)",[383,918,922],{"className":919,"code":920,"language":921,"meta":388,"style":388},"language-java shiki shiki-themes github-light github-dark","if (request.hasAttribute(1 \u002F* APN-based *\u002F)) {\n    apn = getApnSettingForNetworkRequest(request, networkType, ...);\n    if (!\"es_vodafone\".equals(CUSTOMIZED_REGION)\n            && !isInstalledCtsApps(context)          \u002F\u002F ← the loophole\n            && mDataNetworkController.getConfigReady()\n            && apn == null\n            && !mHasApnListRestored\n            && request.hasCapability(12 \u002F* NET_CAPABILITY_INTERNET *\u002F)) {\n        restoreDefaultApnsIfNeeded(apn, request);\n        mHasApnListRestored = true;\n    }\n}\n","java",[20,923,924,947,961,983,1000,1013,1027,1037,1058,1067,1081,1087],{"__ignoreMap":388},[392,925,926,929,932,935,938,941,944],{"class":394,"line":395},[392,927,928],{"class":421},"if",[392,930,931],{"class":576}," (request.",[392,933,934],{"class":398},"hasAttribute",[392,936,937],{"class":576},"(",[392,939,940],{"class":405},"1",[392,942,943],{"class":428}," \u002F* APN-based *\u002F",[392,945,946],{"class":576},")) {\n",[392,948,949,952,955,958],{"class":394,"line":622},[392,950,951],{"class":576},"    apn ",[392,953,954],{"class":421},"=",[392,956,957],{"class":398}," getApnSettingForNetworkRequest",[392,959,960],{"class":576},"(request, networkType, ...);\n",[392,962,963,966,969,972,975,977,980],{"class":394,"line":647},[392,964,965],{"class":421},"    if",[392,967,968],{"class":576}," (",[392,970,971],{"class":421},"!",[392,973,974],{"class":401},"\"es_vodafone\"",[392,976,23],{"class":576},[392,978,979],{"class":398},"equals",[392,981,982],{"class":576},"(CUSTOMIZED_REGION)\n",[392,984,985,988,991,994,997],{"class":394,"line":669},[392,986,987],{"class":421},"            &&",[392,989,990],{"class":421}," !",[392,992,993],{"class":398},"isInstalledCtsApps",[392,995,996],{"class":576},"(context)          ",[392,998,999],{"class":428},"\u002F\u002F ← the loophole\n",[392,1001,1002,1004,1007,1010],{"class":394,"line":690},[392,1003,987],{"class":421},[392,1005,1006],{"class":576}," mDataNetworkController.",[392,1008,1009],{"class":398},"getConfigReady",[392,1011,1012],{"class":576},"()\n",[392,1014,1016,1018,1021,1024],{"class":394,"line":1015},6,[392,1017,987],{"class":421},[392,1019,1020],{"class":576}," apn ",[392,1022,1023],{"class":421},"==",[392,1025,1026],{"class":405}," null\n",[392,1028,1030,1032,1034],{"class":394,"line":1029},7,[392,1031,987],{"class":421},[392,1033,990],{"class":421},[392,1035,1036],{"class":576},"mHasApnListRestored\n",[392,1038,1040,1042,1045,1048,1050,1053,1056],{"class":394,"line":1039},8,[392,1041,987],{"class":421},[392,1043,1044],{"class":576}," request.",[392,1046,1047],{"class":398},"hasCapability",[392,1049,937],{"class":576},[392,1051,1052],{"class":405},"12",[392,1054,1055],{"class":428}," \u002F* NET_CAPABILITY_INTERNET *\u002F",[392,1057,946],{"class":576},[392,1059,1061,1064],{"class":394,"line":1060},9,[392,1062,1063],{"class":398},"        restoreDefaultApnsIfNeeded",[392,1065,1066],{"class":576},"(apn, request);\n",[392,1068,1070,1073,1075,1078],{"class":394,"line":1069},10,[392,1071,1072],{"class":576},"        mHasApnListRestored ",[392,1074,954],{"class":421},[392,1076,1077],{"class":405}," true",[392,1079,1080],{"class":576},";\n",[392,1082,1084],{"class":394,"line":1083},11,[392,1085,1086],{"class":576},"    }\n",[392,1088,1090],{"class":394,"line":1089},12,[392,1091,1092],{"class":576},"}\n",[720,1094,1096,1099],{"id":1095},"restoredefaultapnsifneeded-and-the-thread",[20,1097,1098],{},"restoreDefaultApnsIfNeeded(...)"," and the thread",[383,1101,1103],{"className":919,"code":1102,"language":921,"meta":388,"style":388},"if (!request.hasCapability(INTERNET)) return;\nboolean ok = canHandleDefault(apn);   \u002F\u002F apn != null && apn.canHandleType(TYPE_DEFAULT)\nlog(\"canHandleDefault(apnSetting) isCanHandleDefault=\" + ok);\nif (!ok) new DataProfileManager$4(this).start();\n\n\u002F\u002F DataProfileManager$4.run()\nif (SubscriptionManager.isValidSubscriptionId(mPhone.getSubId())) {\n    log(\"restore apns since apn list is empty\");\n    \u002F\u002F DEFAULTAPN_URI + \"subId\u002F\" + subId → TelephonyProvider deletes and reloads apns-conf.xml\n}\n",[20,1104,1105,1126,1145,1160,1191,1197,1202,1221,1234,1239],{"__ignoreMap":388},[392,1106,1107,1109,1111,1113,1116,1118,1121,1124],{"class":394,"line":395},[392,1108,928],{"class":421},[392,1110,968],{"class":576},[392,1112,971],{"class":421},[392,1114,1115],{"class":576},"request.",[392,1117,1047],{"class":398},[392,1119,1120],{"class":576},"(INTERNET)) ",[392,1122,1123],{"class":421},"return",[392,1125,1080],{"class":576},[392,1127,1128,1131,1134,1136,1139,1142],{"class":394,"line":622},[392,1129,1130],{"class":421},"boolean",[392,1132,1133],{"class":576}," ok ",[392,1135,954],{"class":421},[392,1137,1138],{"class":398}," canHandleDefault",[392,1140,1141],{"class":576},"(apn);   ",[392,1143,1144],{"class":428},"\u002F\u002F apn != null && apn.canHandleType(TYPE_DEFAULT)\n",[392,1146,1147,1149,1151,1154,1157],{"class":394,"line":647},[392,1148,563],{"class":398},[392,1150,937],{"class":576},[392,1152,1153],{"class":401},"\"canHandleDefault(apnSetting) isCanHandleDefault=\"",[392,1155,1156],{"class":421}," +",[392,1158,1159],{"class":576}," ok);\n",[392,1161,1162,1164,1166,1168,1171,1174,1177,1179,1182,1185,1188],{"class":394,"line":669},[392,1163,928],{"class":421},[392,1165,968],{"class":576},[392,1167,971],{"class":421},[392,1169,1170],{"class":576},"ok) ",[392,1172,1173],{"class":421},"new",[392,1175,1176],{"class":398}," DataProfileManager$4",[392,1178,937],{"class":576},[392,1180,1181],{"class":405},"this",[392,1183,1184],{"class":576},").",[392,1186,1187],{"class":398},"start",[392,1189,1190],{"class":576},"();\n",[392,1192,1193],{"class":394,"line":690},[392,1194,1196],{"emptyLinePlaceholder":1195},true,"\n",[392,1198,1199],{"class":394,"line":1015},[392,1200,1201],{"class":428},"\u002F\u002F DataProfileManager$4.run()\n",[392,1203,1204,1206,1209,1212,1215,1218],{"class":394,"line":1029},[392,1205,928],{"class":421},[392,1207,1208],{"class":576}," (SubscriptionManager.",[392,1210,1211],{"class":398},"isValidSubscriptionId",[392,1213,1214],{"class":576},"(mPhone.",[392,1216,1217],{"class":398},"getSubId",[392,1219,1220],{"class":576},"())) {\n",[392,1222,1223,1226,1228,1231],{"class":394,"line":1039},[392,1224,1225],{"class":398},"    log",[392,1227,937],{"class":576},[392,1229,1230],{"class":401},"\"restore apns since apn list is empty\"",[392,1232,1233],{"class":576},");\n",[392,1235,1236],{"class":394,"line":1060},[392,1237,1238],{"class":428},"    \u002F\u002F DEFAULTAPN_URI + \"subId\u002F\" + subId → TelephonyProvider deletes and reloads apns-conf.xml\n",[392,1240,1241],{"class":394,"line":1069},[392,1242,1092],{"class":576},[720,1244,1246],{"id":1245},"what-re-arms-the-latch","What re-arms the latch",[10,1248,1249,1252,1253,348,1256,1259],{},[20,1250,1251],{},"DataNetworkController.updateOverallInternetDataState()"," calls ",[20,1254,1255],{},"setHasApnListRestored(false)",[39,1257,1258],{},"every time"," the set of connected internet networks changes. That's why all three reported triggers (Wi-Fi, Airplane Mode and reboot) lead to the same result: the mobile connection changes state, the latch is re-armed and the next satellite request without an APN fires the restore.",[10,1261,1262],{},"The full chain:",[383,1264,1269],{"className":1265,"code":1267,"language":1268,"meta":388},[1266],"language-text","radio reconnects\n  → updateOverallInternetDataState() → mHasApnListRestored = false\n  → a Google app requests INTERNET over SATELLITE\n  → no APN satisfies it (infrastructure_bitmask=1)  → apn == null\n  → !isInstalledCtsApps() && ... → restoreDefaultApnsIfNeeded()\n  → DataProfileManager$4 thread → carriers\u002Frestore\u002FsubId\u002F4\n  → apns-conf.xml has no 72418 → user APN lost\n","text",[20,1270,1267],{"__ignoreMap":388},[111,1272],{},[28,1274,1276,1277],{"id":1275},"_5-the-loophole-isinstalledctsapps","5. The loophole: ",[20,1278,81],{},[10,1280,1281,1282,1285],{},"The guard exists so the rule doesn't interfere with ",[39,1283,1284],{},"CTS"," (Compatibility Test Suite), Google's certification tests, which manipulate APNs on purpose. This is the actual bytecode:",[383,1287,1290],{"className":1288,"code":1289,"language":1268,"meta":388},[1266],"isInstalledCtsApps:(Landroid\u002Fcontent\u002FContext;)Z\n0004: invoke-virtual {v3}, Landroid\u002Fcontent\u002FContext;.getPackageManager:()...\n0008: invoke-virtual {v3, v2}, Landroid\u002Fcontent\u002Fpm\u002FPackageManager;.getInstalledPackages:(I)...\n...\n0026: iget-object v0, v0, Landroid\u002Fcontent\u002Fpm\u002FPackageInfo;.packageName:Ljava\u002Flang\u002FString;\n002a: const-string v1, \"android.telephony.cts\"\n002c: invoke-virtual {v0, v1}, Ljava\u002Flang\u002FString;.contains:(Ljava\u002Flang\u002FCharSequence;)Z\n0030: if-eqz v0, 0018\n0032: const\u002F4 v2, #int 1\n0033: return v2\n",[20,1291,1289],{"__ignoreMap":388},[10,1293,1294],{},"In Java:",[383,1296,1298],{"className":919,"code":1297,"language":921,"meta":388,"style":388},"for (PackageInfo p : pm.getInstalledPackages(0))\n    if (p.packageName != null && p.packageName.contains(\"android.telephony.cts\"))\n        return true;\nreturn false;\n",[20,1299,1300,1324,1353,1362],{"__ignoreMap":388},[392,1301,1302,1305,1308,1311,1314,1317,1319,1321],{"class":394,"line":395},[392,1303,1304],{"class":421},"for",[392,1306,1307],{"class":576}," (PackageInfo p ",[392,1309,1310],{"class":421},":",[392,1312,1313],{"class":576}," pm.",[392,1315,1316],{"class":398},"getInstalledPackages",[392,1318,937],{"class":576},[392,1320,99],{"class":405},[392,1322,1323],{"class":576},"))\n",[392,1325,1326,1328,1331,1334,1337,1340,1343,1346,1348,1351],{"class":394,"line":622},[392,1327,965],{"class":421},[392,1329,1330],{"class":576}," (p.packageName ",[392,1332,1333],{"class":421},"!=",[392,1335,1336],{"class":405}," null",[392,1338,1339],{"class":421}," &&",[392,1341,1342],{"class":576}," p.packageName.",[392,1344,1345],{"class":398},"contains",[392,1347,937],{"class":576},[392,1349,1350],{"class":401},"\"android.telephony.cts\"",[392,1352,1323],{"class":576},[392,1354,1355,1358,1360],{"class":394,"line":647},[392,1356,1357],{"class":421},"        return",[392,1359,1077],{"class":405},[392,1361,1080],{"class":576},[392,1363,1364,1366,1369],{"class":394,"line":669},[392,1365,1123],{"class":421},[392,1367,1368],{"class":405}," false",[392,1370,1080],{"class":576},[10,1372,1373,1374,1377,1378,1380],{},"The check looks ",[39,1375,1376],{},"only at the package name",", using ",[20,1379,1345],{},". It doesn't verify signature, origin or permissions.",[720,1382,1384],{"id":1383},"before-using-the-loophole-whats-the-blast-radius","Before using the loophole: what's the blast radius?",[10,1386,1387],{},"Disabling a guard without knowing what else it protects would just trade one bug for another. So I checked:",[33,1389,1390,1402,1413],{},[36,1391,1392,1393,1395,1396,56,1399,1401],{},"the string ",[20,1394,1350],{}," appears ",[39,1397,1398],{},"exactly once",[20,1400,898],{},";",[36,1403,1404,1406,1407,268,1410,1401],{},[20,1405,993],{}," has ",[39,1408,1409],{},"exactly one caller",[20,1411,1412],{},"getDataProfileForNetworkRequest",[36,1414,1415,1418],{},[20,1416,1417],{},"mediatek-telephony-common"," doesn't use that string.",[10,1420,1421,1422,1425],{},"In other words, satisfying the check disables ",[39,1423,1424],{},"only"," this auto-restore and affects no other behavior.",[111,1427],{},[28,1429,1431],{"id":1430},"_6-the-guard-apk","6. The guard APK",[383,1433,1437],{"className":1434,"code":1435,"language":1436,"meta":388,"style":388},"language-xml shiki shiki-themes github-light github-dark","\u003Cmanifest xmlns:android=\"http:\u002F\u002Fschemas.android.com\u002Fapk\u002Fres\u002Fandroid\"\n    package=\"br.local.android.telephony.cts.apnguard\"\n    android:versionCode=\"1\" android:versionName=\"1.0\">\n    \u003Cuses-sdk android:minSdkVersion=\"29\" android:targetSdkVersion=\"36\"\u002F>\n    \u003Capplication android:hasCode=\"false\" android:label=\"APN Guard\"\u002F>\n\u003C\u002Fmanifest>\n","xml",[20,1438,1439,1456,1466,1487,1514,1539],{"__ignoreMap":388},[392,1440,1441,1444,1448,1451,1453],{"class":394,"line":395},[392,1442,1443],{"class":576},"\u003C",[392,1445,1447],{"class":1446},"s9eBZ","manifest",[392,1449,1450],{"class":398}," xmlns:android",[392,1452,954],{"class":576},[392,1454,1455],{"class":401},"\"http:\u002F\u002Fschemas.android.com\u002Fapk\u002Fres\u002Fandroid\"\n",[392,1457,1458,1461,1463],{"class":394,"line":622},[392,1459,1460],{"class":398},"    package",[392,1462,954],{"class":576},[392,1464,1465],{"class":401},"\"br.local.android.telephony.cts.apnguard\"\n",[392,1467,1468,1471,1473,1476,1479,1481,1484],{"class":394,"line":647},[392,1469,1470],{"class":398},"    android:versionCode",[392,1472,954],{"class":576},[392,1474,1475],{"class":401},"\"1\"",[392,1477,1478],{"class":398}," android:versionName",[392,1480,954],{"class":576},[392,1482,1483],{"class":401},"\"1.0\"",[392,1485,1486],{"class":576},">\n",[392,1488,1489,1492,1495,1498,1500,1503,1506,1508,1511],{"class":394,"line":669},[392,1490,1491],{"class":576},"    \u003C",[392,1493,1494],{"class":1446},"uses-sdk",[392,1496,1497],{"class":398}," android:minSdkVersion",[392,1499,954],{"class":576},[392,1501,1502],{"class":401},"\"29\"",[392,1504,1505],{"class":398}," android:targetSdkVersion",[392,1507,954],{"class":576},[392,1509,1510],{"class":401},"\"36\"",[392,1512,1513],{"class":576},"\u002F>\n",[392,1515,1516,1518,1521,1524,1526,1529,1532,1534,1537],{"class":394,"line":690},[392,1517,1491],{"class":576},[392,1519,1520],{"class":1446},"application",[392,1522,1523],{"class":398}," android:hasCode",[392,1525,954],{"class":576},[392,1527,1528],{"class":401},"\"false\"",[392,1530,1531],{"class":398}," android:label",[392,1533,954],{"class":576},[392,1535,1536],{"class":401},"\"APN Guard\"",[392,1538,1513],{"class":576},[392,1540,1541,1544,1546],{"class":394,"line":1015},[392,1542,1543],{"class":576},"\u003C\u002F",[392,1545,1447],{"class":1446},[392,1547,1486],{"class":576},[33,1549,1550,1559,1567],{},[36,1551,1552,968,1555,1558],{},[39,1553,1554],{},"No code",[20,1556,1557],{},"hasCode=\"false\"","), no permissions, no activity and no icon. It doesn't run anything: its only effect is existing.",[36,1560,1561,1562,1564,1565,23],{},"The name contains ",[20,1563,89],{},", so the check now returns ",[20,1566,85],{},[36,1568,1569,1570,1573],{},"The final size is ",[39,1571,1572],{},"8,538 bytes",", and removing it takes a single command.",[383,1575,1577],{"className":385,"code":1576,"language":387,"meta":388,"style":388},"SDK=~\u002FLibrary\u002FAndroid\u002Fsdk; BT=$SDK\u002Fbuild-tools\u002F36.1.0\n$BT\u002Faapt2 link -o unsigned.apk --manifest AndroidManifest.xml -I $SDK\u002Fplatforms\u002Fandroid-36\u002Fandroid.jar\n$BT\u002Fzipalign -f 4 unsigned.apk aligned.apk\n$BT\u002Fapksigner sign --ks ~\u002F.android\u002Fdebug.keystore --ks-pass pass:android --key-pass pass:android \\\n  --out apnguard.apk aligned.apk\n$BT\u002Fapksigner verify apnguard.apk\nadb install -r apnguard.apk        # Success\n",[20,1578,1579,1600,1605,1610,1624,1635,1640],{"__ignoreMap":388},[392,1580,1581,1584,1586,1589,1592,1594,1597],{"class":394,"line":395},[392,1582,1583],{"class":576},"SDK",[392,1585,954],{"class":421},[392,1587,1588],{"class":401},"~\u002FLibrary\u002FAndroid\u002Fsdk",[392,1590,1591],{"class":576},"; BT",[392,1593,954],{"class":421},[392,1595,1596],{"class":576},"$SDK",[392,1598,1599],{"class":401},"\u002Fbuild-tools\u002F36.1.0\n",[392,1601,1602],{"class":394,"line":622},[392,1603,1604],{"class":576},"$BT\u002Faapt2 link -o unsigned.apk --manifest AndroidManifest.xml -I $SDK\u002Fplatforms\u002Fandroid-36\u002Fandroid.jar\n",[392,1606,1607],{"class":394,"line":647},[392,1608,1609],{"class":576},"$BT\u002Fzipalign -f 4 unsigned.apk aligned.apk\n",[392,1611,1612,1615,1618,1621],{"class":394,"line":669},[392,1613,1614],{"class":576},"$BT\u002Fapksigner sign --ks ",[392,1616,1617],{"class":421},"~",[392,1619,1620],{"class":576},"\u002F.android\u002Fdebug.keystore --ks-pass pass:android --key-pass pass:android ",[392,1622,1623],{"class":405},"\\\n",[392,1625,1626,1629,1632],{"class":394,"line":690},[392,1627,1628],{"class":398},"  --out",[392,1630,1631],{"class":401}," apnguard.apk",[392,1633,1634],{"class":401}," aligned.apk\n",[392,1636,1637],{"class":394,"line":1015},[392,1638,1639],{"class":576},"$BT\u002Fapksigner verify apnguard.apk\n",[392,1641,1642,1644,1647,1650,1652],{"class":394,"line":1029},[392,1643,22],{"class":398},[392,1645,1646],{"class":401}," install",[392,1648,1649],{"class":405}," -r",[392,1651,1631],{"class":401},[392,1653,1654],{"class":428},"        # Success\n",[720,1656,1658],{"id":1657},"recreating-the-apn-through-the-provider","Recreating the APN through the provider",[10,1660,1661,1662,1665],{},"With the guard installed, the APN was inserted directly into ",[20,1663,1664],{},"TelephonyProvider",", bypassing HyperOS's buggy screen:",[383,1667,1669],{"className":385,"code":1668,"language":387,"meta":388,"style":388},"adb shell content insert --uri content:\u002F\u002Ftelephony\u002Fcarriers \\\n --bind name:s:Solucao --bind numeric:s:72418 --bind mcc:s:724 --bind mnc:s:18 \\\n --bind apn:s:solucao.br --bind type:s:default,supl \\\n --bind protocol:s:IPV4V6 --bind roaming_protocol:s:IPV4V6 \\\n --bind carrier_enabled:i:1 --bind edited:i:1 --bind user_visible:i:1 --bind user_editable:i:1\n\nadb shell content insert --uri content:\u002F\u002Ftelephony\u002Fcarriers\u002Fpreferapn\u002FsubId\u002F4 --bind apn_id:l:5142\n",[20,1670,1671,1693,1718,1732,1746,1768,1772],{"__ignoreMap":388},[392,1672,1673,1675,1678,1681,1684,1687,1690],{"class":394,"line":395},[392,1674,22],{"class":398},[392,1676,1677],{"class":401}," shell",[392,1679,1680],{"class":401}," content",[392,1682,1683],{"class":401}," insert",[392,1685,1686],{"class":405}," --uri",[392,1688,1689],{"class":401}," content:\u002F\u002Ftelephony\u002Fcarriers",[392,1691,1692],{"class":405}," \\\n",[392,1694,1695,1698,1701,1703,1706,1708,1711,1713,1716],{"class":394,"line":622},[392,1696,1697],{"class":405}," --bind",[392,1699,1700],{"class":401}," name:s:Solucao",[392,1702,1697],{"class":405},[392,1704,1705],{"class":401}," numeric:s:72418",[392,1707,1697],{"class":405},[392,1709,1710],{"class":401}," mcc:s:724",[392,1712,1697],{"class":405},[392,1714,1715],{"class":401}," mnc:s:18",[392,1717,1692],{"class":405},[392,1719,1720,1722,1725,1727,1730],{"class":394,"line":647},[392,1721,1697],{"class":405},[392,1723,1724],{"class":401}," apn:s:solucao.br",[392,1726,1697],{"class":405},[392,1728,1729],{"class":401}," type:s:default,supl",[392,1731,1692],{"class":405},[392,1733,1734,1736,1739,1741,1744],{"class":394,"line":669},[392,1735,1697],{"class":405},[392,1737,1738],{"class":401}," protocol:s:IPV4V6",[392,1740,1697],{"class":405},[392,1742,1743],{"class":401}," roaming_protocol:s:IPV4V6",[392,1745,1692],{"class":405},[392,1747,1748,1750,1753,1755,1758,1760,1763,1765],{"class":394,"line":690},[392,1749,1697],{"class":405},[392,1751,1752],{"class":401}," carrier_enabled:i:1",[392,1754,1697],{"class":405},[392,1756,1757],{"class":401}," edited:i:1",[392,1759,1697],{"class":405},[392,1761,1762],{"class":401}," user_visible:i:1",[392,1764,1697],{"class":405},[392,1766,1767],{"class":401}," user_editable:i:1\n",[392,1769,1770],{"class":394,"line":1015},[392,1771,1196],{"emptyLinePlaceholder":1195},[392,1773,1774,1776,1778,1780,1782,1784,1787,1789],{"class":394,"line":1029},[392,1775,22],{"class":398},[392,1777,1677],{"class":401},[392,1779,1680],{"class":401},[392,1781,1683],{"class":401},[392,1783,1686],{"class":405},[392,1785,1786],{"class":401}," content:\u002F\u002Ftelephony\u002Fcarriers\u002Fpreferapn\u002FsubId\u002F4",[392,1788,1697],{"class":405},[392,1790,1791],{"class":401}," apn_id:l:5142\n",[10,1793,1794,1795,1798,1799,1802,1803,1806],{},"A shell detail that cost time: the quoted query must be ",[20,1796,1797],{},"--where \"numeric='72418'\""," with the whole command in quotes. Escaping with ",[20,1800,1801],{},"\\'"," inside ",[20,1804,1805],{},"adb shell"," makes the query come back empty, which looks like \"APN deleted\" when it isn't.",[111,1808],{},[28,1810,1812],{"id":1811},"_7-validation-92-triggers-0-restores","7. Validation: 92 triggers, 0 restores",[10,1814,1815],{},"The test reproduces the radio cycle without touching the phone:",[383,1817,1819],{"className":385,"code":1818,"language":387,"meta":388,"style":388},"#!\u002Fbin\u002Fzsh\n# test_cycle.sh: Airplane Mode ON\u002FOFF and a check on APN 72418\nadb logcat -c -b all\nadb logcat -b all -v threadtime,uid > \"$LOG\" &\nfor i in $(seq 1 $CYCLES); do\n  adb shell cmd connectivity airplane-mode enable;  sleep 12\n  adb shell cmd connectivity airplane-mode disable; sleep 35\n  q   # content query for APN 72418\ndone\ngrep -E \"restore apns since|canHandleDefault|APN db|Internet data state changed\" \"$LOG\"\n",[20,1820,1821,1826,1831,1845,1873,1898,1926,1949,1957,1962],{"__ignoreMap":388},[392,1822,1823],{"class":394,"line":395},[392,1824,1825],{"class":428},"#!\u002Fbin\u002Fzsh\n",[392,1827,1828],{"class":394,"line":622},[392,1829,1830],{"class":428},"# test_cycle.sh: Airplane Mode ON\u002FOFF and a check on APN 72418\n",[392,1832,1833,1835,1837,1840,1842],{"class":394,"line":647},[392,1834,22],{"class":398},[392,1836,402],{"class":401},[392,1838,1839],{"class":405}," -c",[392,1841,406],{"class":405},[392,1843,1844],{"class":401}," all\n",[392,1846,1847,1849,1851,1853,1855,1857,1859,1861,1864,1867,1870],{"class":394,"line":669},[392,1848,22],{"class":398},[392,1850,402],{"class":401},[392,1852,406],{"class":405},[392,1854,409],{"class":401},[392,1856,415],{"class":405},[392,1858,418],{"class":401},[392,1860,422],{"class":421},[392,1862,1863],{"class":401}," \"",[392,1865,1866],{"class":576},"$LOG",[392,1868,1869],{"class":401},"\"",[392,1871,1872],{"class":576}," &\n",[392,1874,1875,1877,1880,1883,1886,1889,1892,1895],{"class":394,"line":690},[392,1876,1304],{"class":421},[392,1878,1879],{"class":576}," i ",[392,1881,1882],{"class":421},"in",[392,1884,1885],{"class":576}," $(",[392,1887,1888],{"class":398},"seq",[392,1890,1891],{"class":405}," 1",[392,1893,1894],{"class":576}," $CYCLES); ",[392,1896,1897],{"class":421},"do\n",[392,1899,1900,1903,1905,1908,1911,1914,1917,1920,1923],{"class":394,"line":1015},[392,1901,1902],{"class":398},"  adb",[392,1904,1677],{"class":401},[392,1906,1907],{"class":401}," cmd",[392,1909,1910],{"class":401}," connectivity",[392,1912,1913],{"class":401}," airplane-mode",[392,1915,1916],{"class":401}," enable",[392,1918,1919],{"class":576},";  ",[392,1921,1922],{"class":398},"sleep",[392,1924,1925],{"class":405}," 12\n",[392,1927,1928,1930,1932,1934,1936,1938,1941,1944,1946],{"class":394,"line":1029},[392,1929,1902],{"class":398},[392,1931,1677],{"class":401},[392,1933,1907],{"class":401},[392,1935,1910],{"class":401},[392,1937,1913],{"class":401},[392,1939,1940],{"class":401}," disable",[392,1942,1943],{"class":576},"; ",[392,1945,1922],{"class":398},[392,1947,1948],{"class":405}," 35\n",[392,1950,1951,1954],{"class":394,"line":1039},[392,1952,1953],{"class":398},"  q",[392,1955,1956],{"class":428},"   # content query for APN 72418\n",[392,1958,1959],{"class":394,"line":1060},[392,1960,1961],{"class":421},"done\n",[392,1963,1964,1966,1969,1972,1974,1976],{"class":394,"line":1069},[392,1965,323],{"class":398},[392,1967,1968],{"class":405}," -E",[392,1970,1971],{"class":401}," \"restore apns since|canHandleDefault|APN db|Internet data state changed\"",[392,1973,1863],{"class":401},[392,1975,1866],{"class":576},[392,1977,1978],{"class":401},"\"\n",[118,1980,1981,1993],{},[121,1982,1983],{},[124,1984,1985,1987,1990],{},[127,1986,129],{},[127,1988,1989],{},"Before",[127,1991,1992],{},"After",[134,1994,1995,2010,2023,2036],{},[124,1996,1997,2002,2005],{},[139,1998,1999,2001],{},[20,2000,759],{}," requests without an APN (the trigger)",[139,2003,2004],{},"yes",[139,2006,2007],{},[39,2008,2009],{},"92",[124,2011,2012,2016,2019],{},[139,2013,2014],{},[20,2015,541],{},[139,2017,2018],{},"1 (APN wiped)",[139,2020,2021],{},[39,2022,99],{},[124,2024,2025,2030,2032],{},[139,2026,2027,2029],{},[20,2028,894],{}," (restore entry point)",[139,2031,940],{},[139,2033,2034],{},[39,2035,99],{},[124,2037,2038,2041,2044],{},[139,2039,2040],{},"APN 5142 after each cycle",[139,2042,2043],{},"wiped",[139,2045,2046,2047],{},"present and ",[20,2048,2049],{},"CONNECTED",[383,2051,2053],{"className":561,"code":2052,"language":563,"meta":388,"style":388},"11-05 09:48:07.698 D DNC-0 : Internet data state changed from CONNECTED to DISCONNECTED.\n11-05 09:48:21.367 D DNC-0 : Internet data state changed from DISCONNECTED to CONNECTED.\n11-05 09:48:56.898 D DNC-0 : Internet data state changed from CONNECTED to DISCONNECTED.\n11-05 09:49:10.377 D DNC-0 : Internet data state changed from DISCONNECTED to CONNECTED.\n",[20,2054,2055,2069,2083,2096],{"__ignoreMap":388},[392,2056,2057,2059,2062,2064,2066],{"class":394,"line":395},[392,2058,570],{"class":405},[392,2060,2061],{"class":428}," 09:48:07.698",[392,2063,586],{"class":576},[392,2065,99],{"class":405},[392,2067,2068],{"class":576}," : Internet data state changed from CONNECTED to DISCONNECTED.\n",[392,2070,2071,2073,2076,2078,2080],{"class":394,"line":622},[392,2072,570],{"class":405},[392,2074,2075],{"class":428}," 09:48:21.367",[392,2077,586],{"class":576},[392,2079,99],{"class":405},[392,2081,2082],{"class":576}," : Internet data state changed from DISCONNECTED to CONNECTED.\n",[392,2084,2085,2087,2090,2092,2094],{"class":394,"line":647},[392,2086,570],{"class":405},[392,2088,2089],{"class":428}," 09:48:56.898",[392,2091,586],{"class":576},[392,2093,99],{"class":405},[392,2095,2068],{"class":576},[392,2097,2098,2100,2103,2105,2107],{"class":394,"line":669},[392,2099,570],{"class":405},[392,2101,2102],{"class":428}," 09:49:10.377",[392,2104,586],{"class":576},[392,2106,99],{"class":405},[392,2108,2082],{"class":576},[10,2110,2111,2112,348,2114,2117],{},"The trigger kept firing, with 92 satellite requests, but the rule that wiped the table never ran once. After a manual reboot, the APN was still present, preferred and connected, with ",[39,2113,99],{},[20,2115,2116],{},"restore apns since"," lines since boot.",[111,2119],{},[28,2121,2123],{"id":2122},"_8-alternatives-ruled-out","8. Alternatives ruled out",[118,2125,2126,2136],{},[121,2127,2128],{},[124,2129,2130,2133],{},[127,2131,2132],{},"Option",[127,2134,2135],{},"Why not",[134,2137,2138,2150,2160,2172,2180],{},[124,2139,2140,2147],{},[139,2141,2142,2143,2146],{},"Managed APN (",[20,2144,2145],{},"owned_by=0",", DPC)",[139,2148,2149],{},"Requires a Device Owner; DPC APNs are invisible unless enforced",[124,2151,2152,2157],{},[139,2153,2154,2155],{},"Adding 72418 to ",[20,2156,71],{},[139,2158,2159],{},"Requires root or a writable system partition",[124,2161,2162,2169],{},[139,2163,2164,2165,2168],{},"Changing ",[20,2166,2167],{},"infrastructure_bitmask"," to satisfy satellite",[139,2170,2171],{},"Uncertain behavior: it might try satellite data when it shouldn't",[124,2173,2174,2177],{},[139,2175,2176],{},"A script on a computer that recreates the APN",[139,2178,2179],{},"A stopgap that depends on a computer being on",[124,2181,2182,2185],{},[139,2183,2184],{},"Blocking the apps' satellite requests",[139,2186,2187],{},"No ADB control without root",[10,2189,2190,2191,23],{},"The guard APK was the only option that is ",[39,2192,2193],{},"local, minimal, reversible and rootless",[111,2195],{},[28,2197,2199],{"id":2198},"_9-risks-and-limits","9. Risks and limits",[33,2201,2202,2208,2218,2224],{},[36,2203,2204,2207],{},[39,2205,2206],{},"It's a workaround."," The real bug is the firmware treating \"no APN satisfies a satellite request\" as \"the table is empty\". Xiaomi is the one who has to fix it.",[36,2209,2210,2213,2214,2217],{},[39,2211,2212],{},"A HyperOS update can break the fix."," If the guard changes, ",[20,2215,2216],{},"test_cycle.sh"," becomes a regression test: after each OTA, it shows within a minute whether the protection still holds.",[36,2219,2220,2223],{},[39,2221,2222],{},"Don't uninstall the guard."," Without it, the APN is wiped again on the first network drop.",[36,2225,2226,2229],{},[39,2227,2228],{},"No new attack surface."," The app has no code and no permissions. In the worst case, it gets ignored.",[111,2231],{},[28,2233,2235],{"id":2234},"_10-back-in-his-hands","10. Back in his hands",[10,2237,2238,2239,2242],{},"With the APN stable, what remained was the part he actually notices. I removed the ad-ridden apps, gave the power button back its classic ",[39,2240,2241],{},"Power Off \u002F Restart"," menu and left on the phone what he uses: WhatsApp, banking and government apps, maps and family photos.",[10,2244,2245],{},"None of those changes show up in a dump. But they're the reason the investigation existed.",[111,2247],{},[28,2249,2251],{"id":2250},"_11-takeaways","11. Takeaways",[2253,2254,2255,2261,2267,2273,2279],"ol",{},[36,2256,2257,2260],{},[39,2258,2259],{},"Save the log right away."," With a 256 KB buffer, the evidence lasts minutes.",[36,2262,2263,2266],{},[39,2264,2265],{},"The thread tells the story."," A single line outside the main thread pointed to the code acting on purpose.",[36,2268,2269,2272],{},[39,2270,2271],{},"AI to read bytecode, a human to decide."," The model read raw Dalvik with no decompiler and proposed the causal chain; every link was confirmed in the dump or the log before becoming a conclusion.",[36,2274,2275,2278],{},[39,2276,2277],{},"Measure the blast radius before using a loophole."," One occurrence of the string and one caller: that alone is what makes the fix safe.",[36,2280,2281,2284],{},[39,2282,2283],{},"The smallest fix that works."," 8,538 bytes, no permissions, one command to undo.",[10,2286,2287],{},"AI fluency isn't about generating boilerplate. It's knowing how to frame a systems-level problem so an agent can disassemble Dalvik bytecode with you, checking every conclusion, and shipping an 8 KB patch so your grandfather can use his phone in peace.",[111,2289],{},[10,2291,2292],{},[2293,2294,2295,2296,268,2298,268,2300,268,2302,268,2304,2306],"em",{},"Tools: Claude Code, ",[20,2297,22],{},[20,2299,293],{},[20,2301,307],{},[20,2303,310],{},[20,2305,313],{},". Device: Redmi A3, HyperOS \u002F Android 16.",[2308,2309,2310],"style",{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}html pre.shiki code .s9eBZ, html code.shiki .s9eBZ{--shiki-default:#22863A;--shiki-dark:#85E89D}",{"title":388,"searchDepth":647,"depth":647,"links":2312},[2313,2314,2315,2316,2319,2325,2329,2332,2333,2334,2335,2336],{"id":30,"depth":622,"text":31},{"id":115,"depth":622,"text":116},{"id":234,"depth":622,"text":235},{"id":373,"depth":622,"text":374,"children":2317},[2318],{"id":722,"depth":647,"text":723},{"id":803,"depth":622,"text":804,"children":2320},[2321,2322,2324],{"id":913,"depth":647,"text":916},{"id":1095,"depth":647,"text":2323},"restoreDefaultApnsIfNeeded(...) and the thread",{"id":1245,"depth":647,"text":1246},{"id":1275,"depth":622,"text":2326,"children":2327},"5. The loophole: isInstalledCtsApps()",[2328],{"id":1383,"depth":647,"text":1384},{"id":1430,"depth":622,"text":1431,"children":2330},[2331],{"id":1657,"depth":647,"text":1658},{"id":1811,"depth":622,"text":1812},{"id":2122,"depth":622,"text":2123},{"id":2198,"depth":622,"text":2199},{"id":2234,"depth":622,"text":2235},{"id":2250,"depth":622,"text":2251},"\u002Fimages\u002Flogbook\u002Fxiaomi-apn-cover.jpg","Open laptop on a wooden table, connected by USB cable to a Xiaomi phone.","AI-generated illustration.","2026-11-21","For two months, my grandfather's phone deleted its own mobile internet settings on every network drop. A logcat, ~1 million lines of Dalvik bytecode and an empty 8 KB APK showed the culprit was a 'self-repair' rule inside HyperOS itself.",false,"md",{},"\u002Flogbook\u002Fxiaomi-apn-firmware",{"title":5,"description":2341},"logbook\u002Fxiaomi-apn-firmware",[2349,2350,2351,2352,2353],"android","reverse-engineering","firmware","ai","debugging","engineering-ai","shgC3zD3XLohWADrtzabX1_eTxiP8C8PL8CulQ23Pnk",[2357,2357],null,1795408456180]