导航菜单

页面标题

页面副标题

Minits v4.9.3.32 - SystemSettings.java 源代码

正在查看: Minits v4.9.3.32 应用的 SystemSettings.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.xone.android.script.runtimeobjects;

import C9.h;
import M9.b;
import Q8.k;
import Q8.m;
import Q9.h;
import Q9.i;
import T9.g;
import U9.AbstractC0295c1;
import U9.AbstractC0298d1;
import U9.AbstractC0301e1;
import U9.AbstractC0313i1;
import U9.C0356x0;
import Y4.c;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.WallpaperManager;
import android.app.admin.DevicePolicyManager;
import android.app.usage.UsageStatsManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentSender;
import android.content.pm.FeatureInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Debug;
import android.os.Environment;
import android.os.PowerManager;
import android.os.Process;
import android.os.SystemClock;
import android.provider.Settings;
import android.security.KeyChain;
import android.security.NetworkSecurityPolicy;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.view.accessibility.AccessibilityManager;
import androidx.annotation.Keep;
import androidx.fragment.app.j;
import com.xone.android.javascript.BaseFunctionJavaMethodWrapper;
import com.xone.android.javascript.XOneJavascript;
import com.xone.android.nfc.runtimeobjects.XoneNFCRuntime;
import com.xone.android.utils.Utils;
import com.xone.annotations.ScriptAllowed;
import com.xone.interfaces.IRuntimeObject;
import fb.q;
import fb.t;
import ha.AbstractC0751f;
import ha.AbstractC0756k;
import ha.M;
import ha.N;
import ha.r;
import ha.v;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
import java.util.concurrent.ExecutionException;
import m4.o;
import m5.x0;
import org.json.JSONException;
import org.mozilla.javascript.BaseFunction;
import org.mozilla.javascript.C0893d0;
import org.mozilla.javascript.C0897f0;
import org.mozilla.javascript.C0907k0;
import org.mozilla.javascript.C0932x0;
import org.mozilla.javascript.Q0;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.Y;
import q9.C0973a;
import qa.EnumC0975b;
import s5.f;
import ua.InterfaceC1013a;
import ua.InterfaceC1016b0;
import ua.InterfaceC1036l0;
import ua.InterfaceC1038m0;
import ua.O0;
import ua.U;
import ua.V;
import ua.W;
import ua.X;
import w7.d;
import w7.e;
import w7.n;
import w7.p;

@ScriptAllowed
@Keep
public final class SystemSettings extends BaseFunction implements IRuntimeObject {
    private static final long C2 = 1000000;
    private static final long C4 = 60000000000L;
    private static final long C5 = 3600000000000L;
    private static final long C6 = 86400000000000L;
    private static final String CLASS_LIVE_WIDGET_PROVIDER = "com.xone.live.widgets.LiveWidgetProvider";
    private static final String CLASS_REPLICATOR_WIDGET_PROVIDER = "com.xone.replicator.ReplicatorWidgetProvider";
    private static final double HoursPerDay = 24.0d;
    private static final double MinutesPerDay = 1440.0d;
    private static final double MinutesPerHour = 60.0d;
    private static final String NAME = "SystemSettings";
    private static final String PROPERTY_GMT_OFFSET = "GMT_OFFSET";
    private static final String PROPERTY_GMT_OFFSET_WITH_DAYLIGHT_SAVING_TIME = "GMT_OFFSET_WITH_DAYLIGHT_SAVING_TIME";
    private static final int REQUEST_CODE_PERMISSIONS_SCRIPT_SYSTEMSETTINGS = 8007;
    private static final double SecondsPerDay = 86400.0d;
    private static final double SecondsPerHour = 3600.0d;
    private static final double SecondsPerMinute = 60.0d;
    private static List<Intent> lstPowerManagerIntents = null;
    private static final double msPerDay = 8.64E7d;
    private static final double msPerHour = 3600000.0d;
    private static final double msPerMinute = 60000.0d;
    private static final double msPerSecond = 1000.0d;
    private InterfaceC1013a analytics;
    private boolean bFinished;
    private boolean bResult;
    private final Context context;
    private final IntentFilter intentFilter = new IntentFilter("target_message_result_action");
    private final g receiver = new g(this);
    private final X scriptRuntime;
    private static final Map<String, W> mapTypeInfo = new Hashtable();
    private static final Map<String, Field> publicFields = new HashMap();

    public static class a {
        public static final int[] a;

