导航菜单

页面标题

页面副标题

Namma Yatri v3.3.7 - DynamicConfig.java 源代码

正在查看: Namma Yatri v3.3.7 应用的 DynamicConfig.java JAVA 源代码文件

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


package com.microsoft.clarity.models;

import Wc.AbstractC0229p;
import Wc.S;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.os.Build;
import com.microsoft.clarity.models.ingest.IngestConfigs;
import com.microsoft.clarity.models.project.ImageCompressionFormat;
import com.microsoft.clarity.models.project.ScreenNameFilter;
import com.microsoft.clarity.models.project.UrlFilter;
import com.microsoft.clarity.q.l;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.m;
import org.json.JSONArray;
import sd.AbstractC1172m;

public final class DynamicConfig {
    public static final Companion Companion = new Companion(null);
    private final boolean allowMeteredNetwork;
    private final boolean disableForLowEndDevices;
    private final boolean disableWebViewCapture;
    private final Bitmap.CompressFormat imageCompressionFormat;
    private final int imageCompressionQuality;
    private final String ingestUrl;
    private final boolean isClarityActivated;
    private final boolean leanMode;
    private final Set<String> maskedClasses;
    private final Set<String> maskedFragments;
    private final Set<String> maskedIds;
    private final Set<String> maskedScreens;
    private final List<Integer> maskedViewIds;
    private final MaskingMode maskingMode;
    private final Set<String> nativeMaskSelectors;
    private final Set<String> nativeUnmaskSelectors;
    private final Long networkMaxDailyDataInMB;
    private final SharedPreferences preferences;
    private final int rawImageCompressionFormat;
    private final int rawImageCompressionQuality;
    private final String reportUrl;
    private final List<ScreenNameFilter> screenCaptureAllowedScreens;
    private final List<ScreenNameFilter> screenCaptureDisallowedScreens;
    private final Set<String> unmaskedClasses;
    private final Set<String> unmaskedFragments;
    private final Set<String> unmaskedIds;
    private final Set<String> unmaskedScreens;
    private final List<Integer> unmaskedViewIds;
    private final Set<String> webMaskSelectors;
    private final Set<String> webUnmaskSelectors;
    private final List<UrlFilter> webViewCaptureAllowedUrls;
    private final List<UrlFilter> webViewCaptureDisallowedUrls;

    public static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        public final SharedPreferences getPreferences(Context context) {
            m.i(context, "context");
            SharedPreferences sharedPreferences = context.getSharedPreferences("CLARITY_SHARED_PREFERENCES", 0);
            m.h(sharedPreferences, "context.getSharedPrefere…le, Context.MODE_PRIVATE)");
            return sharedPreferences;
        }

        public final boolean isFetched(Context context) {
            m.i(context, "context");
            return getPreferences(context).contains("CLARITY_CONFIG_FETCHED");
        }

        public final void updateSharedPreferences(Context context, IngestConfigs ingestConfigs) {
            m.i(context, "context");
            m.i(ingestConfigs, "ingestConfigs");
            SharedPreferences.Editor edit = getPreferences(context).edit();
            edit.putBoolean("CLARITY_CONFIG_FETCHED", true);
            edit.putBoolean("CLARITY_ACTIVATED", ingestConfigs.getActivate());
            edit.putBoolean("LEAN_MODE_ACTIVATED", ingestConfigs.getLean());
            edit.putString("REPORT_URL", ingestConfigs.getReportUrl());
            edit.putString("INGEST_URL", ingestConfigs.getIngestUrl());
            edit.putString("MASKING_MODE", ingestConfigs.getMaskingMode().toString());
            edit.putStringSet("MASKED_WEB_ELEMENTS_LIST", ingestConfigs.getWebMaskSelectors());
            edit.putStringSet("UNMASKED_WEB_ELEMENTS_LIST", ingestConfigs.getWebUnmaskSelectors());
            edit.putStringSet("MASKED_NATIVE_LIST", ingestConfigs.getNativeMaskSelectors());
            edit.putStringSet("UNMASKED_NATIVE_LIST", ingestConfigs.getNativeUnmaskSelectors());
            edit.putBoolean("NETWORK_ALLOW_METERED", ingestConfigs.getNetwork().getAllowMeteredNetwork());
            if (ingestConfigs.getNetwork().getMaxDataVolume() != null) {
                edit.putLong("NETWORK_MAX_DAILY_DATA_VOLUME_MB", ingestConfigs.getNetwork().getMaxDataVolume().longValue());
            } else {
                edit.remove("NETWORK_MAX_DAILY_DATA_VOLUME_MB");
            }
            edit.putBoolean("LOW_END_DEVICES_DISABLE_RECORDINGS", ingestConfigs.getLowEndDevices().getDisableRecordings());
            edit.putBoolean("WEBVIEW_CAPTURE_DISABLED", ingestConfigs.getWebViewCapture().getDisableCapture());
            edit.putString("WEBVIEW_CAPTURE_ALLOWED_URLS", "[" + AbstractC0229p.o0(ingestConfigs.getWebViewCapture().getAllowedUrls(), ",", null, null, 0, null, DynamicConfig$Companion$updateSharedPreferences$lambda$0$$inlined$listToString$1.INSTANCE, 30, null) + ']');
            edit.putString("WEBVIEW_CAPTURE_DISALLOWED_URLS", "[" + AbstractC0229p.o0(ingestConfigs.getWebViewCapture().getDisallowedUrls(), ",", null, null, 0, null, DynamicConfig$Companion$updateSharedPreferences$lambda$0$$inlined$listToString$2.INSTANCE, 30, null) + ']');
            edit.putString("SCREEN_CAPTURE_ALLOWED_SCREENS", "[" + AbstractC0229p.o0(ingestConfigs.getScreenCapture().getAllowedScreens(), ",", null, null, 0, null, DynamicConfig$Companion$updateSharedPreferences$lambda$0$$inlined$listToString$3.INSTANCE, 30, null) + ']');
            edit.putString("SCREEN_CAPTURE_DISALLOWED_SCREENS", "[" + AbstractC0229p.o0(ingestConfigs.getScreenCapture().getDisallowedScreens(), ",", null, null, 0, null, DynamicConfig$Companion$updateSharedPreferences$lambda$0$$inlined$listToString$4.INSTANCE, 30, null) + ']');
            edit.putInt("IMAGE_COMPRESSION_FORMAT", ingestConfigs.getImageCompressionConfigs().getFormat().getValue());
            edit.putInt("IMAGE_COMPRESSION_QUALITY", ingestConfigs.getImageCompressionConfigs().getQuality());
            edit.apply();
            l.b("Clarity shared preferences updated.");
        }

        private Companion() {
        }
    }

    public DynamicConfig(Context context) {
        List<UrlFilter> l;
        List<UrlFilter> l2;
        List<ScreenNameFilter> l3;
        List<ScreenNameFilter> l4;
        Bitmap.CompressFormat compressFormat;
        m.i(context, "context");
        Companion companion = Companion;
        SharedPreferences preferences = companion.getPreferences(context);
        this.preferences = preferences;
        if (!companion.isFetched(context)) {
            throw new IllegalStateException("Dynamic config has not been fetched yet!");
        }
        String string = preferences.getString("MASKING_MODE", "Strict");
        this.maskingMode = MaskingMode.valueOf(string != null ? string : "Strict");
        Set<String> stringSet = preferences.getStringSet("MASKED_WEB_ELEMENTS_LIST", S.e());
        this.webMaskSelectors = stringSet == null ? S.e() : stringSet;
        Set<String> stringSet2 = preferences.getStringSet("UNMASKED_WEB_ELEMENTS_LIST", S.e());
        this.webUnmaskSelectors = stringSet2 == null ? S.e() : stringSet2;
        Set<String> stringSet3 = preferences.getStringSet("MASKED_NATIVE_LIST", S.e());
        stringSet3 = stringSet3 == null ? S.e() : stringSet3;
        this.nativeMaskSelectors = stringSet3;
        Set<String> stringSet4 = preferences.getStringSet("UNMASKED_NATIVE_LIST", S.e());
        this.nativeUnmaskSelectors = stringSet4 == null ? S.e() : stringSet4;
        this.rawImageCompressionFormat = preferences.getInt("IMAGE_COMPRESSION_FORMAT", ImageCompressionFormat.Unknown.getValue());
        this.rawImageCompressionQuality = preferences.getInt("IMAGE_COMPRESSION_QUALITY", 0);
        this.leanMode = preferences.getBoolean("LEAN_MODE_ACTIVATED", false);
        this.isClarityActivated = preferences.getBoolean("CLARITY_ACTIVATED", false);
        String string2 = preferences.getString("INGEST_URL", "https://www.clarity.ms/eus2/");
        this.ingestUrl = string2 != null ? string2 : "https://www.clarity.ms/eus2/";
        this.reportUrl = preferences.getString("REPORT_URL", null);
        ArrayList<String> arrayList = new ArrayList();
        for (Object obj : stringSet3) {
            String it = (String) obj;
            m.h(it, "it");
            if (AbstractC1172m.E(it, ".", false, 2, null)) {
                arrayList.add(obj);
            }
        }
        ArrayList arrayList2 = new ArrayList(AbstractC0229p.v(arrayList, 10));
        for (String it2 : arrayList) {
            m.h(it2, "it");
            arrayList2.add(AbstractC1172m.X0(it2, 1));
        }
        this.maskedClasses = AbstractC0229p.R0(arrayList2);
        Set<String> set = this.nativeUnmaskSelectors;
        ArrayList<String> arrayList3 = new ArrayList();
        for (Object obj2 : set) {
            String it3 = (String) obj2;
            m.h(it3, "it");
            if (AbstractC1172m.E(it3, ".", false, 2, null)) {
                arrayList3.add(obj2);
            }
        }
        ArrayList arrayList4 = new ArrayList(AbstractC0229p.v(arrayList3, 10));
        for (String it4 : arrayList3) {
            m.h(it4, "it");
            arrayList4.add(AbstractC1172m.X0(it4, 1));
        }
        this.unmaskedClasses = AbstractC0229p.R0(arrayList4);
        Set<String> set2 = this.nativeMaskSelectors;
        ArrayList<String> arrayList5 = new ArrayList();
        for (Object obj3 : set2) {
            String it5 = (String) obj3;
            m.h(it5, "it");
            if (AbstractC1172m.E(it5, "&", false, 2, null)) {
                arrayList5.add(obj3);
            }
        }
        ArrayList arrayList6 = new ArrayList(AbstractC0229p.v(arrayList5, 10));
        for (String it6 : arrayList5) {
            m.h(it6, "it");
            arrayList6.add(AbstractC1172m.X0(it6, 1));
        }
        this.maskedScreens = AbstractC0229p.R0(arrayList6);
        Set<String> set3 = this.nativeUnmaskSelectors;
        ArrayList<String> arrayList7 = new ArrayList();
        for (Object obj4 : set3) {
            String it7 = (String) obj4;
            m.h(it7, "it");
            if (AbstractC1172m.E(it7, "&", false, 2, null)) {
                arrayList7.add(obj4);
            }
        }
        ArrayList arrayList8 = new ArrayList(AbstractC0229p.v(arrayList7, 10));
        for (String it8 : arrayList7) {
            m.h(it8, "it");
            arrayList8.add(AbstractC1172m.X0(it8, 1));
        }
        this.unmaskedScreens = AbstractC0229p.R0(arrayList8);
        Set<String> set4 = this.nativeMaskSelectors;
        ArrayList<String> arrayList9 = new ArrayList();
        for (Object obj5 : set4) {
            String it9 = (String) obj5;
            m.h(it9, "it");
            if (AbstractC1172m.E(it9, "*", false, 2, null)) {
                arrayList9.add(obj5);
            }
        }
        ArrayList arrayList10 = new ArrayList(AbstractC0229p.v(arrayList9, 10));
        for (String it10 : arrayList9) {
            m.h(it10, "it");
            arrayList10.add(AbstractC1172m.X0(it10, 1));
        }
        this.maskedFragments = AbstractC0229p.R0(arrayList10);
        Set<String> set5 = this.nativeUnmaskSelectors;
        ArrayList<String> arrayList11 = new ArrayList();
        for (Object obj6 : set5) {
            String it11 = (String) obj6;
            m.h(it11, "it");
            if (AbstractC1172m.E(it11, "*", false, 2, null)) {
                arrayList11.add(obj6);
            }
        }
        ArrayList arrayList12 = new ArrayList(AbstractC0229p.v(arrayList11, 10));
        for (String it12 : arrayList11) {
            m.h(it12, "it");
            arrayList12.add(AbstractC1172m.X0(it12, 1));
        }
        this.unmaskedFragments = AbstractC0229p.R0(arrayList12);
        Set<String> set6 = this.nativeMaskSelectors;
        ArrayList<String> arrayList13 = new ArrayList();
        for (Object obj7 : set6) {
            String it13 = (String) obj7;
            m.h(it13, "it");
            if (AbstractC1172m.E(it13, "#", false, 2, null)) {
                arrayList13.add(obj7);
            }
        }
        ArrayList arrayList14 = new ArrayList(AbstractC0229p.v(arrayList13, 10));
        for (String it14 : arrayList13) {
            m.h(it14, "it");
            arrayList14.add(AbstractC1172m.X0(it14, 1));
        }
        this.maskedIds = AbstractC0229p.R0(arrayList14);
        Set<String> set7 = this.nativeUnmaskSelectors;
        ArrayList<String> arrayList15 = new ArrayList();
        for (Object obj8 : set7) {
            String it15 = (String) obj8;
            m.h(it15, "it");
            if (AbstractC1172m.E(it15, "#", false, 2, null)) {
                arrayList15.add(obj8);
            }
        }
        ArrayList arrayList16 = new ArrayList(AbstractC0229p.v(arrayList15, 10));
        for (String it16 : arrayList15) {
            m.h(it16, "it");
            arrayList16.add(AbstractC1172m.X0(it16, 1));
        }
        this.unmaskedIds = AbstractC0229p.R0(arrayList16);
        Set<String> set8 = this.maskedIds;
        ArrayList arrayList17 = new ArrayList(AbstractC0229p.v(set8, 10));
        Iterator<T> it17 = set8.iterator();
        while (it17.hasNext()) {
            arrayList17.add(Integer.valueOf(context.getResources().getIdentifier((String) it17.next(), "id", context.getPackageName())));
        }
        ArrayList arrayList18 = new ArrayList();
        for (Object obj9 : arrayList17) {
            if (((Number) obj9).intValue() != 0) {
                arrayList18.add(obj9);
            }
        }
        this.maskedViewIds = arrayList18;
        Set<String> set9 = this.unmaskedIds;
        ArrayList arrayList19 = new ArrayList(AbstractC0229p.v(set9, 10));
        Iterator<T> it18 = set9.iterator();
        while (it18.hasNext()) {
            arrayList19.add(Integer.valueOf(context.getResources().getIdentifier((String) it18.next(), "id", context.getPackageName())));
        }
        ArrayList arrayList20 = new ArrayList();
        for (Object obj10 : arrayList19) {
            if (((Number) obj10).intValue() != 0) {
                arrayList20.add(obj10);
            }
        }
        this.unmaskedViewIds = arrayList20;
        this.allowMeteredNetwork = this.preferences.getBoolean("NETWORK_ALLOW_METERED", false);
        this.networkMaxDailyDataInMB = this.preferences.contains("NETWORK_MAX_DAILY_DATA_VOLUME_MB") ? Long.valueOf(this.preferences.getLong("NETWORK_MAX_DAILY_DATA_VOLUME_MB", 0L)) : null;
        this.disableForLowEndDevices = this.preferences.getBoolean("LOW_END_DEVICES_DISABLE_RECORDINGS", false);
        this.disableWebViewCapture = this.preferences.getBoolean("WEBVIEW_CAPTURE_DISABLED", false);
        if (this.preferences.contains("WEBVIEW_CAPTURE_ALLOWED_URLS")) {
            String string3 = this.preferences.getString("WEBVIEW_CAPTURE_ALLOWED_URLS", null);
            UrlFilter.Companion companion2 = UrlFilter.Companion;
            if (string3 == null) {
                l = new ArrayList<>();
            } else {
                JSONArray jSONArray = new JSONArray(string3);
                l = new ArrayList<>();
                int length = jSONArray.length();
                for (int i = 0; i < length; i++) {
                    String jSONObject = jSONArray.getJSONObject(i).toString();
                    m.h(jSONObject, "it.getJSONObject(i).toString()");
                    l.add(companion2.fromJson(jSONObject));
                }
            }
        } else {
            l = AbstractC0229p.l();
        }
        this.webViewCaptureAllowedUrls = l;
        if (this.preferences.contains("WEBVIEW_CAPTURE_DISALLOWED_URLS")) {
            String string4 = this.preferences.getString("WEBVIEW_CAPTURE_DISALLOWED_URLS", null);
            UrlFilter.Companion companion3 = UrlFilter.Companion;
            if (string4 == null) {
                l2 = new ArrayList<>();
            } else {
                JSONArray jSONArray2 = new JSONArray(string4);
                l2 = new ArrayList<>();
                int length2 = jSONArray2.length();
                for (int i2 = 0; i2 < length2; i2++) {
                    String jSONObject2 = jSONArray2.getJSONObject(i2).toString();
                    m.h(jSONObject2, "it.getJSONObject(i).toString()");
                    l2.add(companion3.fromJson(jSONObject2));
                }
            }
        } else {
            l2 = AbstractC0229p.l();
        }
        this.webViewCaptureDisallowedUrls = l2;
        if (this.preferences.contains("SCREEN_CAPTURE_ALLOWED_SCREENS")) {
            String string5 = this.preferences.getString("SCREEN_CAPTURE_ALLOWED_SCREENS", null);
            ScreenNameFilter.Companion companion4 = ScreenNameFilter.Companion;
            if (string5 == null) {
                l3 = new ArrayList<>();
            } else {
                JSONArray jSONArray3 = new JSONArray(string5);
                l3 = new ArrayList<>();
                int length3 = jSONArray3.length();
                for (int i3 = 0; i3 < length3; i3++) {
                    String jSONObject3 = jSONArray3.getJSONObject(i3).toString();
                    m.h(jSONObject3, "it.getJSONObject(i).toString()");
                    l3.add(companion4.fromJson(jSONObject3));
                }
            }
        } else {
            l3 = AbstractC0229p.l();
        }
        this.screenCaptureAllowedScreens = l3;
        if (this.preferences.contains("SCREEN_CAPTURE_DISALLOWED_SCREENS")) {
            String string6 = this.preferences.getString("SCREEN_CAPTURE_DISALLOWED_SCREENS", null);
            ScreenNameFilter.Companion companion5 = ScreenNameFilter.Companion;
            if (string6 == null) {
                l4 = new ArrayList<>();
            } else {
                JSONArray jSONArray4 = new JSONArray(string6);
                l4 = new ArrayList<>();
                int length4 = jSONArray4.length();
                for (int i4 = 0; i4 < length4; i4++) {
                    String jSONObject4 = jSONArray4.getJSONObject(i4).toString();
                    m.h(jSONObject4, "it.getJSONObject(i).toString()");
                    l4.add(companion5.fromJson(jSONObject4));
                }
            }
        } else {
            l4 = AbstractC0229p.l();
        }
        this.screenCaptureDisallowedScreens = l4;
        int i5 = this.rawImageCompressionFormat;
        if (i5 == ImageCompressionFormat.Unknown.getValue()) {
            compressFormat = Bitmap.CompressFormat.PNG;
        } else if (i5 == ImageCompressionFormat.PNG.getValue()) {
            compressFormat = Bitmap.CompressFormat.PNG;
        } else {
            if (i5 != ImageCompressionFormat.WEBP_LOSSY.getValue()) {
                throw new IllegalArgumentException("Unexpected image compression format");
            }
            compressFormat = Build.VERSION.SDK_INT >= 30 ? Bitmap.CompressFormat.WEBP_LOSSY : Bitmap.CompressFormat.PNG;
        }
        this.imageCompressionFormat = compressFormat;
        int i6 = this.rawImageCompressionQuality;
        this.imageCompressionQuality = i6 <= 0 ? 100 : i6;
    }

    public final boolean getAllowMeteredNetwork() {
        return this.allowMeteredNetwork;
    }

    public final boolean getDisableForLowEndDevices() {
        return this.disableForLowEndDevices;
    }

    public final boolean getDisableWebViewCapture() {
        return this.disableWebViewCapture;
    }

    public final Bitmap.CompressFormat getImageCompressionFormat() {
        return this.imageCompressionFormat;
    }

    public final int getImageCompressionQuality() {
        return this.imageCompressionQuality;
    }

    public final String getIngestUrl() {
        return this.ingestUrl;
    }

    public final boolean getLeanMode() {
        return this.leanMode;
    }

    public final Set<String> getMaskedClasses() {
        return this.maskedClasses;
    }

    public final Set<String> getMaskedFragments() {
        return this.maskedFragments;
    }

    public final Set<String> getMaskedIds() {
        return this.maskedIds;
    }

    public final Set<String> getMaskedScreens() {
        return this.maskedScreens;
    }

    public final List<Integer> getMaskedViewIds() {
        return this.maskedViewIds;
    }

    public final MaskingMode getMaskingMode() {
        return this.maskingMode;
    }

    public final Long getNetworkMaxDailyDataInMB() {
        return this.networkMaxDailyDataInMB;
    }

    public final String getReportUrl() {
        return this.reportUrl;
    }

    public final List<ScreenNameFilter> getScreenCaptureAllowedScreens() {
        return this.screenCaptureAllowedScreens;
    }

    public final List<ScreenNameFilter> getScreenCaptureDisallowedScreens() {
        return this.screenCaptureDisallowedScreens;
    }

    public final Set<String> getUnmaskedClasses() {
        return this.unmaskedClasses;
    }

    public final Set<String> getUnmaskedFragments() {
        return this.unmaskedFragments;
    }

    public final Set<String> getUnmaskedIds() {
        return this.unmaskedIds;
    }

    public final Set<String> getUnmaskedScreens() {
        return this.unmaskedScreens;
    }

    public final List<Integer> getUnmaskedViewIds() {
        return this.unmaskedViewIds;
    }

    public final Set<String> getWebMaskSelectors() {
        return this.webMaskSelectors;
    }

    public final Set<String> getWebUnmaskSelectors() {
        return this.webUnmaskSelectors;
    }

    public final List<UrlFilter> getWebViewCaptureAllowedUrls() {
        return this.webViewCaptureAllowedUrls;
    }

    public final List<UrlFilter> getWebViewCaptureDisallowedUrls() {
        return this.webViewCaptureDisallowedUrls;
    }

    public final boolean isAllowedUrl(String urlString) {
        m.i(urlString, "urlString");
        List<UrlFilter> list = this.webViewCaptureDisallowedUrls;
        if (!(list instanceof Collection) || !list.isEmpty()) {
            Iterator<T> it = list.iterator();
            while (it.hasNext()) {
                if (((UrlFilter) it.next()).matches(urlString)) {
                    return false;
                }
            }
        }
        URL url = null;
        try {
            if (!m.d(urlString, "about:blank")) {
                url = new URL(urlString);
            }
        } catch (Exception e) {
            l.e("Failed to parse URL " + urlString + " because of " + e + '.');
        }
        if (url == null) {
            return true;
        }
        String host = url.getHost();
        if (!m.d(url.getProtocol(), "file") && !m.d(host, "appassets.androidplatform.net") && !m.d(host, "localhost") && !this.webViewCaptureAllowedUrls.isEmpty()) {
            List<UrlFilter> list2 = this.webViewCaptureAllowedUrls;
            if ((list2 instanceof Collection) && list2.isEmpty()) {
                return false;
            }
            for (UrlFilter urlFilter : list2) {
                if (!m.d(urlFilter.getUrl(), "*") && !urlFilter.matches(urlString)) {
                }
            }
            return false;
        }
        return true;
    }

    public final boolean isClarityActivated() {
        return this.isClarityActivated;
    }
}