content: /*
   * Copyright 2017-2021 Kirill Rozov
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *    http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package com.kirillr.application;
  
  import android.app.Application;
  import android.os.StrictMode;
  
  import com.kirillr.strictmodehelper.StrictModeCompat;
  
  public class SampleApplication extends Application {
  
      @Override
      public void onCreate() {
          super.onCreate();
          if (BuildConfig.DEVELOPER_MODE) {
              StrictMode.ThreadPolicy threadPolicy = new StrictModeCompat.ThreadPolicy.Builder()
                      .detectResourceMismatches()
                      .detectCustomSlowCalls()
                      .detectUnbufferedIo()  // Available only on Android 8.0+
                      .penaltyLog()
                      .build();
  
              StrictMode.VmPolicy vmPolicy = new StrictModeCompat.VmPolicy.Builder()
                      .detectFileUriExposure()
                      .detectLeakedRegistrationObjects()
                      .detectCleartextNetwork()
                      .detectUntaggedSockets() // Take effect only on Android 8.0+
                      .detectContentUriWithoutPermission()  // Take effect only on Android 8.0+
                      .penaltyLog()
                      .build();
  
              StrictModeCompat.setPolicies(threadPolicy, vmPolicy);
          }
      }
  }
  