Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Source code recreated from a .class file by IntelliJ IDEA
- // (powered by Fernflower decompiler)
- //
- package com.unity3d.player;
- import android.app.Activity;
- import android.app.AlertDialog;
- import android.app.AlertDialog.Builder;
- import android.content.BroadcastReceiver;
- import android.content.ClipData;
- import android.content.ClipboardManager;
- import android.content.Context;
- import android.content.DialogInterface;
- import android.content.Intent;
- import android.content.DialogInterface.OnClickListener;
- import android.content.pm.ApplicationInfo;
- import android.content.res.Configuration;
- import android.graphics.Rect;
- import android.hardware.Sensor;
- import android.hardware.SensorEvent;
- import android.hardware.SensorEventListener;
- import android.hardware.SensorManager;
- import android.net.Uri;
- import android.os.Bundle;
- import android.os.Handler;
- import android.os.Looper;
- import android.os.Message;
- import android.os.Process;
- import android.telephony.PhoneStateListener;
- import android.telephony.TelephonyManager;
- import android.util.TypedValue;
- import android.view.InputEvent;
- 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.view.ViewParent;
- import android.view.SurfaceHolder.Callback;
- import android.widget.FrameLayout;
- import java.io.UnsupportedEncodingException;
- import java.util.concurrent.ConcurrentLinkedQueue;
- import java.util.concurrent.Semaphore;
- import java.util.concurrent.TimeUnit;
- public class UnityPlayer extends FrameLayout implements com.unity3d.player.f {
- public static Activity currentActivity = null;
- private int mInitialScreenOrientation = -1;
- private boolean mMainDisplayOverride = false;
- private boolean mIsFullscreen = true;
- private n mState = new n();
- private final ConcurrentLinkedQueue m_Events = new ConcurrentLinkedQueue();
- private BroadcastReceiver mKillingIsMyBusiness = null;
- private static final int ANR_TIMEOUT_SECONDS = 4;
- private static final int RUN_STATE_CHANGED_MSG_CODE = 2269;
- UnityPlayer.e m_MainThread = new UnityPlayer.e((byte)0);
- private boolean m_AddPhoneCallListener = false;
- private UnityPlayer.c m_PhoneCallListener = new UnityPlayer.c((byte)0);
- private TelephonyManager m_TelephonyManager;
- private ClipboardManager m_ClipboardManager;
- private l m_SplashScreen;
- private GoogleARCoreApi m_ARCoreApi = null;
- private UnityPlayer.a m_FakeListener = new UnityPlayer.a();
- private Camera2Wrapper m_Camera2Wrapper = null;
- private HFPStatus m_HFPStatus = null;
- private AudioVolumeHandler m_AudioVolumeHandler = null;
- private Uri m_launchUri = null;
- private NetworkConnectivity m_NetworkConnectivity = null;
- private Context mContext;
- private SurfaceView mGlView;
- private static boolean mLibMainLoaded;
- private boolean mQuitting;
- private boolean mShutdownWasCalled = false;
- private q mVideoPlayerProxy;
- k mSoftInputDialog = null;
- private static final String SPLASH_ENABLE_METADATA_NAME = "unity.splash-enable";
- private static final String SPLASH_MODE_METADATA_NAME = "unity.splash-mode";
- private static final String TANGO_ENABLE_METADATA_NAME = "unity.tango-enable";
- public UnityPlayer(Context var1) {
- super(var1);
- if (var1 instanceof Activity) {
- currentActivity = (Activity)var1;
- this.mInitialScreenOrientation = currentActivity.getRequestedOrientation();
- this.m_launchUri = currentActivity.getIntent().getData();
- }
- this.EarlyEnableFullScreenIfVrLaunched(currentActivity);
- this.mContext = var1;
- if (currentActivity != null && this.getSplashEnabled()) {
- this.m_SplashScreen = new l(this.mContext, com.unity3d.player.l.a.a()[this.getSplashMode()]);
- this.addView(this.m_SplashScreen);
- }
- loadNative(this.mContext.getApplicationInfo());
- if (!n.c()) {
- AlertDialog var2;
- (var2 = (new Builder(this.mContext)).setTitle("Failure to initialize!").setPositiveButton("OK", new OnClickListener() {
- public final void onClick(DialogInterface var1, int var2) {
- UnityPlayer.this.finish();
- }
- }).setMessage("Your hardware does not support this application, sorry!").create()).setCancelable(false);
- var2.show();
- } else {
- this.initJni(var1);
- this.mState.c(true);
- this.mGlView = this.CreateGlView();
- this.mGlView.setContentDescription(this.GetGlViewContentDescription(var1));
- this.addView(this.mGlView);
- this.bringChildToFront(this.m_SplashScreen);
- this.mQuitting = false;
- this.hideStatusBar();
- this.m_TelephonyManager = (TelephonyManager)this.mContext.getSystemService("phone");
- this.m_ClipboardManager = (ClipboardManager)this.mContext.getSystemService("clipboard");
- this.m_Camera2Wrapper = new Camera2Wrapper(this.mContext);
- this.m_HFPStatus = new HFPStatus(this.mContext);
- this.m_MainThread.start();
- }
- }
- protected void toggleGyroscopeSensor(boolean var1) {
- SensorManager var2;
- Sensor var3 = (var2 = (SensorManager)this.mContext.getSystemService("sensor")).getDefaultSensor(11);
- if (var1) {
- var2.registerListener(this.m_FakeListener, var3, 1);
- } else {
- var2.unregisterListener(this.m_FakeListener);
- }
- }
- private String GetGlViewContentDescription(Context var1) {
- return var1.getResources().getString(var1.getResources().getIdentifier("game_view_content_description", "string", var1.getPackageName()));
- }
- private void DisableStaticSplashScreen() {
- this.runOnUiThread(new Runnable() {
- public final void run() {
- UnityPlayer.this.removeView(UnityPlayer.this.m_SplashScreen);
- UnityPlayer.this.m_SplashScreen = null;
- }
- });
- }
- private void EarlyEnableFullScreenIfVrLaunched(Activity var1) {
- View var2;
- if (var1 != null && var1.getIntent().getBooleanExtra("android.intent.extra.VR_LAUNCH", false) && var1.getWindow() != null && (var2 = var1.getWindow().getDecorView()) != null) {
- var2.setSystemUiVisibility(7);
- }
- }
- private boolean IsWindowTranslucent() {
- if (currentActivity == null) {
- return false;
- } else {
- TypedValue var1 = new TypedValue();
- if (currentActivity.getTheme().resolveAttribute(16842840, var1, true) && var1.type == 18) {
- return var1.data != 0;
- } else {
- return false;
- }
- }
- }
- private SurfaceView CreateGlView() {
- SurfaceView var1 = new SurfaceView(this.mContext);
- if (this.IsWindowTranslucent()) {
- var1.getHolder().setFormat(-3);
- var1.setZOrderOnTop(true);
- } else {
- var1.getHolder().setFormat(-1);
- }
- var1.getHolder().addCallback(new Callback() {
- public final void surfaceCreated(SurfaceHolder var1) {
- UnityPlayer.this.updateGLDisplay(0, var1.getSurface());
- }
- public final void surfaceChanged(SurfaceHolder var1, int var2, int var3, int var4) {
- UnityPlayer.this.updateGLDisplay(0, var1.getSurface());
- UnityPlayer.this.sendSurfaceChangedEvent();
- }
- public final void surfaceDestroyed(SurfaceHolder var1) {
- UnityPlayer.this.updateGLDisplay(0, (Surface)null);
- }
- });
- var1.setFocusable(true);
- var1.setFocusableInTouchMode(true);
- return var1;
- }
- private void sendSurfaceChangedEvent() {
- if (n.c() && this.mState.e()) {
- Runnable var1 = new Runnable() {
- public final void run() {
- UnityPlayer.this.nativeSendSurfaceChangedEvent();
- }
- };
- this.m_MainThread.d(var1);
- }
- }
- private void updateGLDisplay(int var1, Surface var2) {
- if (!this.mMainDisplayOverride) {
- this.updateDisplayInternal(var1, var2);
- }
- }
- private boolean updateDisplayInternal(final int var1, final Surface var2) {
- if (n.c() && this.mState.e()) {
- final Semaphore var3 = new Semaphore(0);
- Runnable var4 = new Runnable() {
- public final void run() {
- UnityPlayer.this.nativeRecreateGfxState(var1, var2);
- var3.release();
- }
- };
- if (var1 == 0) {
- if (var2 == null) {
- this.m_MainThread.b(var4);
- } else {
- this.m_MainThread.c(var4);
- }
- } else {
- var4.run();
- }
- if (var2 == null && var1 == 0) {
- try {
- if (!var3.tryAcquire(4L, TimeUnit.SECONDS)) {
- g.Log(5, "Timeout while trying detaching primary window.");
- }
- } catch (InterruptedException var5) {
- g.Log(5, "UI thread got interrupted while trying to detach the primary window from the Unity Engine.");
- }
- }
- return true;
- } else {
- return false;
- }
- }
- public boolean displayChanged(int var1, Surface var2) {
- if (var1 == 0) {
- this.mMainDisplayOverride = var2 != null;
- this.runOnUiThread(new Runnable() {
- public final void run() {
- if (UnityPlayer.this.mMainDisplayOverride) {
- UnityPlayer.this.removeView(UnityPlayer.this.mGlView);
- } else {
- UnityPlayer.this.addView(UnityPlayer.this.mGlView);
- }
- }
- });
- }
- return this.updateDisplayInternal(var1, var2);
- }
- public static void UnitySendMessage(String var0, String var1, String var2) {
- if (!n.c()) {
- g.Log(5, "Native libraries not loaded - dropping message for " + var0 + "." + var1);
- } else {
- try {
- nativeUnitySendMessage(var0, var1, var2.getBytes("UTF-8"));
- } catch (UnsupportedEncodingException var3) {
- }
- }
- }
- private static native void nativeUnitySendMessage(String var0, String var1, byte[] var2);
- private void finish() {
- if (this.mContext instanceof Activity && !((Activity)this.mContext).isFinishing()) {
- ((Activity)this.mContext).finish();
- }
- }
- void runOnAnonymousThread(Runnable var1) {
- (new Thread(var1)).start();
- }
- void runOnUiThread(Runnable var1) {
- if (this.mContext instanceof Activity) {
- ((Activity)this.mContext).runOnUiThread(var1);
- } else {
- g.Log(5, "Not running Unity from an Activity; ignored...");
- }
- }
- public void init(int var1, boolean var2) {
- }
- public View getView() {
- return this;
- }
- public Bundle getSettings() {
- return Bundle.EMPTY;
- }
- public void quit() {
- this.destroy();
- }
- public void newIntent(Intent var1) {
- this.m_launchUri = var1.getData();
- this.m_MainThread.e();
- }
- protected void kill() {
- Process.killProcess(Process.myPid());
- }
- public void destroy() {
- if (GoogleVrApi.b() != null) {
- GoogleVrApi.a();
- }
- if (this.m_Camera2Wrapper != null) {
- this.m_Camera2Wrapper.a();
- this.m_Camera2Wrapper = null;
- }
- if (this.m_HFPStatus != null) {
- this.m_HFPStatus.a();
- this.m_HFPStatus = null;
- }
- if (this.m_NetworkConnectivity != null) {
- this.m_NetworkConnectivity.b();
- this.m_NetworkConnectivity = null;
- }
- this.mQuitting = true;
- if (!this.mState.d()) {
- this.pause();
- }
- this.m_MainThread.a();
- try {
- this.m_MainThread.join(4000L);
- } catch (InterruptedException var1) {
- this.m_MainThread.interrupt();
- }
- if (this.mKillingIsMyBusiness != null) {
- this.mContext.unregisterReceiver(this.mKillingIsMyBusiness);
- }
- this.mKillingIsMyBusiness = null;
- if (n.c()) {
- this.removeAllViews();
- }
- if (!this.mShutdownWasCalled) {
- this.kill();
- }
- unloadNative();
- }
- public void pause() {
- if (this.m_ARCoreApi != null) {
- this.m_ARCoreApi.pauseARCore();
- }
- if (this.mVideoPlayerProxy != null) {
- this.mVideoPlayerProxy.a();
- }
- GoogleVrProxy var1;
- if ((var1 = GoogleVrApi.b()) != null) {
- var1.pauseGvrLayout();
- }
- if (this.m_AudioVolumeHandler != null) {
- this.m_AudioVolumeHandler.a();
- this.m_AudioVolumeHandler = null;
- }
- this.pauseUnity();
- }
- private void pauseUnity() {
- this.reportSoftInputStr((String)null, 1, true);
- if (this.mState.g()) {
- if (n.c()) {
- final Semaphore var1 = new Semaphore(0);
- Runnable var2;
- if (this.isFinishing()) {
- var2 = new Runnable() {
- public final void run() {
- UnityPlayer.this.shutdown();
- var1.release();
- }
- };
- } else {
- var2 = new Runnable() {
- public final void run() {
- if (UnityPlayer.this.nativePause()) {
- UnityPlayer.this.mQuitting = true;
- UnityPlayer.this.shutdown();
- var1.release(2);
- } else {
- var1.release();
- }
- }
- };
- }
- this.m_MainThread.a(var2);
- try {
- if (!var1.tryAcquire(4L, TimeUnit.SECONDS)) {
- g.Log(5, "Timeout while trying to pause the Unity Engine.");
- }
- } catch (InterruptedException var3) {
- g.Log(5, "UI thread got interrupted while trying to pause the Unity Engine.");
- }
- if (var1.drainPermits() > 0) {
- this.destroy();
- }
- }
- this.mState.d(false);
- this.mState.b(true);
- if (this.m_AddPhoneCallListener) {
- this.m_TelephonyManager.listen(this.m_PhoneCallListener, 0);
- }
- }
- }
- public void resume() {
- if (this.m_ARCoreApi != null) {
- this.m_ARCoreApi.resumeARCore();
- }
- this.mState.b(false);
- if (this.mVideoPlayerProxy != null) {
- this.mVideoPlayerProxy.b();
- }
- this.checkResumePlayer();
- this.nativeRestartActivityIndicator();
- GoogleVrProxy var1;
- if ((var1 = GoogleVrApi.b()) != null) {
- var1.b();
- }
- this.m_AudioVolumeHandler = new AudioVolumeHandler(this.mContext);
- }
- public void lowMemory() {
- if (n.c()) {
- this.queueGLThreadEvent(new Runnable() {
- public final void run() {
- UnityPlayer.this.nativeLowMemory();
- }
- });
- }
- }
- private void shutdown() {
- this.mShutdownWasCalled = true;
- this.nativeDone();
- this.mState.c(false);
- }
- private void checkResumePlayer() {
- if (this.mState.f()) {
- this.mState.d(true);
- this.queueGLThreadEvent(new Runnable() {
- public final void run() {
- UnityPlayer.this.nativeResume();
- }
- });
- this.m_MainThread.b();
- }
- }
- protected boolean skipPermissionsDialog() {
- return j.b && currentActivity != null ? j.d.a(currentActivity) : false;
- }
- protected void requestUserAuthorization(String var1) {
- if (j.b && var1 != null && !var1.isEmpty() && currentActivity != null) {
- j.d.a(currentActivity, var1);
- }
- }
- protected int getNetworkConnectivity() {
- if (j.c) {
- if (this.m_NetworkConnectivity == null) {
- this.m_NetworkConnectivity = new NetworkConnectivity(this.mContext);
- }
- return this.m_NetworkConnectivity.a();
- } else {
- return 0;
- }
- }
- public void configurationChanged(Configuration var1) {
- if (this.mGlView instanceof SurfaceView) {
- this.mGlView.getHolder().setSizeFromLayout();
- }
- if (this.mVideoPlayerProxy != null) {
- this.mVideoPlayerProxy.c();
- }
- GoogleVrProxy var2;
- if ((var2 = GoogleVrApi.b()) != null) {
- var2.c();
- }
- }
- public void windowFocusChanged(boolean var1) {
- this.mState.a(var1);
- if (this.mState.e()) {
- if (var1 && this.mSoftInputDialog != null) {
- this.nativeSoftInputLostFocus();
- this.reportSoftInputStr((String)null, 1, false);
- }
- if (var1) {
- this.m_MainThread.c();
- } else {
- this.m_MainThread.d();
- }
- this.checkResumePlayer();
- }
- }
- protected static boolean loadLibraryStatic(String var0) {
- try {
- System.loadLibrary(var0);
- return true;
- } catch (UnsatisfiedLinkError var1) {
- g.Log(6, "Unable to find " + var0);
- return false;
- } catch (Exception var2) {
- g.Log(6, "Unknown error " + var2);
- return false;
- }
- }
- protected boolean loadLibrary(String var1) {
- return loadLibraryStatic(var1);
- }
- protected void addPhoneCallListener() {
- this.m_AddPhoneCallListener = true;
- this.m_TelephonyManager.listen(this.m_PhoneCallListener, 32);
- }
- private final native void initJni(Context var1);
- private final native boolean nativeRender();
- private final native void nativeSetInputArea(int var1, int var2, int var3, int var4);
- private final native void nativeSetKeyboardIsVisible(boolean var1);
- private final native void nativeSetInputString(String var1);
- private final native void nativeSetInputSelection(int var1, int var2);
- private final native void nativeSoftInputCanceled();
- private final native void nativeSoftInputLostFocus();
- private final native void nativeReportKeyboardConfigChanged();
- private final native boolean nativePause();
- private final native void nativeResume();
- private final native void nativeLowMemory();
- private final native void nativeFocusChanged(boolean var1);
- private final native void nativeRecreateGfxState(int var1, Surface var2);
- private final native void nativeSendSurfaceChangedEvent();
- private final native void nativeDone();
- private final native void nativeSoftInputClosed();
- private final native boolean nativeInjectEvent(InputEvent var1);
- private final native boolean nativeIsAutorotationOn();
- private final native void nativeMuteMasterAudio(boolean var1);
- private final native void nativeRestartActivityIndicator();
- private final native void nativeSetLaunchURL(String var1);
- private static void loadNative(ApplicationInfo var0) {
- if (mLibMainLoaded && NativeLoader.load(var0.nativeLibraryDir)) {
- n.a();
- }
- }
- private static void unloadNative() {
- if (n.c()) {
- if (!NativeLoader.unload()) {
- throw new UnsatisfiedLinkError("Unable to unload libraries from libmain.so");
- } else {
- n.b();
- }
- }
- }
- 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) {
- this.runOnUiThread(new Runnable() {
- public final void run() {
- UnityPlayer.this.mSoftInputDialog = new k(UnityPlayer.this.mContext, UnityPlayer.this, var1, var2, var3, var4, var5, var7, var8, var9);
- UnityPlayer.this.mSoftInputDialog.show();
- UnityPlayer.this.nativeReportKeyboardConfigChanged();
- }
- });
- }
- protected void hideSoftInput() {
- this.reportSoftInputArea(new Rect());
- this.reportSoftInputIsVisible(false);
- final Runnable var1 = new Runnable() {
- public final void run() {
- if (UnityPlayer.this.mSoftInputDialog != null) {
- UnityPlayer.this.mSoftInputDialog.dismiss();
- UnityPlayer.this.mSoftInputDialog = null;
- UnityPlayer.this.nativeReportKeyboardConfigChanged();
- }
- }
- };
- if (j.a) {
- this.queueGLThreadEvent(new UnityPlayer.f() {
- public final void a() {
- UnityPlayer.this.runOnUiThread(var1);
- }
- });
- } else {
- this.runOnUiThread(var1);
- }
- }
- protected void setSoftInputStr(final String var1) {
- this.runOnUiThread(new Runnable() {
- public final void run() {
- if (UnityPlayer.this.mSoftInputDialog != null && var1 != null) {
- UnityPlayer.this.mSoftInputDialog.a(var1);
- }
- }
- });
- }
- protected void setCharacterLimit(final int var1) {
- this.runOnUiThread(new Runnable() {
- public final void run() {
- if (UnityPlayer.this.mSoftInputDialog != null) {
- UnityPlayer.this.mSoftInputDialog.a(var1);
- }
- }
- });
- }
- protected void setHideInputField(final boolean var1) {
- this.runOnUiThread(new Runnable() {
- public final void run() {
- if (UnityPlayer.this.mSoftInputDialog != null) {
- UnityPlayer.this.mSoftInputDialog.a(var1);
- }
- }
- });
- }
- protected void setSelection(final int var1, final int var2) {
- this.runOnUiThread(new Runnable() {
- public final void run() {
- if (UnityPlayer.this.mSoftInputDialog != null) {
- UnityPlayer.this.mSoftInputDialog.a(var1, var2);
- }
- }
- });
- }
- protected String getKeyboardLayout() {
- return this.mSoftInputDialog == null ? null : this.mSoftInputDialog.a();
- }
- protected void reportSoftInputStr(final String var1, final int var2, final boolean var3) {
- if (var2 == 1) {
- this.hideSoftInput();
- }
- this.queueGLThreadEvent(new UnityPlayer.f() {
- public final void a() {
- if (var3) {
- UnityPlayer.this.nativeSoftInputCanceled();
- } else if (var1 != null) {
- UnityPlayer.this.nativeSetInputString(var1);
- }
- if (var2 == 1) {
- UnityPlayer.this.nativeSoftInputClosed();
- }
- }
- });
- }
- protected void reportSoftInputSelection(final int var1, final int var2) {
- this.queueGLThreadEvent(new UnityPlayer.f() {
- public final void a() {
- UnityPlayer.this.nativeSetInputSelection(var1, var2);
- }
- });
- }
- protected void reportSoftInputArea(final Rect var1) {
- this.queueGLThreadEvent(new UnityPlayer.f() {
- public final void a() {
- UnityPlayer.this.nativeSetInputArea(var1.left, var1.top, var1.right, var1.bottom);
- }
- });
- }
- protected void reportSoftInputIsVisible(final boolean var1) {
- this.queueGLThreadEvent(new UnityPlayer.f() {
- public final void a() {
- UnityPlayer.this.nativeSetKeyboardIsVisible(var1);
- }
- });
- }
- protected void setClipboardText(String var1) {
- ClipData var2 = ClipData.newPlainText("Text", var1);
- this.m_ClipboardManager.setPrimaryClip(var2);
- }
- protected String getClipboardText() {
- String var1 = "";
- ClipData var2;
- if ((var2 = this.m_ClipboardManager.getPrimaryClip()) != null) {
- var1 = var2.getItemAt(0).coerceToText(this.mContext).toString();
- }
- return var1;
- }
- protected String getLaunchURL() {
- return this.m_launchUri != null ? this.m_launchUri.toString() : null;
- }
- protected boolean initializeGoogleAr() {
- if (this.m_ARCoreApi == null && currentActivity != null && this.getTangoEnabled()) {
- this.m_ARCoreApi = new GoogleARCoreApi();
- this.m_ARCoreApi.initializeARCore(currentActivity);
- if (!this.mState.d()) {
- this.m_ARCoreApi.resumeARCore();
- }
- }
- return false;
- }
- protected boolean initializeGoogleVr() {
- final GoogleVrProxy var1;
- if ((var1 = GoogleVrApi.b()) == null) {
- GoogleVrApi.a(this);
- if ((var1 = GoogleVrApi.b()) == null) {
- g.Log(6, "Unable to create Google VR subsystem.");
- return false;
- }
- }
- final Semaphore var3 = new Semaphore(0);
- final Runnable var4 = new Runnable() {
- public final void run() {
- UnityPlayer.this.injectEvent(new KeyEvent(0, 4));
- UnityPlayer.this.injectEvent(new KeyEvent(1, 4));
- }
- };
- this.runOnUiThread(new Runnable() {
- public final void run() {
- if (!var1.a(UnityPlayer.currentActivity, UnityPlayer.this.mContext, UnityPlayer.this.CreateGlView(), var4)) {
- g.Log(6, "Unable to initialize Google VR subsystem.");
- }
- if (UnityPlayer.currentActivity != null) {
- var1.a(UnityPlayer.currentActivity.getIntent());
- }
- var3.release();
- }
- });
- try {
- if (!var3.tryAcquire(4L, TimeUnit.SECONDS)) {
- g.Log(5, "Timeout while trying to initialize Google VR.");
- return false;
- }
- } catch (InterruptedException var5) {
- g.Log(5, "UI thread was interrupted while initializing Google VR. " + var5.getLocalizedMessage());
- return false;
- }
- return var1.a();
- }
- protected boolean showVideoPlayer(String var1, int var2, int var3, int var4, boolean var5, int var6, int var7) {
- if (this.mVideoPlayerProxy == null) {
- this.mVideoPlayerProxy = new q(this);
- }
- boolean var8;
- if (var8 = this.mVideoPlayerProxy.a(this.mContext, var1, var2, var3, var4, var5, (long)var6, (long)var7, new com.unity3d.player.q.a() {
- public final void a() {
- UnityPlayer.this.mVideoPlayerProxy = null;
- }
- })) {
- this.runOnUiThread(new Runnable() {
- public final void run() {
- if (UnityPlayer.this.nativeIsAutorotationOn() && UnityPlayer.this.mContext instanceof Activity) {
- ((Activity)UnityPlayer.this.mContext).setRequestedOrientation(UnityPlayer.this.mInitialScreenOrientation);
- }
- }
- });
- }
- return var8;
- }
- protected void moveTaskToBack() {
- this.runOnUiThread(new Runnable() {
- public final void run() {
- if (UnityPlayer.this.mContext instanceof Activity) {
- ((Activity)UnityPlayer.this.mContext).moveTaskToBack(true);
- }
- }
- });
- }
- private ApplicationInfo getApplicationInfo() {
- return this.mContext.getPackageManager().getApplicationInfo(this.mContext.getPackageName(), 128);
- }
- private boolean getSplashEnabled() {
- try {
- return this.getApplicationInfo().metaData.getBoolean("unity.splash-enable");
- } catch (Exception var1) {
- return false;
- }
- }
- private boolean getTangoEnabled() {
- try {
- return this.getApplicationInfo().metaData.getBoolean("unity.tango-enable");
- } catch (Exception var1) {
- return false;
- }
- }
- protected int getSplashMode() {
- try {
- return this.getApplicationInfo().metaData.getInt("unity.splash-mode");
- } catch (Exception var1) {
- return 0;
- }
- }
- protected void executeGLThreadJobs() {
- Runnable var1;
- while((var1 = (Runnable)this.m_Events.poll()) != null) {
- var1.run();
- }
- }
- protected void disableLogger() {
- g.a = true;
- }
- private void queueGLThreadEvent(Runnable var1) {
- if (n.c()) {
- if (Thread.currentThread() == this.m_MainThread) {
- var1.run();
- } else {
- this.m_Events.add(var1);
- }
- }
- }
- private void queueGLThreadEvent(UnityPlayer.f var1) {
- if (!this.isFinishing()) {
- this.queueGLThreadEvent((Runnable)var1);
- }
- }
- protected boolean isFinishing() {
- return this.mQuitting || (this.mQuitting = this.mContext instanceof Activity && ((Activity)this.mContext).isFinishing());
- }
- private void hideStatusBar() {
- if (this.mContext instanceof Activity) {
- ((Activity)this.mContext).getWindow().setFlags(1024, 1024);
- }
- }
- public boolean injectEvent(InputEvent var1) {
- return !n.c() ? false : this.nativeInjectEvent(var1);
- }
- public boolean onKeyUp(int var1, KeyEvent var2) {
- return this.injectEvent(var2);
- }
- public boolean onKeyDown(int var1, KeyEvent var2) {
- return this.injectEvent(var2);
- }
- public boolean onKeyMultiple(int var1, int var2, KeyEvent var3) {
- return this.injectEvent(var3);
- }
- public boolean onKeyLongPress(int var1, KeyEvent var2) {
- return this.injectEvent(var2);
- }
- public boolean onTouchEvent(MotionEvent var1) {
- return this.injectEvent(var1);
- }
- public boolean onGenericMotionEvent(MotionEvent var1) {
- return this.injectEvent(var1);
- }
- private void swapViews(View var1, View var2) {
- boolean var4 = false;
- if (!this.mState.d()) {
- this.pause();
- var4 = true;
- }
- ViewParent var3;
- if (var1 != null && (!((var3 = var1.getParent()) instanceof UnityPlayer) || (UnityPlayer)var3 != this)) {
- if (var3 instanceof ViewGroup) {
- ((ViewGroup)var3).removeView(var1);
- }
- this.addView(var1);
- this.bringChildToFront(var1);
- var1.setVisibility(0);
- }
- if (var2 != null && var2.getParent() == this) {
- var2.setVisibility(8);
- this.removeView(var2);
- }
- if (var4) {
- this.resume();
- }
- }
- public boolean addViewToPlayer(View var1, boolean var2) {
- this.swapViews(var1, var2 ? this.mGlView : null);
- boolean var5 = var1.getParent() == this;
- var2 = var2 && this.mGlView.getParent() == null;
- boolean var3 = this.mGlView.getParent() == this;
- boolean var4;
- if (!(var4 = var5 && (var2 || var3))) {
- if (!var5) {
- g.Log(6, "addViewToPlayer: Failure adding view to hierarchy");
- }
- if (!var2 && !var3) {
- g.Log(6, "addViewToPlayer: Failure removing old view from hierarchy");
- }
- }
- return var4;
- }
- public void removeViewFromPlayer(View var1) {
- this.swapViews(this.mGlView, var1);
- boolean var3 = var1.getParent() == null;
- boolean var2 = this.mGlView.getParent() == this;
- if (!var3 || !var2) {
- if (!var3) {
- g.Log(6, "removeViewFromPlayer: Failure removing view from hierarchy");
- }
- if (!var2) {
- g.Log(6, "removeVireFromPlayer: Failure agging old view to hierarchy");
- }
- }
- }
- public void reportError(String var1, String var2) {
- StringBuilder var3;
- (var3 = new StringBuilder()).append(var1);
- var3.append(": ");
- var3.append(var2);
- g.Log(6, var3.toString());
- }
- static {
- (new m()).a();
- mLibMainLoaded = false;
- mLibMainLoaded = loadLibraryStatic("main");
- }
- private abstract class f implements Runnable {
- private f() {
- }
- public final void run() {
- if (!UnityPlayer.this.isFinishing()) {
- this.a();
- }
- }
- public abstract void a();
- }
- class a implements SensorEventListener {
- a() {
- }
- public final void onAccuracyChanged(Sensor var1, int var2) {
- }
- public final void onSensorChanged(SensorEvent var1) {
- }
- }
- private class c extends PhoneStateListener {
- private c() {
- }
- public final void onCallStateChanged(int var1, String var2) {
- UnityPlayer.this.nativeMuteMasterAudio(var1 == 1);
- }
- }
- private class e extends Thread {
- Handler a;
- boolean b;
- boolean c;
- int d;
- int e;
- private e() {
- this.b = false;
- this.c = false;
- this.d = UnityPlayer.b.b;
- this.e = 5;
- }
- public final void run() {
- this.setName("UnityMain");
- Looper.prepare();
- this.a = new Handler(new android.os.Handler.Callback() {
- private void a() {
- if (e.this.d == UnityPlayer.b.c && e.this.c) {
- UnityPlayer.this.nativeFocusChanged(true);
- e.this.d = UnityPlayer.b.a;
- }
- }
- public final boolean handleMessage(Message var1) {
- if (var1.what != 2269) {
- return false;
- } else {
- UnityPlayer.d var2;
- if ((var2 = (UnityPlayer.d)var1.obj) == UnityPlayer.d.h) {
- UnityPlayer.this.executeGLThreadJobs();
- if (!e.this.b) {
- return true;
- }
- if (!e.this.c) {
- return true;
- }
- if (e.this.e >= 0) {
- if (e.this.e == 0 && UnityPlayer.this.getSplashEnabled()) {
- UnityPlayer.this.DisableStaticSplashScreen();
- }
- --e.this.e;
- }
- if (!UnityPlayer.this.isFinishing() && !UnityPlayer.this.nativeRender()) {
- UnityPlayer.this.finish();
- }
- } else if (var2 == UnityPlayer.d.c) {
- Looper.myLooper().quit();
- } else if (var2 == UnityPlayer.d.b) {
- e.this.b = true;
- } else if (var2 == UnityPlayer.d.a) {
- e.this.b = false;
- } else if (var2 == UnityPlayer.d.d) {
- e.this.c = false;
- } else if (var2 == UnityPlayer.d.e) {
- e.this.c = true;
- this.a();
- } else if (var2 == UnityPlayer.d.f) {
- if (e.this.d == UnityPlayer.b.a) {
- UnityPlayer.this.nativeFocusChanged(false);
- }
- e.this.d = UnityPlayer.b.b;
- } else if (var2 == UnityPlayer.d.g) {
- e.this.d = UnityPlayer.b.c;
- this.a();
- } else if (var2 == UnityPlayer.d.i) {
- UnityPlayer.this.nativeSetLaunchURL(UnityPlayer.this.getLaunchURL());
- }
- if (e.this.b) {
- Message.obtain(e.this.a, 2269, UnityPlayer.d.h).sendToTarget();
- }
- return true;
- }
- }
- });
- Looper.loop();
- }
- public final void a() {
- this.a(UnityPlayer.d.c);
- }
- public final void b() {
- this.a(UnityPlayer.d.b);
- }
- public final void a(Runnable var1) {
- if (this.a != null) {
- this.a(UnityPlayer.d.a);
- Message.obtain(this.a, var1).sendToTarget();
- }
- }
- public final void c() {
- this.a(UnityPlayer.d.g);
- }
- public final void d() {
- this.a(UnityPlayer.d.f);
- }
- public final void b(Runnable var1) {
- if (this.a != null) {
- this.a(UnityPlayer.d.d);
- Message.obtain(this.a, var1).sendToTarget();
- }
- }
- public final void c(Runnable var1) {
- if (this.a != null) {
- Message.obtain(this.a, var1).sendToTarget();
- this.a(UnityPlayer.d.e);
- }
- }
- public final void d(Runnable var1) {
- if (this.a != null) {
- Message.obtain(this.a, var1).sendToTarget();
- }
- }
- public final void e() {
- this.a(UnityPlayer.d.i);
- }
- private void a(UnityPlayer.d var1) {
- if (this.a != null) {
- Message.obtain(this.a, 2269, var1).sendToTarget();
- }
- }
- }
- static enum b {
- a = 1,
- b = 2,
- c = 3;
- static {
- d = new int[]{a, b, c};
- }
- }
- static enum d {
- a,
- b,
- c,
- d,
- e,
- f,
- g,
- h,
- i;
- private d() {
- }
- }
- }
Add Comment
Please, Sign In to add comment