Sunday, September 24, 2017

How do I add an APN via ADB



For hardware reasons (My menu key doesn't work) I can not add an APN via settings. I read here about using sqlite and here about using code. But I need a more convenient way to do it. I need to do it using adb.



Answer





  • 1. Be Root

  • 2. Know APN fileds such as MCC and MNC of your service provider [e.g EthioTelecom is mcc=636 mnc=01]




  • Open adb shell




$ adb shell
$ su


  1. Check if your carrier is listed in the default list of carriers. [] means optional



# content query --uri content://telephony/carriers [--where "name=''"]



  1. If your carrier is not listed, you have to add it to the list, Add other fields as required. NOTE the following is for Internet, for MMS, change the fileds to what is required



# content insert --uri content://telephony/carriers --bind name:s:"" --bind numeric:s:"" --bind type:s:"default,sulp" --bind mcc:i:<mcc> --bind mnc:s:--bind apn:s: --bind user:s:" --bind password:s:""



  1. Then check the listing again like Step 1





  2. Note the _id, replace insert by update if this is not the first time you are setting the prefered apn





# content insert --uri content://telephony/carriers/preferapn --bind apn_id:i:<_id>




  1. Try disabling and enabling your internet connection, if no change, restart your phone. if it is still not working, Keep Going




  2. Change permission of settings file





# chmod 666 /data/data/com.android.settings/shared_prefs/com.android.settings_preferences.xml
# exit
$ exit



  1. After you exit adb shell, in your terminal/comand prompt



$ adb pull /data/data/com.android.settings/shared_prefs/com.android.settings_preferences.xml ~/



  1. Add The following line before the last line that says






  2. then save it and run





$ adb push ~/com.android.settings_preferences.xml /data/data/com.android.settings/shared_prefs/com.android.settings_preferences.xml

Hopefully, You should now see your apn in the access points screen in settings, and it should also work.



No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...