Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add StrictMode for internal builds #270

Open
NightlyNexus opened this issue Feb 1, 2017 · 1 comment
Open

Add StrictMode for internal builds #270

NightlyNexus opened this issue Feb 1, 2017 · 1 comment

Comments

@NightlyNexus
Copy link
Contributor

Or, maybe as a switch in the debug drawer?

@JakeWharton
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants