从应用程序代码访问Androids UpdateEngine(或其他SystemApi类) [英] Accessing Androids UpdateEngine (or other SystemApi classes) from application code

查看:579
本文介绍了从应用程序代码访问Androids UpdateEngine(或其他SystemApi类)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个系统更新程序,该应用程序使用

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.

我将应用程序集成到AOSP树中,但是无法从应用程序目录开始成功编译:当我在应用程序目录中运行 mm 时,我直接遇到以下错误:

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:

导入android.os.UpdateEngine无法解析

The import android.os.UpdateEngine cannot be resolved

如果我只是将import语句添加到一个已经存在的aosp system-app中,也会发生这种情况,例如

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

从应用程序使用UpdateEngine(或实际上任何其他@SystemApi)的正确方法是什么?我不想通过删除所有SystemApi并破坏兼容性来更改android api.

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.

推荐答案

当然,我在发布问题后立即找到了解决方案...

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

以防将来有人偶然发现-问题是我在Android.mk中定义了以下SDK版本:

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:=当前

LOCAL_SDK_VERSION := current

按如下所示更改sdk版本后,可以访问系统API(因此也可以使用UpdateEngine):

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

LOCAL_SDK_VERSION:= system_current

LOCAL_SDK_VERSION := system_current

这篇关于从应用程序代码访问Androids UpdateEngine(或其他SystemApi类)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