        static {
            int[] iArr = new int[EnumC0975b.values().length];
            a = iArr;
            try {
                iArr[EnumC0975b.GetProperty.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                a[EnumC0975b.SetProperty.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                a[EnumC0975b.Method.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
        }
    }

    static {
        initTypeInfoData();
    }

    public SystemSettings(Context context, X x) {
        this.context = context.getApplicationContext();
        this.scriptRuntime = x;
        XOneJavascript.addFunctions(this);
    }

    private static int DateFromTime(double d) {
        int YearFromTime = YearFromTime(d);
        int Day = (int) (Day(d) - DayFromYear(YearFromTime));
        int i = Day - 59;
        if (i < 0) {
            return i < -28 ? Day + 1 : Day - 30;
        }
        if (IsLeapYear(YearFromTime)) {
            if (i == 0) {
                return 29;
            }
            i = Day - 60;
        }
        int i2 = 30;
        int i3 = 31;
        switch (i / 30) {
            case 0:
                return i + 1;
            case 1:
                i2 = 31;
                break;
            case 2:
                i3 = 61;
                break;
            case 3:
                i2 = 31;
                i3 = 92;
                break;
            case 4:
                i3 = 122;
                break;
            case 5:
                i2 = 31;
                i3 = 153;
                break;
            case 6:
                i2 = 31;
                i3 = 184;
                break;
            case org.mozilla.javascript.Context.FEATURE_DYNAMIC_SCOPE:
                i3 = 214;
                break;
            case 8:
                i2 = 31;
                i3 = 245;
                break;
            case org.mozilla.javascript.Context.FEATURE_STRICT_EVAL:
                i3 = 275;
                break;
            case org.mozilla.javascript.Context.FEATURE_LOCATION_INFORMATION_IN_ERROR:
                return i - 274;
            default:
                throw Y.d();
        }
        int i4 = i - i3;
        if (i4 < 0) {
            i4 += i2;
        }
        return i4 + 1;
    }

    private static double Day(double d) {
        return Math.floor(d / msPerDay);
    }

    private static double DayFromMonth(int i, int i2) {
        int i3;
        int i4;
        int i5 = i * 30;
        if (i >= 7) {
            i4 = i / 2;
        } else {
            if (i < 2) {
                i3 = i5 + i;
                if (i >= 2 && IsLeapYear(i2)) {
                    i3++;
                }
                return i3;
            }
            i4 = (i - 1) / 2;
        }
        i3 = i5 + (i4 - 1);
        if (i >= 2) {
            i3++;
        }
        return i3;
    }

    private static double DayFromYear(double d) {
        return ((((d - 1970.0d) * 365.0d) + Math.floor((d - 1969.0d) / 4.0d)) - Math.floor((d - 1901.0d) / 100.0d)) + Math.floor((d - 1601.0d) / 400.0d);
    }

    private static double DaylightSavingTA(double d) {
        if (d < 0.0d) {
            d = MakeDate(MakeDay(EquivalentYear(YearFromTime(d)), MonthFromTime(d), DateFromTime(d)), TimeWithinDay(d));
        }
        if (TimeZone.getDefault().inDaylightTime(new Date((long) d))) {
            return msPerHour;
        }
        return 0.0d;
    }

    private static int EquivalentYear(int i) {
        int DayFromYear = (((int) DayFromYear(i)) + 4) % 7;
        if (DayFromYear < 0) {
            DayFromYear += 7;
        }
        if (IsLeapYear(i)) {
            switch (DayFromYear) {
                case 0:
                    return 1984;
                case 1:
                    return 1996;
                case 2:
                    return 1980;
                case 3:
                    return 1992;
                case 4:
                    return 1976;
                case 5:
                    return 1988;
                case 6:
                    return 1972;
            }
        }
        switch (DayFromYear) {
            case 0:
                return 1978;
            case 1:
                return 1973;
            case 2:
                return 1985;
            case 3:
                return 1986;
            case 4:
                return 1981;
            case 5:
                return 1971;
            case 6:
                return 1977;
        }
        throw Y.d();
    }

    private Object GetProperty(String str) {
        Field field = publicFields.get(str);
        if (field != null) {
            try {
                return Settings.Global.getString(getContentResolver(), (String) field.get(null));
            } catch (IllegalAccessException e) {
                throw AbstractC0751f.e(e);
            }
        }
        if (str.compareTo(PROPERTY_GMT_OFFSET) == 0) {
            return Double.valueOf(getGmtOffset());
        }
        if (str.compareTo(PROPERTY_GMT_OFFSET_WITH_DAYLIGHT_SAVING_TIME) == 0) {
            return Double.valueOf(getGmtOffsetWithDaylightSaving());
        }
        throw new b(getName() + ": Property " + str + " not implemented.");
    }

    private static boolean IsLeapYear(int i) {
        if (i % 4 == 0) {
            return i % 100 != 0 || i % 400 == 0;
        }
        return false;
    }

    private static double MakeDate(double d, double d2) {
        return (d * msPerDay) + d2;
    }

    private static double MakeDay(double d, double d2, double d3) {
        double floor = d + Math.floor(d2 / 12.0d);
        double d4 = d2 % 12.0d;
        if (d4 < 0.0d) {
            d4 += 12.0d;
        }
        return ((Math.floor(TimeFromYear(floor) / msPerDay) + DayFromMonth((int) d4, (int) floor)) + d3) - 1.0d;
    }

    private static int MonthFromTime(double d) {
        int i;
        int YearFromTime = YearFromTime(d);
        int Day = (int) (Day(d) - DayFromYear(YearFromTime));
        int i2 = Day - 59;
        if (i2 < 0) {
            return i2 < -28 ? 0 : 1;
        }
        if (IsLeapYear(YearFromTime)) {
            if (i2 == 0) {
                return 1;
            }
            i2 = Day - 60;
        }
        int i3 = i2 / 30;
        switch (i3) {
            case 0:
                return 2;
            case 1:
                i = 31;
                break;
            case 2:
                i = 61;
                break;
            case 3:
                i = 92;
                break;
            case 4:
                i = 122;
                break;
            case 5:
                i = 153;
                break;
            case 6:
                i = 184;
                break;
            case org.mozilla.javascript.Context.FEATURE_DYNAMIC_SCOPE:
                i = 214;
                break;
            case 8:
                i = 245;
                break;
            case org.mozilla.javascript.Context.FEATURE_STRICT_EVAL:
                i = 275;
                break;
            case org.mozilla.javascript.Context.FEATURE_LOCATION_INFORMATION_IN_ERROR:
                return 11;
            default:
                throw Y.d();
        }
        return i2 >= i ? i3 + 2 : i3 + 1;
    }

    private void SetProperty(String str, Object[] objArr) {
        Utils.g(str, objArr, 1);
        Field field = publicFields.get(str);
        if (field == null) {
            throw new b(getName() + ": Property " + str + " not implemented.");
        }
        try {
            String str2 = (String) field.get(null);
            Object obj = objArr[0];
            if (obj instanceof Float) {
                Settings.Global.putFloat(getContentResolver(), str2, ((Float) objArr[0]).floatValue());
            } else if (obj instanceof Integer) {
                Settings.Global.putInt(getContentResolver(), str2, ((Integer) objArr[0]).intValue());
            } else if (obj instanceof Long) {
                Settings.Global.putLong(getContentResolver(), str2, ((Long) objArr[0]).longValue());
            } else if (obj instanceof Double) {
                Settings.Global.putFloat(getContentResolver(), str2, ((Double) objArr[0]).floatValue());
            } else if (obj instanceof String) {
                Settings.Global.putString(getContentResolver(), str2, (String) objArr[0]);
            }
            throw new b(getName() + ": Property " + str + " not implemented.");
        } catch (IllegalAccessException e) {
            throw AbstractC0751f.e(e);
        }
    }

    private static double TimeFromYear(double d) {
        return DayFromYear(d) * msPerDay;
    }

    private static double TimeWithinDay(double d) {
        double d2 = d % msPerDay;
        return d2 < 0.0d ? d2 + msPerDay : d2;
    }

    private static int YearFromTime(double d) {
        double d2 = d / msPerDay;
        int floor = ((int) Math.floor(d2 / 366.0d)) + 1970;
        int floor2 = ((int) Math.floor(d2 / 365.0d)) + 1970;
        if (floor2 >= floor) {
            floor = floor2;
            floor2 = floor;
        }
        while (floor > floor2) {
            int i = (floor + floor2) / 2;
            if (TimeFromYear(i) > d) {
                floor = i - 1;
            } else {
                floor2 = i + 1;
                if (TimeFromYear(floor2) > d) {
                    return i;
                }
            }
        }
        return floor2;
    }

    private static void addActivityIntentIfExists(PackageManager packageManager, List<Intent> list, String str, String str2) {
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(str, str2));
        if (packageManager.resolveActivity(intent, 65536) != null) {
            list.add(intent);
        }
    }

    @SuppressLint({"HardwareIds", "MissingPermission"})
    private void addImeisWithApi(List<String> list) {
        TelephonyManager telephonyManager = getTelephonyManager();
        if (Build.VERSION.SDK_INT < 23) {
            String deviceId = telephonyManager.getDeviceId();
            if (TextUtils.isEmpty(deviceId)) {
                return;
            }
            list.add(deviceId);
            return;
        }
        int a2 = d.a(telephonyManager);
        for (int i = 0; i < a2; i++) {
            try {
                String a3 = e.a(telephonyManager, i);
                if (!TextUtils.isEmpty(a3)) {
                    list.add(a3);
                }
            } catch (SecurityException unused) {
            }
        }
    }

    private void addPermissionIfDeclared(Collection<String> collection, Collection<String> collection2, String str) {
        if (collection.contains(str)) {
            collection2.add(str);
            return;
        }
        Utils.l("XOneAndroidFramework", "SystemSettings.requestPermissions(): Permission " + str + " requested but it is not present on AndroidManifest.xml. Skipping");
    }

    private boolean canWriteSettings() {
        boolean canWrite;
        if (Build.VERSION.SDK_INT < 23) {
            return true;
        }
        canWrite = Settings.System.canWrite((Context) getApp());
        return canWrite;
    }

    private boolean doWriteSettingsPermissionCheck() {
        if (canWriteSettings()) {
            return false;
        }
        launchEnableWriteSettings();
        return true;
    }

    private AccessibilityManager getAccessibilityManager() {
        Object systemService = this.context.getSystemService("accessibility");
        if (systemService instanceof AccessibilityManager) {
            return (AccessibilityManager) systemService;
        }
        throw new NullPointerException("Cannot obtain AccessibilityManager instance");
    }

    private ActivityManager getActivityManager() {
        Object systemService = this.context.getSystemService("activity");
        if (systemService instanceof ActivityManager) {
            return (ActivityManager) systemService;
        }
        throw new UnsupportedOperationException("Cannot obtain ActivityManager instance");
    }

    private InterfaceC1013a getAnalytics() {
        if (this.analytics == null) {
            this.analytics = (InterfaceC1013a) M.n(null, M.l("com.xone.android.googleanalytics.XOneGoogleAnalyticsManager", "getInstance", Context.class), this.context);
        }
        return this.analytics;
    }

    private InterfaceC1038m0 getApp() {
        return (InterfaceC1038m0) this.context;
    }

    private Configuration getConfiguration() {
        return getResources().getConfiguration();
    }

    private ConnectivityManager getConnectivityManager() {
        Object systemService = this.context.getSystemService("connectivity");
        if (systemService instanceof ConnectivityManager) {
            return (ConnectivityManager) systemService;
        }
        throw new NullPointerException("Cannot obtain ConnectivityManager instance");
    }

    private ContentResolver getContentResolver() {
        return this.context.getContentResolver();
    }

    private DevicePolicyManager getDpm() {
        return (DevicePolicyManager) this.context.getSystemService("device_policy");
    }

    private boolean getFinished() {
        return this.bFinished;
    }

    private double getGmtOffset() {
        return ((TimeZone.getDefault().getOffset(15L) / msPerSecond) / 60.0d) / 60.0d;
    }

    private double getGmtOffsetWithDaylightSaving() {
        double time = new Date().getTime();
        return (((time - getLocalTime(time)) / msPerMinute) / 60.0d) * (-1.0d);
    }

    private InterfaceC1036l0 getLastEditView() {
        return getApp().g();
    }

    private static double getLocalTime(double d) {
        return TimeZone.getDefault().getRawOffset() + d + DaylightSavingTA(d);
    }

    private PackageManager getPackageManager() {
        return this.context.getPackageManager();
    }

    private Intent getPinShortcutIntent(Bundle bundle) {
        Intent intent = new Intent();
        intent.setAction("android.intent.action.VIEW");
        intent.setClassName(this.context, "com.xone.android.framework.MainEntryMessageAlias");
        intent.putExtra("executeOnMessage", true);
        intent.putExtra("intentBundle", bundle);
        return intent;
    }

    private PowerManager getPowerManager() {
        Object systemService = this.context.getSystemService("power");
        if (systemService instanceof PowerManager) {
            return (PowerManager) systemService;
        }
        throw new NullPointerException("Cannot obtain PowerManager instance");
    }

    private static List<Intent> getPowerManagerIntentList(Context context) {
        List<Intent> list = lstPowerManagerIntents;
        if (list != null) {
            return list;
        }
        PackageManager packageManager = context.getPackageManager();
        ArrayList arrayList = new ArrayList();
        lstPowerManagerIntents = arrayList;
        addActivityIntentIfExists(packageManager, arrayList, "com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity");
        addActivityIntentIfExists(packageManager, lstPowerManagerIntents, "com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity");
        addActivityIntentIfExists(packageManager, lstPowerManagerIntents, "com.huawei.systemmanager", "com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity");
        addActivityIntentIfExists(packageManager, lstPowerManagerIntents, "com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity");
        addActivityIntentIfExists(packageManager, lstPowerManagerIntents, "com.huawei.systemmanager", "com.huawei.systemmanager.appcontrol.activity.StartupAppControlActivity");
        addActivityIntentIfExists(packageManager, lstPowerManagerIntents, "com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity");
        addActivityIntentIfExists(packageManager, lstPowerManagerIntents, "com.coloros.safecenter", "com.coloros.safecenter.startupapp.StartupAppListActivity");
        addActivityIntentIfExists(packageManager, lstPowerManagerIntents, "com.oppo.safe", "com.oppo.safe.permission.startup.StartupAppListActivity");
        addActivityIntentIfExists(packageManager, lstPowerManagerIntents, "com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity");
        addActivityIntentIfExists(packageManager, lstPowerManagerIntents, "com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.BgStartUpManager");
        addActivityIntentIfExists(packageManager, lstPowerManagerIntents, "com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity");
        addActivityIntentIfExists(packageManager, lstPowerManagerIntents, "com.samsung.android.lool", "com.samsung.android.sm.ui.battery.BatteryActivity");
        addActivityIntentIfExists(packageManager, lstPowerManagerIntents, "com.htc.pitroad", "com.htc.pitroad.landingpage.activity.LandingPageActivity");
        addActivityIntentIfExists(packageManager, lstPowerManagerIntents, "com.asus.mobilemanager", "com.asus.mobilemanager.MainActivity");
        return lstPowerManagerIntents;
    }

    private Resources getResources() {
        return this.context.getResources();
    }

    private boolean getResult() {
        return this.bResult;
    }

    private <T> T getShortcutManager() {
        if (Build.VERSION.SDK_INT < 25) {
            throw new UnsupportedOperationException("ShortcutManager not implemented on Android < 7.1");
        }
        T t = (T) this.context.getSystemService("shortcut");
        if (AbstractC0295c1.a(t)) {
            return t;
        }
        throw new NullPointerException("Cannot obtain ShortcutManager instance");
    }

    private TelephonyManager getTelephonyManager() {
        Object systemService = this.context.getSystemService("phone");
        if (systemService instanceof TelephonyManager) {
            return (TelephonyManager) systemService;
        }
        throw new NullPointerException("Cannot obtain TelephonyManager instance");
    }

    private WallpaperManager getWallpaperManager() {
        Object systemService = this.context.getSystemService("wallpaper");
        if (systemService instanceof WallpaperManager) {
            return (WallpaperManager) systemService;
        }
        throw new NullPointerException("Cannot obtain WallpaperManager instance");
    }

    private static void initTypeInfoData() {
        for (Field field : Settings.Global.class.getFields()) {
            String name = field.getName();
            publicFields.put(name, field);
            Wa.d dVar = new Wa.d(name, O0.b);
            mapTypeInfo.put(dVar.getName(), dVar);
        }
        Wa.d dVar2 = new Wa.d(PROPERTY_GMT_OFFSET, O0.b);
        Map<String, W> map = mapTypeInfo;
        map.put(dVar2.getName(), dVar2);
        Wa.d dVar3 = new Wa.d(PROPERTY_GMT_OFFSET_WITH_DAYLIGHT_SAVING_TIME, O0.b);
        map.put(dVar3.getName(), dVar3);
        Wa.d dVar4 = new Wa.d("ispasswordsecured", O0.a);
        map.put(dVar4.getName(), dVar4);
        Wa.d dVar5 = new Wa.d("isdeviceintegrityok", O0.a);
        map.put(dVar5.getName(), dVar5);
        Wa.d dVar6 = new Wa.d("isrunninginworkprofile", O0.a);
        map.put(dVar6.getName(), dVar6);
        Wa.d dVar7 = new Wa.d("isrunningwithdeviceowner", O0.a);
        map.put(dVar7.getName(), dVar7);
        Wa.d dVar8 = new Wa.d("isrunninginmdm", O0.a);
        dVar8.c("brightness", 1, true);
        map.put(dVar8.getName(), dVar8);
        Wa.d dVar9 = new Wa.d("getbrightness", O0.a);
        map.put(dVar9.getName(), dVar9);
        Wa.d dVar10 = new Wa.d("setbrightness", O0.a);
        dVar10.c("brightness", 2, false);
        map.put(dVar10.getName(), dVar10);
        Wa.d dVar11 = new Wa.d("setbrightnessmode", O0.a);
        dVar11.c("brightnessmode", 2, false);
        map.put(dVar11.getName(), dVar11);
        Wa.d dVar12 = new Wa.d("gethardwareids", O0.a);
        map.put(dVar12.getName(), dVar12);
        Wa.d dVar13 = new Wa.d("getdeviceid", O0.a);
        map.put(dVar13.getName(), dVar13);
        Wa.d dVar14 = new Wa.d("setdeviceid", O0.a);
        dVar14.c("deviceid", 1, false);
        map.put(dVar14.getName(), dVar14);
        Wa.d dVar15 = new Wa.d("addpinshortcut", O0.a);
        dVar15.c("object", 8, false);
        map.put(dVar15.getName(), dVar15);
        Wa.d dVar16 = new Wa.d("getnetworktime", O0.a);
        dVar16.c("object", 8, false);
        map.put(dVar16.getName(), dVar16);
        Wa.d dVar17 = new Wa.d("ispermissiongranted", O0.a);
        dVar17.c("object", 8, false);
        map.put(dVar17.getName(), dVar17);
        Wa.d dVar18 = new Wa.d("requestpermissions", O0.a);
        dVar18.c("object", 8, false);
        map.put(dVar18.getName(), dVar18);
        Wa.d dVar19 = new Wa.d("revokepermissions", O0.a);
        dVar19.c("permissions", 7, false);
        map.put(dVar19.getName(), dVar19);
        Wa.d dVar20 = new Wa.d("showappsettingswindow", O0.a);
        map.put(dVar20.getName(), dVar20);
        Wa.d dVar21 = new Wa.d("isignoringbatteryoptimizations", O0.a);
        dVar21.c("packageName", 1, true);
        map.put(dVar21.getName(), dVar21);
        Wa.d dVar22 = new Wa.d("requestignorebatteryoptimizations", O0.a);
        dVar22.c("usePermission", 6, true);
        map.put(dVar22.getName(), dVar22);
        Wa.d dVar23 = new Wa.d("requestignorespecialbatteryoptimizations", O0.a);
        map.put(dVar23.getName(), dVar23);
        Wa.d dVar24 = new Wa.d("isbackgroundrestricted", O0.a);
        map.put(dVar24.getName(), dVar24);
        Wa.d dVar25 = new Wa.d("isbackgrounddatadisabled", O0.a);
        map.put(dVar25.getName(), dVar25);
        Wa.d dVar26 = new Wa.d("isairplanemode", O0.a);
        map.put(dVar26.getName(), dVar26);
        Wa.d dVar27 = new Wa.d("mergejavascriptcache", O0.a);
        map.put(dVar27.getName(), dVar27);
        Wa.d dVar28 = new Wa.d("clearjavascriptcache", O0.a);
        map.put(dVar28.getName(), dVar28);
        Wa.d dVar29 = new Wa.d("clearbitmapcache", O0.a);
        map.put(dVar29.getName(), dVar29);
        Wa.d dVar30 = new Wa.d("clearapplicationdata", O0.a);
        map.put(dVar30.getName(), dVar30);
        Wa.d dVar31 = new Wa.d("checkmarketupdate", O0.a);
        dVar31.c("updatetype", 1, true);
        map.put(dVar31.getName(), dVar31);
        Wa.d dVar32 = new Wa.d("getmemorylevel", O0.a);
        map.put(dVar32.getName(), dVar32);
        Wa.d dVar33 = new Wa.d("getmaxmemory", O0.a);
        map.put(dVar33.getName(), dVar33);
        Wa.d dVar34 = new Wa.d("getfreememory", O0.a);
        map.put(dVar34.getName(), dVar34);
        Wa.d dVar35 = new Wa.d("garbagecollect", O0.a);
        map.put(dVar35.getName(), dVar35);
        Wa.d dVar36 = new Wa.d("clearallappscache", O0.a);
        map.put(dVar36.getName(), dVar36);
        Wa.d dVar37 = new Wa.d("isexternalstoragemanager", O0.a);
        dVar37.c("path", 1, true);
        map.put(dVar37.getName(), dVar37);
        Wa.d dVar38 = new Wa.d("requestexternalstoragepermission", O0.a);
        dVar38.c("path", 1, true);
        map.put(dVar38.getName(), dVar38);
        Wa.d dVar39 = new Wa.d("requestscheduleexactalarmpermission", O0.a);
        dVar39.c("path", 1, true);
        map.put(dVar39.getName(), dVar39);
        Wa.d dVar40 = new Wa.d("iscleartexttrafficallowed", O0.a);
        dVar40.c("host", 1, true);
        map.put(dVar40.getName(), dVar40);
        Wa.d dVar41 = new Wa.d("setanalyticsenabled", O0.a);
        dVar41.c("enabled", 6, false);
        map.put(dVar41.getName(), dVar41);
        Wa.d dVar42 = new Wa.d("loganalyticsevent", O0.a);
        dVar42.c("tag", 1, false);
        dVar42.c("data", 8, false);
        map.put(dVar42.getName(), dVar42);
        Wa.d dVar43 = new Wa.d("isaccessibilityenabled", O0.a);
        map.put(dVar43.getName(), dVar43);
        Wa.d dVar44 = new Wa.d("istouchexplorationenabled", O0.a);
        map.put(dVar44.getName(), dVar44);
        Wa.d dVar45 = new Wa.d("isautostartenabled", O0.a);
        map.put(dVar45.getName(), dVar45);
        Wa.d dVar46 = new Wa.d("getintegritytoken", O0.a);
        dVar46.c("nonce", 1, false);
        map.put(dVar46.getName(), dVar46);
        Wa.d dVar47 = new Wa.d("getapilevel", O0.a);
        map.put(dVar47.getName(), dVar47);
        Wa.d dVar48 = new Wa.d("getandroidversion", O0.a);
        map.put(dVar48.getName(), dVar48);
        Wa.d dVar49 = new Wa.d("getminsdkversion", O0.a);
        map.put(dVar49.getName(), dVar49);
        Wa.d dVar50 = new Wa.d("gettargetsdkversion", O0.a);
        map.put(dVar50.getName(), dVar50);
        Wa.d dVar51 = new Wa.d("getwallpaper", O0.a);
        map.put(dVar51.getName(), dVar51);
        Wa.d dVar52 = new Wa.d("setwallpaper", O0.a);
        map.put(dVar52.getName(), dVar52);
        Wa.d dVar53 = new Wa.d("isdebuggerconnected", O0.a);
        map.put(dVar53.getName(), dVar53);
    }

    private void launchEnableWriteSettings() {
        j g;
        if (Build.VERSION.SDK_INT >= 23 && (g = getApp().g()) != null) {
            Intent intent = new Intent("android.settings.action.MANAGE_WRITE_SETTINGS");
            intent.setData(Uri.parse("package:" + getPackageName()));
            intent.addFlags(268435456);
            g.startActivity(intent);
        }
    }

    private static void registerReceiverCompat(Context context, BroadcastReceiver broadcastReceiver, IntentFilter intentFilter, boolean z) {
        if (Build.VERSION.SDK_INT >= 33) {
            x0.a(context, broadcastReceiver, intentFilter, z ? 2 : 4);
        } else {
            context.registerReceiver(broadcastReceiver, intentFilter);
        }
    }

    private static long scale(long j, long j2, long j3) {
        if (j > j3) {
            return Long.MAX_VALUE;
        }
        if (j < (-j3)) {
            return Long.MIN_VALUE;
        }
        return j * j2;
    }

    private boolean setComponentState(String str, boolean z) {
        PackageManager packageManager = getPackageManager();
        Class d = M.d(str);
        if (d == null) {
            return false;
        }
        packageManager.setComponentEnabledSetting(new ComponentName(this.context, (Class<?>) d), z ? 1 : 2, 1);
        return true;
    }

    private static void startActivitySafe(Activity activity, Intent intent) {
        if (activity == null || intent == null) {
            return;
        }
        try {
            activity.startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public W GetTypeInfo(String str) {
        Map<String, W> map = mapTypeInfo;
        if (map.containsKey(str)) {
            return map.get(str);
        }
        for (String str2 : map.keySet()) {
            if (!TextUtils.isEmpty(str2) && str.compareToIgnoreCase(str2) == 0) {
                return mapTypeInfo.get(str2);
            }
        }
        return null;
    }

    @Override
    public java.lang.Object Invoke(java.lang.String r6, qa.EnumC0975b r7, java.lang.Object[] r8) {
        throw new UnsupportedOperationException("Method not decompiled: com.xone.android.script.runtimeobjects.SystemSettings.Invoke(java.lang.String, qa.b, java.lang.Object[]):java.lang.Object");
    }

    @ScriptAllowed
    @Keep
    public Object addPinShortcut(Object... objArr) {
        Icon createWithBitmap;
        ShortcutInfo build;
        boolean addDynamicShortcuts;
        boolean isRequestPinShortcutSupported;
        Utils.j("AddPinShortcut", objArr);
        Utils.g("AddPinShortcut", objArr, 1);
        Object obj = objArr[0];
        if (!(obj instanceof C0932x0)) {
            throw new IllegalArgumentException("Invalid parameter type");
        }
        C0932x0 c0932x0 = (C0932x0) obj;
        String E = k.E(c0932x0, XoneNFCRuntime.TAG_ID_FIELD, null);
        String E2 = k.E(c0932x0, "label", null);
        String E3 = k.E(c0932x0, "icon", null);
        Bundle x = k.x(c0932x0, "extras", null);
        if (TextUtils.isEmpty(E)) {
            throw new IllegalArgumentException("AddPinShortcut(): Empty id parameter");
        }
        if (TextUtils.isEmpty(E2)) {
            throw new IllegalArgumentException("AddPinShortcut(): Empty label parameter");
        }
        if (TextUtils.isEmpty(E3)) {
            throw new IllegalArgumentException("AddPinShortcut(): Empty icon parameter");
        }
        InterfaceC1038m0 app = getApp();
        File q1 = Utils.q1(app.Y(), app.T(), E3, false, 2);
        if (!q1.exists()) {
            throw AbstractC0751f.b("AddPinShortcut(): File " + q1.getAbsolutePath() + " doesn't exists");
        }
        if (!q1.isFile()) {
            throw AbstractC0751f.b("AddPinShortcut(): Path " + q1.getAbsolutePath() + " is not a file");
        }
        if (x == null) {
            x = new Bundle();
        }
        x.putSerializable(XoneNFCRuntime.TAG_ID_FIELD, E);
        Bitmap decodeFile = BitmapFactory.decodeFile(q1.getAbsolutePath());
        if (decodeFile == null) {
            throw new IllegalArgumentException("AddPinShortcut(): Cannot decode icon " + q1.getAbsolutePath());
        }
        int i = Build.VERSION.SDK_INT;
        if (i < 25) {
            throw new UnsupportedOperationException("AddPinShortcut(): Not available on API levels below 25");
        }
        ShortcutManager a2 = AbstractC0313i1.a(getShortcutManager());
        if (i >= 26) {
            isRequestPinShortcutSupported = a2.isRequestPinShortcutSupported();
            if (!isRequestPinShortcutSupported) {
                throw new UnsupportedOperationException("AddPinShortcut(): Pin shortcuts not available on this launcher app");
            }
        }
        AbstractC0301e1.a();
        ShortcutInfo.Builder a3 = AbstractC0298d1.a(this.context, E);
        a3.setShortLabel(E2);
        a3.setLongLabel(E2);
        createWithBitmap = Icon.createWithBitmap(decodeFile);
        a3.setIcon(createWithBitmap);
        a3.setIntent(getPinShortcutIntent(x));
        ArrayList arrayList = new ArrayList();
        build = a3.build();
        arrayList.add(build);
        addDynamicShortcuts = a2.addDynamicShortcuts(arrayList);
        if (addDynamicShortcuts) {
            return null;
        }
        throw new IllegalStateException("AddPinShortcut(): Failed adding shortcut. Is the shortcut limit reached?");
    }

    @Override
    public Object call(org.mozilla.javascript.Context context, Scriptable scriptable, Scriptable scriptable2, Object[] objArr) {
        return new SystemSettings(this.context, this.scriptRuntime);
    }

    @ScriptAllowed
    @Keep
    public boolean checkMarketUpdate(Object... objArr) {
        int i;
        Utils.h("CheckMarketUpdate", objArr, 0, 1);
        String A = t.A(objArr, 0, "immediate");
        A.getClass();
        if (A.equals("immediate")) {
            i = 1;
        } else {
            if (!A.equals("flexible")) {
                throw new IllegalArgumentException("CheckMarketUpdate(): Unknown update type " + A);
            }
            i = 0;
        }
        Y4.b a2 = c.a(this.context);
        try {
            Y4.a aVar = (Y4.a) o.a(a2.a());
            int b = aVar.b();
            if (b == 0) {
                Utils.l("XOneAndroidFramework", "SystemSettings.checkMarketUpdate(): UNKNOWN");
                return false;
            }
            if (b == 1) {
                Utils.l("XOneAndroidFramework", "SystemSettings.checkMarketUpdate(): UPDATE_NOT_AVAILABLE");
                return false;
            }
            if (b != 2) {
                if (b == 3) {
                    Utils.l("XOneAndroidFramework", "SystemSettings.checkMarketUpdate(): DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS");
                    return false;
                }
                Utils.l("XOneAndroidFramework", "SystemSettings.checkMarketUpdate(): Unknown status code received. Code: " + b);
                return false;
            }
            Utils.l("XOneAndroidFramework", "SystemSettings.checkMarketUpdate(): UPDATE_AVAILABLE");
            j g = getApp().g();
            if (g == null) {
                Utils.l("XOneAndroidFramework", "SystemSettings.checkMarketUpdate(): No XOne activity found, cannot launch update. Returning false");
                return false;
            }
            if (!(g instanceof InterfaceC1016b0)) {
                Utils.l("XOneAndroidFramework", "SystemSettings.checkMarketUpdate(): No suitable activity found, cannot launch update. Returning false");
                return false;
            }
            K9.a aVar2 = new K9.a();
            ((InterfaceC1016b0) g).q(aVar2);
            try {
                a2.b(aVar, i, g, aVar2.getRequestCode());
                return true;
            } catch (IntentSender.SendIntentException e) {
                throw AbstractC0751f.e(e);
            }
        } catch (InterruptedException e2) {
            throw AbstractC0751f.e(e2);
        } catch (ExecutionException e3) {
            AbstractC0751f.i(e3).printStackTrace();
            return false;
        }
    }

    @ScriptAllowed
    @Keep
    @SuppressLint({"MissingPermission"})
    public boolean clearAllAppsCache() {
        if (Build.VERSION.SDK_INT < 30) {
            Utils.l("XOneAndroidFramework", "SystemSettings.clearAllAppsCache(): Android version is lower than 11, cannot clear all apps cache");
            return false;
        }
        InterfaceC1016b0 g = getApp().g();
        if (g == null) {
            Utils.l("XOneAndroidFramework", "SystemSettings.clearAllAppsCache(): No edit view found, cannot clear all apps cache");
            return false;
        }
        Intent intent = new Intent("android.os.storage.action.CLEAR_APP_CACHE");
        K9.b bVar = new K9.b();
        g.q(bVar);
        g.startActivityForResult(intent, bVar.getRequestCode());
        return true;
    }

    @ScriptAllowed
    @Keep
    public boolean clearApplicationData() {
        if (getActivityManager().clearApplicationUserData()) {
            return true;
        }
        throw new IllegalStateException("ClearApplicationData(): Cannot delete application data");
    }

    @ScriptAllowed
    @Keep
    public boolean clearBitmapCache() {
        r.a(false);
        return true;
    }

    @ScriptAllowed
    @Keep
    public boolean clearJavascriptCache() {
        XOneJavascript.b(getApp());
        return true;
    }

    @ScriptAllowed
    @Keep
    public boolean disableLiveWidget() {
        return setComponentState(CLASS_LIVE_WIDGET_PROVIDER, false);
    }

    @ScriptAllowed
    @Keep
    public boolean disableReplicatorWidget() {
        return setComponentState(CLASS_REPLICATOR_WIDGET_PROVIDER, false);
    }

    @ScriptAllowed
    @Keep
    public boolean enableLiveWidget() {
        return setComponentState(CLASS_LIVE_WIDGET_PROVIDER, true);
    }

    @ScriptAllowed
    @Keep
    public boolean enableReplicatorWidget() {
        return setComponentState(CLASS_REPLICATOR_WIDGET_PROVIDER, true);
    }

    @ScriptAllowed
    @Keep
    public SystemSettings garbageCollect() {
        Runtime runtime = Runtime.getRuntime();
        runtime.gc();
        runtime.runFinalization();
        return this;
    }

    @Override
    public Object get(String str, Scriptable scriptable) {
        try {
            return GetProperty(str);
        } catch (b unused) {
            return super.get(str, scriptable);
        }
    }

    @ScriptAllowed
    @Keep
    public String getAlarmsPath() {
        File externalStoragePublicDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS);
        return externalStoragePublicDirectory == null ? "" : externalStoragePublicDirectory.getAbsolutePath();
    }

    @ScriptAllowed
    @Keep
    public String getAndroidVersion() {
        return Build.VERSION.RELEASE;
    }

    @ScriptAllowed
    @Keep
    public int getApiLevel() {
        return Build.VERSION.SDK_INT;
    }

    @ScriptAllowed
    @Keep
    @SuppressLint({"SwitchIntDef"})
    public String getAppRestrictionStatus() {
        int appStandbyBucket;
        if (Build.VERSION.SDK_INT < 28) {
            return "active";
        }
        UsageStatsManager usageStatsManager = (UsageStatsManager) this.context.getSystemService("usagestats");
        if (usageStatsManager == null) {
            return "unknown";
        }
        appStandbyBucket = usageStatsManager.getAppStandbyBucket();
        return appStandbyBucket != 5 ? appStandbyBucket != 10 ? appStandbyBucket != 20 ? appStandbyBucket != 30 ? appStandbyBucket != 40 ? appStandbyBucket != 45 ? appStandbyBucket != 50 ? "unknown" : "never_used" : "restricted" : "rare" : "frequent" : "working_set" : "active" : "exempted";
    }

    @ScriptAllowed
    @Keep
    public double getBrightness() {
        try {
            return (Settings.System.getInt(getContentResolver(), "screen_brightness") / 255.0d) * 100.0d;
        } catch (Settings.SettingNotFoundException e) {
            throw AbstractC0751f.e(e);
        }
    }

    @ScriptAllowed
    @Keep
    @SuppressLint({"InlinedApi"})
    public String getBrightnessMode() {
        try {
            int i = Settings.System.getInt(getContentResolver(), "screen_brightness_mode");
            if (i == 0) {
                return "manual";
            }
            if (i == 1) {
                return "automatic";
            }
            throw new IllegalArgumentException("GetBrightnessMode(): Unknown brightness mode " + i);
        } catch (Settings.SettingNotFoundException e) {
            throw AbstractC0751f.e(e);
        }
    }

    @Override
    public String getClassName() {
        return NAME;
    }

    @ScriptAllowed
    @Keep
    public C0893d0 getDeclaredPermissions() {
        return new C0893d0(C9.e.k(this.context).toArray());
    }

    @Override
    public String getDefaultMethod() {
        return null;
    }

    @ScriptAllowed
    @Keep
    public String getDeviceId() {
        return Utils.Y0(this.context);
    }

    @ScriptAllowed
    @Keep
    public C0932x0 getDeviceUptime() {
        long elapsedRealtime = SystemClock.elapsedRealtime();
        long j = elapsedRealtime / 86400000;
        long scale = (elapsedRealtime / 3600000) - scale(j, 24L, 384307168202282325L);
        long scale2 = (elapsedRealtime / 60000) - scale(scale, 60L, 153722867280912930L);
        C0932x0 c0932x0 = new C0932x0();
        k.Q(c0932x0, "ms", elapsedRealtime);
        k.Q(c0932x0, "days", j);
        k.Q(c0932x0, "hours", scale);
        k.Q(c0932x0, "minutes", scale2);
        return c0932x0;
    }

    @ScriptAllowed
    @Keep
    public String getDocumentsPath() {
        File externalStoragePublicDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS);
        return externalStoragePublicDirectory == null ? "" : externalStoragePublicDirectory.getAbsolutePath();
    }

    @ScriptAllowed
    @Keep
    public String getDownloadsPath() {
        File externalStoragePublicDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
        return externalStoragePublicDirectory == null ? "" : externalStoragePublicDirectory.getAbsolutePath();
    }

    @ScriptAllowed
    @Keep
    public String getExternalStoragePath() {
        return Environment.getExternalStorageDirectory().getAbsolutePath();
    }

    @ScriptAllowed
    @Keep
    public C0893d0 getFeatures() {
        FeatureInfo[] systemAvailableFeatures = getPackageManager().getSystemAvailableFeatures();
        ArrayList arrayList = new ArrayList();
        if (systemAvailableFeatures == null || systemAvailableFeatures.length == 0) {
            return m.u(arrayList);
        }
        List i = M.i(PackageManager.class, "FEATURE_", String.class, 25);
        List a2 = M.a(i);
        for (FeatureInfo featureInfo : systemAvailableFeatures) {
            if (featureInfo != null) {
                String str = featureInfo.name;
                if (!TextUtils.isEmpty(str)) {
                    int indexOf = a2.indexOf(str);
                    if (indexOf >= 0) {
                        str = ((Field) i.get(indexOf)).getName();
                    }
                    arrayList.add(str);
                }
            }
        }
        return m.u(arrayList);
    }

    @ScriptAllowed
    @Keep
    public long getFreeMemory() {
        Runtime runtime = Runtime.getRuntime();
        return runtime.maxMemory() - (runtime.totalMemory() - runtime.freeMemory());
    }

    @ScriptAllowed
    @Keep
    public String getGalleryPath() {
        File externalStoragePublicDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
        return externalStoragePublicDirectory == null ? "" : externalStoragePublicDirectory.getAbsolutePath();
    }

    @ScriptAllowed
    @Keep
    public C0893d0 getGrantedPermissions() {
        Set<String> k = C9.e.k(this.context);
        ArrayList arrayList = new ArrayList();
        for (String str : k) {
            if (C9.e.q(this.context, str)) {
                arrayList.add(str);
            }
        }
        return new C0893d0(arrayList.toArray());
    }

    @ScriptAllowed
    @Keep
    @SuppressLint({"HardwareIds", "MissingPermission"})
    public C0932x0 getHardwareIds() {
        ArrayList arrayList = new ArrayList();
        String a1 = Utils.a1(this.context);
        if (!TextUtils.isEmpty(a1)) {
            arrayList.add(a1);
        }
        addImeisWithApi(arrayList);
        if (Build.VERSION.SDK_INT >= 29 && arrayList.isEmpty() && N.e(this.context)) {
            arrayList.addAll(Utils.Z1(this.context));
        }
        C0932x0 c0932x0 = new C0932x0();
        Q0.putProperty(c0932x0, "deviceIdCount", Integer.valueOf(arrayList.size()));
        for (int i = 0; i < arrayList.size(); i++) {
            Q0.putProperty(c0932x0, "deviceId" + i, arrayList.get(i));
        }
        String V2 = Utils.V2(this.context);
        if (TextUtils.isEmpty(V2)) {
            V2 = "";
        }
        Q0.putProperty(c0932x0, "wifiMacAddress", TextUtils.equals(V2, "02:00:00:00:00:00") ? "" : V2);
        Q0.putProperty(c0932x0, "androidId", Utils.G0(this.context));
        return c0932x0;
    }

    @ScriptAllowed
    @Keep
    public String getIntegrityToken(Object... objArr) {
        Utils.g("GetIntegrityToken", objArr, 1);
        String y = t.y(objArr[0]);
        if (!TextUtils.isEmpty(y)) {
            return AbstractC0756k.b(this.context, y);
        }
        throw new IllegalArgumentException("GetIntegrityToken(): Empty nonce argument");
    }

    @ScriptAllowed
    @Keep
    public String getIntuneAgentOutdatedMessage() {
        return Utils.getIntuneAgentOutdatedMessage();
    }

    @ScriptAllowed
    @Keep
    public String getIntuneId() {
        return Utils.getIntuneId();
    }

    @ScriptAllowed
    @Keep
    public C0932x0 getLiveConfig() {
        Class d = M.d("com.xone.live.tools.LiveUtils");
        if (d == null) {
            C0932x0 c0932x0 = new C0932x0();
            Q0.putProperty(c0932x0, "idsUrl", "");
            Q0.putProperty(c0932x0, "idsTokenEndpoint", "");
            Q0.putProperty(c0932x0, "idsClientId", "");
            Q0.putProperty(c0932x0, "idsScope", "");
            Q0.putProperty(c0932x0, "idsGrantType", "");
            Q0.putProperty(c0932x0, "idsClientSc", "");
            Q0.putProperty(c0932x0, "remoteMapped", "");
            Q0.putProperty(c0932x0, "remoteDest", "");
            Boolean bool = Boolean.FALSE;
            Q0.putProperty(c0932x0, "remoteBroker", bool);
            Q0.putProperty(c0932x0, "useRest", bool);
            Q0.putProperty(c0932x0, "tkey", "");
            Q0.putProperty(c0932x0, "remoteEndpoint", "");
            Q0.putProperty(c0932x0, "remoteDatabase", "");
            Q0.putProperty(c0932x0, "remotePackageRep", "");
            Q0.putProperty(c0932x0, "logServer", "");
            Q0.putProperty(c0932x0, "remoteAutoRegisterUrl", "");
            Q0.putProperty(c0932x0, "remoteAutoRegisterModel", "");
            Q0.putProperty((Scriptable) c0932x0, "slot", (Object) 0);
            return c0932x0;
        }
        String str = (String) M.v(M.k(d, "getIdsUrl", Context.class), this.context);
        String str2 = (String) M.v(M.k(d, "getIdsTokenEndpoint", Context.class), this.context);
        String str3 = (String) M.v(M.k(d, "getIdsClientId", Context.class), this.context);
        String str4 = (String) M.v(M.k(d, "getIdsScope", Context.class), this.context);
        String str5 = (String) M.v(M.k(d, "getIdsGrantType", Context.class), this.context);
        String str6 = (String) M.v(M.k(d, "getIdsClientSc", Context.class), this.context);
        String str7 = (String) M.v(M.k(d, "getRemoteMapped", Context.class), this.context);
        String str8 = (String) M.v(M.k(d, "getRemoteDest", Context.class), this.context);
        Boolean bool2 = (Boolean) M.v(M.k(d, "getRemoteBroker", Context.class), this.context);
        Boolean bool3 = (Boolean) M.v(M.k(d, "getUseRest", Context.class), this.context);
        String str9 = (String) M.v(M.k(d, "getTKey", Context.class), this.context);
        String str10 = (String) M.v(M.k(d, "getRemoteEndpoint", Context.class), this.context);
        String str11 = (String) M.v(M.k(d, "getRemoteDatabase", Context.class), this.context);
        String str12 = (String) M.v(M.k(d, "getRemotePackageRep", Context.class), this.context);
        String str13 = (String) M.v(M.k(d, "getLogServer", Context.class), this.context);
        String str14 = (String) M.v(M.k(d, "getRemoteAutoRegisterUrl", Context.class), this.context);
        String str15 = (String) M.v(M.k(d, "getRemoteAutoRegisterModel", Context.class), this.context);
        Integer num = (Integer) M.v(M.k(d, "getSlot", Context.class), this.context);
        C0932x0 c0932x02 = new C0932x0();
        Q0.putProperty(c0932x02, "idsUrl", str == null ? "" : str);
        Q0.putProperty(c0932x02, "idsTokenEndpoint", str2 == null ? "" : str2);
        Q0.putProperty(c0932x02, "idsClientId", str3 == null ? "" : str3);
        Q0.putProperty(c0932x02, "idsScope", str4 == null ? "" : str4);
        Q0.putProperty(c0932x02, "idsGrantType", str5 == null ? "" : str5);
        Q0.putProperty(c0932x02, "idsClientSc", str6 == null ? "" : str6);
        Q0.putProperty(c0932x02, "remoteMapped", str7 == null ? "" : str7);
        Q0.putProperty(c0932x02, "remoteDest", str8 == null ? "" : str8);
        Q0.putProperty(c0932x02, "remoteBroker", Boolean.valueOf(bool2 != null && bool2.booleanValue()));
        Q0.putProperty(c0932x02, "useRest", Boolean.valueOf(bool3 != null && bool3.booleanValue()));
        Q0.putProperty(c0932x02, "tkey", str9 == null ? "" : str9);
        Q0.putProperty(c0932x02, "remoteEndpoint", str10 == null ? "" : str10);
        Q0.putProperty(c0932x02, "remoteDatabase", str11 == null ? "" : str11);
        Q0.putProperty(c0932x02, "remotePackageRep", str12 == null ? "" : str12);
        Q0.putProperty(c0932x02, "logServer", str13 == null ? "" : str13);
        Q0.putProperty(c0932x02, "remoteAutoRegisterUrl", str14 == null ? "" : str14);
        Q0.putProperty(c0932x02, "remoteAutoRegisterModel", str15 == null ? "" : str15);
        Q0.putProperty(c0932x02, "slot", Integer.valueOf(num != null ? num.intValue() : 0));
        return c0932x02;
    }

    @ScriptAllowed
    @Keep
    public long getMaxMemory() {
        return Runtime.getRuntime().maxMemory();
    }

    @ScriptAllowed
    @Keep
    public String getMemoryLevel() {
        return Utils.W1(getApp().q());
    }

    @ScriptAllowed
    @Keep
    public int getMinSdkVersion() {
        if (Build.VERSION.SDK_INT < 24) {
            throw new UnsupportedOperationException("Not available on API levels lower than 24 (Android Nougat)");
        }
        try {
            return f.a(getPackageManager().getApplicationInfo(this.context.getPackageName(), 0));
        } catch (PackageManager.NameNotFoundException e) {
            throw AbstractC0751f.e(e);
        }
    }

    @ScriptAllowed
    @Keep
    public String getMusicPath() {
        File externalStoragePublicDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);
        return externalStoragePublicDirectory == null ? "" : externalStoragePublicDirectory.getAbsolutePath();
    }

    @Override
    public String getName() {
        return NAME;
    }

    @ScriptAllowed
    @Keep
    public C0907k0 getNetworkTime(Object... objArr) {
        Utils.h("GetNetworkTime", objArr, 0, 1);
        String E = k.E((C0932x0) Utils.w(objArr, 0, null), "ntpServer", "time.google.com");
        if (!TextUtils.isEmpty(E)) {
            return (C0907k0) m.C(C0973a.e().m(E).f().h());
        }
        throw new IllegalArgumentException("GetNetworkTime(): Empty NTP server argument");
    }

    @ScriptAllowed
    @Keep
    public C0893d0 getNotGrantedPermissions() {
        Set<String> k = C9.e.k(this.context);
        ArrayList arrayList = new ArrayList();
        for (String str : k) {
            if (!C9.e.q(this.context, str)) {
                arrayList.add(str);
            }
        }
        return new C0893d0(arrayList.toArray());
    }

    @ScriptAllowed
    @Keep
    public String getPackageName() {
        return this.context.getPackageName();
    }

    @ScriptAllowed
    @Keep
    public String getPhoneNumber() {
        String n2 = Utils.n2(this.context);
        return n2 == null ? "" : n2;
    }

    @ScriptAllowed
    @Keep
    public int getPid() {
        return Process.myPid();
    }

    @ScriptAllowed
    @Keep
    public String getRingtonesPath() {
        File externalStoragePublicDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RINGTONES);
        return externalStoragePublicDirectory == null ? "" : externalStoragePublicDirectory.getAbsolutePath();
    }

    @Override
    public V getScope() {
        X x = this.scriptRuntime;
        if (x == null) {
            return null;
        }
        return x.c();
    }

    @ScriptAllowed
    @Keep
    public String getScreenshotsPath() {
        String str;
        if (Build.VERSION.SDK_INT < 29) {
            return "";
        }
        str = Environment.DIRECTORY_SCREENSHOTS;
        File externalStoragePublicDirectory = Environment.getExternalStoragePublicDirectory(str);
        return externalStoragePublicDirectory == null ? "" : externalStoragePublicDirectory.getAbsolutePath();
    }

    @ScriptAllowed
    @Keep
    public String getSharedUserId() {
        try {
            PackageInfo packageInfo = getPackageManager().getPackageInfo(this.context.getPackageName(), 0);
            if (packageInfo == null) {
                return "";
            }
            String str = packageInfo.sharedUserId;
            return str == null ? "" : str;
        } catch (PackageManager.NameNotFoundException e) {
            throw AbstractC0751f.e(e);
        }
    }

    @ScriptAllowed
    @Keep
    public int getTargetSdkVersion() {
        try {
            return getPackageManager().getApplicationInfo(this.context.getPackageName(), 0).targetSdkVersion;
        } catch (PackageManager.NameNotFoundException e) {
            throw AbstractC0751f.e(e);
        }
    }

