在Android 5.0(及其他)设备所有者whitout植根设备,通过NFC设备配置 [英] Device Owner on Android 5.0 (and others) whitout rooted devices, device provisioning by NFC

查看:214
本文介绍了在Android 5.0(及其他)设备所有者whitout植根设备,通过NFC设备配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道如何设置我的应用程序,设备所有者的Andr​​oid 5.0,4.4和4.3(?)。我还没有尝试过的方法,扎根设备(在那里描述),成功。我看到的伟大工程中的Andr​​oid 5.0和4.4.2模拟器和氰AOSP 4.4.4(根源于设备)。但是,我必须要试试这对其他非root权限的设备,在安卓5.0开发者API,你可以阅读

I need to know how to set my application as Device owner in Android 5.0, 4.4 and 4.3(?). I've yet tried the method for rooted devices (described in there), successfully. I saw that works great in android 5.0 and 4.4.2 emulator and in CyanoGen AOSP 4.4.4 (all rooted devices). But I must need to try this on other non rooted devices, in Android 5.0 Developer API you can read this

部署和激活的设备拥有者,您必须执行的NFC数据   从编程的应用程序传送到该设备,而该设备处于   其未接通的状态。

"To deploy and activate a device owner, you must perform an NFC data transfer from a programming app to the device while the device is in its unprovisioned state."

但我不明白它的意思,或更好的,我所要做。有人可以帮助我,或解释我一步做什么?

but I don't understand what it means, or better, what I've to do. Can someone help me, or explain me the step to do?

PS。我知道什么是NFC以及它是如何工作的,但我不明白如何使用这一问题。

PS. I know what NFC is and how it works but I can't understand how to use for this issue.

推荐答案

创建NFC触发应用程序并安装一个装置,具有NFC(不是你想使你的应用程序作为设备所有者的以外)上。

Create a NFC trigger application and install that on a device (other than the one on which you want to make your app as device owner) having NFC.

以下是$ C $下NFC触发

Following is the code for NFC trigger

public class MainActivity extends Activity implements CreateNdefMessageCallback {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
        nfcAdapter.setNdefPushMessageCallback(this, this);
    }

    @Override
    public NdefMessage createNdefMessage(NfcEvent event) {
        try {
            Properties p = new Properties();

            p.setProperty(
                    DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME,
                    "apk package name");
            p.setProperty(
                    DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION,
                    "app download url");
            p.setProperty(
                    DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM,
                    "apk checksum");
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            OutputStream out = new ObjectOutputStream(bos);
            p.store(out, "");
            final 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);
        }
    }
}

有关校验运行以下命令

猫your_device_owner_app_name.apk | OpenSSL的DGST -binary -sha1 | OpenSSL的BASE64 | TR'+ /''-_| TR -d=

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

  • 粘贴NFC触发code生成的校验和。
  • 在编译和运行设备的NFC触发应用程序。

现在上传您想使作为谷歌设备所有者驱动器或Dropbox的应用程序的apk。

Now upload your application apk which you want to make as device owner on google drive or dropbox.

取新鲜的设备或工厂重置要设置您的应用程序,设备所有者的设备。

Take a fresh device or factory reset the device on which you want to set your application as device owner.

重新启动设备,并第一个屏幕上使含有NFC触发应用和触摸的光束传输设备。

Reboot the device and on first screen bring your device containing NFC trigger application and touch for beam transfer.

您的应用程序将被下载并得到安装的设备所有者。

Your application will be downloaded and will get installed as device owner.

这篇关于在Android 5.0(及其他)设备所有者whitout植根设备,通过NFC设备配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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