mickeyevers

UnitPlayer

Jun 27th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.33 KB | None | 0 0
  1. //
  2. // Source code recreated from a .class file by IntelliJ IDEA
  3. // (powered by Fernflower decompiler)
  4. //
  5.  
  6. package com.unity3d.player;
  7.  
  8. import android.app.Activity;
  9. import android.app.AlertDialog;
  10. import android.app.AlertDialog.Builder;
  11. import android.content.BroadcastReceiver;
  12. import android.content.ClipData;
  13. import android.content.ClipboardManager;
  14. import android.content.Context;
  15. import android.content.DialogInterface;
  16. import android.content.Intent;
  17. import android.content.DialogInterface.OnClickListener;
  18. import android.content.pm.ApplicationInfo;
  19. import android.content.res.Configuration;
  20. import android.graphics.Rect;
  21. import android.hardware.Sensor;
  22. import android.hardware.SensorEvent;
  23. import android.hardware.SensorEventListener;
  24. import android.hardware.SensorManager;
  25. import android.net.Uri;
  26. import android.os.Bundle;
  27. import android.os.Handler;
  28. import android.os.Looper;
  29. import android.os.Message;
  30. import android.os.Process;
  31. import android.telephony.PhoneStateListener;
  32. import android.telephony.TelephonyManager;
  33. import android.util.TypedValue;
  34. import android.view.InputEvent;
  35. import android.view.KeyEvent;
  36. import android.view.MotionEvent;
  37. import android.view.Surface;
  38. import android.view.SurfaceHolder;
  39. import android.view.SurfaceView;
  40. import android.view.View;
  41. import android.view.ViewGroup;
  42. import android.view.ViewParent;
  43. import android.view.SurfaceHolder.Callback;
  44. import android.widget.FrameLayout;
  45. import java.io.UnsupportedEncodingException;
  46. import java.util.concurrent.ConcurrentLinkedQueue;
  47. import java.util.concurrent.Semaphore;
  48. import java.util.concurrent.TimeUnit;
  49.  
  50. public class UnityPlayer extends FrameLayout implements com.unity3d.player.f {
  51. public static Activity currentActivity = null;
  52. private int mInitialScreenOrientation = -1;
  53. private boolean mMainDisplayOverride = false;
  54. private boolean mIsFullscreen = true;
  55. private n mState = new n();
  56. private final ConcurrentLinkedQueue m_Events = new ConcurrentLinkedQueue();
  57. private BroadcastReceiver mKillingIsMyBusiness = null;
  58. private static final int ANR_TIMEOUT_SECONDS = 4;
  59. private static final int RUN_STATE_CHANGED_MSG_CODE = 2269;
  60. UnityPlayer.e m_MainThread = new UnityPlayer.e((byte)0);
  61. private boolean m_AddPhoneCallListener = false;
  62. private UnityPlayer.c m_PhoneCallListener = new UnityPlayer.c((byte)0);
  63. private TelephonyManager m_TelephonyManager;
  64. private ClipboardManager m_ClipboardManager;
  65. private l m_SplashScreen;
  66. private GoogleARCoreApi m_ARCoreApi = null;
  67. private UnityPlayer.a m_FakeListener = new UnityPlayer.a();
  68. private Camera2Wrapper m_Camera2Wrapper = null;
  69. private HFPStatus m_HFPStatus = null;
  70. private AudioVolumeHandler m_AudioVolumeHandler = null;
  71. private Uri m_launchUri = null;
  72. private NetworkConnectivity m_NetworkConnectivity = null;
  73. private Context mContext;
  74. private SurfaceView mGlView;
  75. private static boolean mLibMainLoaded;
  76. private boolean mQuitting;
  77. private boolean mShutdownWasCalled = false;
  78. private q mVideoPlayerProxy;
  79. k mSoftInputDialog = null;
  80. private static final String SPLASH_ENABLE_METADATA_NAME = "unity.splash-enable";
  81. private static final String SPLASH_MODE_METADATA_NAME = "unity.splash-mode";
  82. private static final String TANGO_ENABLE_METADATA_NAME = "unity.tango-enable";
  83.  
  84. public UnityPlayer(Context var1) {
  85. super(var1);
  86. if (var1 instanceof Activity) {
  87. currentActivity = (Activity)var1;
  88. this.mInitialScreenOrientation = currentActivity.getRequestedOrientation();
  89. this.m_launchUri = currentActivity.getIntent().getData();
  90. }
  91.  
  92. this.EarlyEnableFullScreenIfVrLaunched(currentActivity);
  93. this.mContext = var1;
  94. if (currentActivity != null && this.getSplashEnabled()) {
  95. this.m_SplashScreen = new l(this.mContext, com.unity3d.player.l.a.a()[this.getSplashMode()]);
  96. this.addView(this.m_SplashScreen);
  97. }
  98.  
  99. loadNative(this.mContext.getApplicationInfo());
  100. if (!n.c()) {
  101. AlertDialog var2;
  102. (var2 = (new Builder(this.mContext)).setTitle("Failure to initialize!").setPositiveButton("OK", new OnClickListener() {
  103. public final void onClick(DialogInterface var1, int var2) {
  104. UnityPlayer.this.finish();
  105. }
  106. }).setMessage("Your hardware does not support this application, sorry!").create()).setCancelable(false);
  107. var2.show();
  108. } else {
  109. this.initJni(var1);
  110. this.mState.c(true);
  111. this.mGlView = this.CreateGlView();
  112. this.mGlView.setContentDescription(this.GetGlViewContentDescription(var1));
  113. this.addView(this.mGlView);
  114. this.bringChildToFront(this.m_SplashScreen);
  115. this.mQuitting = false;
  116. this.hideStatusBar();
  117. this.m_TelephonyManager = (TelephonyManager)this.mContext.getSystemService("phone");
  118. this.m_ClipboardManager = (ClipboardManager)this.mContext.getSystemService("clipboard");
  119. this.m_Camera2Wrapper = new Camera2Wrapper(this.mContext);
  120. this.m_HFPStatus = new HFPStatus(this.mContext);
  121. this.m_MainThread.start();
  122. }
  123. }
  124.  
  125. protected void toggleGyroscopeSensor(boolean var1) {
  126. SensorManager var2;
  127. Sensor var3 = (var2 = (SensorManager)this.mContext.getSystemService("sensor")).getDefaultSensor(11);
  128. if (var1) {
  129. var2.registerListener(this.m_FakeListener, var3, 1);
  130. } else {
  131. var2.unregisterListener(this.m_FakeListener);
  132. }
  133. }
  134.  
  135. private String GetGlViewContentDescription(Context var1) {
  136. return var1.getResources().getString(var1.getResources().getIdentifier("game_view_content_description", "string", var1.getPackageName()));
  137. }
  138.  
  139. private void DisableStaticSplashScreen() {
  140. this.runOnUiThread(new Runnable() {
  141. public final void run() {
  142. UnityPlayer.this.removeView(UnityPlayer.this.m_SplashScreen);
  143. UnityPlayer.this.m_SplashScreen = null;
  144. }
  145. });
  146. }
  147.  
  148. private void EarlyEnableFullScreenIfVrLaunched(Activity var1) {
  149. View var2;
  150. if (var1 != null && var1.getIntent().getBooleanExtra("android.intent.extra.VR_LAUNCH", false) && var1.getWindow() != null && (var2 = var1.getWindow().getDecorView()) != null) {
  151. var2.setSystemUiVisibility(7);
  152. }
  153.  
  154. }
  155.  
  156. private boolean IsWindowTranslucent() {
  157. if (currentActivity == null) {
  158. return false;
  159. } else {
  160. TypedValue var1 = new TypedValue();
  161. if (currentActivity.getTheme().resolveAttribute(16842840, var1, true) && var1.type == 18) {
  162. return var1.data != 0;
  163. } else {
  164. return false;
  165. }
  166. }
  167. }
  168.  
  169. private SurfaceView CreateGlView() {
  170. SurfaceView var1 = new SurfaceView(this.mContext);
  171. if (this.IsWindowTranslucent()) {
  172. var1.getHolder().setFormat(-3);
  173. var1.setZOrderOnTop(true);
  174. } else {
  175. var1.getHolder().setFormat(-1);
  176. }
  177.  
  178. var1.getHolder().addCallback(new Callback() {
  179. public final void surfaceCreated(SurfaceHolder var1) {
  180. UnityPlayer.this.updateGLDisplay(0, var1.getSurface());
  181. }
  182.  
  183. public final void surfaceChanged(SurfaceHolder var1, int var2, int var3, int var4) {
  184. UnityPlayer.this.updateGLDisplay(0, var1.getSurface());
  185. UnityPlayer.this.sendSurfaceChangedEvent();
  186. }
  187.  
  188. public final void surfaceDestroyed(SurfaceHolder var1) {
  189. UnityPlayer.this.updateGLDisplay(0, (Surface)null);
  190. }
  191. });
  192. var1.setFocusable(true);
  193. var1.setFocusableInTouchMode(true);
  194. return var1;
  195. }
  196.  
  197. private void sendSurfaceChangedEvent() {
  198. if (n.c() && this.mState.e()) {
  199. Runnable var1 = new Runnable() {
  200. public final void run() {
  201. UnityPlayer.this.nativeSendSurfaceChangedEvent();
  202. }
  203. };
  204. this.m_MainThread.d(var1);
  205. }
  206. }
  207.  
  208. private void updateGLDisplay(int var1, Surface var2) {
  209. if (!this.mMainDisplayOverride) {
  210. this.updateDisplayInternal(var1, var2);
  211. }
  212. }
  213.  
  214. private boolean updateDisplayInternal(final int var1, final Surface var2) {
  215. if (n.c() && this.mState.e()) {
  216. final Semaphore var3 = new Semaphore(0);
  217. Runnable var4 = new Runnable() {
  218. public final void run() {
  219. UnityPlayer.this.nativeRecreateGfxState(var1, var2);
  220. var3.release();
  221. }
  222. };
  223. if (var1 == 0) {
  224. if (var2 == null) {
  225. this.m_MainThread.b(var4);
  226. } else {
  227. this.m_MainThread.c(var4);
  228. }
  229. } else {
  230. var4.run();
  231. }
  232.  
  233. if (var2 == null && var1 == 0) {
  234. try {
  235. if (!var3.tryAcquire(4L, TimeUnit.SECONDS)) {
  236. g.Log(5, "Timeout while trying detaching primary window.");
  237. }
  238. } catch (InterruptedException var5) {
  239. g.Log(5, "UI thread got interrupted while trying to detach the primary window from the Unity Engine.");
  240. }
  241. }
  242.  
  243. return true;
  244. } else {
  245. return false;
  246. }
  247. }
  248.  
  249. public boolean displayChanged(int var1, Surface var2) {
  250. if (var1 == 0) {
  251. this.mMainDisplayOverride = var2 != null;
  252. this.runOnUiThread(new Runnable() {
  253. public final void run() {
  254. if (UnityPlayer.this.mMainDisplayOverride) {
  255. UnityPlayer.this.removeView(UnityPlayer.this.mGlView);
  256. } else {
  257. UnityPlayer.this.addView(UnityPlayer.this.mGlView);
  258. }
  259. }
  260. });
  261. }
  262.  
  263. return this.updateDisplayInternal(var1, var2);
  264. }
  265.  
  266. public static void UnitySendMessage(String var0, String var1, String var2) {
  267. if (!n.c()) {
  268. g.Log(5, "Native libraries not loaded - dropping message for " + var0 + "." + var1);
  269. } else {
  270. try {
  271. nativeUnitySendMessage(var0, var1, var2.getBytes("UTF-8"));
  272. } catch (UnsupportedEncodingException var3) {
  273. }
  274. }
  275. }
  276.  
  277. private static native void nativeUnitySendMessage(String var0, String var1, byte[] var2);
  278.  
  279. private void finish() {
  280. if (this.mContext instanceof Activity && !((Activity)this.mContext).isFinishing()) {
  281. ((Activity)this.mContext).finish();
  282. }
  283.  
  284. }
  285.  
  286. void runOnAnonymousThread(Runnable var1) {
  287. (new Thread(var1)).start();
  288. }
  289.  
  290. void runOnUiThread(Runnable var1) {
  291. if (this.mContext instanceof Activity) {
  292. ((Activity)this.mContext).runOnUiThread(var1);
  293. } else {
  294. g.Log(5, "Not running Unity from an Activity; ignored...");
  295. }
  296. }
  297.  
  298. public void init(int var1, boolean var2) {
  299. }
  300.  
  301. public View getView() {
  302. return this;
  303. }
  304.  
  305. public Bundle getSettings() {
  306. return Bundle.EMPTY;
  307. }
  308.  
  309. public void quit() {
  310. this.destroy();
  311. }
  312.  
  313. public void newIntent(Intent var1) {
  314. this.m_launchUri = var1.getData();
  315. this.m_MainThread.e();
  316. }
  317.  
  318. protected void kill() {
  319. Process.killProcess(Process.myPid());
  320. }
  321.  
  322. public void destroy() {
  323. if (GoogleVrApi.b() != null) {
  324. GoogleVrApi.a();
  325. }
  326.  
  327. if (this.m_Camera2Wrapper != null) {
  328. this.m_Camera2Wrapper.a();
  329. this.m_Camera2Wrapper = null;
  330. }
  331.  
  332. if (this.m_HFPStatus != null) {
  333. this.m_HFPStatus.a();
  334. this.m_HFPStatus = null;
  335. }
  336.  
  337. if (this.m_NetworkConnectivity != null) {
  338. this.m_NetworkConnectivity.b();
  339. this.m_NetworkConnectivity = null;
  340. }
  341.  
  342. this.mQuitting = true;
  343. if (!this.mState.d()) {
  344. this.pause();
  345. }
  346.  
  347. this.m_MainThread.a();
  348.  
  349. try {
  350. this.m_MainThread.join(4000L);
  351. } catch (InterruptedException var1) {
  352. this.m_MainThread.interrupt();
  353. }
  354.  
  355. if (this.mKillingIsMyBusiness != null) {
  356. this.mContext.unregisterReceiver(this.mKillingIsMyBusiness);
  357. }
  358.  
  359. this.mKillingIsMyBusiness = null;
  360. if (n.c()) {
  361. this.removeAllViews();
  362. }
  363.  
  364. if (!this.mShutdownWasCalled) {
  365. this.kill();
  366. }
  367.  
  368. unloadNative();
  369. }
  370.  
  371. public void pause() {
  372. if (this.m_ARCoreApi != null) {
  373. this.m_ARCoreApi.pauseARCore();
  374. }
  375.  
  376. if (this.mVideoPlayerProxy != null) {
  377. this.mVideoPlayerProxy.a();
  378. }
  379.  
  380. GoogleVrProxy var1;
  381. if ((var1 = GoogleVrApi.b()) != null) {
  382. var1.pauseGvrLayout();
  383. }
  384.  
  385. if (this.m_AudioVolumeHandler != null) {
  386. this.m_AudioVolumeHandler.a();
  387. this.m_AudioVolumeHandler = null;
  388. }
  389.  
  390. this.pauseUnity();
  391. }
  392.  
  393. private void pauseUnity() {
  394. this.reportSoftInputStr((String)null, 1, true);
  395. if (this.mState.g()) {
  396. if (n.c()) {
  397. final Semaphore var1 = new Semaphore(0);
  398. Runnable var2;
  399. if (this.isFinishing()) {
  400. var2 = new Runnable() {
  401. public final void run() {
  402. UnityPlayer.this.shutdown();
  403. var1.release();
  404. }
  405. };
  406. } else {
  407. var2 = new Runnable() {
  408. public final void run() {
  409. if (UnityPlayer.this.nativePause()) {
  410. UnityPlayer.this.mQuitting = true;
  411. UnityPlayer.this.shutdown();
  412. var1.release(2);
  413. } else {
  414. var1.release();
  415. }
  416. }
  417. };
  418. }
  419.  
  420. this.m_MainThread.a(var2);
  421.  
  422. try {
  423. if (!var1.tryAcquire(4L, TimeUnit.SECONDS)) {
  424. g.Log(5, "Timeout while trying to pause the Unity Engine.");
  425. }
  426. } catch (InterruptedException var3) {
  427. g.Log(5, "UI thread got interrupted while trying to pause the Unity Engine.");
  428. }
  429.  
  430. if (var1.drainPermits() > 0) {
  431. this.destroy();
  432. }
  433. }
  434.  
  435. this.mState.d(false);
  436. this.mState.b(true);
  437. if (this.m_AddPhoneCallListener) {
  438. this.m_TelephonyManager.listen(this.m_PhoneCallListener, 0);
  439. }
  440.  
  441. }
  442. }
  443.  
  444. public void resume() {
  445. if (this.m_ARCoreApi != null) {
  446. this.m_ARCoreApi.resumeARCore();
  447. }
  448.  
  449. this.mState.b(false);
  450. if (this.mVideoPlayerProxy != null) {
  451. this.mVideoPlayerProxy.b();
  452. }
  453.  
  454. this.checkResumePlayer();
  455. this.nativeRestartActivityIndicator();
  456. GoogleVrProxy var1;
  457. if ((var1 = GoogleVrApi.b()) != null) {
  458. var1.b();
  459. }
  460.  
  461. this.m_AudioVolumeHandler = new AudioVolumeHandler(this.mContext);
  462. }
  463.  
  464. public void lowMemory() {
  465. if (n.c()) {
  466. this.queueGLThreadEvent(new Runnable() {
  467. public final void run() {
  468. UnityPlayer.this.nativeLowMemory();
  469. }
  470. });
  471. }
  472. }
  473.  
  474. private void shutdown() {
  475. this.mShutdownWasCalled = true;
  476. this.nativeDone();
  477. this.mState.c(false);
  478. }
  479.  
  480. private void checkResumePlayer() {
  481. if (this.mState.f()) {
  482. this.mState.d(true);
  483. this.queueGLThreadEvent(new Runnable() {
  484. public final void run() {
  485. UnityPlayer.this.nativeResume();
  486. }
  487. });
  488. this.m_MainThread.b();
  489. }
  490. }
  491.  
  492. protected boolean skipPermissionsDialog() {
  493. return j.b && currentActivity != null ? j.d.a(currentActivity) : false;
  494. }
  495.  
  496. protected void requestUserAuthorization(String var1) {
  497. if (j.b && var1 != null && !var1.isEmpty() && currentActivity != null) {
  498. j.d.a(currentActivity, var1);
  499. }
  500.  
  501. }
  502.  
  503. protected int getNetworkConnectivity() {
  504. if (j.c) {
  505. if (this.m_NetworkConnectivity == null) {
  506. this.m_NetworkConnectivity = new NetworkConnectivity(this.mContext);
  507. }
  508.  
  509. return this.m_NetworkConnectivity.a();
  510. } else {
  511. return 0;
  512. }
  513. }
  514.  
  515. public void configurationChanged(Configuration var1) {
  516. if (this.mGlView instanceof SurfaceView) {
  517. this.mGlView.getHolder().setSizeFromLayout();
  518. }
  519.  
  520. if (this.mVideoPlayerProxy != null) {
  521. this.mVideoPlayerProxy.c();
  522. }
  523.  
  524. GoogleVrProxy var2;
  525. if ((var2 = GoogleVrApi.b()) != null) {
  526. var2.c();
  527. }
  528.  
  529. }
  530.  
  531. public void windowFocusChanged(boolean var1) {
  532. this.mState.a(var1);
  533. if (this.mState.e()) {
  534. if (var1 && this.mSoftInputDialog != null) {
  535. this.nativeSoftInputLostFocus();
  536. this.reportSoftInputStr((String)null, 1, false);
  537. }
  538.  
  539. if (var1) {
  540. this.m_MainThread.c();
  541. } else {
  542. this.m_MainThread.d();
  543. }
  544.  
  545. this.checkResumePlayer();
  546. }
  547. }
  548.  
  549. protected static boolean loadLibraryStatic(String var0) {
  550. try {
  551. System.loadLibrary(var0);
  552. return true;
  553. } catch (UnsatisfiedLinkError var1) {
  554. g.Log(6, "Unable to find " + var0);
  555. return false;
  556. } catch (Exception var2) {
  557. g.Log(6, "Unknown error " + var2);
  558. return false;
  559. }
  560. }
  561.  
  562. protected boolean loadLibrary(String var1) {
  563. return loadLibraryStatic(var1);
  564. }
  565.  
  566. protected void addPhoneCallListener() {
  567. this.m_AddPhoneCallListener = true;
  568. this.m_TelephonyManager.listen(this.m_PhoneCallListener, 32);
  569. }
  570.  
  571. private final native void initJni(Context var1);
  572.  
  573. private final native boolean nativeRender();
  574.  
  575. private final native void nativeSetInputArea(int var1, int var2, int var3, int var4);
  576.  
  577. private final native void nativeSetKeyboardIsVisible(boolean var1);
  578.  
  579. private final native void nativeSetInputString(String var1);
  580.  
  581. private final native void nativeSetInputSelection(int var1, int var2);
  582.  
  583. private final native void nativeSoftInputCanceled();
  584.  
  585. private final native void nativeSoftInputLostFocus();
  586.  
  587. private final native void nativeReportKeyboardConfigChanged();
  588.  
  589. private final native boolean nativePause();
  590.  
  591. private final native void nativeResume();
  592.  
  593. private final native void nativeLowMemory();
  594.  
  595. private final native void nativeFocusChanged(boolean var1);
  596.  
  597. private final native void nativeRecreateGfxState(int var1, Surface var2);
  598.  
  599. private final native void nativeSendSurfaceChangedEvent();
  600.  
  601. private final native void nativeDone();
  602.  
  603. private final native void nativeSoftInputClosed();
  604.  
  605. private final native boolean nativeInjectEvent(InputEvent var1);
  606.  
  607. private final native boolean nativeIsAutorotationOn();
  608.  
  609. private final native void nativeMuteMasterAudio(boolean var1);
  610.  
  611. private final native void nativeRestartActivityIndicator();
  612.  
  613. private final native void nativeSetLaunchURL(String var1);
  614.  
  615. private static void loadNative(ApplicationInfo var0) {
  616. if (mLibMainLoaded && NativeLoader.load(var0.nativeLibraryDir)) {
  617. n.a();
  618. }
  619.  
  620. }
  621.  
  622. private static void unloadNative() {
  623. if (n.c()) {
  624. if (!NativeLoader.unload()) {
  625. throw new UnsatisfiedLinkError("Unable to unload libraries from libmain.so");
  626. } else {
  627. n.b();
  628. }
  629. }
  630. }
  631.  
  632. protected void showSoftInput(final String var1, final int var2, final boolean var3, final boolean var4, final boolean var5, final boolean var6, final String var7, final int var8, final boolean var9) {
  633. this.runOnUiThread(new Runnable() {
  634. public final void run() {
  635. UnityPlayer.this.mSoftInputDialog = new k(UnityPlayer.this.mContext, UnityPlayer.this, var1, var2, var3, var4, var5, var7, var8, var9);
  636. UnityPlayer.this.mSoftInputDialog.show();
  637. UnityPlayer.this.nativeReportKeyboardConfigChanged();
  638. }
  639. });
  640. }
  641.  
  642. protected void hideSoftInput() {
  643. this.reportSoftInputArea(new Rect());
  644. this.reportSoftInputIsVisible(false);
  645. final Runnable var1 = new Runnable() {
  646. public final void run() {
  647. if (UnityPlayer.this.mSoftInputDialog != null) {
  648. UnityPlayer.this.mSoftInputDialog.dismiss();
  649. UnityPlayer.this.mSoftInputDialog = null;
  650. UnityPlayer.this.nativeReportKeyboardConfigChanged();
  651. }
  652.  
  653. }
  654. };
  655. if (j.a) {
  656. this.queueGLThreadEvent(new UnityPlayer.f() {
  657. public final void a() {
  658. UnityPlayer.this.runOnUiThread(var1);
  659. }
  660. });
  661. } else {
  662. this.runOnUiThread(var1);
  663. }
  664. }
  665.  
  666. protected void setSoftInputStr(final String var1) {
  667. this.runOnUiThread(new Runnable() {
  668. public final void run() {
  669. if (UnityPlayer.this.mSoftInputDialog != null && var1 != null) {
  670. UnityPlayer.this.mSoftInputDialog.a(var1);
  671. }
  672.  
  673. }
  674. });
  675. }
  676.  
  677. protected void setCharacterLimit(final int var1) {
  678. this.runOnUiThread(new Runnable() {
  679. public final void run() {
  680. if (UnityPlayer.this.mSoftInputDialog != null) {
  681. UnityPlayer.this.mSoftInputDialog.a(var1);
  682. }
  683.  
  684. }
  685. });
  686. }
  687.  
  688. protected void setHideInputField(final boolean var1) {
  689. this.runOnUiThread(new Runnable() {
  690. public final void run() {
  691. if (UnityPlayer.this.mSoftInputDialog != null) {
  692. UnityPlayer.this.mSoftInputDialog.a(var1);
  693. }
  694.  
  695. }
  696. });
  697. }
  698.  
  699. protected void setSelection(final int var1, final int var2) {
  700. this.runOnUiThread(new Runnable() {
  701. public final void run() {
  702. if (UnityPlayer.this.mSoftInputDialog != null) {
  703. UnityPlayer.this.mSoftInputDialog.a(var1, var2);
  704. }
  705.  
  706. }
  707. });
  708. }
  709.  
  710. protected String getKeyboardLayout() {
  711. return this.mSoftInputDialog == null ? null : this.mSoftInputDialog.a();
  712. }
  713.  
  714. protected void reportSoftInputStr(final String var1, final int var2, final boolean var3) {
  715. if (var2 == 1) {
  716. this.hideSoftInput();
  717. }
  718.  
  719. this.queueGLThreadEvent(new UnityPlayer.f() {
  720. public final void a() {
  721. if (var3) {
  722. UnityPlayer.this.nativeSoftInputCanceled();
  723. } else if (var1 != null) {
  724. UnityPlayer.this.nativeSetInputString(var1);
  725. }
  726.  
  727. if (var2 == 1) {
  728. UnityPlayer.this.nativeSoftInputClosed();
  729. }
  730.  
  731. }
  732. });
  733. }
  734.  
  735. protected void reportSoftInputSelection(final int var1, final int var2) {
  736. this.queueGLThreadEvent(new UnityPlayer.f() {
  737. public final void a() {
  738. UnityPlayer.this.nativeSetInputSelection(var1, var2);
  739. }
  740. });
  741. }
  742.  
  743. protected void reportSoftInputArea(final Rect var1) {
  744. this.queueGLThreadEvent(new UnityPlayer.f() {
  745. public final void a() {
  746. UnityPlayer.this.nativeSetInputArea(var1.left, var1.top, var1.right, var1.bottom);
  747. }
  748. });
  749. }
  750.  
  751. protected void reportSoftInputIsVisible(final boolean var1) {
  752. this.queueGLThreadEvent(new UnityPlayer.f() {
  753. public final void a() {
  754. UnityPlayer.this.nativeSetKeyboardIsVisible(var1);
  755. }
  756. });
  757. }
  758.  
  759. protected void setClipboardText(String var1) {
  760. ClipData var2 = ClipData.newPlainText("Text", var1);
  761. this.m_ClipboardManager.setPrimaryClip(var2);
  762. }
  763.  
  764. protected String getClipboardText() {
  765. String var1 = "";
  766. ClipData var2;
  767. if ((var2 = this.m_ClipboardManager.getPrimaryClip()) != null) {
  768. var1 = var2.getItemAt(0).coerceToText(this.mContext).toString();
  769. }
  770.  
  771. return var1;
  772. }
  773.  
  774. protected String getLaunchURL() {
  775. return this.m_launchUri != null ? this.m_launchUri.toString() : null;
  776. }
  777.  
  778. protected boolean initializeGoogleAr() {
  779. if (this.m_ARCoreApi == null && currentActivity != null && this.getTangoEnabled()) {
  780. this.m_ARCoreApi = new GoogleARCoreApi();
  781. this.m_ARCoreApi.initializeARCore(currentActivity);
  782. if (!this.mState.d()) {
  783. this.m_ARCoreApi.resumeARCore();
  784. }
  785. }
  786.  
  787. return false;
  788. }
  789.  
  790. protected boolean initializeGoogleVr() {
  791. final GoogleVrProxy var1;
  792. if ((var1 = GoogleVrApi.b()) == null) {
  793. GoogleVrApi.a(this);
  794. if ((var1 = GoogleVrApi.b()) == null) {
  795. g.Log(6, "Unable to create Google VR subsystem.");
  796. return false;
  797. }
  798. }
  799.  
  800. final Semaphore var3 = new Semaphore(0);
  801. final Runnable var4 = new Runnable() {
  802. public final void run() {
  803. UnityPlayer.this.injectEvent(new KeyEvent(0, 4));
  804. UnityPlayer.this.injectEvent(new KeyEvent(1, 4));
  805. }
  806. };
  807. this.runOnUiThread(new Runnable() {
  808. public final void run() {
  809. if (!var1.a(UnityPlayer.currentActivity, UnityPlayer.this.mContext, UnityPlayer.this.CreateGlView(), var4)) {
  810. g.Log(6, "Unable to initialize Google VR subsystem.");
  811. }
  812.  
  813. if (UnityPlayer.currentActivity != null) {
  814. var1.a(UnityPlayer.currentActivity.getIntent());
  815. }
  816.  
  817. var3.release();
  818. }
  819. });
  820.  
  821. try {
  822. if (!var3.tryAcquire(4L, TimeUnit.SECONDS)) {
  823. g.Log(5, "Timeout while trying to initialize Google VR.");
  824. return false;
  825. }
  826. } catch (InterruptedException var5) {
  827. g.Log(5, "UI thread was interrupted while initializing Google VR. " + var5.getLocalizedMessage());
  828. return false;
  829. }
  830.  
  831. return var1.a();
  832. }
  833.  
  834. protected boolean showVideoPlayer(String var1, int var2, int var3, int var4, boolean var5, int var6, int var7) {
  835. if (this.mVideoPlayerProxy == null) {
  836. this.mVideoPlayerProxy = new q(this);
  837. }
  838.  
  839. boolean var8;
  840. if (var8 = this.mVideoPlayerProxy.a(this.mContext, var1, var2, var3, var4, var5, (long)var6, (long)var7, new com.unity3d.player.q.a() {
  841. public final void a() {
  842. UnityPlayer.this.mVideoPlayerProxy = null;
  843. }
  844. })) {
  845. this.runOnUiThread(new Runnable() {
  846. public final void run() {
  847. if (UnityPlayer.this.nativeIsAutorotationOn() && UnityPlayer.this.mContext instanceof Activity) {
  848. ((Activity)UnityPlayer.this.mContext).setRequestedOrientation(UnityPlayer.this.mInitialScreenOrientation);
  849. }
  850.  
  851. }
  852. });
  853. }
  854.  
  855. return var8;
  856. }
  857.  
  858. protected void moveTaskToBack() {
  859. this.runOnUiThread(new Runnable() {
  860. public final void run() {
  861. if (UnityPlayer.this.mContext instanceof Activity) {
  862. ((Activity)UnityPlayer.this.mContext).moveTaskToBack(true);
  863. }
  864.  
  865. }
  866. });
  867. }
  868.  
  869. private ApplicationInfo getApplicationInfo() {
  870. return this.mContext.getPackageManager().getApplicationInfo(this.mContext.getPackageName(), 128);
  871. }
  872.  
  873. private boolean getSplashEnabled() {
  874. try {
  875. return this.getApplicationInfo().metaData.getBoolean("unity.splash-enable");
  876. } catch (Exception var1) {
  877. return false;
  878. }
  879. }
  880.  
  881. private boolean getTangoEnabled() {
  882. try {
  883. return this.getApplicationInfo().metaData.getBoolean("unity.tango-enable");
  884. } catch (Exception var1) {
  885. return false;
  886. }
  887. }
  888.  
  889. protected int getSplashMode() {
  890. try {
  891. return this.getApplicationInfo().metaData.getInt("unity.splash-mode");
  892. } catch (Exception var1) {
  893. return 0;
  894. }
  895. }
  896.  
  897. protected void executeGLThreadJobs() {
  898. Runnable var1;
  899. while((var1 = (Runnable)this.m_Events.poll()) != null) {
  900. var1.run();
  901. }
  902.  
  903. }
  904.  
  905. protected void disableLogger() {
  906. g.a = true;
  907. }
  908.  
  909. private void queueGLThreadEvent(Runnable var1) {
  910. if (n.c()) {
  911. if (Thread.currentThread() == this.m_MainThread) {
  912. var1.run();
  913. } else {
  914. this.m_Events.add(var1);
  915. }
  916. }
  917. }
  918.  
  919. private void queueGLThreadEvent(UnityPlayer.f var1) {
  920. if (!this.isFinishing()) {
  921. this.queueGLThreadEvent((Runnable)var1);
  922. }
  923. }
  924.  
  925. protected boolean isFinishing() {
  926. return this.mQuitting || (this.mQuitting = this.mContext instanceof Activity && ((Activity)this.mContext).isFinishing());
  927. }
  928.  
  929. private void hideStatusBar() {
  930. if (this.mContext instanceof Activity) {
  931. ((Activity)this.mContext).getWindow().setFlags(1024, 1024);
  932. }
  933.  
  934. }
  935.  
  936. public boolean injectEvent(InputEvent var1) {
  937. return !n.c() ? false : this.nativeInjectEvent(var1);
  938. }
  939.  
  940. public boolean onKeyUp(int var1, KeyEvent var2) {
  941. return this.injectEvent(var2);
  942. }
  943.  
  944. public boolean onKeyDown(int var1, KeyEvent var2) {
  945. return this.injectEvent(var2);
  946. }
  947.  
  948. public boolean onKeyMultiple(int var1, int var2, KeyEvent var3) {
  949. return this.injectEvent(var3);
  950. }
  951.  
  952. public boolean onKeyLongPress(int var1, KeyEvent var2) {
  953. return this.injectEvent(var2);
  954. }
  955.  
  956. public boolean onTouchEvent(MotionEvent var1) {
  957. return this.injectEvent(var1);
  958. }
  959.  
  960. public boolean onGenericMotionEvent(MotionEvent var1) {
  961. return this.injectEvent(var1);
  962. }
  963.  
  964. private void swapViews(View var1, View var2) {
  965. boolean var4 = false;
  966. if (!this.mState.d()) {
  967. this.pause();
  968. var4 = true;
  969. }
  970.  
  971. ViewParent var3;
  972. if (var1 != null && (!((var3 = var1.getParent()) instanceof UnityPlayer) || (UnityPlayer)var3 != this)) {
  973. if (var3 instanceof ViewGroup) {
  974. ((ViewGroup)var3).removeView(var1);
  975. }
  976.  
  977. this.addView(var1);
  978. this.bringChildToFront(var1);
  979. var1.setVisibility(0);
  980. }
  981.  
  982. if (var2 != null && var2.getParent() == this) {
  983. var2.setVisibility(8);
  984. this.removeView(var2);
  985. }
  986.  
  987. if (var4) {
  988. this.resume();
  989. }
  990.  
  991. }
  992.  
  993. public boolean addViewToPlayer(View var1, boolean var2) {
  994. this.swapViews(var1, var2 ? this.mGlView : null);
  995. boolean var5 = var1.getParent() == this;
  996. var2 = var2 && this.mGlView.getParent() == null;
  997. boolean var3 = this.mGlView.getParent() == this;
  998. boolean var4;
  999. if (!(var4 = var5 && (var2 || var3))) {
  1000. if (!var5) {
  1001. g.Log(6, "addViewToPlayer: Failure adding view to hierarchy");
  1002. }
  1003.  
  1004. if (!var2 && !var3) {
  1005. g.Log(6, "addViewToPlayer: Failure removing old view from hierarchy");
  1006. }
  1007. }
  1008.  
  1009. return var4;
  1010. }
  1011.  
  1012. public void removeViewFromPlayer(View var1) {
  1013. this.swapViews(this.mGlView, var1);
  1014. boolean var3 = var1.getParent() == null;
  1015. boolean var2 = this.mGlView.getParent() == this;
  1016. if (!var3 || !var2) {
  1017. if (!var3) {
  1018. g.Log(6, "removeViewFromPlayer: Failure removing view from hierarchy");
  1019. }
  1020.  
  1021. if (!var2) {
  1022. g.Log(6, "removeVireFromPlayer: Failure agging old view to hierarchy");
  1023. }
  1024. }
  1025.  
  1026. }
  1027.  
  1028. public void reportError(String var1, String var2) {
  1029. StringBuilder var3;
  1030. (var3 = new StringBuilder()).append(var1);
  1031. var3.append(": ");
  1032. var3.append(var2);
  1033. g.Log(6, var3.toString());
  1034. }
  1035.  
  1036. static {
  1037. (new m()).a();
  1038. mLibMainLoaded = false;
  1039. mLibMainLoaded = loadLibraryStatic("main");
  1040. }
  1041.  
  1042. private abstract class f implements Runnable {
  1043. private f() {
  1044. }
  1045.  
  1046. public final void run() {
  1047. if (!UnityPlayer.this.isFinishing()) {
  1048. this.a();
  1049. }
  1050.  
  1051. }
  1052.  
  1053. public abstract void a();
  1054. }
  1055.  
  1056. class a implements SensorEventListener {
  1057. a() {
  1058. }
  1059.  
  1060. public final void onAccuracyChanged(Sensor var1, int var2) {
  1061. }
  1062.  
  1063. public final void onSensorChanged(SensorEvent var1) {
  1064. }
  1065. }
  1066.  
  1067. private class c extends PhoneStateListener {
  1068. private c() {
  1069. }
  1070.  
  1071. public final void onCallStateChanged(int var1, String var2) {
  1072. UnityPlayer.this.nativeMuteMasterAudio(var1 == 1);
  1073. }
  1074. }
  1075.  
  1076. private class e extends Thread {
  1077. Handler a;
  1078. boolean b;
  1079. boolean c;
  1080. int d;
  1081. int e;
  1082.  
  1083. private e() {
  1084. this.b = false;
  1085. this.c = false;
  1086. this.d = UnityPlayer.b.b;
  1087. this.e = 5;
  1088. }
  1089.  
  1090. public final void run() {
  1091. this.setName("UnityMain");
  1092. Looper.prepare();
  1093. this.a = new Handler(new android.os.Handler.Callback() {
  1094. private void a() {
  1095. if (e.this.d == UnityPlayer.b.c && e.this.c) {
  1096. UnityPlayer.this.nativeFocusChanged(true);
  1097. e.this.d = UnityPlayer.b.a;
  1098. }
  1099.  
  1100. }
  1101.  
  1102. public final boolean handleMessage(Message var1) {
  1103. if (var1.what != 2269) {
  1104. return false;
  1105. } else {
  1106. UnityPlayer.d var2;
  1107. if ((var2 = (UnityPlayer.d)var1.obj) == UnityPlayer.d.h) {
  1108. UnityPlayer.this.executeGLThreadJobs();
  1109. if (!e.this.b) {
  1110. return true;
  1111. }
  1112.  
  1113. if (!e.this.c) {
  1114. return true;
  1115. }
  1116.  
  1117. if (e.this.e >= 0) {
  1118. if (e.this.e == 0 && UnityPlayer.this.getSplashEnabled()) {
  1119. UnityPlayer.this.DisableStaticSplashScreen();
  1120. }
  1121.  
  1122. --e.this.e;
  1123. }
  1124.  
  1125. if (!UnityPlayer.this.isFinishing() && !UnityPlayer.this.nativeRender()) {
  1126. UnityPlayer.this.finish();
  1127. }
  1128. } else if (var2 == UnityPlayer.d.c) {
  1129. Looper.myLooper().quit();
  1130. } else if (var2 == UnityPlayer.d.b) {
  1131. e.this.b = true;
  1132. } else if (var2 == UnityPlayer.d.a) {
  1133. e.this.b = false;
  1134. } else if (var2 == UnityPlayer.d.d) {
  1135. e.this.c = false;
  1136. } else if (var2 == UnityPlayer.d.e) {
  1137. e.this.c = true;
  1138. this.a();
  1139. } else if (var2 == UnityPlayer.d.f) {
  1140. if (e.this.d == UnityPlayer.b.a) {
  1141. UnityPlayer.this.nativeFocusChanged(false);
  1142. }
  1143.  
  1144. e.this.d = UnityPlayer.b.b;
  1145. } else if (var2 == UnityPlayer.d.g) {
  1146. e.this.d = UnityPlayer.b.c;
  1147. this.a();
  1148. } else if (var2 == UnityPlayer.d.i) {
  1149. UnityPlayer.this.nativeSetLaunchURL(UnityPlayer.this.getLaunchURL());
  1150. }
  1151.  
  1152. if (e.this.b) {
  1153. Message.obtain(e.this.a, 2269, UnityPlayer.d.h).sendToTarget();
  1154. }
  1155.  
  1156. return true;
  1157. }
  1158. }
  1159. });
  1160. Looper.loop();
  1161. }
  1162.  
  1163. public final void a() {
  1164. this.a(UnityPlayer.d.c);
  1165. }
  1166.  
  1167. public final void b() {
  1168. this.a(UnityPlayer.d.b);
  1169. }
  1170.  
  1171. public final void a(Runnable var1) {
  1172. if (this.a != null) {
  1173. this.a(UnityPlayer.d.a);
  1174. Message.obtain(this.a, var1).sendToTarget();
  1175. }
  1176. }
  1177.  
  1178. public final void c() {
  1179. this.a(UnityPlayer.d.g);
  1180. }
  1181.  
  1182. public final void d() {
  1183. this.a(UnityPlayer.d.f);
  1184. }
  1185.  
  1186. public final void b(Runnable var1) {
  1187. if (this.a != null) {
  1188. this.a(UnityPlayer.d.d);
  1189. Message.obtain(this.a, var1).sendToTarget();
  1190. }
  1191. }
  1192.  
  1193. public final void c(Runnable var1) {
  1194. if (this.a != null) {
  1195. Message.obtain(this.a, var1).sendToTarget();
  1196. this.a(UnityPlayer.d.e);
  1197. }
  1198. }
  1199.  
  1200. public final void d(Runnable var1) {
  1201. if (this.a != null) {
  1202. Message.obtain(this.a, var1).sendToTarget();
  1203. }
  1204.  
  1205. }
  1206.  
  1207. public final void e() {
  1208. this.a(UnityPlayer.d.i);
  1209. }
  1210.  
  1211. private void a(UnityPlayer.d var1) {
  1212. if (this.a != null) {
  1213. Message.obtain(this.a, 2269, var1).sendToTarget();
  1214. }
  1215.  
  1216. }
  1217. }
  1218.  
  1219. static enum b {
  1220. a = 1,
  1221. b = 2,
  1222. c = 3;
  1223.  
  1224. static {
  1225. d = new int[]{a, b, c};
  1226. }
  1227. }
  1228.  
  1229. static enum d {
  1230. a,
  1231. b,
  1232. c,
  1233. d,
  1234. e,
  1235. f,
  1236. g,
  1237. h,
  1238. i;
  1239.  
  1240. private d() {
  1241. }
  1242. }
  1243. }
Add Comment
Please, Sign In to add comment