    @ScriptAllowed
    @Keep
    public int getThreadPriority(Object... objArr) {
        Utils.h("GetThreadPriority", objArr, 0, 1);
        return Process.getThreadPriority(Utils.u(objArr, 1, Process.myTid()));
    }

    @ScriptAllowed
    @Keep
    public int getTid() {
        return Process.myTid();
    }

    @ScriptAllowed
    @Keep
    public int getUid() {
        return Process.myUid();
    }

    @ScriptAllowed
    @Keep
    public Object getWallpaper(Object... objArr) {
        FileOutputStream fileOutputStream;
        Utils.g("GetWallpaper", objArr, 1);
        FileOutputStream fileOutputStream2 = null;
        String z = t.z(objArr[0], null);
        if (TextUtils.isEmpty(z)) {
            throw new IllegalArgumentException("GetWallpaper(): File name cannot be null");
        }
        String h2 = Utils.h2(getApp().Y(), getApp().T(), z);
        if (TextUtils.isEmpty(h2)) {
            throw new IllegalArgumentException("Cannot obtain file path");
        }
        File file = new File(h2);
        File parentFile = file.getParentFile();
        if (parentFile != null && !parentFile.exists() && !parentFile.mkdirs()) {
            throw AbstractC0751f.c("Cannot create parent folder " + parentFile.getAbsolutePath());
        }
        Drawable drawable = getWallpaperManager().getDrawable();
        if (drawable == null) {
            throw new NullPointerException("Cannot obtain wallpaper");
        }
        Bitmap b0 = r.b0(drawable);
        if (b0 == null) {
            throw new NullPointerException("Cannot obtain wallpaper bitmap");
        }
        try {
            try {
                fileOutputStream = new FileOutputStream(file);
            } catch (IOException e) {
                e = e;
            }
        } catch (Throwable th) {
            th = th;
        }
        try {
            b0.compress(r.y(file), 100, fileOutputStream);
            Utils.N(fileOutputStream);
            return null;
        } catch (IOException e2) {
            e = e2;
            fileOutputStream2 = fileOutputStream;
            throw AbstractC0751f.e(e);
        } catch (Throwable th2) {
            th = th2;
            fileOutputStream2 = fileOutputStream;
            Utils.N(fileOutputStream2);
            throw th;
        }
    }

