简体   繁体   English

配置Android Lollipop时的校验和错误

[英]Checksum Error while provisioning Android Lollipop

I get the message Couldn't use the admin app due to a checksum error. Contact your IT department Couldn't use the admin app due to a checksum error. Contact your IT department我收到消息Couldn't use the admin app due to a checksum error. Contact your IT department Couldn't use the admin app due to a checksum error. Contact your IT department when using the code below. 使用以下代码时,请Couldn't use the admin app due to a checksum error. Contact your IT department Basically you have two Android Lollipop devices. 基本上你有两个Android Lollipop设备。 One device is unprovisioned (Factory reset) and the other has this programming app on it. 一个设备未设置(恢复出厂设置),另一个设备上有此编程应用程序。 The programming app sends an NFC command to the unprovisioned device to tell it to start provisioning using the data you pass to it. 编程应用程序向未设置的设备发送NFC命令,告诉它使用您传递给它的数据开始配置。 There are three fields required (APK Location, APK file checksum, and package name) as per DevicePolicyManager. 根据DevicePolicyManager,需要三个字段(APK位置,APK文件校验和和包名称)。 MIME_TYPE_PROVISIONING_NFC . MIME_TYPE_PROVISIONING_NFC

The APK is getting downloaded. APK正在下载。 I'm checking my server logs and it's clearly coming from the device ( AndroidDownloadManager is in the user agent). 我正在检查我的服务器日志,它显然来自设备( AndroidDownloadManager在用户代理中)。

According to DevicePolicyManager. 根据DevicePolicyManager。 EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM it is a SHA-1 checksum of the file. EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM它是文件的SHA-1校验和。 The checksum is not matching. 校验和不匹配。 I've tried many different formats of this checksum (hex, hex with spaces, uppercase/lowercase, base64, text) and I guess it's possible I missed a test. 我已经尝试了许多不同格式的校验和(十六进制,带有空格的十六进制,大写/小写,base64,文本),我想我可能错过了一个测试。

Unfortunately, the Android Lollipop source is not yet available otherwise I would be checking there. 不幸的是,Android Lollipop源代码尚不可用,否则我会在那里查看。

How do I fix this? 我该如何解决? Any thoughts? 有什么想法吗?

public class ProvisionerActivity extends Activity implements CreateNdefMessageCallback {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        NfcAdapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
        mNfcAdapter.setNdefPushMessageCallback(this, this);
    }

    @Override
    public NdefMessage createNdefMessage(NfcEvent event) {
        try {
            Properties p = new Properties();
            p.setProperty(DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME, "com.example.deviceownertest");
            p.setProperty(DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION, "http://example.com/DeviceOwnerTest.apk");
            p.setProperty(DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM, "19138948d8a607617971af724ffd08dd7eab771b");

            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            OutputStream out = new ObjectOutputStream(bos);
            p.store(out, "");
            byte[] bytes = bos.toByteArray();

            NdefMessage msg = new NdefMessage(NdefRecord.createMime(DevicePolicyManager.MIME_TYPE_PROVISIONING_NFC, bytes));
            return msg;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}

Note: This is using the latest Android L Developer Preview . 注意:这是使用最新的Android L开发人员预览版 I guess it is entirely possible that this feature isn't finished yet. 我想完全有可能这个功能还没有完成。 Update: Actual release acts this way too. 更新:实际版本也是这样做的。


APK: https://storage.googleapis.com/randy/DeviceOwnerCheck.apk APK: https //storage.googleapis.com/randy/DeviceOwnerCheck.apk
Checksum: FRaAsqdPSjp9nC5hKIU/ElPv+e4 校验和: FRaAsqdPSjp9nC5hKIU / ElPv + e4
Result: Using this URL and this checksum gives an error and doesn't even get to the encrypt device screen. 结果:使用此URL和此校验和会出现错误,甚至无法访问加密设备屏幕。


I also posted two applications to GitHub . 我还向GitHub发布了两个应用程序。 One sends the NFC data to provision. 一个人发送NFC数据。 The other is just an app to check if the app is device admin or device owner. 另一个只是一个应用程序来检查应用程序是设备管理员还是设备所有者。 Hopefully someone finds this useful. 希望有人发现这很有用。 You'll need to modify the URL and the checksum if you want to build DeviceOwnerCheck yourself. 如果要自己构建DeviceOwnerCheck,则需要修改URL和校验和。

The hash code must be url safe. 哈希码必须是url安全的。 This converts and removes trailing padding 这会转换并删除尾随填充

$ cat Something.apk | openssl dgst -binary -sha1 | openssl base64 | tr '+/' '-_' | tr -d '='

It appears that it doesn't like the special characters in the checksum. 它似乎不喜欢校验和中的特殊字符。 I was able to get it to work with my apk file, but the checksum didn't have any special characters. 我能够使用我的apk文件,但校验和没有任何特殊字符。 When I tried using your apk file I got the same error. 当我尝试使用你的apk文件时,我得到了同样的错误。 Try recreating the apk until it doesn't have special characters, and then it should work. 尝试重新创建apk,直到它没有特殊字符,然后它应该工作。

I'm guessing there is some sort of escaping of special characters that is missing. 我猜测有一些特殊字符丢失了。

Here is the command to get the hash code. 这是获取哈希码的命令。

$ cat Something.apk | openssl dgst -binary -sha1 | openssl base64

Also, remove any trailing paddings (=). 此外,删除任何尾随填充(=)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 创建设备所有者Android Lollipop时出现校验和错误 - Checksum Error while Creating Device Owner Android Lollipop 在配置Android Lollipop设备时,坚持使用“连接到WiFi”屏幕 - Stuck on “Connecting to WiFi” screen while provisioning Android Lollipop device 在Ubuntu 14.04 LTS 64位上构建android源代码(Lollipop-> master分支)时出错 - Error while building android source code ( Lollipop -> master branch) on ubuntu 14.04 LTS 64-bit 安装错误:在真实设备上运行的未知错误android棒棒糖5.0 - Installation Error:Unknown Failure-while running on real device android lollipop 5.0 Android棒棒糖错误:尝试读取手机contcats时出现空指针异常 - Android lollipop error: Null pointer exception while trying to read phone contcats 在pre-Lollipop版本上运行时出错 - Error while running on pre-Lollipop versions 棒棒糖中的Android Edittext Onclick Datepickerdialog错误 - Error in Android Edittext Onclick Datepickerdialog in lollipop 在使用Android Lollipop中的工具栏时,如何在Android中更改ActionBarToggle的颜色? - How to change the color of ActionBarToggle in android while using toolbar in android lollipop? 在Android Lollipop中启动服务时获取ANR对话框 - Getting ANR dialog while starting a service in Android Lollipop Android 5 Lollipop中的Bazaar(伊朗Android Market)inAppBilling错误 - Bazaar(Iranian Android Market) inAppBilling error in Android 5 Lollipop
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM