- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
233 lines
9.0 KiB
Java
233 lines
9.0 KiB
Java
package androidx.core.view;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.app.UiModeManager;
|
|
import android.content.Context;
|
|
import android.graphics.Point;
|
|
import android.os.Build;
|
|
import android.text.TextUtils;
|
|
import android.view.Display;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RequiresApi;
|
|
import androidx.core.util.Preconditions;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class DisplayCompat {
|
|
private static final int DISPLAY_SIZE_4K_HEIGHT = 2160;
|
|
private static final int DISPLAY_SIZE_4K_WIDTH = 3840;
|
|
|
|
private DisplayCompat() {
|
|
}
|
|
|
|
@NonNull
|
|
public static ModeCompat getMode(@NonNull Context context, @NonNull Display display) {
|
|
return Api23Impl.getMode(context, display);
|
|
}
|
|
|
|
@NonNull
|
|
private static Point getDisplaySize(@NonNull Context context, @NonNull Display display) {
|
|
Point currentDisplaySizeFromWorkarounds = getCurrentDisplaySizeFromWorkarounds(context, display);
|
|
if (currentDisplaySizeFromWorkarounds != null) {
|
|
return currentDisplaySizeFromWorkarounds;
|
|
}
|
|
Point point = new Point();
|
|
display.getRealSize(point);
|
|
return point;
|
|
}
|
|
|
|
@NonNull
|
|
@SuppressLint({"ArrayReturn"})
|
|
public static ModeCompat[] getSupportedModes(@NonNull Context context, @NonNull Display display) {
|
|
return Api23Impl.getSupportedModes(context, display);
|
|
}
|
|
|
|
private static Point parseDisplaySize(@NonNull String str) throws NumberFormatException {
|
|
String[] split = str.trim().split("x", -1);
|
|
if (split.length == 2) {
|
|
int parseInt = Integer.parseInt(split[0]);
|
|
int parseInt2 = Integer.parseInt(split[1]);
|
|
if (parseInt > 0 && parseInt2 > 0) {
|
|
return new Point(parseInt, parseInt2);
|
|
}
|
|
}
|
|
throw new NumberFormatException();
|
|
}
|
|
|
|
@Nullable
|
|
private static String getSystemProperty(String str) {
|
|
try {
|
|
Class<?> cls = Class.forName("android.os.SystemProperties");
|
|
return (String) cls.getMethod("get", String.class).invoke(cls, str);
|
|
} catch (Exception unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private static boolean isTv(@NonNull Context context) {
|
|
UiModeManager uiModeManager = (UiModeManager) context.getSystemService("uimode");
|
|
return uiModeManager != null && uiModeManager.getCurrentModeType() == 4;
|
|
}
|
|
|
|
@Nullable
|
|
private static Point parsePhysicalDisplaySizeFromSystemProperties(@NonNull String str, @NonNull Display display) {
|
|
if (display.getDisplayId() != 0) {
|
|
return null;
|
|
}
|
|
String systemProperty = getSystemProperty(str);
|
|
if (!TextUtils.isEmpty(systemProperty) && systemProperty != null) {
|
|
try {
|
|
return parseDisplaySize(systemProperty);
|
|
} catch (NumberFormatException unused) {
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static Point getCurrentDisplaySizeFromWorkarounds(@NonNull Context context, @NonNull Display display) {
|
|
Point parsePhysicalDisplaySizeFromSystemProperties;
|
|
if (Build.VERSION.SDK_INT < 28) {
|
|
parsePhysicalDisplaySizeFromSystemProperties = parsePhysicalDisplaySizeFromSystemProperties("sys.display-size", display);
|
|
} else {
|
|
parsePhysicalDisplaySizeFromSystemProperties = parsePhysicalDisplaySizeFromSystemProperties("vendor.display-size", display);
|
|
}
|
|
if (parsePhysicalDisplaySizeFromSystemProperties != null) {
|
|
return parsePhysicalDisplaySizeFromSystemProperties;
|
|
}
|
|
if (isSonyBravia4kTv(context) && isCurrentModeTheLargestMode(display)) {
|
|
return new Point(DISPLAY_SIZE_4K_WIDTH, DISPLAY_SIZE_4K_HEIGHT);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private static boolean isSonyBravia4kTv(@NonNull Context context) {
|
|
return isTv(context) && "Sony".equals(Build.MANUFACTURER) && Build.MODEL.startsWith("BRAVIA") && context.getPackageManager().hasSystemFeature("com.sony.dtv.hardware.panel.qfhd");
|
|
}
|
|
|
|
public static boolean isCurrentModeTheLargestMode(@NonNull Display display) {
|
|
return Api23Impl.isCurrentModeTheLargestMode(display);
|
|
}
|
|
|
|
@RequiresApi(23)
|
|
public static class Api23Impl {
|
|
private Api23Impl() {
|
|
}
|
|
|
|
@NonNull
|
|
public static ModeCompat getMode(@NonNull Context context, @NonNull Display display) {
|
|
Display.Mode mode = display.getMode();
|
|
Point currentDisplaySizeFromWorkarounds = DisplayCompat.getCurrentDisplaySizeFromWorkarounds(context, display);
|
|
if (currentDisplaySizeFromWorkarounds == null || physicalSizeEquals(mode, currentDisplaySizeFromWorkarounds)) {
|
|
return new ModeCompat(mode, true);
|
|
}
|
|
return new ModeCompat(mode, currentDisplaySizeFromWorkarounds);
|
|
}
|
|
|
|
@NonNull
|
|
@SuppressLint({"ArrayReturn"})
|
|
public static ModeCompat[] getSupportedModes(@NonNull Context context, @NonNull Display display) {
|
|
ModeCompat modeCompat;
|
|
Display.Mode[] supportedModes = display.getSupportedModes();
|
|
ModeCompat[] modeCompatArr = new ModeCompat[supportedModes.length];
|
|
Display.Mode mode = display.getMode();
|
|
Point currentDisplaySizeFromWorkarounds = DisplayCompat.getCurrentDisplaySizeFromWorkarounds(context, display);
|
|
if (currentDisplaySizeFromWorkarounds == null || physicalSizeEquals(mode, currentDisplaySizeFromWorkarounds)) {
|
|
for (int i = 0; i < supportedModes.length; i++) {
|
|
modeCompatArr[i] = new ModeCompat(supportedModes[i], physicalSizeEquals(supportedModes[i], mode));
|
|
}
|
|
} else {
|
|
for (int i2 = 0; i2 < supportedModes.length; i2++) {
|
|
if (physicalSizeEquals(supportedModes[i2], mode)) {
|
|
modeCompat = new ModeCompat(supportedModes[i2], currentDisplaySizeFromWorkarounds);
|
|
} else {
|
|
modeCompat = new ModeCompat(supportedModes[i2], false);
|
|
}
|
|
modeCompatArr[i2] = modeCompat;
|
|
}
|
|
}
|
|
return modeCompatArr;
|
|
}
|
|
|
|
public static boolean isCurrentModeTheLargestMode(@NonNull Display display) {
|
|
Display.Mode mode = display.getMode();
|
|
for (Display.Mode mode2 : display.getSupportedModes()) {
|
|
if (mode.getPhysicalHeight() < mode2.getPhysicalHeight() || mode.getPhysicalWidth() < mode2.getPhysicalWidth()) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static boolean physicalSizeEquals(Display.Mode mode, Point point) {
|
|
return (mode.getPhysicalWidth() == point.x && mode.getPhysicalHeight() == point.y) || (mode.getPhysicalWidth() == point.y && mode.getPhysicalHeight() == point.x);
|
|
}
|
|
|
|
public static boolean physicalSizeEquals(Display.Mode mode, Display.Mode mode2) {
|
|
return mode.getPhysicalWidth() == mode2.getPhysicalWidth() && mode.getPhysicalHeight() == mode2.getPhysicalHeight();
|
|
}
|
|
}
|
|
|
|
public static final class ModeCompat {
|
|
private final boolean mIsNative;
|
|
private final Display.Mode mMode;
|
|
private final Point mPhysicalSize;
|
|
|
|
@Deprecated
|
|
public boolean isNative() {
|
|
return this.mIsNative;
|
|
}
|
|
|
|
@Nullable
|
|
@RequiresApi(23)
|
|
public Display.Mode toMode() {
|
|
return this.mMode;
|
|
}
|
|
|
|
public ModeCompat(@NonNull Point point) {
|
|
Preconditions.checkNotNull(point, "physicalSize == null");
|
|
this.mPhysicalSize = point;
|
|
this.mMode = null;
|
|
this.mIsNative = true;
|
|
}
|
|
|
|
@RequiresApi(23)
|
|
public ModeCompat(@NonNull Display.Mode mode, boolean z) {
|
|
Preconditions.checkNotNull(mode, "mode == null, can't wrap a null reference");
|
|
this.mPhysicalSize = new Point(Api23Impl.getPhysicalWidth(mode), Api23Impl.getPhysicalHeight(mode));
|
|
this.mMode = mode;
|
|
this.mIsNative = z;
|
|
}
|
|
|
|
@RequiresApi(23)
|
|
public ModeCompat(@NonNull Display.Mode mode, @NonNull Point point) {
|
|
Preconditions.checkNotNull(mode, "mode == null, can't wrap a null reference");
|
|
Preconditions.checkNotNull(point, "physicalSize == null");
|
|
this.mPhysicalSize = point;
|
|
this.mMode = mode;
|
|
this.mIsNative = true;
|
|
}
|
|
|
|
public int getPhysicalWidth() {
|
|
return this.mPhysicalSize.x;
|
|
}
|
|
|
|
public int getPhysicalHeight() {
|
|
return this.mPhysicalSize.y;
|
|
}
|
|
|
|
@RequiresApi(23)
|
|
public static class Api23Impl {
|
|
private Api23Impl() {
|
|
}
|
|
|
|
public static int getPhysicalWidth(Display.Mode mode) {
|
|
return mode.getPhysicalWidth();
|
|
}
|
|
|
|
public static int getPhysicalHeight(Display.Mode mode) {
|
|
return mode.getPhysicalHeight();
|
|
}
|
|
}
|
|
}
|
|
}
|