package com.ea.ironmonkey; import android.annotation.SuppressLint; import android.app.Activity; import android.app.ActivityManager; import android.app.AlertDialog; import android.app.PendingIntent; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.res.AssetManager; import android.content.res.Configuration; import android.graphics.Rect; import android.hardware.Sensor; import android.hardware.SensorManager; import android.media.AudioManager; 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.PowerManager; import android.os.Process; import android.provider.Settings; import android.util.DisplayMetrics; import android.view.Display; import android.view.DisplayCutout; import android.view.KeyEvent; import android.view.OrientationEventListener; import android.view.View; import android.view.ViewParent; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; import android.widget.FrameLayout; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ComponentActivity; import com.ea.EAIO.EAIO; import com.ea.EAMIO.StorageDirectory; import com.ea.nimble.ApplicationLifecycle; import com.ea.nimble.Global; import com.google.gson.Gson; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.TreeMap; import java.util.concurrent.TimeUnit; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.opengles.GL10; import org.fmod.FMODAudioDevice; /* loaded from: classes.dex */ public class GameActivityMain extends AppCompatActivity implements DrawFrameListener { private static final String DOWNLOAD_PROPERTIES = "downloadcontent/config.properties"; public static final int LIFECYCLE_CREATED = 1; public static final int LIFECYCLE_DESTROYED = 5; public static final int LIFECYCLE_NONE = 0; public static final int LIFECYCLE_RUNNING = 3; public static final int LIFECYCLE_STARTED = 2; public static final int LIFECYCLE_STOPPED = 4; private static String SDCARD_DATA_FOLDER = ""; public static final int STATE_ADC_PROCESS = 4; public static final int STATE_ADC_START = 3; public static final int STATE_FULL_PROCESS = 6; public static final int STATE_FULL_START = 5; public static final int STATE_GAME_START = 8; public static final int STATE_GOOGLE_DRM = 2; public static final int STATE_RESTORE_CONTEXT = 7; public static final int STATE_SPLASH = 0; public static final int STATE_SPLASH_PROCESS = 1; public static final String TAG = "GameActivityMain"; private static boolean assetsReady; public static GameActivityMain instance; private static boolean isAmazonDev; private static AudioManager mAudioManager; private static int oldState; private static boolean sIsOtherMusicPlaying; public static int state; private Accelerometer accelerometer; private GameGLSurfaceView gameGLSurfaceView; private GameRenderer gameRenderer; private Handler handler; private int laststate; private int lifecycle; private AlertDialog.Builder mAd; private FMODAudioDevice mFMODAudioDevice; private FrameLayout mFrameLayout; private OrientationEventListener mOrientationListener; private Map mResources; private PowerManager.WakeLock mWakeLock; public int naturalOrientation; private RunLoop runLoop; private SplashScreen splash; private int splashCounter; private long splashDelay; private long splashTimer; private boolean isXperiaPlay = false; private boolean isSleepModeEnabled = true; private int mRotation = 0; private AssetLocationType mAssetLocationType = AssetLocationType.EXTERNAL; private String[] lifecycleNames = {"LIFECYCLE_NONE", "LIFECYCLE_CREATED", "LIFECYCLE_STARTED", "LIFECYCLE_RUNNING", "LIFECYCLE_STOPPED", "LIFECYCLE_DESTROYED"}; public File getSave() { return save; } public void setSave(File save) { this.save = save; } enum AssetLocationType { EXTERNAL, ASSETS, OBB } private void updateRequestedOrientation(int i) { } public boolean IsSystemKey(int i) { if (i == 3 || i == 91) { return true; } switch (i) { case 5: case 6: return true; default: switch (i) { case 24: case 25: case 26: case 27: return true; default: return false; } } } public native void nativeOnCreate(); public native void nativeOnDestroy(); public native void nativeOnMusicPlayerStateChanged(); public native void nativeOnOrientationChange(int i); public native void nativeOnPause(); public native void nativeOnPhysicalKeyDown(int i, int i2); public native void nativeOnPhysicalKeyUp(int i, int i2); public native void nativeOnPhysicalKeyboardVisibilityChanged(boolean z); public native void nativeOnPhysicalNavigationVisibilityChanged(boolean z); public native void nativeOnRestart(); public native void nativeOnResume(); public native void nativeOnStart(); public native void nativeOnStop(); public native boolean nativeRestoreContext(); public native void nativeSurfaceChanged(GL10 gl10, int i, int i2); public native void nativeSurfaceCreated(GL10 gl10, EGLConfig eGLConfig); @Override // android.app.Activity public void onCreate(Bundle bundle) { restoreSave(); Log.setEnable(true); Log.i(TAG, "onCreate"); super.onCreate(bundle); instance = this; if (this.lifecycle == 5) { Log.w(TAG, "onCreate called on destroyed app, finishing"); finish(); return; } if (this.lifecycle >= 1) { Log.w(TAG, "onCreate ignored, lifecycle is already " + this.lifecycleNames[this.lifecycle]); return; } this.handler = new Handler(); setLifecycle(1); Log.d("Model", Build.MODEL); if (Build.MODEL.length() > 4 && Build.MODEL.substring(0, 4).equals("R800")) { this.isXperiaPlay = true; } String packageName = getPackageName(); if (packageName.endsWith("_azn_na") || packageName.endsWith("_azn_row")) { Log.d(TAG, "It's Amazon dev"); isAmazonDev = true; } if (!isAtLeastAPI(18) && getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } if (isAtLeastAPI(28)) { getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; getWindow().addFlags(67108864); } getWindow().setFlags(1024, 1024); requestWindowFeature(1); this.mOrientationListener = new OrientationEventListener(getApplicationContext()) { // from class: com.ea.ironmonkey.GameActivityMain.1 @Override // android.view.OrientationEventListener public void onOrientationChanged(int i) { int rotation; if (GameActivityMain.this.accelerometer == null || GameActivityMain.this.mRotation == (rotation = GameActivityMain.this.getWindow().getWindowManager().getDefaultDisplay().getRotation())) { return; } GameActivityMain.this.mRotation = rotation; if (Settings.System.getInt(GameActivityMain.this.getContentResolver(), "accelerometer_rotation", 0) == 1 || !GameActivityMain.isAtLeastAPI(18) || GameActivityMain.isAmazonDev) { GameActivityMain.this.accelerometer.updateOrientation(GameActivityMain.this.mRotation); GameActivityMain.this.nativeOnOrientationChange(GameActivityMain.this.mRotation); Log.d(GameActivityMain.TAG, "OrientationEventListener::onOrientationChanged mRotation = " + Integer.toString(GameActivityMain.this.mRotation)); return; } Log.d(GameActivityMain.TAG, "OrientationEventListener::onOrientationChanged rotation disabled!"); } }; if (this.mOrientationListener.canDetectOrientation()) { this.mOrientationListener.enable(); } mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); sIsOtherMusicPlaying = mAudioManager.isMusicActive(); Log.i(TAG, "onCreate() isMusicActive = " + Boolean.toString(sIsOtherMusicPlaying)); this.mFMODAudioDevice = new FMODAudioDevice(); if (isAmazonDev) { try { Log.d(TAG, "onCreate open resources.json"); InputStream open = getAssetManager().open("resources.json"); this.mResources = new Gson().fromJson(new InputStreamReader(open), new TypeToken>>() { // from class: com.ea.ironmonkey.GameActivityMain.2 }.getType()); Log.d(TAG, "onCreate resources.json contains " + Integer.toString(this.mResources.size()) + " items"); open.close(); this.mAssetLocationType = AssetLocationType.ASSETS; } catch (Exception e) { Log.d(TAG, "onCreate exception on opening resources.json"); Log.e(TAG, e.getMessage()); this.mResources = new HashMap(); } } if (this.mAssetLocationType != AssetLocationType.ASSETS) { try { InputStream open2 = getResources().getAssets().open("obb.size"); if (open2 != null) { this.mAssetLocationType = AssetLocationType.OBB; open2.close(); } } catch (IOException e2) { Log.e(TAG, e2.getMessage()); } } SensorManager sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); Sensor defaultSensor = sensorManager.getDefaultSensor(1); int rotation = getWindow().getWindowManager().getDefaultDisplay().getRotation(); switch (rotation) { case 0: Log.d(TAG, "Orientation: ROTATION_0"); break; case 1: Log.d(TAG, "Orientation: ROTATION_90"); break; case 2: Log.d(TAG, "Orientation: ROTATION_180"); break; case 3: Log.d(TAG, "Orientation: ROTATION_270"); break; } this.mRotation = rotation; updateRequestedOrientation(rotation); if (defaultSensor != null) { this.accelerometer = new Accelerometer(sensorManager, defaultSensor, rotation); } this.gameGLSurfaceView = new GameGLSurfaceView(this); this.gameRenderer = new GameRenderer(this); this.gameRenderer.setDrawFrameListener(this); this.gameGLSurfaceView.setRenderer(this.gameRenderer); this.runLoop = new RunLoop(this.gameGLSurfaceView); this.mFrameLayout = new FrameLayout(this); this.mFrameLayout.addView(this.gameGLSurfaceView); setContentView(this.mFrameLayout); System.loadLibrary("fmodex"); System.loadLibrary("fmodevent"); System.loadLibrary("c++_shared"); System.loadLibrary(Global.NIMBLE_ID); System.loadLibrary("app"); Log.d(TAG, "Init EAIO/EAMIO"); EAIO.Startup(this); StorageDirectory.Startup(this); ApplicationLifecycle.onActivityCreate(bundle, this); Log.d(TAG, "nativeOnCreate"); nativeOnCreate(); } public String[] forEach(String input) { return new String[] { input }; } public int getAssetSize(String str) { Log.d(TAG, "getAssetSize filename = " + str); File file = new File(str); String parent = file.getParent(); if (parent == null) { if (this.mResources.containsKey(str)) { Log.d(TAG, "getAssetSize mResources contains " + str); return -1; } Log.d(TAG, "getAssetSize mResources not contains " + str); } else { Log.d(TAG, "getAssetSize path = " + parent); if (this.mResources.containsKey(parent)) { Log.d(TAG, "getAssetSize mResources contains " + parent); Map map = (Map) this.mResources.get(parent); String name = file.getName(); Log.d(TAG, "getAssetSize name = " + name); if (map.containsKey(name)) { Log.d(TAG, "getAssetSize dir contains " + name); FSNode fSNode = map.get(name); int i = fSNode.directory ? -1 : fSNode.size; Log.d(TAG, "getAssetSize filename = " + str + ", directory = " + Boolean.toString(fSNode.directory) + ", size = " + Integer.toString(fSNode.size)); return i; } Log.d(TAG, "getAssetSize dir not contains " + name); } else { Log.d(TAG, "getAssetSize mResources not contains " + parent); } } return -2; } public boolean isObbAssets() { return this.mAssetLocationType == AssetLocationType.OBB; } public boolean isFullApkAssets() { return this.mAssetLocationType == AssetLocationType.ASSETS; } public boolean useAssetsFileSystem() { return this.mAssetLocationType != AssetLocationType.EXTERNAL; } private int getVersionCode() { try { return getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return 0; } } public String getObbFullPath() { Log.i(this.getClass().getName(), getObbDir() + "/" + ObbHelper.getObbFileName(this, getVersionCode())); return getObbDir() + "/" + ObbHelper.getObbFileName(this, getVersionCode()); } public AssetManager getAssetManager() { return getResources().getAssets(); } public static boolean isAnyMusicPlaying() { return sIsOtherMusicPlaying; } public static boolean isAmazon() { return isAmazonDev; } public static boolean isAtLeastAPI(int i) { return Build.VERSION.SDK_INT >= i; } public void enableSleepMode() { if (this.isSleepModeEnabled) { return; } this.isSleepModeEnabled = true; wakeLockRelease(); } public void disableSleepMode() { if (this.isSleepModeEnabled) { this.isSleepModeEnabled = false; wakeLockAcquire(); } } private void checkAnyMusicActive() { if (mAudioManager != null) { sIsOtherMusicPlaying = mAudioManager.isMusicActive(); nativeOnMusicPlayerStateChanged(); } } @Override // android.app.Activity public void onStart() { CallGC(); Log.i(TAG, "onStart"); super.onStart(); Log.i(TAG, "onStart 1"); wakeLockAcquire(); Log.i(TAG, "onStart 2"); if (this.lifecycle >= 2 && this.lifecycle < 4) { Log.w(TAG, "onStart ignored, lifecycle is already " + this.lifecycleNames[this.lifecycle]); return; } Log.i(TAG, "onStart 3"); setLifecycle(2); Log.i(TAG, "nativeOnStart"); nativeOnStart(); Log.i(TAG, "nativeOnStart - end"); if (this.isXperiaPlay) { switch (getResources().getConfiguration().navigationHidden) { case 1: nativeOnPhysicalNavigationVisibilityChanged(true); break; case 2: nativeOnPhysicalNavigationVisibilityChanged(false); break; } } Log.i(TAG, "ApplicationLifecycle"); ApplicationLifecycle.onActivityStart(this); } // Методы для воостановления сейва и его сохранения чтобы всегда использовать внешний сейв private String saveFileName = "nfstr_save.sb"; private File save = null; private File externalSave = new File(Environment.getStorageDirectory(),"games/nfsmw/nfstr_save.sb"); // Сохранить private void storeSave() { try { save = new File(getFilesDir(), "var/nfstr_save.sb"); // Создаем директории, если они не существуют externalSave.getParentFile().mkdirs(); // Копируем файл из внутреннего хранилища во внешнее try (InputStream in = new FileInputStream(save); OutputStream out = new FileOutputStream(externalSave)) { byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } } } catch (IOException e) { e.printStackTrace(); // Обработка ошибки сохранения } } // Восстановить private void restoreSave() { try { save = new File(getFilesDir(), "var/nfstr_save.sb"); // Проверяем, существует ли внешний файл if (!externalSave.exists()) { return; // ничего не делаем, если файла нет } // Создаем директории для внутреннего файла, если нужно save.getParentFile().mkdirs(); // Копируем файл из внешнего хранилища во внутреннее try (InputStream in = new FileInputStream(externalSave); OutputStream out = new FileOutputStream(save)) { byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } } } catch (IOException e) { e.printStackTrace(); // Обработка ошибки восстановления } } @Override // android.app.Activity public void onRestart() { Log.i(TAG, "onRestart"); super.onRestart(); ApplicationLifecycle.onActivityRestart(this); nativeOnRestart(); } @Override // android.app.Activity public void onPause() { Log.i(TAG, "onPause state=" + state); super.onPause(); this.mFMODAudioDevice.stop(); if (this.mOrientationListener.canDetectOrientation()) { this.mOrientationListener.disable(); } if (this.lifecycle != 3) { Log.w(TAG, "onPause ignored, lifecycle is currently " + this.lifecycleNames[this.lifecycle]); return; } setLifecycle(2); this.gameGLSurfaceView.onPause(); ApplicationLifecycle.onActivityPause(this); nativeOnPause(); this.splash = null; } private void ForceHideVirtualKeyboard() { View currentFocus = getCurrentFocus(); if (currentFocus != null) { ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(currentFocus.getWindowToken(), 0); } getWindow().setSoftInputMode(3); } @Override // android.app.Activity public void onResume() { Log.i(TAG, "onResume"); super.onResume(); if (state != 7) { oldState = state; state = 7; this.gameRenderer.setDrawFrameListener(this); } if (this.mOrientationListener.canDetectOrientation()) { this.mOrientationListener.enable(); } if (this.lifecycle == 3) { Log.w(TAG, "onResume ignored, lifecycle is currently " + this.lifecycleNames[this.lifecycle]); return; } setLifecycle(3); this.gameGLSurfaceView.onResume(); ApplicationLifecycle.onActivityResume(this); nativeOnResume(); checkAnyMusicActive(); this.mFMODAudioDevice.start(); Log.i(TAG, "onResume() isMusicActive = " + Boolean.toString(sIsOtherMusicPlaying)); } @Override // android.app.Activity public void onStop() { Log.i(TAG, "onStop"); super.onStop(); if (this.lifecycle >= 4) { Log.w(TAG, "onStop ignored, lifecycle is already " + this.lifecycleNames[this.lifecycle]); return; } setLifecycle(4); wakeLockRelease(); nativeOnStop(); } @Override // android.app.Activity public void onDestroy() { Log.i(TAG, "onDestroy"); super.onDestroy(); if (this.lifecycle >= 5) { Log.w(TAG, "onDestroy ignored, lifecycle is already " + this.lifecycleNames[this.lifecycle]); return; } setLifecycle(5); storeSave(); if (state == 8) { ApplicationLifecycle.onActivityDestroy(this); nativeOnDestroy(); } StorageDirectory.Shutdown(); EAIO.Shutdown(); System.exit(0); } @SuppressLint("InvalidWakeLockTag") public void wakeLockAcquire() { if (this.isSleepModeEnabled) { return; } if (this.mWakeLock == null) { this.mWakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(10, TAG); } if (this.mWakeLock.isHeld()) { return; } try { this.mWakeLock.acquire(); } catch (SecurityException unused) { Log.w(TAG, "Missing WAKE_LOCK permission."); } } public void wakeLockRelease() { if (this.isSleepModeEnabled) { return; } try { if (this.mWakeLock == null || !this.mWakeLock.isHeld()) { return; } this.mWakeLock.release(); } catch (SecurityException unused) { Log.w(TAG, "Missing WAKE_LOCK permission."); } } @Override // android.app.Activity protected void onSaveInstanceState(Bundle bundle) { super.onSaveInstanceState(bundle); ApplicationLifecycle.onActivitySaveInstanceState(bundle, this); } @Override // android.app.Activity public void onActivityResult(int i, int i2, Intent intent) { super.onActivityResult(i, i2, intent); ApplicationLifecycle.onActivityResult(i, i2, intent, this); } @Override // android.app.Activity, android.view.KeyEvent.Callback public boolean onKeyDown(final int i, KeyEvent keyEvent) { super.onKeyDown(i, keyEvent); if (state != 8) { return true; } if ((i == 4 || i == 108) && keyEvent.getRepeatCount() > 0) { return true; } final int scanCode = keyEvent.getScanCode(); this.gameGLSurfaceView.queueEvent(new Runnable() { // from class: com.ea.ironmonkey.GameActivityMain.3 @Override // java.lang.Runnable public void run() { GameActivityMain.this.nativeOnPhysicalKeyDown(i, scanCode); } }); return !IsSystemKey(i); } @Override // android.app.Activity, android.view.KeyEvent.Callback public boolean onKeyUp(final int i, KeyEvent keyEvent) { super.onKeyUp(i, keyEvent); if (state != 8) { return true; } final int scanCode = keyEvent.getScanCode(); this.gameGLSurfaceView.queueEvent(new Runnable() { // from class: com.ea.ironmonkey.GameActivityMain.4 @Override // java.lang.Runnable public void run() { GameActivityMain.this.nativeOnPhysicalKeyUp(i, scanCode); } }); return !IsSystemKey(i); } @Override // android.app.Activity public void onBackPressed() { //super.onBackPressed(); if (state == 1 || state == 0 || state == 7) { finish(); } ApplicationLifecycle.onBackPressed(); } @Override // android.app.Activity, android.content.ComponentCallbacks public void onConfigurationChanged(Configuration configuration) { Log.d(TAG, "onConfigurationChanged(" + configuration.toString() + ")"); super.onConfigurationChanged(configuration); if (this.accelerometer != null) { int rotation = getWindow().getWindowManager().getDefaultDisplay().getRotation(); switch (rotation) { case 0: Log.i(TAG, "Orientation: ROTATION_0"); break; case 1: Log.i(TAG, "Orientation: ROTATION_90"); break; case 2: Log.i(TAG, "Orientation: ROTATION_180"); break; case 3: Log.i(TAG, "Orientation: ROTATION_270"); break; } if (isAmazonDev) { this.accelerometer.updateOrientation(rotation); } } if (this.isXperiaPlay) { switch (configuration.navigationHidden) { case 1: nativeOnPhysicalNavigationVisibilityChanged(true); break; case 2: nativeOnPhysicalNavigationVisibilityChanged(false); break; } } } @Override // android.app.Activity, android.view.Window.Callback public void onWindowFocusChanged(boolean z) { super.onWindowFocusChanged(z); Log.i(TAG, "onWindowsFocusChanged(" + z + ") state=" + state); if (getGameGLSurfaceView() != null) { getGameGLSurfaceView().setRenderMode(z ? 1 : 0); } if (!z) { if (this.mFMODAudioDevice.isMixing()) { this.mFMODAudioDevice.stop(); checkAnyMusicActive(); } Log.i(TAG, "onWindowFocusChanged() isMusicActive = " + Boolean.toString(sIsOtherMusicPlaying)); ForceHideVirtualKeyboard(); nativeOnPhysicalKeyDown(131, 0); nativeOnPhysicalKeyUp(131, 0); if (state == 8 && !isAmazonDev) { oldState = state; state = 7; this.gameRenderer.setDrawFrameListener(this); } } else { if (!this.mFMODAudioDevice.isMixing()) { checkAnyMusicActive(); this.mFMODAudioDevice.start(); } Log.i(TAG, "onWindowFocusChanged() isMusicActive = " + Boolean.toString(sIsOtherMusicPlaying)); if (!isAmazonDev) { getWindow().getDecorView().setSystemUiVisibility(5894); } } ApplicationLifecycle.onActivityWindowFocusChanged(z, this); } private void setLifecycle(int i) { if (i == this.lifecycle) { return; } Log.i(TAG, this.lifecycleNames[this.lifecycle] + " -> " + this.lifecycleNames[i]); this.lifecycle = i; } public RunLoop getRunLoop() { return this.runLoop; } public GameGLSurfaceView getGameGLSurfaceView() { return this.gameGLSurfaceView; } public ViewParent GetViewRoot() { return getWindow().getDecorView().getRootView().getParent(); } public void CallGC() { Log.d(TAG, "Call garbage collector"); System.gc(); } public static String GetDeviceName() { return Build.MODEL; } public static String getOsVersion() { return Build.VERSION.RELEASE; } public static String GetDefaultLanguage() { return Locale.getDefault().toString().substring(0, 2); } public static String GetDeviceLocale() { String upperCase = Locale.getDefault().toString().replace('_', '-').toUpperCase(); Log.d(TAG, "GetDeviceLocale locale = " + upperCase); return upperCase; } public void ShowMessage(String str, String[] strArr, final boolean z) { Log.d(TAG, "ShowMessage msg=" + str + " finish=" + z); this.mAd = new AlertDialog.Builder(this); this.mAd.setMessage(str); this.mAd.setCancelable(false); this.mAd.setPositiveButton(strArr[0], new DialogInterface.OnClickListener() { // from class: com.ea.ironmonkey.GameActivityMain.5 @Override // android.content.DialogInterface.OnClickListener public void onClick(DialogInterface dialogInterface, int i) { if (z) { GameActivityMain.this.finish(); } } }); this.handler.postDelayed(new Runnable() { // from class: com.ea.ironmonkey.GameActivityMain.6 @Override // java.lang.Runnable public void run() { GameActivityMain.this.mAd.show(); } }, 20L); } @Override // android.app.Activity, android.content.ComponentCallbacks public void onLowMemory() { ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo(); activityManager.getMemoryInfo(memoryInfo); super.onLowMemory(); } public static String GetApplicationVersion() { try { return instance.getPackageManager().getPackageInfo(instance.getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return "1.0.1"; } } public int GetNaturalOrientation() { int width; int height; Display defaultDisplay = getWindow().getWindowManager().getDefaultDisplay(); switch (defaultDisplay.getRotation()) { case 0: case 2: width = defaultDisplay.getWidth(); height = defaultDisplay.getHeight(); break; case 1: case 3: width = defaultDisplay.getHeight(); height = defaultDisplay.getWidth(); break; default: height = 0; width = 0; break; } if (width > height) { Log.d(TAG, "NaturalOrientation = LANDSCAPE"); return 0; } Log.d(TAG, "NaturalOrientation = PORTRAIT"); return 1; } public Accelerometer getAccelerometer() { return this.accelerometer; } public DisplayMetrics getDisplayMetrics() { if (Build.VERSION.SDK_INT >= 17) { DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getRealMetrics(displayMetrics); return displayMetrics; } return getResources().getDisplayMetrics(); } public boolean isAssetsReady() { return assetsReady; } @Override // android.app.Activity public void setContentView(View view) { Log.d(TAG, "setContentView(" + view + ")"); if (view != null) { if (view == this.mFrameLayout) { super.setContentView(view); return; } int childCount = this.mFrameLayout.getChildCount(); for (int i = 0; i < childCount; i++) { View childAt = this.mFrameLayout.getChildAt(i); if (childAt != this.gameGLSurfaceView) { this.mFrameLayout.removeView(childAt); } } if (view != this.gameGLSurfaceView) { this.mFrameLayout.addView(view); } this.mFrameLayout.bringChildToFront(view); } } @Override // com.ea.ironmonkey.DrawFrameListener public void onDrawFrame(GL10 gl10) { InputStream inputStream; if (state != this.laststate) { Log.d(TAG, "onDrawFrame state=" + state); this.laststate = state; } boolean z = false; switch (state) { case 0: this.splash = new SplashScreen(this); this.splash.init(gl10, this.gameRenderer.getWidth(), this.gameRenderer.getHeight()); state = 1; this.splashCounter = 3; break; case 1: if (this.splashCounter > 0) { this.splashCounter--; break; } else { this.splashTimer = System.currentTimeMillis() + 2500; if (!assetsReady) { try { inputStream = getAssets().open(DOWNLOAD_PROPERTIES); try { inputStream.close(); } catch (Exception unused) { } } catch (Exception unused2) { inputStream = null; } if (inputStream != null) { this.handler.postDelayed(new Runnable() { // from class: com.ea.ironmonkey.GameActivityMain.8 @Override // java.lang.Runnable public void run() { } }, 20L); Log.i(TAG, "state ADC start"); state = 3; break; } else { Log.i(TAG, "STATE_GAME_START 1"); state = 8; break; } } else { Log.i(TAG, "STATE_GAME_START 2"); state = 8; break; } } case 3: Log.i(TAG, "ADC start"); break; case 7: if (this.splash == null) { this.splash = new SplashScreen(this); this.splash.init(gl10, this.gameRenderer.getWidth(), this.gameRenderer.getHeight()); this.splashDelay = System.currentTimeMillis() + 2000; } if (this.splashDelay < System.currentTimeMillis() && hasWindowFocus()) { if (oldState == 8) { this.splashTimer = System.currentTimeMillis() + 300; state = 8; break; } else { state = oldState; break; } } break; case 8: if (this.splashTimer < System.currentTimeMillis() && nativeRestoreContext()) { assetsReady = true; nativeOnStart(); nativeOnResume(); this.gameRenderer.setDrawFrameListener(null); z = true; break; } break; } GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); GLES20.glClear(16640); if (this.splash != null) { this.splash.draw(gl10, this.gameRenderer.getWidth(), this.gameRenderer.getHeight()); } if (!z || this.splash == null) { return; } this.splash.destroy(gl10); this.splash = null; } public void onResult(String str, int i) { Log.w(TAG, "onResult(" + str + "," + i + ")"); if (i == -1) { File file = new File(new File(str).getParent() + "/.nomedia"); if (!file.exists()) { try { file.createNewFile(); } catch (Exception unused) { } } this.handler.postDelayed(new Runnable() { // from class: com.ea.ironmonkey.GameActivityMain.9 @Override // java.lang.Runnable public void run() { GameActivityMain.this.setContentView(GameActivityMain.this.gameGLSurfaceView); } }, 20L); if (hasWindowFocus()) { state = 8; return; } else { oldState = 8; state = 7; return; } } finish(); Process.killProcess(Process.myPid()); } public int getTotalMemory() { return 40000; } public void openURL(String str) { openURLinBrowser(str); } public void openURLinBrowser(String str) { String replace = str.replace("http://", "https://"); Log.d("OpenURLinBrowser", replace); try { startActivity(new Intent("android.intent.action.VIEW", Uri.parse(replace))); } catch (Exception e) { e.printStackTrace(); } } public float getPerformanceScore() { return 6.6f; } public boolean needInstallWallpaper() { Log.i(TAG, "needInstallWallpaper()"); return false; } public void installWallpaper() {} public long getUtcTime() { return TimeUnit.MILLISECONDS.toDays(System.currentTimeMillis()); } public int[][] getNotchesBoundingRects() { DisplayCutout displayCutout; int[][] iArr = (int[][]) Array.newInstance((Class) int.class, 0, 0); if (Build.VERSION.SDK_INT < 28 || (displayCutout = getWindow().getDecorView().getRootWindowInsets().getDisplayCutout()) == null) { return iArr; } List boundingRects = displayCutout.getBoundingRects(); int[][] iArr2 = (int[][]) Array.newInstance((Class) int.class, boundingRects.size(), 4); for (int i = 0; i < boundingRects.size(); i++) { iArr2[i][0] = boundingRects.get(i).left; iArr2[i][1] = boundingRects.get(i).top; iArr2[i][2] = boundingRects.get(i).width(); iArr2[i][3] = boundingRects.get(i).height(); } return iArr2; } class FSNode { @SerializedName("directory") public boolean directory; @SerializedName("size") public int size; FSNode() { } } }