package com.google.android.exoplayer2.util; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.os.Build; import android.os.Parcel; import android.text.TextUtils; import com.facebook.internal.FacebookRequestErrorClassification; import com.google.common.base.Ascii; import com.ironsource.mediationsdk.utils.IronSourceConstants; import com.mbridge.msdk.foundation.download.core.DownloadCommon; import com.mbridge.msdk.foundation.same.report.i; import com.mbridge.msdk.playercommon.exoplayer2.C; import com.mbridge.msdk.playercommon.exoplayer2.extractor.ts.PsExtractor; import com.unity3d.services.ads.gmascar.utils.ScarConstants; import com.vungle.ads.internal.protos.Sdk; import com.vungle.ads.internal.signals.SignalKey; import java.util.Formatter; import java.util.HashMap; import java.util.Locale; import java.util.MissingResourceException; import java.util.regex.Pattern; /* loaded from: classes2.dex */ public abstract class Util { public static final int[] CRC32_BYTES_MSBF; public static final int[] CRC8_BYTES_MSBF; public static final String DEVICE; public static final String DEVICE_DEBUG_INFO; public static final byte[] EMPTY_BYTE_ARRAY; public static final Pattern ESCAPED_CHARACTER_PATTERN; public static final Pattern ISM_URL_PATTERN; public static final String MANUFACTURER; public static final String MODEL; public static final int SDK_INT; public static final Pattern XS_DATE_TIME_PATTERN; public static final Pattern XS_DURATION_PATTERN; public static final String[] additionalIsoLanguageReplacements; public static final String[] isoLegacyTagReplacements; public static HashMap languageTagReplacementMap; public static Object castNonNull(Object obj) { return obj; } static { int i; String str = Build.VERSION.CODENAME; if ("S".equals(str)) { i = 31; } else { i = "R".equals(str) ? 30 : Build.VERSION.SDK_INT; } SDK_INT = i; String str2 = Build.DEVICE; DEVICE = str2; String str3 = Build.MANUFACTURER; MANUFACTURER = str3; String str4 = Build.MODEL; MODEL = str4; StringBuilder sb = new StringBuilder(String.valueOf(str2).length() + 17 + String.valueOf(str4).length() + String.valueOf(str3).length()); sb.append(str2); sb.append(", "); sb.append(str4); sb.append(", "); sb.append(str3); sb.append(", "); sb.append(i); DEVICE_DEBUG_INFO = sb.toString(); EMPTY_BYTE_ARRAY = new byte[0]; XS_DATE_TIME_PATTERN = Pattern.compile("(\\d\\d\\d\\d)\\-(\\d\\d)\\-(\\d\\d)[Tt](\\d\\d):(\\d\\d):(\\d\\d)([\\.,](\\d+))?([Zz]|((\\+|\\-)(\\d?\\d):?(\\d\\d)))?"); XS_DURATION_PATTERN = Pattern.compile("^(-)?P(([0-9]*)Y)?(([0-9]*)M)?(([0-9]*)D)?(T(([0-9]*)H)?(([0-9]*)M)?(([0-9.]*)S)?)?$"); ESCAPED_CHARACTER_PATTERN = Pattern.compile("%([A-Fa-f0-9]{2})"); ISM_URL_PATTERN = Pattern.compile(".*\\.isml?(?:/(manifest(.*))?)?"); additionalIsoLanguageReplacements = new String[]{"alb", "sq", "arm", "hy", "baq", "eu", "bur", "my", "tib", "bo", "chi", "zh", "cze", "cs", "dut", "nl", "ger", DownloadCommon.DOWNLOAD_REPORT_DOWNLOAD_ERROR, "gre", "el", "fre", "fr", "geo", "ka", "ice", "is", "mac", "mk", "mao", "mi", "may", "ms", "per", "fa", "rum", "ro", "scc", "hbs-srp", "slo", "sk", "wel", "cy", "id", "ms-ind", "iw", "he", "heb", "he", "ji", "yi", ScarConstants.IN_SIGNAL_KEY, "ms-ind", "ind", "ms-ind", "nb", "no-nob", "nob", "no-nob", "nn", "no-nno", "nno", "no-nno", "tw", "ak-twi", "twi", "ak-twi", "bs", "hbs-bos", "bos", "hbs-bos", "hr", "hbs-hrv", "hrv", "hbs-hrv", "sr", "hbs-srp", "srp", "hbs-srp", "cmn", "zh-cmn", "hak", "zh-hak", "nan", "zh-nan", "hsn", "zh-hsn"}; isoLegacyTagReplacements = new String[]{"i-lux", "lb", "i-hak", "zh-hak", "i-navajo", "nv", "no-bok", "no-nob", "no-nyn", "no-nno", "zh-guoyu", "zh-cmn", "zh-hakka", "zh-hak", "zh-min-nan", "zh-nan", "zh-xiang", "zh-hsn"}; CRC32_BYTES_MSBF = new int[]{0, 79764919, 159529838, 222504665, 319059676, 398814059, 445009330, 507990021, 638119352, 583659535, 797628118, 726387553, 890018660, 835552979, 1015980042, 944750013, 1276238704, 1221641927, 1167319070, 1095957929, 1595256236, 1540665371, 1452775106, 1381403509, 1780037320, 1859660671, 1671105958, 1733955601, 2031960084, 2111593891, 1889500026, 1952343757, -1742489888, -1662866601, -1851683442, -1788833735, -1960329156, -1880695413, -2103051438, -2040207643, -1104454824, -1159051537, -1213636554, -1284997759, -1389417084, -1444007885, -1532160278, -1603531939, -734892656, -789352409, -575645954, -646886583, -952755380, -1007220997, -827056094, -898286187, -231047128, -151282273, -71779514, -8804623, -515967244, -436212925, -390279782, -327299027, 881225847, 809987520, 1023691545, 969234094, 662832811, 591600412, 771767749, 717299826, 311336399, 374308984, 453813921, 533576470, 25881363, 88864420, 134795389, 214552010, 2023205639, 2086057648, 1897238633, 1976864222, 1804852699, 1867694188, 1645340341, 1724971778, 1587496639, 1516133128, 1461550545, 1406951526, 1302016099, 1230646740, 1142491917, 1087903418, -1398421865, -1469785312, -1524105735, -1578704818, -1079922613, -1151291908, -1239184603, -1293773166, -1968362705, -1905510760, -2094067647, -2014441994, -1716953613, -1654112188, -1876203875, -1796572374, -525066777, -462094256, -382327159, -302564546, -206542021, -143559028, -97365931, -17609246, -960696225, -1031934488, -817968335, -872425850, -709327229, -780559564, -600130067, -654598054, 1762451694, 1842216281, 1619975040, 1682949687, 2047383090, 2127137669, 1938468188, 2001449195, 1325665622, 1271206113, 1183200824, 1111960463, 1543535498, 1489069629, 1434599652, 1363369299, 622672798, 568075817, 748617968, 677256519, 907627842, 853037301, 1067152940, 995781531, 51762726, 131386257, 177728840, 240578815, 269590778, 349224269, 429104020, 491947555, -248556018, -168932423, -122852000, -60002089, -500490030, -420856475, -341238852, -278395381, -685261898, -739858943, -559578920, -630940305, -1004286614, -1058877219, -845023740, -916395085, -1119974018, -1174433591, -1262701040, -1333941337, -1371866206, -1426332139, -1481064244, -1552294533, -1690935098, -1611170447, -1833673816, -1770699233, -2009983462, -1930228819, -2119160460, -2056179517, 1569362073, 1498123566, 1409854455, 1355396672, 1317987909, 1246755826, 1192025387, 1137557660, 2072149281, 2135122070, 1912620623, 1992383480, 1753615357, 1816598090, 1627664531, 1707420964, 295390185, 358241886, 404320391, 483945776, 43990325, 106832002, 186451547, 266083308, 932423249, 861060070, 1041341759, 986742920, 613929101, 542559546, 756411363, 701822548, -978770311, -1050133554, -869589737, -924188512, -693284699, -764654318, -550540341, -605129092, -475935807, -413084042, -366743377, -287118056, -257573603, -194731862, -114850189, -35218492, -1984365303, -1921392450, -2143631769, -2063868976, -1698919467, -1635936670, -1824608069, -1744851700, -1347415887, -1418654458, -1506661409, -1561119128, -1129027987, -1200260134, -1254728445, -1309196108}; CRC8_BYTES_MSBF = new int[]{0, 7, 14, 9, 28, 27, 18, 21, 56, 63, 54, 49, 36, 35, 42, 45, 112, 119, 126, 121, 108, SignalKey.EVENT_ID, 98, 101, 72, 79, 70, 65, 84, 83, 90, 93, 224, 231, 238, 233, 252, 251, 242, 245, 216, Sdk.SDKError.Reason.STALE_CACHED_RESPONSE_VALUE, 214, 209, 196, 195, 202, 205, 144, 151, 158, 153, IronSourceConstants.USING_CACHE_FOR_INIT_EVENT, 139, 130, 133, 168, 175, 166, 161, 180, 179, 186, PsExtractor.PRIVATE_STREAM_1, 199, PsExtractor.AUDIO_STREAM, 201, 206, 219, 220, 213, 210, 255, 248, 241, 246, 227, 228, 237, 234, 183, 176, 185, FacebookRequestErrorClassification.EC_INVALID_TOKEN, 171, 172, 165, 162, 143, 136, 129, 134, 147, 148, 157, 154, 39, 32, 41, 46, 59, 60, 53, 50, 31, 24, 17, 22, 3, 4, 13, 10, 87, 80, 89, 94, 75, 76, 69, 66, 111, 104, 97, 102, 115, 116, 125, 122, 137, 142, 135, 128, 149, 146, 155, 156, 177, 182, 191, 184, 173, 170, 163, 164, 249, 254, 247, PsExtractor.VIDEO_STREAM_MASK, 229, 226, 235, 236, 193, 198, 207, 200, 221, 218, 211, 212, 105, 110, 103, 96, 117, 114, 123, 124, 81, 86, 95, 88, 77, 74, 67, 68, 25, 30, 23, 16, 5, 2, 11, 12, 33, 38, 47, 40, 61, 58, 51, 52, 78, 73, 64, 71, 82, 85, 92, 91, 118, 113, 120, 127, 106, 109, 100, 99, 62, 57, 48, 55, 34, 37, 44, 43, 6, 1, 8, 15, 26, 29, 20, 19, 174, 169, 160, 167, 178, 181, 188, 187, IronSourceConstants.REWARDED_VIDEO_DAILY_CAPPED, 145, 152, 159, 138, 141, 132, 131, 222, 217, 208, 215, 194, 197, 204, 203, 230, 225, 232, 239, 250, 253, 244, 243}; } public static ComponentName startForegroundService(Context context, Intent intent) { if (SDK_INT >= 26) { return context.startForegroundService(intent); } return context.startService(intent); } public static boolean areEqual(Object obj, Object obj2) { if (obj == null) { return obj2 == null; } return obj.equals(obj2); } public static boolean readBoolean(Parcel parcel) { return parcel.readInt() != 0; } public static void writeBoolean(Parcel parcel, boolean z) { parcel.writeInt(z ? 1 : 0); } public static String normalizeLanguageCode(String str) { if (str == null) { return null; } String replace = str.replace('_', '-'); if (!replace.isEmpty() && !replace.equals(C.LANGUAGE_UNDETERMINED)) { str = replace; } String lowerCase = Ascii.toLowerCase(str); String str2 = splitAtFirst(lowerCase, "-")[0]; if (languageTagReplacementMap == null) { languageTagReplacementMap = createIsoLanguageReplacementMap(); } String str3 = (String) languageTagReplacementMap.get(str2); if (str3 != null) { String valueOf = String.valueOf(lowerCase.substring(str2.length())); lowerCase = valueOf.length() != 0 ? str3.concat(valueOf) : new String(str3); str2 = str3; } return ("no".equals(str2) || i.a.equals(str2) || "zh".equals(str2)) ? maybeReplaceLegacyLanguageTags(lowerCase) : lowerCase; } public static String[] splitAtFirst(String str, String str2) { return str.split(str2, 2); } public static String formatInvariant(String str, Object... objArr) { return String.format(Locale.US, str, objArr); } public static int constrainValue(int i, int i2, int i3) { return Math.max(i2, Math.min(i, i3)); } public static long constrainValue(long j, long j2, long j3) { return Math.max(j2, Math.min(j, j3)); } public static String getStringForTime(StringBuilder sb, Formatter formatter, long j) { if (j == C.TIME_UNSET) { j = 0; } String str = j < 0 ? "-" : ""; long abs = (Math.abs(j) + 500) / 1000; long j2 = abs % 60; long j3 = (abs / 60) % 60; long j4 = abs / 3600; sb.setLength(0); if (j4 > 0) { return formatter.format("%s%d:%02d:%02d", str, Long.valueOf(j4), Long.valueOf(j3), Long.valueOf(j2)).toString(); } return formatter.format("%s%02d:%02d", str, Long.valueOf(j3), Long.valueOf(j2)).toString(); } public static HashMap createIsoLanguageReplacementMap() { String[] iSOLanguages = Locale.getISOLanguages(); HashMap hashMap = new HashMap(iSOLanguages.length + additionalIsoLanguageReplacements.length); int i = 0; for (String str : iSOLanguages) { try { String iSO3Language = new Locale(str).getISO3Language(); if (!TextUtils.isEmpty(iSO3Language)) { hashMap.put(iSO3Language, str); } } catch (MissingResourceException unused) { } } while (true) { String[] strArr = additionalIsoLanguageReplacements; if (i >= strArr.length) { return hashMap; } hashMap.put(strArr[i], strArr[i + 1]); i += 2; } } public static String maybeReplaceLegacyLanguageTags(String str) { int i = 0; while (true) { String[] strArr = isoLegacyTagReplacements; if (i >= strArr.length) { return str; } if (str.startsWith(strArr[i])) { String valueOf = String.valueOf(strArr[i + 1]); String valueOf2 = String.valueOf(str.substring(strArr[i].length())); return valueOf2.length() != 0 ? valueOf.concat(valueOf2) : new String(valueOf); } i += 2; } } }