Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing Androids UpdateEngine (or other SystemApi classes) from application code

I'm trying to write a system-updater application, which uses the UpdateEngine of Android 7+. However, I can't seem to get access to it from my java code, since the class and its methods are marked with @SystemApi.

I integrated my application into the AOSP tree, but I can't start a successful compile from my application directory: When i run mm in the app dir, I directly get the following error:

The import android.os.UpdateEngine cannot be resolved

This also happens if I just add the import statement to an already existing aosp system-app, e.g.

What is the correct way to use UpdateEngine (or actually any other @SystemApi) from an application? I don't want to change the android api by removing all the SystemApi and break compatibility.

like image 878
andreas-hofmann Avatar asked Jul 06 '17 06:07

andreas-hofmann


1 Answers

Of course I find the solution right after posting the question...

In case someone else stumbles upon this in the future - The problem was that I had the following SDK version defined in my Android.mk:

LOCAL_SDK_VERSION := current

System APIs (and thus UpdateEngine) became accessible after changing the sdk version as follows:

LOCAL_SDK_VERSION := system_current

like image 110
andreas-hofmann Avatar answered Sep 25 '22 15:09

andreas-hofmann