严格模式违反列表 [英] Strict mode violations list

查看:389
本文介绍了严格模式违反列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行在shell亚行logcat我看到这样的事情

StrictMode违反政策; 〜持续时间= 337毫秒:$ android.os.StrictMode StrictModeDiskReadViolation:政策= 23 =违规2


  1. 什么政策= 23的手段?

  2. 什么是违反= 2?

我正在寻找此值的含义,但我无法找到任何文件
白衣违反和政策清单,也许我间$ P $从我在一个糟糕的方​​式搜索PTED的结果,但我会AP preciate一些解释这个


解决方案

  

什么政策= 23的手段?


您可以配置StrictMode通知您的某些事情,你可以告诉它你想如何获得通知的(简单的日志信息,异常...)的。看到的启用StrictMode 这篇博客文章,以供参考。

策略是跟踪该配置的内部位掩码。因为它是一个口罩更直观地间preT以二进制,这是10111然后你可以在 BlockGuard.java 源文件中查找相关位。下面是从<一个很短的副本href=\"http://source-android.frandroid.com/libcore/dalvik/src/main/java/dalvik/system/BlockGuard.java\">this网站的(不知道Android版本也就是可能有更多的事情在新版本中,我没有我的机器上的电流源现在)的:

 公共静态最终诠释DISALLOW_DISK_WRITE = 0×01;
公共静态最终诠释DISALLOW_DISK_READ = 0×02;
公共静态最终诠释DISALLOW_NETWORK = 0×04;
公共静态最终诠释PASS_RESTRICTIONS_VIA_RPC = 0x08的;
公共静态最终诠释PENALTY_LOG = 0×10;
公共静态最终诠释PENALTY_DIALOG = 0x20的;
公共静态最终诠释PENALTY_DEATH = 0X40;

使用,你可以告诉你的StrictMode配置为通过日志消息通知您DISK_READ,DISK_WRITE和网络侵权行为。


  

,什么是违反= 2?


这IST的vialolation一些内部整型常量的只是类型。它不会帮你多少,因为异常的名称给出走了。笔者刚刚定义的所有不同,子类StrictMode异常使用了一个的getMessage()方法。仅供参考,这些常量在<定义href=\"http://source-android.frandroid.com/frameworks/base/core/java/android/os/StrictMode.java\">StrictMode.java.

running adb logcat in the shell i see something like this

StrictMode policy violation; ~duration=337 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=23 violation=2

  1. what the policy=23 means ?
  2. what is violation=2 ?

I was searching for the meanings of this values but I couldn't find any documentation whit violation and policy list, or maybe I interpreted the results from my search in a bad way, but I will appreciate some explanation about this

解决方案

what the policy=23 means ?

You can configure StrictMode to notify you of certain things and you can tell it how you'd like to get notified (simple log message, exception, ...). See the Enabling StrictMode section in this blog post for reference.

Policy is a bitmask that keeps track of that configuration internally. Since it's a mask it more intuitive to interpret it in binary, which is 10111. Then you can look up the relevant bits within the BlockGuard.java source file. Here is a short copy from this site (not sure what android version that is, there might be more things in newer versions; I don't have the current source on my machine right now):

public static final int DISALLOW_DISK_WRITE = 0x01;
public static final int DISALLOW_DISK_READ = 0x02;
public static final int DISALLOW_NETWORK = 0x04;
public static final int PASS_RESTRICTIONS_VIA_RPC = 0x08;
public static final int PENALTY_LOG = 0x10;
public static final int PENALTY_DIALOG = 0x20;
public static final int PENALTY_DEATH = 0x40;

With that you can tell that your StrictMode is configured to notify you of DISK_READ, DISK_WRITE and NETWORK violations via a log message.

and what is violation=2 ?

This ist just the type of the vialolation as some internal int constant. It doesn't help you much since the name of the exception gives that away already. The author just defined one getMessage() method that's used across all the different, subclassed StrictMode exceptions. Just for reference, these constants are defined within StrictMode.java.

这篇关于严格模式违反列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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