简体   繁体   English

棒棒糖设备所有者应用中断电话

[英]Lollipop Device-Owner App breaks phone

Thanks to such so answers I was able to setup a device-owner App on my smartphone. 有了这样的答案,我得以在智能手机上设置设备所有者的应用程序。 This is a very basic test app just made to enable / disable screen pinning mode... 这是一个非常基本的测试应用,仅用于启用/禁用屏幕固定模式...

Anyway, at the end it works but with a very, very bad drawback : I've lost all access to the phone capabilities 无论如何,最后它仍然有效,但有一个非常非常糟糕的缺点:我已经失去了使用电话功能的所有权限

  • No more phone icon, except in the Settings > Applications > All 除了“设置”>“应用程序”>“全部”以外,没有其他电话图标
  • If I call it, it's ringing on the caller side, but the phone does not react at all... 如果我拨打电话,它会在呼叫方响起,但电话根本不响应...
  • However the status cellular icon indicates that it has 3G network. 但是,状态蜂窝状图标表示它具有3G网络。

All of those symptoms are pretty weird and leads me to wonder if my tiny device-owner app is locking something somewhere : Would anyone have any thoughts or experience about this ? 所有这些症状都很怪异,使我想知道我的微型设备所有者应用程序是否在某处锁定了某个东西:是否有人对此有任何想法或经验?

I found my own answer. 我找到了自己的答案。

The key thing is to re-enable the default system applications with the DevicePolicyManager.enableSystemApp method, because for some reason when provisioning device with your NFC-triggered-device-owner-app at install time, it prevents further installation of all the default apps (at least on my Nexus 6). 关键是要使用DevicePolicyManager.enableSystemApp方法重新启用默认系统应用程序,因为由于某些原因,在安装时使用NFC-triggered-device-owner-app配置设备时,它会阻止进一步安装所有默认应用程序(至少在我的Nexus 6上)。

So, once provisioned etc. I listed all the uninstalled apps and re-enabled them with the code below: 因此,一旦配置好,等等。我列出了所有已卸载的应用程序,并使用以下代码重新启用了它们:

        DevicePolicyManager mDPM = (DevicePolicyManager) this.getSystemService(Context.DEVICE_POLICY_SERVICE);
        ComponentName mDeviceAdminRcvr = new ComponentName(this, DeviceAdminRcvr.class);

        List<PackageInfo> packs = getPackageManager().getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES);
        for (int i=0; i<packs.size(); i++) 
        {
            PackageInfo p = packs.get(i);
            try {
                mDPM.enableSystemApp(mDeviceAdminRcvr, p.packageName);
            } catch (Exception e) {
                // TODO: handle exception
            }
        }

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM