小红书.apk(点击下载) / w.java


package sy;

import android.app.Activity;
import android.app.AppOpsManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.PowerManager;
import android.os.Process;
import com.tencent.wcdb.database.SQLiteDatabase;
import com.xingin.alpha.R$string;
import com.xingin.alpha.base.AlphaApplication;
import java.lang.reflect.Method;
import kk2.b;
import kk2.d;
import kk2.e;
import kotlin.Unit;
import kotlin.collections.CollectionsKt__CollectionsKt;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;

public final class w {

    /* renamed from: a */
    public static final w f131784a = new w();

    public static final e a(Context context, String str, Function0<Unit> function0, Function0<Unit> function02, boolean z14) {
        Intrinsics.checkNotNullParameter(context, "context");
        Intrinsics.checkNotNullParameter(str, "msgRes");
        Intrinsics.checkNotNullParameter(function0, "positiveCallback");
        Intrinsics.checkNotNullParameter(function02, "negativeCallback");
        String string = context.getString(R$string.aaj);
        Intrinsics.checkNotNullExpressionValue(string, "context.getString(R.stri…ve_permission_tips_title)");
        e eVar = new e(context, new d(0, string, str, CollectionsKt__CollectionsKt.listOf((Object[]) new b[]{new b(R$string.widgets_dialog_btn_ok, function0, 0, 4, null), new b(R$string.widgets_dialog_btn_cancel, function02, 0, 4, null)}), 1, null));
        eVar.setCanceledOnTouchOutside(false);
        if (z14) {
            if (!(context instanceof Activity)) {
                eVar.show();
            } else if (!((Activity) context).isFinishing()) {
                eVar.show();
            }
        }
        return eVar;
    }

    public static /* synthetic */ e b(Context context, String str, Function0 function0, Function0 function02, boolean z14, int i10, Object obj) {
        if ((i10 & 16) != 0) {
            z14 = true;
        }
        return a(context, str, function0, function02, z14);
    }

    public static final boolean d() {
        if (Build.VERSION.SDK_INT < 23) {
            return true;
        }
        AlphaApplication alphaApplication = AlphaApplication.INSTANCE;
        Object systemService = alphaApplication.getAPP().getSystemService("power");
        PowerManager powerManager = systemService instanceof PowerManager ? (PowerManager) systemService : null;
        if (powerManager == null) {
            return false;
        }
        try {
            return powerManager.isIgnoringBatteryOptimizations(alphaApplication.getAPP().getPackageName());
        } catch (Exception unused) {
            return false;
        }
    }

    public static final void e() {
        if (Build.VERSION.SDK_INT >= 23) {
            try {
                Intent intent = new Intent("android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS");
                StringBuilder sb3 = new StringBuilder();
                sb3.append("package:");
                AlphaApplication alphaApplication = AlphaApplication.INSTANCE;
                sb3.append(alphaApplication.getAPP().getPackageName());
                intent.setData(Uri.parse(sb3.toString()));
                intent.addFlags(SQLiteDatabase.CREATE_IF_NECESSARY);
                alphaApplication.getAPP().startActivity(intent);
            } catch (Exception e14) {
                e14.printStackTrace();
            }
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:22:0x006e, code lost:
        if (r3.intValue() == 0) goto L_0x0072;
     */
    public final boolean c() {
        Method method;
        boolean z14 = true;
        if (Build.VERSION.SDK_INT < 23) {
            return true;
        }
        try {
            AlphaApplication alphaApplication = AlphaApplication.INSTANCE;
            Object systemService = alphaApplication.getAPP().getSystemService("appops");
            AppOpsManager appOpsManager = systemService instanceof AppOpsManager ? (AppOpsManager) systemService : null;
            if (appOpsManager != null) {
                Class<?> cls = appOpsManager.getClass();
                Class<?> cls2 = Integer.TYPE;
                method = cls.getMethod("checkOpNoThrow", cls2, cls2, String.class);
            } else {
                method = null;
            }
            Object invoke = method != null ? method.invoke(appOpsManager, 10021, Integer.valueOf(Process.myUid()), alphaApplication.getAPP().getPackageName()) : null;
            Integer num = invoke instanceof Integer ? (Integer) invoke : null;
            if (num == null) {
            }
            z14 = false;
            return z14;
        } catch (Exception e14) {
            v0.f131783a.c("alpha-log", null, "check miui background permission error," + e14.getMessage());
            return false;
        }
    }
}