    @ScriptAllowed
    @Keep
    public boolean hasGpsLocationFeature() {
        return getPackageManager().hasSystemFeature("android.hardware.location.gps");
    }

    @ScriptAllowed
    @Keep
    public boolean hasHardwareKeyboard() {
        return getConfiguration().keyboard != 1;
    }

    @ScriptAllowed
    @Keep
    public boolean hasLocationFeature() {
        return getPackageManager().hasSystemFeature("android.hardware.location");
    }

    @ScriptAllowed
    @Keep
    public boolean hasNetworkLocationFeature() {
        return getPackageManager().hasSystemFeature("android.hardware.location.network");
    }

    @ScriptAllowed
    @Keep
    public boolean hasOverlayPermission() {
        boolean canDrawOverlays;
        if (Build.VERSION.SDK_INT < 23) {
            return true;
        }
        canDrawOverlays = Settings.canDrawOverlays(this.context);
        return canDrawOverlays;
    }

    @ScriptAllowed
    @Keep
    public boolean hasQwertyKeyboard() {
        return getConfiguration().keyboard == 2;
    }

    @ScriptAllowed
    @Keep
    public boolean hasTwelveKeysKeyboard() {
        return getConfiguration().keyboard == 3;
    }

    @ScriptAllowed
    @Keep
    public boolean installCertificate(Object... objArr) {
        Utils.j("InstallCertificate", objArr);
        Utils.g("InstallCertificate", objArr, 1);
        C0932x0 c0932x0 = (C0932x0) objArr[0];
        String E = k.E(c0932x0, "file", "");
        String E2 = k.E(c0932x0, "name", "");
        File file = new File(getApp().T(), "files/" + E);
        if (!file.exists()) {
            throw new IllegalArgumentException("InstallCertificate(): File " + file.getAbsolutePath() + " does not exist");
        }
        if (!file.isFile()) {
            throw new IllegalArgumentException("InstallCertificate(): Path " + file.getAbsolutePath() + " is not a file");
        }
        byte[] B3 = Utils.B3(file);
        InterfaceC1016b0 g = getApp().g();
        if (!(g instanceof InterfaceC1016b0)) {
            throw new UnsupportedOperationException("InstallCertificate(): Edit view is not an instance of IStartActivityForResult");
        }
        Intent createInstallIntent = KeyChain.createInstallIntent();
        createInstallIntent.putExtra("CERT", B3);
        createInstallIntent.putExtra("name", E2);
        C0356x0 c0356x0 = new C0356x0();
        g.q(c0356x0);
        g.startActivityForResult(createInstallIntent, c0356x0.getRequestCode());
        return true;
    }

