【问题标题】:Permissions associated with Android Application Shortcuts与 Android 应用程序快捷方式相关的权限
【发布时间】:2017-03-20 19:53:05
【问题描述】:

我正在尝试解决我正在开发的 Android 应用程序上的一些安全审查项目,并且我正在查看一些与快捷方式相关的“高严重性”项目。

安全审查纯粹是一项静态代码分析工作,报告突出显示的许多项目都是红鲱鱼。我怀疑这些也是,但我正在寻找第二个意见。

已标记的代码/配置区域与设置快捷方式有关:

Intent shortcutIntent = new Intent(context, MyShortcutActivity.class);
shortcutIntent.setAction(Intent.ACTION_DEFAULT);

Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "My shortcut");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, getShortCutIconResource()));
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
addIntent.putExtra("duplicate", false);
this.context.sendBroadcast(addIntent);

安全报告抱怨我创建这些意图时没有权限。但它们是预期由 Android 操作系统调用的意图——操作系统创建快捷方式,如果单击快捷方式,操作系统将启动 MyShortcutActivity。所以我觉得没有任何适用的特殊许可。

报告还标记了 MyShortcutActivity 的定义:

<activity
    android:name=".MyShortcutActivity"
    ...
    android:exported="true">
        <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
</activity>

再次抱怨它缺乏许可。但是由于它可以通过快捷方式启动,所以我并没有真正看到适用的权限。

有什么建议吗?

更新:所以我的清单中已经有了 INSTALL_SHORTCUT 权限。根据答案,在这里,我更改了上面的代码,如下所示:

this.context.sendBroadcast(addIntent, Manifest.permission.INSTALL_SHORTCUT);

但这似乎不起作用。

【问题讨论】:

标签: android android-permissions android-security android-shortcut


【解决方案1】:

您需要添加此权限才能在启动器菜单上创建快捷方式:

com.android.launcher.permission.INSTALL_SHORTCUT

【讨论】:

  • 谢谢。这很有帮助。对快捷方式本身的权限有何想法?
  • 如果你在application标签中声明了上述权限,Activity标签应该不需要声明任何额外的权限
【解决方案2】:

谷歌搜索几秒钟后,您可以找到拥有大量权限列表的 Android 开发者网站。

INSTALL_SHORTCUT

Added in API level 19
String INSTALL_SHORTCUT
Allows an application to install a shortcut in Launcher.

Protection level: normal

Constant Value: "com.android.launcher.permission.INSTALL_SHORTCUT"

https://developer.android.com/reference/android/Manifest.permission.html#INSTALL_SHORTCUT

【讨论】:

  • 酷。我承认,当我尝试组合“android”、“permission”、“shortcut”等时,我发现自己正在筛选很多不相关的页面。但你的回应有帮助。对问题的其他两个部分有任何见解吗?
  • @bcholmes 抱歉,我不明白。添加权限后会发生什么?它仍然被标记吗?您应该在问题中提及静态分析工具。
  • 遗憾的是,这不是我正在运行的工具。有人将我的代码发送给了第三方安全审计公司,该公司在上面运行了他们的工具(我怀疑“他们的工具”主要是专有的、内部的东西)。我只是在门户网站上获得了一份报告。这不是我可以按需重新运行的东西。
猜你喜欢
  • 1970-01-01
  • 2010-10-10
  • 2021-03-21
  • 2017-06-09
  • 2013-05-31
  • 2012-06-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多