校验和错误而供应的Andr​​oid棒棒糖 [英] Checksum Error while provisioning Android Lollipop

查看:307
本文介绍了校验和错误而供应的Andr​​oid棒棒糖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到的消息无法使用管理应用程序由于校验和错误。 使用下面的code时,请联系您的IT部门。基本上,你有两个棒棒糖的Andr​​oid设备。一个设备未被接通(出厂设置),另一个上有这种编程应用程序。编程应用程序发送一个NFC命令未接通的设备,告诉它开始使用您传递给它的数据供应。有需要(APK位置,APK文件校验和包名)按DevicePolicyManager三个字段。<一个href="https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#MIME_TYPE_PROVISIONING_NFC"相对=nofollow> MIME_TYPE_PROVISIONING_NFC 。

I get the message Couldn't use the admin app due to a checksum error. Contact your IT department when using the code below. Basically you have two Android Lollipop devices. 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. There are three fields required (APK Location, APK file checksum, and package name) as per DevicePolicyManager.MIME_TYPE_PROVISIONING_NFC.

的APK是越来越下载。我检查我的服务器日志,它显然来自设备( AndroidDownloadManager 是在用户代理)。

The APK is getting downloaded. I'm checking my server logs and it's clearly coming from the device (AndroidDownloadManager is in the user agent).

据DevicePolicyManager。<一个href="https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM"相对=nofollow> EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM 它是一个SHA-1校验的文件。校验和不匹配。我尝试过许多不同的格式此校验和(十六进制,十六进制与空间,大/小写,BASE64,文字),我想这是有可能我错过了一个测试。

According to DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM it is a SHA-1 checksum of the file. 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.

不幸的是,Android的棒棒堂源尚未有效,否则我会被检查那里。

Unfortunately, the Android Lollipop source is not yet available otherwise I would be checking there.

我该如何解决这个问题?有什么想法?

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);
        }
    }
}


注意:这是采用了最新的 Android的大号开发preVIEW 。我想这是完全有可能的,这个功能还没有完成。 更新:实际发行行为太这样


Note: This is using the latest Android L Developer Preview. 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 /兰迪/ DeviceOwnerCheck.apk
校验: FRaAsqdPSjp9nC5hKIU / ElPv + E4
结果:使用这个网址,这个校验给出了一个错误,甚至没有得到加密设备屏幕。

APK: https://storage.googleapis.com/randy/DeviceOwnerCheck.apk
Checksum: FRaAsqdPSjp9nC5hKIU/ElPv+e4
Result: Using this URL and this checksum gives an error and doesn't even get to the encrypt device screen.

我也贴两个应用程序 GitHub上。其中发送NFC数据提供。另一种是只是一个应用程序来检查应用程序的设备管理员或设备所有者。希望有人认为这是有用的。您需要修改URL和校验,如果你想自己打造DeviceOwnerCheck。

I also posted two applications to GitHub. One sends the NFC data to provision. 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.

推荐答案

散列code必须是URL安全的。这种转换并移除尾随填充

The hash code must be url safe. This converts and removes trailing padding

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

这篇关于校验和错误而供应的Andr​​oid棒棒糖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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