    @ScriptAllowed
    @Keep
    public boolean is64Bit() {
        boolean is64Bit;
        if (Build.VERSION.SDK_INT < 23) {
            return false;
        }
        is64Bit = Process.is64Bit();
        return is64Bit;
    }

    @ScriptAllowed
    @Keep
    public boolean isAccessibilityEnabled() {
        return getAccessibilityManager().isEnabled();
    }

    @ScriptAllowed
    @Keep
    public boolean isAirplaneMode() {
        return Settings.Global.getInt(getContentResolver(), "airplane_mode_on", 0) != 0;
    }

    @ScriptAllowed
    @Keep
    public boolean isAppInactive(Object... objArr) {
        UsageStatsManager usageStatsManager;
        boolean isAppInactive;
        Utils.h("IsAppInactive", objArr, 0, 1);
        String x = Utils.x(objArr, 0, "");
        if (TextUtils.isEmpty(x)) {
            x = this.context.getPackageName();
        }
        if (Build.VERSION.SDK_INT < 23 || (usageStatsManager = (UsageStatsManager) this.context.getSystemService("usagestats")) == null) {
            return false;
        }
        isAppInactive = usageStatsManager.isAppInactive(x);
        return isAppInactive;
    }

    @ScriptAllowed
    @Keep
    public boolean isAutoStartEnabled() {
        if (Q9.e.c()) {
            return Q9.e.b(this.context, false);
        }
        return true;
    }

    @ScriptAllowed
    @Keep
    public boolean isBackgroundDataDisabled() {
        int restrictBackgroundStatus;
        ConnectivityManager connectivityManager = getConnectivityManager();
        if (Build.VERSION.SDK_INT < 24) {
            return false;
        }
        restrictBackgroundStatus = connectivityManager.getRestrictBackgroundStatus();
        return restrictBackgroundStatus == 3;
    }

    @ScriptAllowed
    @Keep
    public boolean isBackgroundRestricted() {
        boolean isBackgroundRestricted;
        ActivityManager activityManager = getActivityManager();
        if (Build.VERSION.SDK_INT < 28) {
            return false;
        }
        isBackgroundRestricted = activityManager.isBackgroundRestricted();
        return isBackgroundRestricted;
    }

