ADD week 5

This commit is contained in:
2025-03-31 16:33:42 +02:00
parent 86f265f22d
commit bf645048e6
4927 changed files with 544053 additions and 0 deletions

View File

@ -0,0 +1,49 @@
package androidx.core.telephony;
import android.os.Build;
import android.telephony.SubscriptionManager;
import androidx.core.app.NotificationCompat$Style$$ExternalSyntheticApiModelOutline0;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/* loaded from: classes.dex */
public class SubscriptionManagerCompat {
private static Method sGetSlotIndexMethod;
public static int getSlotIndex(int i) {
if (i == -1) {
return -1;
}
if (Build.VERSION.SDK_INT >= 29) {
return Api29Impl.getSlotIndex(i);
}
try {
if (sGetSlotIndexMethod == null) {
if (Build.VERSION.SDK_INT >= 26) {
sGetSlotIndexMethod = NotificationCompat$Style$$ExternalSyntheticApiModelOutline0.m$2().getDeclaredMethod("getSlotIndex", Integer.TYPE);
} else {
sGetSlotIndexMethod = NotificationCompat$Style$$ExternalSyntheticApiModelOutline0.m$2().getDeclaredMethod("getSlotId", Integer.TYPE);
}
sGetSlotIndexMethod.setAccessible(true);
}
Integer num = (Integer) sGetSlotIndexMethod.invoke(null, Integer.valueOf(i));
if (num != null) {
return num.intValue();
}
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException unused) {
}
return -1;
}
private SubscriptionManagerCompat() {
}
private static class Api29Impl {
private Api29Impl() {
}
static int getSlotIndex(int i) {
return SubscriptionManager.getSlotIndex(i);
}
}
}

View File

@ -0,0 +1,89 @@
package androidx.core.telephony;
import android.os.Build;
import android.telephony.TelephonyManager;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/* loaded from: classes.dex */
public class TelephonyManagerCompat {
private static Method sGetDeviceIdMethod;
private static Method sGetSubIdMethod;
public static String getImei(TelephonyManager telephonyManager) {
int subscriptionId;
if (Build.VERSION.SDK_INT >= 26) {
return Api26Impl.getImei(telephonyManager);
}
if (Build.VERSION.SDK_INT >= 22 && (subscriptionId = getSubscriptionId(telephonyManager)) != Integer.MAX_VALUE && subscriptionId != -1) {
int slotIndex = SubscriptionManagerCompat.getSlotIndex(subscriptionId);
if (Build.VERSION.SDK_INT >= 23) {
return Api23Impl.getDeviceId(telephonyManager, slotIndex);
}
try {
if (sGetDeviceIdMethod == null) {
Method declaredMethod = TelephonyManager.class.getDeclaredMethod("getDeviceId", Integer.TYPE);
sGetDeviceIdMethod = declaredMethod;
declaredMethod.setAccessible(true);
}
return (String) sGetDeviceIdMethod.invoke(telephonyManager, Integer.valueOf(slotIndex));
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException unused) {
return null;
}
}
return telephonyManager.getDeviceId();
}
public static int getSubscriptionId(TelephonyManager telephonyManager) {
if (Build.VERSION.SDK_INT >= 30) {
return Api30Impl.getSubscriptionId(telephonyManager);
}
if (Build.VERSION.SDK_INT < 22) {
return Integer.MAX_VALUE;
}
try {
if (sGetSubIdMethod == null) {
Method declaredMethod = TelephonyManager.class.getDeclaredMethod("getSubId", new Class[0]);
sGetSubIdMethod = declaredMethod;
declaredMethod.setAccessible(true);
}
Integer num = (Integer) sGetSubIdMethod.invoke(telephonyManager, new Object[0]);
if (num == null || num.intValue() == -1) {
return Integer.MAX_VALUE;
}
return num.intValue();
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException unused) {
return Integer.MAX_VALUE;
}
}
private TelephonyManagerCompat() {
}
private static class Api30Impl {
private Api30Impl() {
}
static int getSubscriptionId(TelephonyManager telephonyManager) {
return telephonyManager.getSubscriptionId();
}
}
private static class Api26Impl {
private Api26Impl() {
}
static String getImei(TelephonyManager telephonyManager) {
return telephonyManager.getImei();
}
}
private static class Api23Impl {
private Api23Impl() {
}
static String getDeviceId(TelephonyManager telephonyManager, int i) {
return telephonyManager.getDeviceId(i);
}
}
}

View File

@ -0,0 +1,45 @@
package androidx.core.telephony.mbms;
import android.content.Context;
import android.os.Build;
import android.telephony.mbms.ServiceInfo;
import java.util.Iterator;
import java.util.Locale;
import java.util.Set;
/* loaded from: classes.dex */
public final class MbmsHelper {
private MbmsHelper() {
}
public static CharSequence getBestNameForService(Context context, ServiceInfo serviceInfo) {
if (Build.VERSION.SDK_INT >= 28) {
return Api28Impl.getBestNameForService(context, serviceInfo);
}
return null;
}
static class Api28Impl {
private Api28Impl() {
}
static CharSequence getBestNameForService(Context context, ServiceInfo serviceInfo) {
Set<Locale> namedContentLocales = serviceInfo.getNamedContentLocales();
if (namedContentLocales.isEmpty()) {
return null;
}
String[] strArr = new String[namedContentLocales.size()];
Iterator<Locale> it = serviceInfo.getNamedContentLocales().iterator();
int i = 0;
while (it.hasNext()) {
strArr[i] = it.next().toLanguageTag();
i++;
}
Locale firstMatch = context.getResources().getConfiguration().getLocales().getFirstMatch(strArr);
if (firstMatch == null) {
return null;
}
return serviceInfo.getNameForLocale(firstMatch);
}
}
}