// Path: app/src/main/java/com/jachness/blockcalls/stuff/PermUtil.java
// @SuppressWarnings("SimplifiableIfStatement")
// public class PermUtil {
//     public static final String READ_CONTACTS = Manifest.permission.READ_CONTACTS;
//     public static final String CALL_PHONE = Manifest.permission.CALL_PHONE;
//     public static final String WRITE_EXTERNAL_STORAGE = Manifest.permission.WRITE_EXTERNAL_STORAGE;
//     @SuppressLint("InlinedApi")
//     public static final String READ_EXTERNAL_STORAGE = Manifest.permission.READ_EXTERNAL_STORAGE;
// 
//     @DebugLog
//     public static boolean checkReadContacts(Context context) {
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//             return context.checkSelfPermission(READ_CONTACTS) == PackageManager.PERMISSION_GRANTED;
//         }
//         return true;
//     }
// 
//     @DebugLog
//     public static boolean checkCallPhone(Context context) {
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//             return context.checkSelfPermission(CALL_PHONE) == PackageManager.PERMISSION_GRANTED;
//         }
//         return true;
//     }
// 
//     @DebugLog
//     public static boolean checkWriteExternalStorage(Context context) {
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//             return context.checkSelfPermission(WRITE_EXTERNAL_STORAGE) == PackageManager
//                     .PERMISSION_GRANTED;
//         }
//         return true;
//     }
// 
//     @DebugLog
//     public static boolean checkReadExternalStorage(Context context) {
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//             return context.checkSelfPermission(READ_EXTERNAL_STORAGE) == PackageManager
//                     .PERMISSION_GRANTED;
//         }
//         return true;
//     }
// 
//     @DebugLog
//     private static boolean checkNotificationPolicyAccess(Context context) {
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
//             return ManagerUtil.getNotificationManager(context).isNotificationPolicyAccessGranted();
//         }
//         return true;
//     }
// 
// 
//     @DebugLog
//     public static boolean[] checkInitialPermissions(AppContext context) {
//         return new boolean[]{checkCallPhone(context), checkNotificationPolicyAccess(context),
//                 checkProtectedApps(context)};
//     }
// 
//     /**
//      * This is for Huawei phones. It has built in a "feature" called Protected Apps, that can be
//      * accessed from the phone settings (Battery Manager > Protected Apps). This allows elected
//      * apps to keep running after the screen is turned off.
//      */
//     private static boolean checkProtectedApps(AppContext context) {
//         if (context.getAppPreferences().isShowProtectedAppsMessage()) {
//             Intent intent = new Intent();
//             intent.setClassName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize" +
//                     ".process.ProtectActivity");
//             List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent,
//                     PackageManager.MATCH_DEFAULT_ONLY);
//             return list.size() == 0;
//         }
//         return true;
//     }
// 
// 
// }