    @ScriptAllowed
    @Keep
    public boolean isClearTextTrafficAllowed(Object... objArr) {
        NetworkSecurityPolicy a2;
        Utils.h("IsClearTextTrafficAllowed", objArr, 0, 1);
        String x = Utils.x(objArr, 0, "");
        int i = Build.VERSION.SDK_INT;
        if (i >= 23 && (a2 = n.a()) != null) {
            return (i < 24 || TextUtils.isEmpty(x)) ? p.a(a2) : w7.o.a(a2, x);
        }
        return true;
    }

    @ScriptAllowed
    @Keep
    public boolean isDebuggerConnected() {
        return Debug.isDebuggerConnected() || Debug.waitingForDebugger();
    }

    @ScriptAllowed
    @Keep
    public boolean isDeviceIntegrityOk() {
        return !Q9.d.k(this.context);
    }

    @ScriptAllowed
    @Keep
    public boolean isExternalStorageManager(Object... objArr) {
        boolean isExternalStorageManager;
        Utils.h("IsExternalStorageManager", objArr, 0, 1);
        String x = Utils.x(objArr, 0, "");
        if (Build.VERSION.SDK_INT < 30) {
            return true;
        }
        if (TextUtils.isEmpty(x)) {
            return p7.r.a();
        }
        isExternalStorageManager = Environment.isExternalStorageManager(new File(x));
        return isExternalStorageManager;
    }

    @ScriptAllowed
    @Keep
    public boolean isIgnoringBatteryOptimizations(Object... objArr) {
        boolean isIgnoringBatteryOptimizations;
        Utils.h("IsIgnoringBatteryOptimizations", objArr, 0, 1);
        String x = Utils.x(objArr, 0, this.context.getPackageName());
        if (Build.VERSION.SDK_INT < 23) {
            return true;
        }
        isIgnoringBatteryOptimizations = getPowerManager().isIgnoringBatteryOptimizations(x);
        return isIgnoringBatteryOptimizations;
    }

    @ScriptAllowed
    @Keep
    public boolean isIntuneAgentOutdated() {
        return Utils.isIntuneAgentOutdated();
    }

    @ScriptAllowed
    @Keep
    public boolean isIntuneCompilation() {
        return Utils.isIntuneCompilation();
    }

    @ScriptAllowed
    @Keep
    public boolean isIntunePinRequired() {
        return Utils.isIntunePinRequired(this.context);
    }

    @ScriptAllowed
    @Keep
    public boolean isNetworkAutoTimeEnabled() {
        return t.l(Settings.System.getString(getContentResolver(), "auto_time"), false);
    }

    @ScriptAllowed
    @Keep
    @SuppressLint({"InlinedApi"})
    public boolean isPasswordSecured() {
        if (N.f(this.context)) {
            DevicePolicyManager dpm = getDpm();
            return dpm != null && dpm.isActivePasswordSufficient();
        }
        setFinished(false);
        setResult(false);
        if (N.e(this.context)) {
            registerReceiverCompat(this.context, this.receiver, this.intentFilter, true);
            Intent intent = new Intent();
            intent.setClassName("com.xone.live.services", "com.xone.mdm.receivers.MessagesReceiver");
            intent.putExtra("message", "isPasswordSecured");
            intent.putExtra("target", "target_message_result_action");
            intent.addFlags(268435456);
            List<ResolveInfo> queryBroadcastReceivers = getPackageManager().queryBroadcastReceivers(intent, 0);
            if (queryBroadcastReceivers == null || queryBroadcastReceivers.isEmpty()) {
                return getResult();
            }
            this.context.sendBroadcast(intent);
            while (!getFinished()) {
                try {
                    Thread.sleep(100L);
                } catch (InterruptedException e) {
                    throw AbstractC0751f.e(e);
                }
            }
        }
        return getResult();
    }

    @ScriptAllowed
    @Keep
    public boolean isPermissionAutoRevokeEnabled(Object... objArr) {
        Utils.h("IsPermissionAutoRevokeEnabled", objArr, 0, 1);
        if (Build.VERSION.SDK_INT < 30) {
            return false;
        }
        String x = Utils.x(objArr, 0, null);
        PackageManager packageManager = getPackageManager();
        return !(TextUtils.isEmpty(x) ? packageManager.isAutoRevokeWhitelisted() : packageManager.isAutoRevokeWhitelisted(x));
    }

    @ScriptAllowed
    @Keep
    public boolean isPermissionGranted(Object... objArr) {
        Utils.g("IsPermissionGranted", objArr, 1);
        HashSet hashSet = new HashSet();
        Object obj = objArr[0];
        PackageManager packageManager = getPackageManager();
        if (obj instanceof CharSequence) {
            String obj2 = obj.toString();
            if (TextUtils.isEmpty(obj2)) {
                throw new IllegalArgumentException("IsPermissionGranted(): Empty permission argument");
            }
            try {
                if (packageManager.getPermissionInfo(obj2, 0) != null) {
                    hashSet.add(obj2);
                }
            } catch (PackageManager.NameNotFoundException unused) {
                hashSet.addAll(C9.e.u(this.context, obj2));
            }
            return C9.e.d(this.context, hashSet);
        }
        if (!(obj instanceof C0893d0)) {
            throw new IllegalArgumentException("IsPermissionGranted(): Invalid argument of type " + obj.getClass().getSimpleName());
        }
        C0893d0 c0893d0 = (C0893d0) obj;
        for (int i = 0; i < c0893d0.size(); i++) {
            Object obj3 = c0893d0.get(i);
            if (obj3 == null) {
                throw new IllegalArgumentException("IsPermissionGranted(): Empty permission group value found in array position: " + i);
            }
            if (!(obj3 instanceof CharSequence)) {
                throw new IllegalArgumentException("IsPermissionGranted(): Invalid argument of type " + obj3.getClass().getSimpleName() + " found in array position: " + i);
            }
            String obj4 = obj3.toString();
            try {
                if (packageManager.getPermissionInfo(obj4, 0) != null) {
                    hashSet.add(obj4);
                }
            } catch (PackageManager.NameNotFoundException unused2) {
                hashSet.addAll(C9.e.u(this.context, obj4));
            }
        }
        return C9.e.d(this.context, hashSet);
    }

    @ScriptAllowed
    @Keep
    public boolean isRunningInMdm(Object... objArr) {
        Utils.h("IsRunningInMdm", objArr, 0, 1);
        String str = (String) Utils.w(objArr, 0, null);
        return !TextUtils.isEmpty(str) ? N.g(this.context, str) : N.h(this.context);
    }

    @ScriptAllowed
    @Keep
    public boolean isRunningInWorkProfile(Object... objArr) {
        return N.d(this.context);
    }

    @ScriptAllowed
    @Keep
    public boolean isRunningWithDeviceOwner(Object... objArr) {
        return N.b(this.context);
    }

    @ScriptAllowed
    @Keep
    public boolean isTouchExplorationEnabled() {
        return getAccessibilityManager().isTouchExplorationEnabled();
    }

    @ScriptAllowed
    @Keep
    public void killProcess(Object... objArr) {
        Utils.j("KillProcess", objArr);
        Utils.g("KillProcess", objArr, 1);
        int p = q.p(objArr[0], -1);
        if (p != -1) {
            Process.killProcess(p);
            return;
        }
        throw new IllegalArgumentException("KillProcess(): Process ID argument cannot be empty");
    }

    @ScriptAllowed
    @Keep
    public boolean logAnalyticsEvent(Object... objArr) {
        Utils.g("LogAnalyticsEvent", objArr, 1);
        C0932x0 c0932x0 = (C0932x0) objArr[0];
        if (c0932x0 == null) {
            throw new IllegalArgumentException("LogAnalyticsEvent(): Empty event argument");
        }
        try {
            Bundle d0 = k.d0(c0932x0);
            String string = d0.getString("eventTag");
            d0.remove("eventTag");
            if (TextUtils.isEmpty(string)) {
                throw new IllegalArgumentException("LogAnalyticsEvent(): Empty eventTag argument");
            }
            InterfaceC1013a analytics = getAnalytics();
            if (analytics == null) {
                Utils.l("XOneAndroidFramework", "Google Analytics is not present on this build");
                return false;
            }
            analytics.logEvent(string, d0);
            return true;
        } catch (JSONException e) {
            throw AbstractC0751f.e(e);
        }
    }

    @ScriptAllowed
    @Keep
    public boolean mergeJavascriptCache() {
        XOneJavascript.t(getApp());
        return true;
    }

    @Override
    public void put(String str, Scriptable scriptable, Object obj) {
        try {
            if (obj instanceof BaseFunctionJavaMethodWrapper) {
                super.put(str, scriptable, obj);
            } else {
                SetProperty(str, new Object[]{obj});
            }
        } catch (b unused) {
            super.put(str, scriptable, obj);
        }
    }

    @ScriptAllowed
    @Keep
    public void requestDisablePermissionAutoRevoke() {
        if (Build.VERSION.SDK_INT < 30) {
            return;
        }
        Uri fromParts = Uri.fromParts("package", this.context.getPackageName(), null);
        Intent intent = new Intent("android.intent.action.AUTO_REVOKE_PERMISSIONS");
        intent.setData(fromParts);
        Activity activity = (Activity) getLastEditView();
        if (activity == null) {
            return;
        }
        activity.startActivity(intent);
    }

    @ScriptAllowed
    @Keep
    public FutureScriptWrapper<Boolean> requestExternalStoragePermission(Object... objArr) {
        Utils.h("RequestExternalStoragePermission", objArr, 0, 1);
        String x = Utils.x(objArr, 0, "");
        InterfaceC1036l0 lastEditView = getLastEditView();
        if (!(lastEditView instanceof InterfaceC1016b0)) {
            throw new IllegalStateException("RequestExternalStoragePermission(): No edit view is visible");
        }
        InterfaceC1016b0 interfaceC1016b0 = (InterfaceC1016b0) lastEditView;
        Q9.g gVar = new Q9.g(this.context, x);
        interfaceC1016b0.q(gVar);
        gVar.a((Activity) interfaceC1016b0);
        return new FutureScriptWrapper<>(gVar);
    }

