下面的紅色代碼處就是關閉紅框;你能夠去除「&& (IS_USER_BUILD || suppress)」條件;或者你也能夠在android系統中build.prop添加「persist.sys.strictmode.disable=1」的property。java
public static final String DISABLE_PROPERTY = "persist.sys.strictmode.disable";android
public static final String VISUAL_PROPERTY = "persist.sys.strictmode.visual";app
StrictMode.java (\frameworks\base\core\java\android\os) ide
public static boolean conditionallyEnableDebugLogging() {oop
boolean doFlashes = SystemProperties.getBoolean(VISUAL_PROPERTY, false)ui
&& !amTheSystemServerProcess();this
final boolean suppress = SystemProperties.getBoolean(DISABLE_PROPERTY, false);spa
// For debug builds, log event loop stalls to dropbox for analysis.debug
// Similar logic also appears in ActivityThread.java for system apps.調試
if (!doFlashes && (IS_USER_BUILD || suppress)) {
setCloseGuardEnabled(false);
return false;
}
// Eng builds have flashes on all the time. The suppression property
// overrides this, so we force the behavior only after the short-circuit
// check above.
if (IS_ENG_BUILD) {
doFlashes = true;
}
// Thread policy controls BlockGuard.
int threadPolicyMask = StrictMode.DETECT_DISK_WRITE |
StrictMode.DETECT_DISK_READ |
StrictMode.DETECT_NETWORK;
if (!IS_USER_BUILD) {
threadPolicyMask |= StrictMode.PENALTY_DROPBOX;
}
if (doFlashes) {
threadPolicyMask |= StrictMode.PENALTY_FLASH;
}
StrictMode.setThreadPolicyMask(threadPolicyMask);
// VM Policy controls CloseGuard, detection of Activity leaks,
// and instance counting.
if (IS_USER_BUILD) {
setCloseGuardEnabled(false);
} else {
VmPolicy.Builder policyBuilder = new VmPolicy.Builder().detectAll().penaltyDropBox();
if (IS_ENG_BUILD) {
policyBuilder.penaltyLog();
}
setVmPolicy(policyBuilder.build());
setCloseGuardEnabled(vmClosableObjectLeaksEnabled());
}
return true;
}
前提到的「能夠在android系統中build.prop添加「persist.sys.strictmode.disable=1」的property」是臨時調試方法,下面的紅色標註添加是固化到編譯的Img中。
\configs\init_for_mmc.rc
\configs\init_for_mmc_sd2.rc
\configs\init_for_nand.rc
setprop ro.sf.lcd_density 133
setprop dalvik.vm.heapsize 48m
setprop persist.sys.usb.config adb,mass_storage
setprop persist.sys.strictmode.disable 1
setprop persist.sys.strictmode.visual 0
setprop persist.current.usb.mode device
setprop ro.atc.drm 0