- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
865 lines
30 KiB
Java
865 lines
30 KiB
Java
package com.mbridge.msdk.playercommon.exoplayer2.util;
|
|
|
|
import android.annotation.TargetApi;
|
|
import android.app.Activity;
|
|
import android.content.ComponentName;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.pm.PackageManager;
|
|
import android.graphics.Point;
|
|
import android.net.Uri;
|
|
import android.os.Build;
|
|
import android.os.Parcel;
|
|
import android.text.TextUtils;
|
|
import android.view.Display;
|
|
import android.view.WindowManager;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import com.mbridge.msdk.newreward.function.common.MBridgeCommon;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.C;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.ExoPlayerLibraryInfo;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.ParserException;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.SeekParameters;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.upstream.DataSource;
|
|
import csdk.gluads.Consts;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.Closeable;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.math.BigDecimal;
|
|
import java.nio.charset.Charset;
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
import java.util.Formatter;
|
|
import java.util.GregorianCalendar;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.MissingResourceException;
|
|
import java.util.TimeZone;
|
|
import java.util.UUID;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.ThreadFactory;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public final class Util {
|
|
private static final int[] CRC32_BYTES_MSBF;
|
|
public static final String DEVICE;
|
|
public static final String DEVICE_DEBUG_INFO;
|
|
private static final Pattern ESCAPED_CHARACTER_PATTERN;
|
|
public static final String MANUFACTURER;
|
|
public static final String MODEL;
|
|
public static final int SDK_INT;
|
|
private static final String TAG = "Util";
|
|
private static final Pattern XS_DATE_TIME_PATTERN;
|
|
private static final Pattern XS_DURATION_PATTERN;
|
|
|
|
private Util() {
|
|
}
|
|
|
|
public static long addWithOverflowDefault(long j, long j2, long j3) {
|
|
long j4 = j + j2;
|
|
return ((j ^ j4) & (j2 ^ j4)) < 0 ? j3 : j4;
|
|
}
|
|
|
|
public static int compareLong(long j, long j2) {
|
|
if (j < j2) {
|
|
return -1;
|
|
}
|
|
return j == j2 ? 0 : 1;
|
|
}
|
|
|
|
public static int getAudioContentTypeForStreamType(int i) {
|
|
if (i != 0) {
|
|
return (i == 1 || i == 2 || i == 4 || i == 5 || i == 8) ? 4 : 2;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
public static int getAudioUsageForStreamType(int i) {
|
|
if (i == 0) {
|
|
return 2;
|
|
}
|
|
if (i == 1) {
|
|
return 13;
|
|
}
|
|
if (i == 2) {
|
|
return 6;
|
|
}
|
|
int i2 = 4;
|
|
if (i != 4) {
|
|
i2 = 5;
|
|
if (i != 5) {
|
|
return i != 8 ? 1 : 3;
|
|
}
|
|
}
|
|
return i2;
|
|
}
|
|
|
|
public static int getPcmEncoding(int i) {
|
|
if (i == 8) {
|
|
return 3;
|
|
}
|
|
if (i == 16) {
|
|
return 2;
|
|
}
|
|
if (i != 24) {
|
|
return i != 32 ? 0 : 1073741824;
|
|
}
|
|
return Integer.MIN_VALUE;
|
|
}
|
|
|
|
public static int getStreamTypeForAudioUsage(int i) {
|
|
if (i == 13) {
|
|
return 1;
|
|
}
|
|
switch (i) {
|
|
case 2:
|
|
return 0;
|
|
case 3:
|
|
return 8;
|
|
case 4:
|
|
return 4;
|
|
case 5:
|
|
case 7:
|
|
case 8:
|
|
case 9:
|
|
case 10:
|
|
return 5;
|
|
case 6:
|
|
return 2;
|
|
default:
|
|
return 3;
|
|
}
|
|
}
|
|
|
|
public static boolean isEncodingHighResolutionIntegerPcm(int i) {
|
|
return i == Integer.MIN_VALUE || i == 1073741824;
|
|
}
|
|
|
|
public static boolean isEncodingPcm(int i) {
|
|
return i == 3 || i == 2 || i == Integer.MIN_VALUE || i == 1073741824 || i == 4;
|
|
}
|
|
|
|
public static boolean isLinebreak(int i) {
|
|
return i == 10 || i == 13;
|
|
}
|
|
|
|
@TargetApi(23)
|
|
public static boolean maybeRequestReadExternalStoragePermission(Activity activity, Uri... uriArr) {
|
|
return false;
|
|
}
|
|
|
|
private static boolean shouldEscapeCharacter(char c) {
|
|
return c == '\"' || c == '%' || c == '*' || c == '/' || c == ':' || c == '<' || c == '\\' || c == '|' || c == '>' || c == '?';
|
|
}
|
|
|
|
public static long subtractWithOverflowDefault(long j, long j2, long j3) {
|
|
long j4 = j - j2;
|
|
return ((j ^ j4) & (j2 ^ j)) < 0 ? j3 : j4;
|
|
}
|
|
|
|
static {
|
|
int i = Build.VERSION.SDK_INT;
|
|
SDK_INT = i;
|
|
String str = Build.DEVICE;
|
|
DEVICE = str;
|
|
String str2 = Build.MANUFACTURER;
|
|
MANUFACTURER = str2;
|
|
String str3 = Build.MODEL;
|
|
MODEL = str3;
|
|
DEVICE_DEBUG_INFO = str + ", " + str3 + ", " + str2 + ", " + i;
|
|
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})");
|
|
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};
|
|
}
|
|
|
|
public static byte[] toByteArray(InputStream inputStream) throws IOException {
|
|
byte[] bArr = new byte[4096];
|
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
while (true) {
|
|
int read = inputStream.read(bArr);
|
|
if (read != -1) {
|
|
byteArrayOutputStream.write(bArr, 0, read);
|
|
} else {
|
|
return byteArrayOutputStream.toByteArray();
|
|
}
|
|
}
|
|
}
|
|
|
|
public static ComponentName startForegroundService(Context context, Intent intent) {
|
|
if (SDK_INT >= 26) {
|
|
return context.startForegroundService(intent);
|
|
}
|
|
return context.startService(intent);
|
|
}
|
|
|
|
public static boolean isLocalFileUri(Uri uri) {
|
|
String scheme = uri.getScheme();
|
|
return TextUtils.isEmpty(scheme) || "file".equals(scheme);
|
|
}
|
|
|
|
public static boolean areEqual(@Nullable Object obj, @Nullable Object obj2) {
|
|
if (obj == null) {
|
|
return obj2 == null;
|
|
}
|
|
return obj.equals(obj2);
|
|
}
|
|
|
|
public static boolean contains(Object[] objArr, Object obj) {
|
|
for (Object obj2 : objArr) {
|
|
if (areEqual(obj2, obj)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static <T> void removeRange(List<T> list, int i, int i2) {
|
|
list.subList(i, i2).clear();
|
|
}
|
|
|
|
public static <T> T[] nullSafeArrayCopy(T[] tArr, int i) {
|
|
Assertions.checkArgument(i <= tArr.length);
|
|
return (T[]) Arrays.copyOf(tArr, i);
|
|
}
|
|
|
|
public static ExecutorService newSingleThreadExecutor(final String str) {
|
|
return Executors.newSingleThreadExecutor(new ThreadFactory() { // from class: com.mbridge.msdk.playercommon.exoplayer2.util.Util.1
|
|
@Override // java.util.concurrent.ThreadFactory
|
|
public Thread newThread(@NonNull Runnable runnable) {
|
|
return new Thread(runnable, str);
|
|
}
|
|
});
|
|
}
|
|
|
|
public static void closeQuietly(DataSource dataSource) {
|
|
if (dataSource != null) {
|
|
try {
|
|
dataSource.close();
|
|
} catch (IOException unused) {
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void closeQuietly(Closeable closeable) {
|
|
if (closeable != null) {
|
|
try {
|
|
closeable.close();
|
|
} catch (IOException unused) {
|
|
}
|
|
}
|
|
}
|
|
|
|
public static boolean readBoolean(Parcel parcel) {
|
|
return parcel.readInt() != 0;
|
|
}
|
|
|
|
public static void writeBoolean(Parcel parcel, boolean z) {
|
|
parcel.writeInt(z ? 1 : 0);
|
|
}
|
|
|
|
@Nullable
|
|
public static String normalizeLanguageCode(@Nullable String str) {
|
|
if (str == null) {
|
|
return null;
|
|
}
|
|
try {
|
|
return new Locale(str).getISO3Language();
|
|
} catch (MissingResourceException unused) {
|
|
return toLowerInvariant(str);
|
|
}
|
|
}
|
|
|
|
public static String fromUtf8Bytes(byte[] bArr) {
|
|
return new String(bArr, Charset.forName("UTF-8"));
|
|
}
|
|
|
|
public static String fromUtf8Bytes(byte[] bArr, int i, int i2) {
|
|
return new String(bArr, i, i2, Charset.forName("UTF-8"));
|
|
}
|
|
|
|
public static byte[] getUtf8Bytes(String str) {
|
|
return str.getBytes(Charset.forName("UTF-8"));
|
|
}
|
|
|
|
public static String[] split(String str, String str2) {
|
|
return str.split(str2, -1);
|
|
}
|
|
|
|
public static String[] splitAtFirst(String str, String str2) {
|
|
return str.split(str2, 2);
|
|
}
|
|
|
|
public static String toLowerInvariant(String str) {
|
|
if (str == null) {
|
|
return null;
|
|
}
|
|
return str.toLowerCase(Locale.US);
|
|
}
|
|
|
|
public static String toUpperInvariant(String str) {
|
|
if (str == null) {
|
|
return null;
|
|
}
|
|
return str.toUpperCase(Locale.US);
|
|
}
|
|
|
|
public static String formatInvariant(String str, Object... objArr) {
|
|
return String.format(Locale.US, str, objArr);
|
|
}
|
|
|
|
public static int ceilDivide(int i, int i2) {
|
|
return ((i + i2) - 1) / i2;
|
|
}
|
|
|
|
public static long ceilDivide(long j, long j2) {
|
|
return ((j + j2) - 1) / j2;
|
|
}
|
|
|
|
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 float constrainValue(float f, float f2, float f3) {
|
|
return Math.max(f2, Math.min(f, f3));
|
|
}
|
|
|
|
public static int binarySearchFloor(int[] iArr, int i, boolean z, boolean z2) {
|
|
int i2;
|
|
int i3;
|
|
int binarySearch = Arrays.binarySearch(iArr, i);
|
|
if (binarySearch < 0) {
|
|
i3 = -(binarySearch + 2);
|
|
} else {
|
|
while (true) {
|
|
i2 = binarySearch - 1;
|
|
if (i2 < 0 || iArr[i2] != i) {
|
|
break;
|
|
}
|
|
binarySearch = i2;
|
|
}
|
|
i3 = z ? binarySearch : i2;
|
|
}
|
|
return z2 ? Math.max(0, i3) : i3;
|
|
}
|
|
|
|
public static int binarySearchFloor(long[] jArr, long j, boolean z, boolean z2) {
|
|
int i;
|
|
int i2;
|
|
int binarySearch = Arrays.binarySearch(jArr, j);
|
|
if (binarySearch < 0) {
|
|
i2 = -(binarySearch + 2);
|
|
} else {
|
|
while (true) {
|
|
i = binarySearch - 1;
|
|
if (i < 0 || jArr[i] != j) {
|
|
break;
|
|
}
|
|
binarySearch = i;
|
|
}
|
|
i2 = z ? binarySearch : i;
|
|
}
|
|
return z2 ? Math.max(0, i2) : i2;
|
|
}
|
|
|
|
public static <T> int binarySearchFloor(List<? extends Comparable<? super T>> list, T t, boolean z, boolean z2) {
|
|
int i;
|
|
int i2;
|
|
int binarySearch = Collections.binarySearch(list, t);
|
|
if (binarySearch < 0) {
|
|
i2 = -(binarySearch + 2);
|
|
} else {
|
|
while (true) {
|
|
i = binarySearch - 1;
|
|
if (i < 0 || list.get(i).compareTo(t) != 0) {
|
|
break;
|
|
}
|
|
binarySearch = i;
|
|
}
|
|
i2 = z ? binarySearch : i;
|
|
}
|
|
return z2 ? Math.max(0, i2) : i2;
|
|
}
|
|
|
|
public static int binarySearchCeil(long[] jArr, long j, boolean z, boolean z2) {
|
|
int i;
|
|
int i2;
|
|
int binarySearch = Arrays.binarySearch(jArr, j);
|
|
if (binarySearch < 0) {
|
|
i2 = ~binarySearch;
|
|
} else {
|
|
while (true) {
|
|
i = binarySearch + 1;
|
|
if (i >= jArr.length || jArr[i] != j) {
|
|
break;
|
|
}
|
|
binarySearch = i;
|
|
}
|
|
i2 = z ? binarySearch : i;
|
|
}
|
|
return z2 ? Math.min(jArr.length - 1, i2) : i2;
|
|
}
|
|
|
|
public static <T> int binarySearchCeil(List<? extends Comparable<? super T>> list, T t, boolean z, boolean z2) {
|
|
int i;
|
|
int i2;
|
|
int binarySearch = Collections.binarySearch(list, t);
|
|
if (binarySearch < 0) {
|
|
i2 = ~binarySearch;
|
|
} else {
|
|
int size = list.size();
|
|
while (true) {
|
|
i = binarySearch + 1;
|
|
if (i >= size || list.get(i).compareTo(t) != 0) {
|
|
break;
|
|
}
|
|
binarySearch = i;
|
|
}
|
|
i2 = z ? binarySearch : i;
|
|
}
|
|
return z2 ? Math.min(list.size() - 1, i2) : i2;
|
|
}
|
|
|
|
public static long parseXsDuration(String str) {
|
|
Matcher matcher = XS_DURATION_PATTERN.matcher(str);
|
|
if (matcher.matches()) {
|
|
boolean isEmpty = true ^ TextUtils.isEmpty(matcher.group(1));
|
|
String group = matcher.group(3);
|
|
double parseDouble = group != null ? Double.parseDouble(group) * 3.1556908E7d : 0.0d;
|
|
String group2 = matcher.group(5);
|
|
double parseDouble2 = parseDouble + (group2 != null ? Double.parseDouble(group2) * 2629739.0d : 0.0d);
|
|
String group3 = matcher.group(7);
|
|
double parseDouble3 = parseDouble2 + (group3 != null ? Double.parseDouble(group3) * 86400.0d : 0.0d);
|
|
String group4 = matcher.group(10);
|
|
double parseDouble4 = parseDouble3 + (group4 != null ? Double.parseDouble(group4) * 3600.0d : 0.0d);
|
|
String group5 = matcher.group(12);
|
|
double parseDouble5 = parseDouble4 + (group5 != null ? Double.parseDouble(group5) * 60.0d : 0.0d);
|
|
String group6 = matcher.group(14);
|
|
long parseDouble6 = (long) ((parseDouble5 + (group6 != null ? Double.parseDouble(group6) : 0.0d)) * 1000.0d);
|
|
return isEmpty ? -parseDouble6 : parseDouble6;
|
|
}
|
|
return (long) (Double.parseDouble(str) * 3600.0d * 1000.0d);
|
|
}
|
|
|
|
public static long parseXsDateTime(String str) throws ParserException {
|
|
Matcher matcher = XS_DATE_TIME_PATTERN.matcher(str);
|
|
if (!matcher.matches()) {
|
|
throw new ParserException("Invalid date/time format: " + str);
|
|
}
|
|
int i = 0;
|
|
if (matcher.group(9) != null && !matcher.group(9).equalsIgnoreCase("Z")) {
|
|
i = (Integer.parseInt(matcher.group(12)) * 60) + Integer.parseInt(matcher.group(13));
|
|
if ("-".equals(matcher.group(11))) {
|
|
i *= -1;
|
|
}
|
|
}
|
|
GregorianCalendar gregorianCalendar = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
|
|
gregorianCalendar.clear();
|
|
gregorianCalendar.set(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)) - 1, Integer.parseInt(matcher.group(3)), Integer.parseInt(matcher.group(4)), Integer.parseInt(matcher.group(5)), Integer.parseInt(matcher.group(6)));
|
|
if (!TextUtils.isEmpty(matcher.group(8))) {
|
|
gregorianCalendar.set(14, new BigDecimal("0." + matcher.group(8)).movePointRight(3).intValue());
|
|
}
|
|
long timeInMillis = gregorianCalendar.getTimeInMillis();
|
|
return i != 0 ? timeInMillis - (i * MBridgeCommon.DEFAULT_LOAD_TIMEOUT) : timeInMillis;
|
|
}
|
|
|
|
public static long scaleLargeTimestamp(long j, long j2, long j3) {
|
|
if (j3 >= j2 && j3 % j2 == 0) {
|
|
return j / (j3 / j2);
|
|
}
|
|
if (j3 < j2 && j2 % j3 == 0) {
|
|
return j * (j2 / j3);
|
|
}
|
|
return (long) (j * (j2 / j3));
|
|
}
|
|
|
|
public static long[] scaleLargeTimestamps(List<Long> list, long j, long j2) {
|
|
int size = list.size();
|
|
long[] jArr = new long[size];
|
|
int i = 0;
|
|
if (j2 >= j && j2 % j == 0) {
|
|
long j3 = j2 / j;
|
|
while (i < size) {
|
|
jArr[i] = list.get(i).longValue() / j3;
|
|
i++;
|
|
}
|
|
} else if (j2 >= j || j % j2 != 0) {
|
|
double d = j / j2;
|
|
while (i < size) {
|
|
jArr[i] = (long) (list.get(i).longValue() * d);
|
|
i++;
|
|
}
|
|
} else {
|
|
long j4 = j / j2;
|
|
while (i < size) {
|
|
jArr[i] = list.get(i).longValue() * j4;
|
|
i++;
|
|
}
|
|
}
|
|
return jArr;
|
|
}
|
|
|
|
public static void scaleLargeTimestampsInPlace(long[] jArr, long j, long j2) {
|
|
int i = 0;
|
|
if (j2 >= j && j2 % j == 0) {
|
|
long j3 = j2 / j;
|
|
while (i < jArr.length) {
|
|
jArr[i] = jArr[i] / j3;
|
|
i++;
|
|
}
|
|
return;
|
|
}
|
|
if (j2 < j && j % j2 == 0) {
|
|
long j4 = j / j2;
|
|
while (i < jArr.length) {
|
|
jArr[i] = jArr[i] * j4;
|
|
i++;
|
|
}
|
|
return;
|
|
}
|
|
double d = j / j2;
|
|
while (i < jArr.length) {
|
|
jArr[i] = (long) (jArr[i] * d);
|
|
i++;
|
|
}
|
|
}
|
|
|
|
public static long getMediaDurationForPlayoutDuration(long j, float f) {
|
|
return f == 1.0f ? j : Math.round(j * f);
|
|
}
|
|
|
|
public static long getPlayoutDurationForMediaDuration(long j, float f) {
|
|
return f == 1.0f ? j : Math.round(j / f);
|
|
}
|
|
|
|
public static long resolveSeekPositionUs(long j, SeekParameters seekParameters, long j2, long j3) {
|
|
if (SeekParameters.EXACT.equals(seekParameters)) {
|
|
return j;
|
|
}
|
|
long subtractWithOverflowDefault = subtractWithOverflowDefault(j, seekParameters.toleranceBeforeUs, Long.MIN_VALUE);
|
|
long addWithOverflowDefault = addWithOverflowDefault(j, seekParameters.toleranceAfterUs, Long.MAX_VALUE);
|
|
boolean z = false;
|
|
boolean z2 = subtractWithOverflowDefault <= j2 && j2 <= addWithOverflowDefault;
|
|
if (subtractWithOverflowDefault <= j3 && j3 <= addWithOverflowDefault) {
|
|
z = true;
|
|
}
|
|
return (z2 && z) ? Math.abs(j2 - j) <= Math.abs(j3 - j) ? j2 : j3 : z2 ? j2 : z ? j3 : subtractWithOverflowDefault;
|
|
}
|
|
|
|
public static int[] toArray(List<Integer> list) {
|
|
if (list == null) {
|
|
return null;
|
|
}
|
|
int size = list.size();
|
|
int[] iArr = new int[size];
|
|
for (int i = 0; i < size; i++) {
|
|
iArr[i] = list.get(i).intValue();
|
|
}
|
|
return iArr;
|
|
}
|
|
|
|
public static int getIntegerCodeForString(String str) {
|
|
int length = str.length();
|
|
Assertions.checkArgument(length <= 4);
|
|
int i = 0;
|
|
for (int i2 = 0; i2 < length; i2++) {
|
|
i = (i << 8) | str.charAt(i2);
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public static byte[] getBytesFromHexString(String str) {
|
|
int length = str.length() / 2;
|
|
byte[] bArr = new byte[length];
|
|
for (int i = 0; i < length; i++) {
|
|
int i2 = i * 2;
|
|
bArr[i] = (byte) ((Character.digit(str.charAt(i2), 16) << 4) + Character.digit(str.charAt(i2 + 1), 16));
|
|
}
|
|
return bArr;
|
|
}
|
|
|
|
public static String getCommaDelimitedSimpleClassNames(Object[] objArr) {
|
|
StringBuilder sb = new StringBuilder();
|
|
for (int i = 0; i < objArr.length; i++) {
|
|
sb.append(objArr[i].getClass().getSimpleName());
|
|
if (i < objArr.length - 1) {
|
|
sb.append(", ");
|
|
}
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
public static String getUserAgent(Context context, String str) {
|
|
String str2;
|
|
try {
|
|
str2 = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
|
|
} catch (PackageManager.NameNotFoundException unused) {
|
|
str2 = "?";
|
|
}
|
|
return str + "/" + str2 + " (Linux;Android " + Build.VERSION.RELEASE + ") " + ExoPlayerLibraryInfo.VERSION_SLASHY;
|
|
}
|
|
|
|
public static String getCodecsOfType(String str, int i) {
|
|
if (TextUtils.isEmpty(str)) {
|
|
return null;
|
|
}
|
|
String[] split = split(str.trim(), "(\\s*,\\s*)");
|
|
StringBuilder sb = new StringBuilder();
|
|
for (String str2 : split) {
|
|
if (i == MimeTypes.getTrackTypeOfCodec(str2)) {
|
|
if (sb.length() > 0) {
|
|
sb.append(",");
|
|
}
|
|
sb.append(str2);
|
|
}
|
|
}
|
|
if (sb.length() > 0) {
|
|
return sb.toString();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static int getPcmFrameSize(int i, int i2) {
|
|
if (i == Integer.MIN_VALUE) {
|
|
return i2 * 3;
|
|
}
|
|
if (i != 1073741824) {
|
|
if (i == 2) {
|
|
return i2 * 2;
|
|
}
|
|
if (i == 3) {
|
|
return i2;
|
|
}
|
|
if (i != 4) {
|
|
throw new IllegalArgumentException();
|
|
}
|
|
}
|
|
return i2 * 4;
|
|
}
|
|
|
|
public static UUID getDrmUuid(String str) {
|
|
String lowerInvariant = toLowerInvariant(str);
|
|
lowerInvariant.hashCode();
|
|
switch (lowerInvariant) {
|
|
case "playready":
|
|
return C.PLAYREADY_UUID;
|
|
case "widevine":
|
|
return C.WIDEVINE_UUID;
|
|
case "clearkey":
|
|
return C.CLEARKEY_UUID;
|
|
default:
|
|
try {
|
|
return UUID.fromString(str);
|
|
} catch (RuntimeException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public static int inferContentType(Uri uri, String str) {
|
|
if (TextUtils.isEmpty(str)) {
|
|
return inferContentType(uri);
|
|
}
|
|
return inferContentType(Consts.STRING_PERIOD + str);
|
|
}
|
|
|
|
public static int inferContentType(Uri uri) {
|
|
String path = uri.getPath();
|
|
if (path == null) {
|
|
return 3;
|
|
}
|
|
return inferContentType(path);
|
|
}
|
|
|
|
public static int inferContentType(String str) {
|
|
String lowerInvariant = toLowerInvariant(str);
|
|
if (lowerInvariant.endsWith(".mpd")) {
|
|
return 0;
|
|
}
|
|
if (lowerInvariant.endsWith(".m3u8")) {
|
|
return 2;
|
|
}
|
|
return lowerInvariant.matches(".*\\.ism(l)?(/manifest(\\(.+\\))?)?") ? 1 : 3;
|
|
}
|
|
|
|
public static String getStringForTime(StringBuilder sb, Formatter formatter, long j) {
|
|
if (j == C.TIME_UNSET) {
|
|
j = 0;
|
|
}
|
|
long j2 = (j + 500) / 1000;
|
|
long j3 = j2 % 60;
|
|
long j4 = (j2 / 60) % 60;
|
|
long j5 = j2 / 3600;
|
|
sb.setLength(0);
|
|
if (j5 > 0) {
|
|
return formatter.format("%d:%02d:%02d", Long.valueOf(j5), Long.valueOf(j4), Long.valueOf(j3)).toString();
|
|
}
|
|
return formatter.format("%02d:%02d", Long.valueOf(j4), Long.valueOf(j3)).toString();
|
|
}
|
|
|
|
public static int getDefaultBufferSize(int i) {
|
|
if (i == 0) {
|
|
return 16777216;
|
|
}
|
|
if (i == 1) {
|
|
return C.DEFAULT_AUDIO_BUFFER_SIZE;
|
|
}
|
|
if (i == 2) {
|
|
return C.DEFAULT_VIDEO_BUFFER_SIZE;
|
|
}
|
|
if (i == 3 || i == 4) {
|
|
return 131072;
|
|
}
|
|
throw new IllegalStateException();
|
|
}
|
|
|
|
public static String escapeFileName(String str) {
|
|
int length = str.length();
|
|
int i = 0;
|
|
int i2 = 0;
|
|
for (int i3 = 0; i3 < length; i3++) {
|
|
if (shouldEscapeCharacter(str.charAt(i3))) {
|
|
i2++;
|
|
}
|
|
}
|
|
if (i2 == 0) {
|
|
return str;
|
|
}
|
|
StringBuilder sb = new StringBuilder((i2 * 2) + length);
|
|
while (i2 > 0) {
|
|
int i4 = i + 1;
|
|
char charAt = str.charAt(i);
|
|
if (shouldEscapeCharacter(charAt)) {
|
|
sb.append('%');
|
|
sb.append(Integer.toHexString(charAt));
|
|
i2--;
|
|
} else {
|
|
sb.append(charAt);
|
|
}
|
|
i = i4;
|
|
}
|
|
if (i < length) {
|
|
sb.append((CharSequence) str, i, length);
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
public static String unescapeFileName(String str) {
|
|
int length = str.length();
|
|
int i = 0;
|
|
int i2 = 0;
|
|
for (int i3 = 0; i3 < length; i3++) {
|
|
if (str.charAt(i3) == '%') {
|
|
i2++;
|
|
}
|
|
}
|
|
if (i2 == 0) {
|
|
return str;
|
|
}
|
|
int i4 = length - (i2 * 2);
|
|
StringBuilder sb = new StringBuilder(i4);
|
|
Matcher matcher = ESCAPED_CHARACTER_PATTERN.matcher(str);
|
|
while (i2 > 0 && matcher.find()) {
|
|
char parseInt = (char) Integer.parseInt(matcher.group(1), 16);
|
|
sb.append((CharSequence) str, i, matcher.start());
|
|
sb.append(parseInt);
|
|
i = matcher.end();
|
|
i2--;
|
|
}
|
|
if (i < length) {
|
|
sb.append((CharSequence) str, i, length);
|
|
}
|
|
if (sb.length() != i4) {
|
|
return null;
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
public static void sneakyThrow(Throwable th) {
|
|
sneakyThrowInternal(th);
|
|
}
|
|
|
|
private static <T extends Throwable> void sneakyThrowInternal(Throwable th) throws Throwable {
|
|
throw th;
|
|
}
|
|
|
|
public static void recursiveDelete(File file) {
|
|
if (file.isDirectory()) {
|
|
for (File file2 : file.listFiles()) {
|
|
recursiveDelete(file2);
|
|
}
|
|
}
|
|
file.delete();
|
|
}
|
|
|
|
public static File createTempDirectory(Context context, String str) throws IOException {
|
|
File createTempFile = createTempFile(context, str);
|
|
createTempFile.delete();
|
|
createTempFile.mkdir();
|
|
return createTempFile;
|
|
}
|
|
|
|
public static File createTempFile(Context context, String str) throws IOException {
|
|
return File.createTempFile(str, null, context.getCacheDir());
|
|
}
|
|
|
|
public static int crc(byte[] bArr, int i, int i2, int i3) {
|
|
while (i < i2) {
|
|
i3 = CRC32_BYTES_MSBF[((i3 >>> 24) ^ (bArr[i] & 255)) & 255] ^ (i3 << 8);
|
|
i++;
|
|
}
|
|
return i3;
|
|
}
|
|
|
|
public static Point getPhysicalDisplaySize(Context context) {
|
|
return getPhysicalDisplaySize(context, ((WindowManager) context.getSystemService("window")).getDefaultDisplay());
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:44:0x006e, code lost:
|
|
|
|
if (r6.equals("TPM171E") == false) goto L41;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public static android.graphics.Point getPhysicalDisplaySize(android.content.Context r6, android.view.Display r7) {
|
|
/*
|
|
Method dump skipped, instructions count: 249
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.playercommon.exoplayer2.util.Util.getPhysicalDisplaySize(android.content.Context, android.view.Display):android.graphics.Point");
|
|
}
|
|
|
|
@TargetApi(23)
|
|
private static void getDisplaySizeV23(Display display, Point point) {
|
|
Display.Mode mode = display.getMode();
|
|
point.x = mode.getPhysicalWidth();
|
|
point.y = mode.getPhysicalHeight();
|
|
}
|
|
|
|
@TargetApi(17)
|
|
private static void getDisplaySizeV17(Display display, Point point) {
|
|
display.getRealSize(point);
|
|
}
|
|
|
|
@TargetApi(16)
|
|
private static void getDisplaySizeV16(Display display, Point point) {
|
|
display.getSize(point);
|
|
}
|
|
|
|
private static void getDisplaySizeV9(Display display, Point point) {
|
|
point.x = display.getWidth();
|
|
point.y = display.getHeight();
|
|
}
|
|
}
|