    @ScriptAllowed
    @Keep
    public boolean requestIgnoreBatteryOptimizations(Object... objArr) {
        Intent intent;
        Utils.h("RequestIgnoreBatteryOptimizations", objArr, 0, 1);
        boolean f = (objArr == null || objArr.length <= 0) ? true : q.f(objArr[0], true);
        if (Build.VERSION.SDK_INT < 23) {
            return true;
        }
        Utils.l("XOneAndroidFramework", "SystemSettings.requestIgnoreBatteryOptimizations() has been invoked");
        j g = getApp().g();
        if (g == null) {
            Utils.l("XOneAndroidFramework", "No edit view is visible, cannot request battery optimization whitelist");
            return false;
        }
        if (f && C9.e.p((Context) getApp(), "android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS")) {
            intent = new Intent("android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS", Uri.parse("package:" + getPackageName()));
        } else {
            intent = new Intent("android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS");
        }
        g.startActivity(intent);
        return true;
    }

    @ScriptAllowed
    @Keep
    public boolean requestIgnoreSpecialBatteryOptimizations(Object... objArr) {
        Utils.l("XOneAndroidFramework", "SystemSettings.requestIgnoreSpecialBatteryOptimizations() has been invoked");
        j g = getApp().g();
        if (g == null) {
            Utils.l("XOneAndroidFramework", "No edit view is visible, cannot request battery optimization whitelist");
            return false;
        }
        List<Intent> powerManagerIntentList = getPowerManagerIntentList(this.context);
        if (powerManagerIntentList.isEmpty()) {
            return true;
        }
        Iterator<Intent> it = powerManagerIntentList.iterator();
        while (it.hasNext()) {
            startActivitySafe(g, it.next());
        }
        return true;
    }

    @ScriptAllowed
    @Keep
    public FutureScriptWrapper<Boolean> requestOverlayPermission() {
        InterfaceC1036l0 lastEditView = getLastEditView();
        if (!(lastEditView instanceof InterfaceC1016b0)) {
            throw new IllegalStateException("RequestOverlayPermission(): No edit view is visible");
        }
        InterfaceC1016b0 interfaceC1016b0 = (InterfaceC1016b0) lastEditView;
        h hVar = new h(this.context);
        interfaceC1016b0.q(hVar);
        hVar.a((Activity) interfaceC1016b0);
        return new FutureScriptWrapper<>(hVar);
    }

    @ScriptAllowed
    @Keep
    public synchronized FutureScriptWrapper<Boolean> requestPermissions(Object... objArr) {
        final i iVar;
        try {
            Utils.h("RequestPermissions", objArr, 1, -1);
            PackageManager packageManager = getPackageManager();
            C0932x0 c0932x0 = (C0932x0) objArr[0];
            String E = k.E(c0932x0, "requestMessage", null);
            if (TextUtils.isEmpty(E)) {
                E = this.context.getString(v.b);
            }
            boolean a2 = k.a(c0932x0, "mandatory", false);
            Set<String> K = k.K(c0932x0, "permissions", null);
            if (K == null || K.isEmpty()) {
                throw new IllegalArgumentException("RequestPermissions(): Empty permissions array");
            }
            Collection<String> k = C9.e.k(this.context);
            HashSet hashSet = new HashSet();
            for (String str : K) {
                if (TextUtils.isEmpty(str)) {
                    throw new IllegalArgumentException("RequestPermissions(): Empty permission argument");
                }
                Set u = C9.e.u(this.context, str);
                Iterator it = u.iterator();
                while (it.hasNext()) {
                    addPermissionIfDeclared(k, hashSet, (String) it.next());
                }
                if (u.isEmpty()) {
                    try {
                        if (packageManager.getPermissionInfo(str, 0) != null) {
                            addPermissionIfDeclared(k, hashSet, str);
                        }
                    } catch (PackageManager.NameNotFoundException unused) {
                        Utils.l("XOneAndroidFramework", "SystemSettings.requestPermissions(): Unknown permission value " + str + ". Skipping");
                    }
                }
            }
            InterfaceC1036l0 interfaceC1036l0 = (InterfaceC1036l0) getApp().g();
            if (interfaceC1036l0 == null) {
                throw new NullPointerException("RequestPermissions(): No activity is visible, cannot request permissions");
            }
            iVar = new i();
            try {
                new h.a().d(a2).e(REQUEST_CODE_PERMISSIONS_SCRIPT_SYSTEMSETTINGS).f(E).c(new C9.c() {
                    @Override
                    public final void a(Set set) {
                        Q9.i.this.c(true);
                    }
                }).b(new C9.b() {
                    @Override
                    public final void a(Set set) {
                        Q9.i.this.c(false);
                    }
                }).g(hashSet).a().i(interfaceC1036l0);
            } catch (Exception e) {
                throw AbstractC0751f.e(e);
            }
        } catch (Throwable th) {
            throw th;
        }
        return new FutureScriptWrapper<>(iVar);
    }

    @ScriptAllowed
    @Keep
    public FutureScriptWrapper<Boolean> requestScheduleExactAlarmPermission() {
        InterfaceC1036l0 lastEditView = getLastEditView();
        if (!(lastEditView instanceof InterfaceC1016b0)) {
            throw new IllegalStateException("RequestScheduleExactAlarmPermission(): No edit view is visible");
        }
        InterfaceC1016b0 interfaceC1016b0 = (InterfaceC1016b0) lastEditView;
        Q9.k kVar = new Q9.k(this.context);
        interfaceC1016b0.q(kVar);
        kVar.b((Activity) interfaceC1016b0);
        return new FutureScriptWrapper<>(kVar);
    }

    @ScriptAllowed
    @Keep
    public SystemSettings revokePermissions(Object... objArr) {
        Utils.j("RevokePermissions", objArr);
        Utils.h("RevokePermissions", objArr, 1, -1);
        if (Build.VERSION.SDK_INT < 33) {
            return this;
        }
        HashSet hashSet = new HashSet();
        for (Object obj : objArr) {
            if (obj != null) {
                if (obj instanceof CharSequence) {
                    hashSet.addAll(C9.e.u(this.context, obj.toString()));
                } else if (obj instanceof C0893d0) {
                    C0897f0 it = ((C0893d0) obj).iterator();
                    while (it.hasNext()) {
                        E next = it.next();
                        if (next instanceof CharSequence) {
                            hashSet.addAll(C9.e.u(this.context, next.toString()));
                        }
                    }
                }
            }
        }
        this.context.revokeSelfPermissionsOnKill(hashSet);
        return this;
    }

    @ScriptAllowed
    @Keep
    public boolean setAnalyticsEnabled(Object... objArr) {
        Utils.g("SetAnalyticsEnabled", objArr, 1);
        boolean H = t.H(objArr[0]);
        InterfaceC1013a analytics = getAnalytics();
        if (analytics == null) {
            Utils.l("XOneAndroidFramework", "Google Analytics is not present on this build");
            return false;
        }
        analytics.setEnabled(H);
        return true;
    }

    @ScriptAllowed
    @Keep
    public boolean setBrightness(Object... objArr) {
        Utils.j("SetBrightness", objArr);
        Utils.g("SetBrightness", objArr, 1);
        double h = q.h(objArr[0]);
        if (h < 0.0d) {
            h = 0.0d;
        } else if (h > 100.0d) {
            h = 100.0d;
        }
        double d = (h / 100.0d) * 255.0d;
        ContentResolver contentResolver = getContentResolver();
        if (doWriteSettingsPermissionCheck()) {
            return false;
        }
        return Settings.System.putInt(contentResolver, "screen_brightness", (int) d);
    }

    @ScriptAllowed
    @Keep
    @SuppressLint({"InlinedApi"})
    public boolean setBrightnessMode(Object... objArr) {
        Utils.j("SetBrightnessMode", objArr);
        int i = 1;
        Utils.g("SetBrightnessMode", objArr, 1);
        String y = t.y(objArr[0]);
        if (TextUtils.isEmpty(y)) {
            throw new IllegalArgumentException("SetBrightnessMode(): Empty brightness mode");
        }
        y.getClass();
        if (y.equals("manual")) {
            i = 0;
        } else if (!y.equals("automatic")) {
            throw new IllegalArgumentException("SetBrightnessMode(): Unknown brightness mode " + y);
        }
        if (doWriteSettingsPermissionCheck()) {
            return false;
        }
        return Settings.System.putInt(getContentResolver(), "screen_brightness_mode", i);
    }

    @ScriptAllowed
    @Keep
    public Object setDeviceId(Object... objArr) {
        Utils.g("SetDeviceId", objArr, 1);
        String z = t.z(objArr[0], "");
        if (!TextUtils.isEmpty(z)) {
            Utils.Z3(this.context, z);
            return null;
        }
        throw new IllegalArgumentException("SetDeviceId(): Device ID argument must not be empty");
    }

    public void setFinished(boolean z) {
        this.bFinished = z;
    }

    public void setResult(boolean z) {
        this.bResult = z;
    }

    @ScriptAllowed
    @Keep
    @SuppressLint({"MissingPermission"})
    public Object setWallpaper(Object... objArr) {
        Utils.g("SetWallpaper", objArr, 1);
        String z = t.z(objArr[0], null);
        if (TextUtils.isEmpty(z)) {
            throw new IllegalArgumentException("SetWallpaper(): File name cannot be null");
        }
        String h2 = Utils.h2(getApp().Y(), getApp().T(), z);
        if (TextUtils.isEmpty(h2)) {
            throw new IllegalArgumentException("SetWallpaper(): Cannot obtain file path");
        }
        Bitmap decodeFile = BitmapFactory.decodeFile(h2);
        if (decodeFile == null) {
            throw new IllegalArgumentException("SetWallpaper(): Cannot decode wallpaper bitmap");
        }
        if (C9.e.p(this.context, "android.permission.SET_WALLPAPER")) {
            try {
                getWallpaperManager().setBitmap(decodeFile);
                return null;
            } catch (IOException e) {
                throw AbstractC0751f.e(e);
            }
        }
        throw new SecurityException("SetWallpaper(): Permission android.permission.SET_WALLPAPER not granted, cannot set wallpaper");
    }

    @ScriptAllowed
    @Keep
    public SystemSettings showAppSettingsWindow() {
        if (Build.VERSION.SDK_INT < 23) {
            return this;
        }
        Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
        intent.addFlags(268435456);
        intent.setData(Uri.fromParts("package", this.context.getPackageName(), null));
        this.context.startActivity(intent);
        return this;
    }

    @ScriptAllowed
    @Keep
    public String toString() {
        return "SystemSettings object with access to several device properties";
    }

    @Override
    public U GetPropertyManager(String str, Object[] objArr) {
        Xa.U u = new Xa.U(str, this, this.scriptRuntime);
        u.e(objArr);
        return u;
    }
}