当我在我的应用程序onCreate()
打开StrictMode时,一切都很好,问题已修复。
但是,我发现根据this issue存在StrictMode的错误。所以我做了解决方法(使用Handler
),确实有更多问题浮出水面。我可以识别它们来抑制或修复它们。
但是下面的错误是我不知道的事情,因为堆栈跟踪似乎与我可能相关的任何代码片段无关。
D/StrictMode: StrictMode policy violation; ~duration=38 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=4522015 violation=2
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1263)
at libcore.io.BlockGuardOs.access(BlockGuardOs.java:67)
at java.io.File.doAccess(File.java:281)
at java.io.File.exists(File.java:362)
at com.android.server.policy.sec.TspStateManager.updateTspState(TspStateManager.java:139)
at com.android.server.policy.sec.TspStateManager.updateWindowPolicy(TspStateManager.java:103)
at com.android.server.policy.PhoneWindowManager.focusChangedLw(PhoneWindowManager.java:8640)
at com.android.server.wm.WindowManagerService.updateFocusedWindowLocked(WindowManagerService.java:18320)
at com.android.server.wm.WindowManagerService.relayoutWindow(WindowManagerService.java:5768)
at com.android.server.wm.Session.relayout(Session.java:208)
at android.view.IWindowSession$Stub.onTransact(IWindowSession.java:288)
at com.android.server.wm.Session.onTransact(Session.java:139)
at android.os.Binder.execTransact(Binder.java:453)
# via Binder call with stack:
android.os.StrictMode$LogStackTrace
at android.os.StrictMode.readAndHandleBinderCallViolations(StrictMode.java:1911)
at android.os.Parcel.readExceptionCode(Parcel.java:1601)
at android.os.Parcel.readException(Parcel.java:1570)
at android.view.IWindowSession$Stub$Proxy.relayout(IWindowSession.java:956)
at android.view.ViewRootImpl.relayoutWindow(ViewRootImpl.java:6690)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1994)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1437)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7403)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:920)
at android.view.Choreographer.doCallbacks(Choreographer.java:695)
at android.view.Choreographer.doFrame(Choreographer.java:631)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:906)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
此错误发生在Samsung S7手机上,但不会发生在Nexus 6P上。我想要抑制此错误,但我首先需要知道触发此错误的代码部分,因此我可以在该代码上生成不同的线程或关闭该部分的detectDiskReads。
有关如何检查此功能的任何帮助?从哪里开始?