hn.java 源代码
package com.inmobi.media;
import android.app.Activity;
import android.content.Context;
import android.graphics.Insets;
import android.util.DisplayMetrics;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import java.util.HashMap;
import java.util.Map;
public class hn {
private static final String f15722a = "hn";
private static String f15723b;
public static int b(int i6) {
return Math.round(i6 / a().f15728c);
}
public static Map<String, String> c() {
String str;
HashMap hashMap = new HashMap();
try {
hashMap.put("d-device-screen-density", String.valueOf(a().f15728c));
ho a7 = a();
hashMap.put("d-device-screen-size", a7.f15726a + "X" + a7.f15727b);
Context c6 = gy.c();
if (c6 == null) {
str = "0x0";
} else {
DisplayMetrics displayMetrics = new DisplayMetrics();
((WindowManager) c6.getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics);
str = displayMetrics.widthPixels + "x" + displayMetrics.heightPixels;
}
hashMap.put("d-density-dependent-screen-size", str);
hashMap.put("d-orientation", String.valueOf((int) b()));
hashMap.put("d-textsize", String.valueOf(new TextView(gy.c()).getTextSize()));
} catch (Exception unused) {
}
return hashMap;
}
@Nullable
public static String d() {
String b6;
String str = f15723b;
if (str != null) {
return str;
}
Context c6 = gy.c();
if (c6 == null) {
b6 = null;
} else {
b6 = gt.a(c6, "gesture_info_store").b("gesture_margin");
}
f15723b = b6;
return b6;
}
public static int a(int i6) {
return Math.round(i6 * a().f15728c);
}
public static byte b() {
Context c6 = gy.c();
if (c6 == null) {
return (byte) 1;
}
int rotation = ((WindowManager) c6.getSystemService("window")).getDefaultDisplay().getRotation();
int i6 = c6.getResources().getConfiguration().orientation;
if (i6 == 1) {
return (rotation == 1 || rotation == 2) ? (byte) 2 : (byte) 1;
}
if (i6 != 2) {
return (byte) 1;
}
return (rotation == 0 || rotation == 1) ? (byte) 3 : (byte) 4;
}
public static ho a() {
Context c6 = gy.c();
if (c6 == null) {
return new ho(0, 0, 2.0f);
}
DisplayMetrics displayMetrics = new DisplayMetrics();
((WindowManager) c6.getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics);
float f6 = displayMetrics.density;
return new ho(Math.round(displayMetrics.widthPixels / f6), Math.round(displayMetrics.heightPixels / f6), f6);
}
@RequiresApi(api = 29)
public static void a(Context context) {
WindowInsets rootWindowInsets;
if (!(context instanceof Activity) || (r0 = ((Activity) context).getWindow()) == null || rootWindowInsets == null) {
return;
}
a(context, rootWindowInsets);
}
@RequiresApi(api = 29)
public static void a(final Context context, final WindowInsets windowInsets) {
gy.a(new Runnable() {
@Override
public final void run() {
Insets systemGestureInsets;
String insets;
try {
systemGestureInsets = windowInsets.getSystemGestureInsets();
insets = systemGestureInsets.toString();
String[] split = insets.split("Insets");
StringBuffer stringBuffer = new StringBuffer();
if (split.length > 1) {
String[] split2 = split[1].replaceAll("[^0-9,=a-zA-Z]*", "").split(",");
stringBuffer.append("{");
for (int i6 = 0; i6 < split2.length; i6++) {
String[] split3 = split2[i6].split("=");
if (split3.length == 2) {
stringBuffer.append("\"" + split3[0] + "\"");
stringBuffer.append(":");
stringBuffer.append(hn.b(Integer.parseInt(split3[1])));
if (i6 < split2.length - 1) {
stringBuffer.append(", ");
}
}
}
stringBuffer.append("}");
}
if (stringBuffer.length() > 0) {
String unused = hn.f15723b = stringBuffer.toString();
gt.a(context, "gesture_info_store").a("gesture_margin", stringBuffer.toString());
}
} catch (Exception unused2) {
String unused3 = hn.f15722a;
}
}
});
}
}