简体   繁体   English

以编程方式更改在Android设备中从未知来源安装apk的权限

[英]Programmatically change the permission of installing apk from unknown source in android device

For allowing or preventing manually installation of apk file from sdcard we ticks/unticks the checkbox which says "Allow installation of app from unknown source". 为了允许或阻止从SD卡手动安装apk文件,我们勾选/取消选中“允许从未知来源安装应用程序”的复选框。

Can we do this Programmatically by avoiding any User Interface? 我们能否以编程方式避免任何用户界面?

Thanks, 谢谢,

Nirav Nirav

No, not unless you're a carrier, or not unless you're on an enterprise phone that your company has admin access over. 不,除非您是运营商,否则除非您使用公司管理员访问过的企业电话。

This is part of the security model of Android, so that a user can not lose the control of his phone to a malicious application. 这是Android安全模型的一部分,因此用户不能失去对恶意应用程序的手机控制权。

Here are the actual permissions you would need to do something like that: 以下是您需要执行以下操作所需的实际权限:

<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />

You can try using those permissions, but by design they won't work unless you have root access to the device. 您可以尝试使用这些权限,但通过设计他们将无法正常工作,除非你有对设备的root访问权限。

Within the device settings, users are able to view permissions for applications they have previously installed. 在设备设置中,用户可以查看以前安装的应用程序的权限。 Users can also turn off some functionality globally when they choose, such as disabling GPS, radio, or wi-fi. 用户还可以在选择时全局关闭某些功能,例如禁用GPS,无线电或Wi-Fi。

In the event that an application attempts to use a protected feature which has not been declared in the application's manifest, the permission failure will typically result in a security exception being thrown back to the application. 如果应用程序尝试使用尚未在应用程序清单中声明的​​受保护功能,则权限失败通常会导致将安全性异常抛回应用程序。 Protected API permission checks are enforced at the lowest possible level to prevent circumvention. 受保护的API权限检查以尽可能低的级别强制执行,以防止规避。

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

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