Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically check for Android OTA system updates

Tags:

android

ota

If you go to Settings->About Phone->Check for updates a check is initiated to see if theres any system updates ready for your phone.

How can I do this action programmatically? Further, I am trying to locate where in the Android source code this happens so I can see it fully and understand it better. Does anyone have any suggestions?

like image 529
CompEng88 Avatar asked Aug 06 '12 22:08

CompEng88


1 Answers

As far as I know, there is no known broadcast, intent or API to do this programmatically.

And it depends on the ROM, and manufacturer.

Sony for example uses a service which, when the wifi is activated, the service checks on Sony's servers for any updates and informs of it.

But when talking about AOSP source, that I do not think happens.

The nearest point of System update is found in packages/apps/Settings/src/com/android/settings/DeviceInfoSettings.java

Protip: grep the string "System update" within the res/values directory and work backwords and find out where that string variable identifier is used!

Edit:

Here's an example broadcast receiver:

public class SystemUpdateClass extends BroadcastReceiver{
   @Override
   public void onReceive(Context context, Intent intent){
      if (intent.getAction().equals("android.settings.SYSTEM_UPDATE_SETTINGS")){
           Toast.makeText(context, 
                 "Yup! Received a system update broadcast", 
                 Toast.LENGTH_SHORT).show();
      }
   }
}

Here's an example code, from within a activity's onCreate:

SystemUpdateClass sysUpdate = new SystemUpdateClass();
IntentFilter filter = new IntentFilter();
filter.addAction("android.settings.SYSTEM_UPDATE_SETTINGS");
registerReceiver(sysUpdate, filter);

Now, what should happen is your app should receive the broadcast, unless I am mistaken that the broadcast is only for system-signed apps... however the rest is left as an exercise :)

like image 196
t0mm13b Avatar answered Sep 19 '22 02:09

t0mm13b