正在查看: Jurassic World v1.83.4 应用的 GameActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Jurassic World v1.83.4 应用的 GameActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.ludia.engine.application;
import android.app.Activity;
import android.app.KeyguardManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.hardware.display.DisplayManager;
import android.net.Uri;
import android.opengl.GLES20;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.os.PowerManager;
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.window.OnBackInvokedCallback;
import com.google.protobuf.Reader;
import com.vungle.ads.VungleError;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.IntBuffer;
import java.util.Hashtable;
import java.util.Locale;
public class GameActivity extends Activity {
private static final int GA_NOTIFICATION_TYPE_LOCAL = 1;
private static final int GA_NOTIFICATION_TYPE_PUSH = 2;
private static boolean s_loadedJni = false;
private Hashtable<Integer, IActivityResultCallback> m_activityCb;
private ProgressBar m_activityIndicator;
private ActivityInfo m_activityInfo;
private Runnable m_cappedLoop;
private ContentObserver m_contentObserver;
private int m_deadChar;
private DebugView m_debugView;
private DelayedEvents m_delayedEvents;
private DelayedShowSurfaceCb m_delayedShowSurfaceCb;
private boolean m_delayedShowSurfaceOnStart;
private DisplayCb m_displayCb;
private DisplayManager m_displayManager;
private boolean m_hpe;
private Locale m_locale;
private LockCb m_lockCb;
private IntentFilter m_lockCbFilter;
private boolean m_locked;
private MotionDevice m_motion;
private MotionCb m_motionCb;
private String m_notificationContent;
private String m_notificationParam;
private String m_notificationSource;
private int m_notificationType;
private RelativeLayout m_rootLayout;
private float m_screenScale;
private SurfaceView m_surfaceView;
private int m_surfaceViewVisibilityCount;
private int m_screenRotation = 0;
private boolean m_deferNotification = false;
private boolean m_hasDoneShutDown = false;
private boolean m_requestFinish = false;
private final String m_createDebugViewKey = "DebugView";
private native void initializeFileManagerInternal(AssetManager assetManager, String str, String str2);
public native void activateSurfaceWatchdog();
public native void notifyChar(int i);
public native void notifyKeyEvent(int i, boolean z, int i2);
public native boolean notifyMotionEvent(int i, int i2, int i3, int[] iArr, float[] fArr);
public native void notifyUrlOpened(String str);
@Override
public void onBackPressed() {
}
public native void onNotificationInternal(int i, String str, String str2, String str3);
public native void onPauseInternal();
public native void onRequestPermissionsResultInternal(int i, String[] strArr, int[] iArr);
public native void onRestartInternal();
public native void onResumeInternal();
public native void onStartInternal();
public native void onStopInternal();
public native void postGraphicsInit();
public native void preGraphicsInit();
public native void setLocaleInfo(Locale locale);
public native void setRenderingSurface(Surface surface, boolean z);
public native void setScreenLocked(boolean z);
public native void setScreenOrientation(int i);
public native void setScreenScale(float f);
public native void shutdown();
public native void update();
public native void verifyCampaignLaunch(String str);
public void initializeFileManager() {
initializeFileManagerInternal(getAssets(), getFilesDir().getAbsolutePath(), getCacheDir().getAbsolutePath());
}
public void UiChangeListener() {
final View decorView = getWindow().getDecorView();
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int i) {
if ((i & 4) == 0) {
decorView.setSystemUiVisibility(5894);
}
}
});
}
@Override
protected void onCreate(Bundle bundle) {
Object[] objArr = new Object[1];
objArr[0] = Boolean.valueOf(bundle != null);
Application.trace("GameActivity.onCreate() with bundle %b", objArr);
Object[] objArr2 = 0;
Object[] objArr3 = 0;
if (!s_loadedJni) {
bundle = null;
}
PackageManager packageManager = getPackageManager();
Intent intent = getIntent();
try {
this.m_activityInfo = getPackageManager().getActivityInfo(intent.getComponent(), 128);
} catch (PackageManager.NameNotFoundException unused) {
}
super.onCreate(bundle);
ActivityManager.setActivity(this);
if (bundle != null) {
ActivityManager.onRecreate();
} else {
loadJniLibrary();
ActivityManager.onCreate();
}
getWindow().setBackgroundDrawable(null);
RelativeLayout relativeLayout = new RelativeLayout(this);
this.m_rootLayout = relativeLayout;
addContentView(relativeLayout, new ViewGroup.LayoutParams(-1, -1));
SurfaceView surfaceView = new SurfaceView(this);
this.m_surfaceView = surfaceView;
this.m_surfaceViewVisibilityCount = 1;
addView(surfaceView);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-2, -2);
layoutParams.addRule(13, -1);
ProgressBar progressBar = new ProgressBar(this);
this.m_activityIndicator = progressBar;
progressBar.setIndeterminate(true);
this.m_activityIndicator.setLayoutParams(layoutParams);
this.m_activityIndicator.setVisibility(8);
this.m_rootLayout.addView(this.m_activityIndicator, layoutParams);
this.m_hpe = packageManager.hasSystemFeature("com.google.android.play.feature.HPE_EXPERIENCE");
this.m_delayedShowSurfaceCb = new DelayedShowSurfaceCb();
this.m_lockCb = new LockCb();
IntentFilter intentFilter = new IntentFilter();
this.m_lockCbFilter = intentFilter;
intentFilter.addAction("android.intent.action.SCREEN_OFF");
this.m_lockCbFilter.addAction("android.intent.action.SCREEN_ON");
this.m_lockCbFilter.addAction("android.intent.action.USER_PRESENT");
registerReceiver(this.m_lockCb, this.m_lockCbFilter);
this.m_displayManager = (DisplayManager) getSystemService("display");
this.m_displayCb = new DisplayCb();
this.m_motion = new MotionDevice();
this.m_motionCb = new MotionCb();
this.m_activityCb = new Hashtable<>();
if (bundle == null) {
preGraphicsInit();
}
initializeEngineStuff(bundle == null);
if ("android.intent.action.VIEW".equals(intent.getAction())) {
String dataString = intent.getDataString();
Application.trace("GameActivity.onCreate Intent.ACTION_VIEW(%s)", dataString);
if (dataString != null && dataString.length() > 0) {
verifyCampaignLaunch(dataString);
}
}
if (bundle != null && bundle.getBoolean("DebugView")) {
createDebugView();
}
hideSystemBars();
UiChangeListener();
checkForPushNotification(intent, true);
setOnBackPressedCallback();
}
private void loadJniLibrary() {
if (s_loadedJni) {
return;
}
try {
ActivityInfo activityInfo = this.m_activityInfo;
if (activityInfo != null) {
String string = activityInfo.applicationInfo.metaData.getString("com.ludia.engine.application.additionalSoName");
if (string != null) {
Log.d("LudiaSDK/JNI", String.format("Loading additional JNI library \"%s\".", string));
System.loadLibrary(string);
}
String string2 = this.m_activityInfo.metaData.getString("com.ludia.engine.application.soname");
Log.d("LudiaSDK/JNI", String.format("Loading JNI library \"%s\".", string2));
System.loadLibrary(string2);
s_loadedJni = true;
}
} catch (UnsatisfiedLinkError e) {
e.printStackTrace();
}
}
@Override
public void onWindowFocusChanged(boolean z) {
super.onWindowFocusChanged(z);
if (z) {
hideSystemBarsWithDelay();
onResumeInternal();
} else {
onPauseInternal();
}
}
public void hideSystemBarsWithDelay() {
Application.trace("Hide system bars in 200ms", new Object[0]);
hideSystemBarsWithDelay(100, true);
hideSystemBarsWithDelay(VungleError.INVALID_EVENT_ID_ERROR, false);
}
public void hideSystemBarsWithDelay(int i, final boolean z) {
Application.getHandler().postDelayed(new Runnable() {
@Override
public void run() {
if (z) {
GameActivity.this.hideSystemBarsResetStep();
} else {
GameActivity.this.hideSystemBars();
}
}
}, i);
}
public void hideSystemBarsResetStep() {
Application.trace("Resetting system bars visibility", new Object[0]);
getWindow().getDecorView().setSystemUiVisibility(0);
}
public void hideSystemBars() {
Application.trace("Attempting to hide system bars", new Object[0]);
getWindow().getDecorView().setSystemUiVisibility(5894);
}
public MotionDevice getMotionDevice() {
return this.m_motion;
}
public String getLaunchArguments() {
return getIntent().getStringExtra("args");
}
public static String getLocaleScript() {
for (Locale locale : Locale.getAvailableLocales()) {
if (locale.getLanguage().equals(Locale.getDefault().getLanguage()) && locale.getCountry().equals(Locale.getDefault().getCountry())) {
return locale.getScript();
}
}
return "";
}
public Bitmap makeScreenshot() {
Point point = new Point();
getWindowManager().getDefaultDisplay().getSize(point);
int[] iArr = new int[point.x * point.y];
int[] iArr2 = new int[point.x * point.y];
IntBuffer wrap = IntBuffer.wrap(iArr);
wrap.position(0);
GLES20.glReadPixels(0, 0, point.x, point.y, 6408, 5121, wrap);
int i = 0;
int i2 = 0;
while (i < point.y) {
for (int i3 = 0; i3 < point.x; i3++) {
int i4 = iArr[(point.x * i) + i3];
iArr2[(((point.y - i2) - 1) * point.x) + i3] = (i4 & (-16711936)) | ((i4 << 16) & (-65536)) | ((i4 >> 16) & 255);
}
i++;
i2++;
}
return Bitmap.createBitmap(iArr2, point.x, point.y, Bitmap.Config.ARGB_8888);
}
public void saveScreenshotPNG(String str) {
try {
FileOutputStream fileOutputStream = new FileOutputStream(str);
makeScreenshot().compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public String createWorldReadableFolder(String str) {
File file = new File(getExternalFilesDir(null), str);
file.mkdirs();
return file.getAbsolutePath().replaceFirst(Environment.getExternalStorageDirectory().getAbsolutePath(), System.getenv("EXTERNAL_STORAGE"));
}
public void createDebugView() {
DebugView debugView = new DebugView(this);
this.m_debugView = debugView;
debugView.setVisibility(8);
addView(this.m_debugView);
}
protected boolean isDebugViewVisible() {
DebugView debugView = this.m_debugView;
return debugView != null && debugView.getVisibility() == 0;
}
protected void showDebugView() {
DebugView debugView = this.m_debugView;
if (debugView == null) {
return;
}
debugView.setVisibility(0);
this.m_debugView.bringToFront();
}
protected void hideDebugView() {
DebugView debugView = this.m_debugView;
if (debugView == null) {
return;
}
debugView.setVisibility(4);
}
protected void toggleDebugView() {
DebugView debugView = this.m_debugView;
if (debugView == null) {
return;
}
if (debugView.getVisibility() == 0) {
hideDebugView();
} else {
showDebugView();
}
}
public void updateCustomStatInt(String str, int i, int i2, int i3) {
this.m_debugView.addStatInt(str, i, i2, i3);
}
public void updateCustomStatFloat(String str, int i, float f, int i2) {
this.m_debugView.addStatFloat(str, i, f, i2);
}
public void updateCustomStatBoolean(String str, int i, boolean z, int i2) {
this.m_debugView.addStatBoolean(str, i, z, i2);
}
public void updateCustomStatString(String str, int i, String str2, int i2) {
this.m_debugView.addStatString(str, i, str2, i2);
}
public void updateGraph(int i, float[] fArr, float f, int i2) {
this.m_debugView.addGraph(i, fArr, f, i2);
}
public void flushCustomStat() {
this.m_debugView.flushStat();
}
private void updateDebugView() {
this.m_debugView.invalidate();
}
public void startLoop(final int i) {
Application.trace("startLoop(%d)", Integer.valueOf(i));
if (this.m_hasDoneShutDown) {
Application.trace("Abording, game has shut down", new Object[0]);
return;
}
stopLoop();
this.m_cappedLoop = new Runnable() {
@Override
public void run() {
if (GameActivity.this.m_hasDoneShutDown) {
return;
}
if (GameActivity.this.m_requestFinish) {
if (!GameActivity.this.m_hasDoneShutDown) {
GameActivity.this.m_hasDoneShutDown = true;
GameActivity.this.shutdown();
}
GameActivity.this.stopLoop();
GameActivity.this.finish();
return;
}
Application.getHandler().postDelayed(this, i);
GameActivity.this.update();
}
};
Application.getHandler().postDelayed(this.m_cappedLoop, i);
}
public void stopLoop() {
if (this.m_cappedLoop != null) {
Application.getHandler().removeCallbacks(this.m_cappedLoop);
}
this.m_cappedLoop = null;
}
public void postFinish() {
Application.trace("postFinish()", new Object[0]);
this.m_requestFinish = true;
}
protected void checkForPushNotification(Intent intent) {
checkForPushNotification(intent, !isGraphicsInitialized());
}
protected void checkForPushNotification(Intent intent, boolean z) {
if (intent != null) {
int i = 0;
if (intent.getBooleanExtra("LocalNotification", false)) {
i = 1;
} else if (intent.getBooleanExtra("PushNotification", false)) {
i = 2;
}
if (i > 0) {
String stringExtra = intent.getExtras().containsKey("content") ? intent.getStringExtra("content") : "";
String stringExtra2 = intent.getExtras().containsKey("utm_source") ? intent.getStringExtra("utm_source") : "";
String stringExtra3 = intent.getExtras().containsKey("utm_param") ? intent.getStringExtra("utm_param") : "";
if (z) {
this.m_deferNotification = true;
this.m_notificationType = i;
this.m_notificationContent = stringExtra;
this.m_notificationSource = stringExtra2;
this.m_notificationParam = stringExtra3;
return;
}
onNotificationInternal(i, stringExtra, stringExtra2, stringExtra3);
}
}
}
@Override
protected void onStart() {
Application.trace("GameActivity.onStart()", new Object[0]);
ActivityManager.onStart();
super.onStart();
this.m_displayManager.registerDisplayListener(this.m_displayCb, null);
this.m_motion.onStart();
if (this.m_delayedShowSurfaceOnStart) {
setSurfaceViewVisibleDelayed();
this.m_delayedShowSurfaceOnStart = false;
}
setScreenOrientation(getResources().getConfiguration().orientation);
if (isGraphicsInitialized()) {
onStartInternal();
} else {
this.m_delayedEvents.m_doStart = true;
}
}
@Override
protected void onRestart() {
Application.trace("GameActivity.onRestart()", new Object[0]);
ActivityManager.onRestart();
super.onRestart();
if (isGraphicsInitialized()) {
onRestartInternal();
}
}
@Override
protected void onResume() {
Application.trace("GameActivity.onResume()", new Object[0]);
AutoRotationHandler.manageRotation(this);
this.m_contentObserver = new ContentObserver(new Handler(Looper.getMainLooper())) {
@Override
public void onChange(boolean z) {
AutoRotationHandler.manageRotation(GameActivity.this);
}
};
getContentResolver().registerContentObserver(Settings.System.getUriFor("accelerometer_rotation"), true, this.m_contentObserver);
ActivityManager.onResume();
super.onResume();
if (isGraphicsInitialized()) {
onResumeInternal();
} else {
this.m_delayedEvents.m_doResume = true;
}
}
@Override
public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
Application.trace("GameActivity.onRequestPermissions()", new Object[0]);
onRequestPermissionsResultInternal(i, strArr, iArr);
}
@Override
protected void onSaveInstanceState(Bundle bundle) {
super.onSaveInstanceState(bundle);
bundle.putBoolean("DebugView", this.m_debugView != null);
}
@Override
protected void onPause() {
Application.trace("GameActivity.onPause()", new Object[0]);
ActivityManager.onPause();
this.m_deadChar = 0;
super.onPause();
if (this.m_hasDoneShutDown) {
return;
}
if (isGraphicsInitialized()) {
onPauseInternal();
} else {
this.m_delayedEvents.m_doResume = false;
}
getContentResolver().unregisterContentObserver(this.m_contentObserver);
}
@Override
protected void onStop() {
Application.trace("GameActivity.onStop()", new Object[0]);
ActivityManager.onStop();
if (!this.m_delayedShowSurfaceOnStart) {
setSurfaceViewVisibility(false);
this.m_delayedShowSurfaceOnStart = true;
}
this.m_motion.onStop();
this.m_displayManager.unregisterDisplayListener(this.m_displayCb);
if (isGraphicsInitialized()) {
onStopInternal();
} else {
this.m_delayedEvents.m_doStart = false;
}
super.onStop();
}
@Override
protected void onDestroy() {
Application.trace("GameActivity.onDestroy()", new Object[0]);
ActivityManager.onDestroy();
unregisterReceiver(this.m_lockCb);
if (isFinishing()) {
stopLoop();
this.m_hasDoneShutDown = true;
shutdown();
}
super.onDestroy();
}
@Override
public void onConfigurationChanged(Configuration configuration) {
Application.trace("GameActivity.onConfigurationChanged()", new Object[0]);
super.onConfigurationChanged(configuration);
setScreenOrientation(configuration.orientation);
Locale locale = configuration.getLocales().get(0);
if (Locale.getDefault().getLanguage().equals(Locale.getDefault().getLanguage()) && Locale.getDefault().getCountry().equals(Locale.getDefault().getCountry())) {
return;
}
this.m_locale = locale;
setLocaleInfo(locale);
}
@Override
public boolean onKeyDown(int i, KeyEvent keyEvent) {
boolean z;
Application.trace("GameActivity.onKeyDown(%d, %s)", Integer.valueOf(i), keyEvent);
if (this.m_debugView != null) {
int repeatCount = keyEvent.getRepeatCount();
if (repeatCount == 1 && keyEvent.isLongPress()) {
if (i != 24) {
if (i != 25) {
if (i == 82) {
toggleDebugView();
return true;
}
} else if (isDebugViewVisible()) {
hideDebugView();
return true;
}
} else if (!isDebugViewVisible()) {
showDebugView();
return true;
}
} else if (repeatCount == 0) {
if (i != 43) {
if (i != 44) {
if (i == 133) {
toggleDebugView();
return true;
}
} else if (isDebugViewVisible()) {
this.m_debugView.nextGroup();
this.m_debugView.invalidate();
return true;
}
} else if (isDebugViewVisible()) {
this.m_debugView.previousGroup();
this.m_debugView.invalidate();
return true;
}
}
}
if (Keyboard.isKeyHandled(i)) {
notifyKeyEvent(i, true, keyEvent.getRepeatCount());
z = true;
} else {
z = false;
}
int unicodeChar = keyEvent.getUnicodeChar();
if (unicodeChar != 0) {
int i2 = this.m_deadChar;
if (i2 != 0) {
int i3 = unicodeChar & Reader.READ_DONE;
this.m_deadChar = 0;
keyEvent.getKeyCharacterMap();
int deadChar = KeyCharacterMap.getDeadChar(i2, i3);
if (deadChar == 0) {
notifyChar(i2);
notifyChar(i3);
return true;
}
notifyChar(deadChar);
return true;
}
int i4 = unicodeChar & Reader.READ_DONE;
if ((unicodeChar & Integer.MIN_VALUE) == 0) {
notifyChar(i4);
return true;
}
this.m_deadChar = i4;
}
return z;
}
@Override
public boolean onKeyUp(int i, KeyEvent keyEvent) {
Application.trace("GameActivity.onKeyUp(%d, %s)", Integer.valueOf(i), keyEvent);
if (!Keyboard.isKeyHandled(i)) {
return false;
}
notifyKeyEvent(i, false, 0);
return true;
}
@Override
protected void onNewIntent(Intent intent) {
String dataString = intent.getDataString();
Application.trace("GameActivity.onNewIntent(%s)", dataString);
if (dataString != null && dataString.length() > 0) {
verifyCampaignLaunch(dataString);
notifyUrlOpened(dataString);
}
checkForPushNotification(intent);
}
@Override
protected void onActivityResult(int i, int i2, Intent intent) {
Application.trace("GameActivity.onActivityResult(%d, %d)", Integer.valueOf(i), Integer.valueOf(i2));
IActivityResultCallback iActivityResultCallback = this.m_activityCb.get(Integer.valueOf(i));
if (iActivityResultCallback != null) {
iActivityResultCallback.onActivityResult(i, i2, intent);
}
}
public float getScreenScale() {
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
return displayMetrics.density;
}
private void initializeEngineStuff(final boolean z) {
setVolumeControlStream(3);
this.m_screenScale = getScreenScale();
this.m_delayedEvents = new DelayedEvents();
this.m_surfaceView.getHolder().addCallback(new SurfaceCb() {
{
super();
}
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
Application.trace("GameActivity.SurfaceCb.surfaceCreated first time override", new Object[0]);
GameActivity.this.setRenderingSurface(surfaceHolder.getSurface(), !z);
if (z) {
GameActivity.this.postGraphicsInit();
}
GameActivity.this.m_delayedEvents.ApplyEvents();
GameActivity.this.m_delayedEvents = null;
GameActivity.this.m_surfaceView.getHolder().removeCallback(this);
GameActivity.this.m_surfaceView.getHolder().addCallback(new SurfaceCb());
}
});
enableMotionRelay(this.m_surfaceView);
}
private void setOnBackPressedCallback() {
if (Build.VERSION.SDK_INT >= 33) {
getOnBackInvokedDispatcher().registerOnBackInvokedCallback(1000000, new OnBackInvokedCallback() {
@Override
public void onBackInvoked() {
Application.trace("GameActivity.BackInvokedCb.onBackInvoked", new Object[0]);
if (Keyboard.isKeyHandled(4)) {
GameActivity.this.notifyKeyEvent(4, true, 1);
GameActivity.this.notifyKeyEvent(4, false, 0);
}
}
});
}
}
private boolean isGraphicsInitialized() {
return this.m_delayedEvents == null;
}
private static RelativeLayout.LayoutParams makeLayoutParams(int i, int i2, int i3, int i4, boolean z) {
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(i3, i4);
layoutParams.leftMargin = i;
layoutParams.topMargin = i2;
if (z) {
layoutParams.addRule(13);
}
return layoutParams;
}
public void setSurfaceViewVisibleDelayed() {
Application.trace("Posting delated surface show in 50ms.", new Object[0]);
Application.getHandler().postDelayed(this.m_delayedShowSurfaceCb, 50L);
}
public boolean setSurfaceViewVisibility(boolean z) {
if (z) {
int i = this.m_surfaceViewVisibilityCount + 1;
this.m_surfaceViewVisibilityCount = i;
Application.trace("Attempting to show surface view, show count = %d", Integer.valueOf(i));
if (this.m_surfaceViewVisibilityCount == 1) {
this.m_surfaceView.setVisibility(0);
}
} else {
int i2 = this.m_surfaceViewVisibilityCount - 1;
this.m_surfaceViewVisibilityCount = i2;
Application.trace("Attempting to hide surface view, show count = %d", Integer.valueOf(i2));
if (this.m_surfaceViewVisibilityCount == 0) {
this.m_surfaceView.setVisibility(4);
}
}
return this.m_surfaceViewVisibilityCount > 0;
}
public void pulseSurfaceViewVisibility() {
Application.trace("Attempting to nudge surface view into working properly.", new Object[0]);
setSurfaceViewVisibility(false);
setSurfaceViewVisibleDelayed();
}
private void bringDebugViewToFront(View view) {
DebugView debugView = this.m_debugView;
if (debugView == null || debugView == view) {
return;
}
debugView.bringToFront();
}
public DebugView getDebugView() {
return this.m_debugView;
}
public void addView(View view) {
this.m_rootLayout.addView(view, -1, -1);
bringDebugViewToFront(view);
}
public void addView(View view, int i, int i2, int i3, int i4) {
this.m_rootLayout.addView(view, makeLayoutParams(i, i2, i3, i4, false));
bringDebugViewToFront(view);
}
public void addCenteredView(View view, int i, int i2) {
this.m_rootLayout.addView(view, makeLayoutParams(0, 0, i, i2, true));
bringDebugViewToFront(view);
}
public void moveView(View view, int i, int i2, int i3, int i4) {
view.setLayoutParams(makeLayoutParams(i, i2, i3, i4, false));
}
public void removeView(View view) {
this.m_rootLayout.removeView(view);
}
public void enableMotionRelay(View view) {
view.setOnTouchListener(this.m_motionCb);
view.setOnGenericMotionListener(this.m_motionCb);
}
public void addActivityResultCallback(int i, IActivityResultCallback iActivityResultCallback) {
this.m_activityCb.put(Integer.valueOf(i), iActivityResultCallback);
}
public void removeActivityResultCallback(int i) {
this.m_activityCb.remove(Integer.valueOf(i));
}
public void setActivityIndicatorEnabled(boolean z) {
if (z) {
this.m_activityIndicator.bringToFront();
this.m_activityIndicator.setVisibility(0);
} else {
this.m_activityIndicator.setVisibility(8);
}
}
public boolean isActivityIndicatorEnabled() {
return this.m_activityIndicator.getVisibility() == 0;
}
public boolean canOpenUrl(String str) {
return getPackageManager().queryIntentActivities(new Intent("android.intent.action.VIEW", Uri.parse(str)), 0).size() > 0;
}
public boolean openUrl(String str) {
boolean canOpenUrl = canOpenUrl(str);
if (canOpenUrl) {
startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
}
return canOpenUrl;
}
public boolean openAppSettings() {
Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS", Uri.parse("package:" + getPackageName()));
boolean z = getPackageManager().queryIntentActivities(intent, 0).size() > 0;
if (z) {
startActivity(intent);
}
return z;
}
public void keepScreenOn(boolean z) {
if (z) {
getWindow().addFlags(128);
} else {
getWindow().clearFlags(128);
}
}
public boolean isViewReversed() {
int rotation = getWindowManager().getDefaultDisplay().getRotation();
return rotation == 2 || rotation == 3;
}
public int getThermalState() {
if (Build.VERSION.SDK_INT >= 29) {
PowerManager powerManager = (PowerManager) getSystemService("power");
if (powerManager != null) {
return powerManager.getCurrentThermalStatus();
}
} else {
if (registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED")) != null) {
float intExtra = r0.getIntExtra("temperature", -1) / 10.0f;
if (intExtra < 30.0f) {
return 0;
}
if (intExtra < 35.0f) {
return 1;
}
if (intExtra < 40.0f) {
return 2;
}
return intExtra < 43.0f ? 3 : 4;
}
}
return 0;
}
private class DelayedEvents {
public boolean m_doResume;
public boolean m_doStart;
private DelayedEvents() {
}
public void ApplyEvents() {
if (this.m_doStart) {
GameActivity.this.onStartInternal();
}
if (this.m_doResume) {
GameActivity.this.onResumeInternal();
}
if (GameActivity.this.m_deferNotification) {
GameActivity.this.m_deferNotification = false;
GameActivity gameActivity = GameActivity.this;
gameActivity.onNotificationInternal(gameActivity.m_notificationType, GameActivity.this.m_notificationContent, GameActivity.this.m_notificationSource, GameActivity.this.m_notificationParam);
}
}
}
private class SurfaceCb implements SurfaceHolder.Callback {
private SurfaceCb() {
}
@Override
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
Application.trace("GameActivity.SurfaceCb.surfaceChanged(%dx%d fmt=%d)", Integer.valueOf(i2), Integer.valueOf(i3), Integer.valueOf(i));
GameActivity.this.setRenderingSurface(surfaceHolder.getSurface(), true);
}
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
Application.trace("GameActivity.SurfaceCb.surfaceCreated", new Object[0]);
GameActivity.this.setRenderingSurface(surfaceHolder.getSurface(), true);
}
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
Application.trace("GameActivity.SurfaceCb.surfaceDestroyed", new Object[0]);
GameActivity.this.setRenderingSurface(null, true);
}
}
private class DelayedShowSurfaceCb implements Runnable {
private DelayedShowSurfaceCb() {
}
@Override
public void run() {
Application.trace("Delayed surface re-creation happening now.", new Object[0]);
if (GameActivity.this.setSurfaceViewVisibility(true)) {
GameActivity.this.activateSurfaceWatchdog();
}
}
}
private class MotionCb implements View.OnTouchListener, View.OnGenericMotionListener {
private final int[][] m_pointerIdArrays = new int[4][];
private final float[][] m_pointerXYArrays = new float[4][];
public MotionCb() {
}
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return onMotionEvent(view, motionEvent);
}
@Override
public boolean onGenericMotion(View view, MotionEvent motionEvent) {
return onMotionEvent(view, motionEvent);
}
private boolean onMotionEvent(View view, MotionEvent motionEvent) {
int i;
int i2;
float f;
float f2;
int[] pointerIdArray;
float[] pointerXYArray;
int i3;
int[] iArr;
if ((motionEvent.getSource() & 255) != 2) {
return false;
}
int actionMasked = motionEvent.getActionMasked();
int actionButton = (actionMasked == 11 || actionMasked == 12) ? motionEvent.getActionButton() : 0;
if (actionMasked != 8) {
int[] iArr2 = new int[2];
view.getLocationInWindow(iArr2);
f = iArr2[0];
f2 = iArr2[1];
i = 0;
i2 = 1;
} else {
i = 10;
i2 = 9;
f = 0.0f;
f2 = 0.0f;
}
float[] fArr = null;
if (actionMasked == 5 || actionMasked == 6) {
int actionIndex = motionEvent.getActionIndex();
pointerIdArray = getPointerIdArray(1);
pointerIdArray[0] = motionEvent.getPointerId(actionIndex);
pointerXYArray = getPointerXYArray(1);
pointerXYArray[0] = motionEvent.getAxisValue(i, actionIndex) + f;
pointerXYArray[1] = motionEvent.getAxisValue(i2, actionIndex) + f2;
i3 = 1;
} else {
int pointerCount = motionEvent.getPointerCount();
if (pointerCount > 0) {
pointerIdArray = getPointerIdArray(pointerCount);
for (int i4 = 0; i4 < pointerCount; i4++) {
pointerIdArray[i4] = motionEvent.getPointerId(i4);
}
pointerXYArray = getPointerXYArray(pointerCount);
for (int i5 = 0; i5 < pointerCount; i5++) {
int i6 = i5 * 2;
pointerXYArray[i6] = motionEvent.getAxisValue(i, i5) + f;
pointerXYArray[i6 + 1] = motionEvent.getAxisValue(i2, i5) + f2;
}
i3 = pointerCount;
} else {
i3 = pointerCount;
iArr = null;
return GameActivity.this.notifyMotionEvent(actionMasked, actionButton, i3, iArr, fArr);
}
}
iArr = pointerIdArray;
fArr = pointerXYArray;
return GameActivity.this.notifyMotionEvent(actionMasked, actionButton, i3, iArr, fArr);
}
private int[] getPointerIdArray(int i) {
if (i <= 0) {
return null;
}
int i2 = i - 1;
int[][] iArr = this.m_pointerIdArrays;
if (i2 >= iArr.length) {
return new int[i];
}
int[] iArr2 = iArr[i2];
if (iArr2 != null) {
return iArr2;
}
int[] iArr3 = new int[i];
iArr[i2] = iArr3;
return iArr3;
}
private float[] getPointerXYArray(int i) {
if (i <= 0) {
return null;
}
int i2 = i - 1;
float[][] fArr = this.m_pointerXYArrays;
if (i2 >= fArr.length) {
return new float[i * 2];
}
float[] fArr2 = fArr[i2];
if (fArr2 != null) {
return fArr2;
}
float[] fArr3 = new float[i * 2];
fArr[i2] = fArr3;
return fArr3;
}
}
private class LockCb extends BroadcastReceiver {
private LockCb() {
}
private boolean isLockScreenEnabled() {
boolean isKeyguardLocked = ((KeyguardManager) GameActivity.this.getSystemService("keyguard")).isKeyguardLocked();
Object[] objArr = new Object[1];
objArr[0] = isKeyguardLocked ? "enabled" : "disabled";
Application.trace("Lock screen is %s.", objArr);
return isKeyguardLocked;
}
@Override
public void onReceive(Context context, Intent intent) {
Object[] objArr = new Object[2];
objArr[0] = intent.getAction();
objArr[1] = GameActivity.this.m_locked ? "locked" : "unlocked";
Application.trace("GameActivity.LockCb.onReceive(\"%s\") : %s", objArr);
String action = intent.getAction();
if ("android.intent.action.SCREEN_OFF".equals(action)) {
if (GameActivity.this.m_locked) {
return;
}
GameActivity.this.m_locked = true;
GameActivity.this.setScreenLocked(true);
GameActivity.this.setSurfaceViewVisibility(false);
return;
}
if (((!"android.intent.action.SCREEN_ON".equals(action) || isLockScreenEnabled()) && !"android.intent.action.USER_PRESENT".equals(action)) || !GameActivity.this.m_locked) {
return;
}
GameActivity.this.m_locked = false;
GameActivity.this.setScreenLocked(false);
GameActivity.this.setSurfaceViewVisibleDelayed();
}
}
private class DisplayCb implements DisplayManager.DisplayListener {
private DisplayCb() {
}
@Override
public void onDisplayAdded(int i) {
Application.trace("GameActivity.DisplayCb.onDisplayAdded(%d)", Integer.valueOf(i));
}
@Override
public void onDisplayChanged(int i) {
Application.trace("GameActivity.DisplayCb.onDisplayChanged(%d)", Integer.valueOf(i));
float screenScale = GameActivity.this.getScreenScale();
if (GameActivity.this.m_screenScale != screenScale) {
GameActivity.this.m_screenScale = screenScale;
GameActivity.this.setScreenScale(screenScale);
if (GameActivity.this.m_debugView != null) {
GameActivity.this.m_debugView.resetCached();
GameActivity.this.m_debugView.invalidate();
}
}
}
@Override
public void onDisplayRemoved(int i) {
Application.trace("GameActivity.DisplayCb.onDisplayRemoved(%d)", Integer.valueOf(i));
}
}
}