AppOpsManager.noteOp: 如何配置我的应用程序在特定操作时崩溃

AppOpsManager.noteOp: How can I configure my app to crash on specific op

AppOpsManager.noteOp里面说SecurityException会被抛出

if the app has been configured to crash on this op

我找不到有关如何执行此操作的任何信息。应用开发者可以在源代码中配置吗?

我的错。 AppOpsManager

的文档中已经说明了

To control access the app-op can be set to a mode to:

MODE_ERRORED Throw a SecurityException on access. This can be suppressed by using a ...noThrow method to check the mode

要设置MODE_ERRORED,可以使用adb shell命令:cmd appops set <package> <OP> deny