1

我正在玩 AOSP,并尝试应用 OTA 包

1)。我为 Google Pixel 构建了 AOSP 并安装了它

2)。我创建了一个简单的应用程序,它下载 OTA 包,并尝试应用它(它基于这篇文章:http: //jhshi.me/2013/12/13/how-to-apply-downloaded-ota-package/index.html) html )

我在打电话 RecoverySystem.installPackage(getContext(), file);,它让我

java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.os.IRecoverySystem.setupBcb(java.lang.String)' on a null object reference
    at android.os.RecoverySystem.setupBcb(RecoverySystem.java:895)
    at android.os.RecoverySystem.installPackage(RecoverySystem.java:496)
    at android.os.RecoverySystem.installPackage(RecoverySystem.java:421)

谁能指点我如何解决它?

4

2 回答 2

2

As far as I can see, your error comes from this piece of code:

In RecoverySystem.java:

RecoverySystem rs = (RecoverySystem) context.getSystemService(
                Context.RECOVERY_SERVICE);
if (!rs.setupBcb(command)) {
    throw new IOException("Setup BCB failed");
}

....

/**
 * Talks to RecoverySystemService via Binder to set up the BCB.
 */
private boolean setupBcb(String command) {
    try {
        return mService.setupBcb(command);
    } catch (RemoteException unused) {
    }
    return false;
}

In the first piece of code, the if evaluation, your error is rs has it's mService member as null. Which is used in the ''setupBcb` method. So it looks like the context you are using does NOT have Context.RECOVERY_SERVICE reachable somehow.

Are you using activity context? I would git Application Context a try.

于 2017-07-20T15:24:21.197 回答
1

这是一个旧线程,但我在 Android 7.1 上遇到了完全相同的问题,即使在设置了所需的权限并将 apk 文件放入 /system/app/myapp. 我通过将此行添加到 AndroidManifest.xml 来解决它。

android:sharedUserId="android.uid.system"

我的清单文件是这样的 -

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.myapp"
    android:sharedUserId="android.uid.system"
    tools:ignore="GoogleAppIndexingWarning">
于 2019-07-26T08:34:50.793 回答