JakeWharton/u2020

Add StrictMode for internal builds

NightlyNexus opened this issue · 1 comments

Or, maybe as a switch in the debug drawer?

We do this with the following in Application#onCreate:

    if (BuildConfig.IS_DEVELOPER_BUILD) {
      // ActivityThread does not allow setting StrictMode during Application#onCreate. Post it
      // to run as soon as possible after this method.
      new Handler(Looper.getMainLooper()).postAtFrontOfQueue(() -> {
        StrictMode.setVmPolicy(new VmPolicy.Builder() //
            .detectAll() //
            .penaltyLog() //
            .penaltyDeath() //
            .build());
        StrictMode.setThreadPolicy(new ThreadPolicy.Builder() //
            .detectAll() //
            .penaltyLog() //
            .penaltyDeath() //
            .build());
      });
    }

Where IS_DEVELOPER_BUILD detects local debug builds, although that distinction here is probably irrelevant and could just be DEBUG