import com.jachness.blockcalls.stuff.PermUtil;
import hugo.weaving.DebugLog;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import com.jachness.blockcalls.BuildConfig;
import com.jachness.blockcalls.R;

    }


    @Override
    @DebugLog
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        if (null != fragment) {
            outState.putString(TAG_FRAGMENT, fragment.getTag());
        }
    }

    @Override
    @DebugLog
    protected void onRestart() {
        super.onRestart();
        if (!hasGrantedPermissions()) {
            if (BuildConfig.DEBUG) Log.d(TAG, "Finish activity due to contact permission revoked");
            finish();
        }
    }

    @SuppressWarnings("BooleanMethodIsAlwaysInverted")
    private boolean hasGrantedPermissions() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            String val = getIntent().getExtras().getString(FRAGMENT_KEY);
            if (val.equals(FRAGMENT_CONTACTS)) {
                return PermUtil.checkReadContacts(this);
            } else if (val.equals(FRAGMENT_CALLLOG)) {
// Path: app/src/main/java/com/jachness/blockcalls/stuff/PermUtil.java
// @SuppressWarnings("SimplifiableIfStatement")
// public class PermUtil {
//     public static final String READ_CONTACTS = Manifest.permission.READ_CONTACTS;
//     public static final String CALL_PHONE = Manifest.permission.CALL_PHONE;
//     public static final String WRITE_EXTERNAL_STORAGE = Manifest.permission.WRITE_EXTERNAL_STORAGE;
//     @SuppressLint("InlinedApi")
//     public static final String READ_EXTERNAL_STORAGE = Manifest.permission.READ_EXTERNAL_STORAGE;
// 
//     @DebugLog
//     public static boolean checkReadContacts(Context context) {
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//             return context.checkSelfPermission(READ_CONTACTS) == PackageManager.PERMISSION_GRANTED;
//         }
//         return true;
//     }
// 
//     @DebugLog
//     public static boolean checkCallPhone(Context context) {
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//             return context.checkSelfPermission(CALL_PHONE) == PackageManager.PERMISSION_GRANTED;
//         }
//         return true;
//     }
// 
//     @DebugLog
//     public static boolean checkWriteExternalStorage(Context context) {
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//             return context.checkSelfPermission(WRITE_EXTERNAL_STORAGE) == PackageManager
//                     .PERMISSION_GRANTED;
//         }
//         return true;
//     }
// 
//     @DebugLog
//     public static boolean checkReadExternalStorage(Context context) {
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//             return context.checkSelfPermission(READ_EXTERNAL_STORAGE) == PackageManager
//                     .PERMISSION_GRANTED;
//         }
//         return true;
//     }
// 
//     @DebugLog
//     private static boolean checkNotificationPolicyAccess(Context context) {
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
//             return ManagerUtil.getNotificationManager(context).isNotificationPolicyAccessGranted();
//         }
//         return true;
//     }
// 
// 
//     @DebugLog
//     public static boolean[] checkInitialPermissions(AppContext context) {
//         return new boolean[]{checkCallPhone(context), checkNotificationPolicyAccess(context),
//                 checkProtectedApps(context)};
//     }
// 
//     /**
//      * This is for Huawei phones. It has built in a "feature" called Protected Apps, that can be
//      * accessed from the phone settings (Battery Manager > Protected Apps). This allows elected
//      * apps to keep running after the screen is turned off.
//      */
//     private static boolean checkProtectedApps(AppContext context) {
//         if (context.getAppPreferences().isShowProtectedAppsMessage()) {
//             Intent intent = new Intent();
//             intent.setClassName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize" +
//                     ".process.ProtectActivity");
//             List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent,
//                     PackageManager.MATCH_DEFAULT_ONLY);
//             return list.size() == 0;
//         }
//         return true;
//     }
// 
// 
// }


// Path: app/src/main/java/com/jachness/blockcalls/activities/AddActivity.java
import com.jachness.blockcalls.stuff.PermUtil;
import hugo.weaving.DebugLog;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import com.jachness.blockcalls.BuildConfig;
import com.jachness.blockcalls.R;


    }


    @Override
    @DebugLog
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        if (null != fragment) {
            outState.putString(TAG_FRAGMENT, fragment.getTag());
        }
    }

    @Override
    @DebugLog
    protected void onRestart() {
        super.onRestart();
        if (!hasGrantedPermissions()) {
            if (BuildConfig.DEBUG) Log.d(TAG, "Finish activity due to contact permission revoked");
            finish();
        }
    }

    @SuppressWarnings("BooleanMethodIsAlwaysInverted")
    private boolean hasGrantedPermissions() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            String val = getIntent().getExtras().getString(FRAGMENT_KEY);
            if (val.equals(FRAGMENT_CONTACTS)) {
                return PermUtil.checkReadContacts(this);
            } else if (val.equals(FRAGMENT_CALLLOG)) {
                return PermUtil.checkCallPhone(this);