Initial commit
This commit is contained in:
12
sources/com/unity3d/ads/BuildConfig.java
Normal file
12
sources/com/unity3d/ads/BuildConfig.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.unity3d.ads;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class BuildConfig {
|
||||
public static final String APPLICATION_ID = "com.unity3d.ads";
|
||||
public static final String BUILD_TYPE = "release";
|
||||
public static final boolean DEBUG = false;
|
||||
public static final String FLAVOR = "";
|
||||
public static final int VERSION_CODE = 2300;
|
||||
public static final String VERSION_NAME = "2.3.0";
|
||||
public static final String WEBVIEW_BRANCH = "2.3.0";
|
||||
}
|
||||
14
sources/com/unity3d/ads/IUnityAdsListener.java
Normal file
14
sources/com/unity3d/ads/IUnityAdsListener.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.unity3d.ads;
|
||||
|
||||
import com.unity3d.ads.UnityAds;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface IUnityAdsListener {
|
||||
void onUnityAdsError(UnityAds.UnityAdsError unityAdsError, String str);
|
||||
|
||||
void onUnityAdsFinish(String str, UnityAds.FinishState finishState);
|
||||
|
||||
void onUnityAdsReady(String str);
|
||||
|
||||
void onUnityAdsStart(String str);
|
||||
}
|
||||
7
sources/com/unity3d/ads/R.java
Normal file
7
sources/com/unity3d/ads/R.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.unity3d.ads;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class R {
|
||||
private R() {
|
||||
}
|
||||
}
|
||||
264
sources/com/unity3d/ads/UnityAds.java
Normal file
264
sources/com/unity3d/ads/UnityAds.java
Normal file
@@ -0,0 +1,264 @@
|
||||
package com.unity3d.ads;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Point;
|
||||
import android.os.Build;
|
||||
import android.view.Display;
|
||||
import android.view.WindowManager;
|
||||
import com.baidu.cloud.media.player.misc.IMediaFormat;
|
||||
import com.unity3d.ads.adunit.AdUnitOpen;
|
||||
import com.unity3d.ads.api.AdUnit;
|
||||
import com.unity3d.ads.api.Broadcast;
|
||||
import com.unity3d.ads.api.Cache;
|
||||
import com.unity3d.ads.api.Connectivity;
|
||||
import com.unity3d.ads.api.DeviceInfo;
|
||||
import com.unity3d.ads.api.Intent;
|
||||
import com.unity3d.ads.api.Lifecycle;
|
||||
import com.unity3d.ads.api.Listener;
|
||||
import com.unity3d.ads.api.Preferences;
|
||||
import com.unity3d.ads.api.Purchasing;
|
||||
import com.unity3d.ads.api.Request;
|
||||
import com.unity3d.ads.api.Resolve;
|
||||
import com.unity3d.ads.api.Sdk;
|
||||
import com.unity3d.ads.api.SensorInfo;
|
||||
import com.unity3d.ads.api.Storage;
|
||||
import com.unity3d.ads.api.VideoPlayer;
|
||||
import com.unity3d.ads.api.WebPlayer;
|
||||
import com.unity3d.ads.configuration.Configuration;
|
||||
import com.unity3d.ads.configuration.EnvironmentCheck;
|
||||
import com.unity3d.ads.configuration.InitializeThread;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.misc.Utilities;
|
||||
import com.unity3d.ads.placement.Placement;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
import com.unity3d.ads.properties.SdkProperties;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class UnityAds {
|
||||
private static boolean _configurationInitialized = false;
|
||||
private static boolean _debugMode = false;
|
||||
|
||||
public enum FinishState {
|
||||
ERROR,
|
||||
SKIPPED,
|
||||
COMPLETED
|
||||
}
|
||||
|
||||
public enum PlacementState {
|
||||
READY,
|
||||
NOT_AVAILABLE,
|
||||
DISABLED,
|
||||
WAITING,
|
||||
NO_FILL
|
||||
}
|
||||
|
||||
public enum UnityAdsError {
|
||||
NOT_INITIALIZED,
|
||||
INITIALIZE_FAILED,
|
||||
INVALID_ARGUMENT,
|
||||
VIDEO_PLAYER_ERROR,
|
||||
INIT_SANITY_CHECK_FAIL,
|
||||
AD_BLOCKER_DETECTED,
|
||||
FILE_IO_ERROR,
|
||||
DEVICE_ID_ERROR,
|
||||
SHOW_ERROR,
|
||||
INTERNAL_ERROR
|
||||
}
|
||||
|
||||
public static boolean getDebugMode() {
|
||||
return _debugMode;
|
||||
}
|
||||
|
||||
public static IUnityAdsListener getListener() {
|
||||
return ClientProperties.getListener();
|
||||
}
|
||||
|
||||
public static PlacementState getPlacementState() {
|
||||
return (isSupported() && isInitialized()) ? Placement.getPlacementState() : PlacementState.NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
public static String getVersion() {
|
||||
return SdkProperties.getVersionName();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static void handleShowError(final String str, final UnityAdsError unityAdsError, String str2) {
|
||||
final String str3 = "Unity Ads show failed: " + str2;
|
||||
DeviceLog.error(str3);
|
||||
final IUnityAdsListener listener = ClientProperties.getListener();
|
||||
if (listener != null) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.UnityAds.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
IUnityAdsListener.this.onUnityAdsError(unityAdsError, str3);
|
||||
String str4 = str;
|
||||
if (str4 != null) {
|
||||
IUnityAdsListener.this.onUnityAdsFinish(str4, FinishState.ERROR);
|
||||
} else {
|
||||
IUnityAdsListener.this.onUnityAdsFinish("", FinishState.ERROR);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void initialize(Activity activity, String str, IUnityAdsListener iUnityAdsListener) {
|
||||
initialize(activity, str, iUnityAdsListener, false);
|
||||
}
|
||||
|
||||
public static boolean isInitialized() {
|
||||
return SdkProperties.isInitialized();
|
||||
}
|
||||
|
||||
public static boolean isReady() {
|
||||
return isSupported() && isInitialized() && Placement.isReady();
|
||||
}
|
||||
|
||||
public static boolean isSupported() {
|
||||
return Build.VERSION.SDK_INT >= 16;
|
||||
}
|
||||
|
||||
public static void setDebugMode(boolean z) {
|
||||
_debugMode = z;
|
||||
if (z) {
|
||||
DeviceLog.setLogLevel(8);
|
||||
} else {
|
||||
DeviceLog.setLogLevel(4);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setListener(IUnityAdsListener iUnityAdsListener) {
|
||||
ClientProperties.setListener(iUnityAdsListener);
|
||||
}
|
||||
|
||||
public static void show(Activity activity) {
|
||||
if (Placement.getDefaultPlacement() != null) {
|
||||
show(activity, Placement.getDefaultPlacement());
|
||||
} else {
|
||||
handleShowError("", UnityAdsError.NOT_INITIALIZED, "Unity Ads default placement is not initialized");
|
||||
}
|
||||
}
|
||||
|
||||
public static void initialize(Activity activity, String str, IUnityAdsListener iUnityAdsListener, boolean z) {
|
||||
DeviceLog.entered();
|
||||
if (_configurationInitialized) {
|
||||
if (ClientProperties.getGameId() == null || ClientProperties.getGameId().equals(str)) {
|
||||
return;
|
||||
}
|
||||
DeviceLog.warning("You are trying to re-initialize with a different gameId");
|
||||
return;
|
||||
}
|
||||
_configurationInitialized = true;
|
||||
if (!isSupported()) {
|
||||
DeviceLog.error("Error while initializing Unity Ads: device is not supported");
|
||||
return;
|
||||
}
|
||||
SdkProperties.setInitializationTime(System.currentTimeMillis());
|
||||
if (str == null || str.length() == 0) {
|
||||
DeviceLog.error("Error while initializing Unity Ads: empty game ID, halting Unity Ads init");
|
||||
if (iUnityAdsListener != null) {
|
||||
iUnityAdsListener.onUnityAdsError(UnityAdsError.INVALID_ARGUMENT, "Empty game ID");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (activity == null) {
|
||||
DeviceLog.error("Error while initializing Unity Ads: null activity, halting Unity Ads init");
|
||||
if (iUnityAdsListener != null) {
|
||||
iUnityAdsListener.onUnityAdsError(UnityAdsError.INVALID_ARGUMENT, "Null activity");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (z) {
|
||||
DeviceLog.info("Initializing Unity Ads " + SdkProperties.getVersionName() + " (" + SdkProperties.getVersionCode() + ") with game id " + str + " in test mode");
|
||||
} else {
|
||||
DeviceLog.info("Initializing Unity Ads " + SdkProperties.getVersionName() + " (" + SdkProperties.getVersionCode() + ") with game id " + str + " in production mode");
|
||||
}
|
||||
setDebugMode(_debugMode);
|
||||
ClientProperties.setGameId(str);
|
||||
ClientProperties.setListener(iUnityAdsListener);
|
||||
ClientProperties.setApplicationContext(activity.getApplicationContext());
|
||||
ClientProperties.setApplication(activity.getApplication());
|
||||
SdkProperties.setTestMode(z);
|
||||
if (EnvironmentCheck.isEnvironmentOk()) {
|
||||
DeviceLog.info("Unity Ads environment check OK");
|
||||
Configuration configuration = new Configuration();
|
||||
configuration.setWebAppApiClassList(new Class[]{AdUnit.class, Broadcast.class, Cache.class, Connectivity.class, DeviceInfo.class, Listener.class, Storage.class, Sdk.class, Request.class, Resolve.class, VideoPlayer.class, com.unity3d.ads.api.Placement.class, Intent.class, Lifecycle.class, WebPlayer.class, Preferences.class, Purchasing.class, SensorInfo.class});
|
||||
InitializeThread.initialize(configuration);
|
||||
return;
|
||||
}
|
||||
DeviceLog.error("Error during Unity Ads environment check, halting Unity Ads init");
|
||||
if (iUnityAdsListener != null) {
|
||||
iUnityAdsListener.onUnityAdsError(UnityAdsError.INIT_SANITY_CHECK_FAIL, "Unity Ads init environment check failed");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isReady(String str) {
|
||||
return isSupported() && isInitialized() && str != null && Placement.isReady(str);
|
||||
}
|
||||
|
||||
public static PlacementState getPlacementState(String str) {
|
||||
if (isSupported() && isInitialized() && str != null) {
|
||||
return Placement.getPlacementState(str);
|
||||
}
|
||||
return PlacementState.NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
public static void show(final Activity activity, final String str) {
|
||||
if (activity == null) {
|
||||
handleShowError(str, UnityAdsError.INVALID_ARGUMENT, "Activity must not be null");
|
||||
return;
|
||||
}
|
||||
if (isReady(str)) {
|
||||
DeviceLog.info("Unity Ads opening new ad unit for placement " + str);
|
||||
ClientProperties.setActivity(activity);
|
||||
new Thread(new Runnable() { // from class: com.unity3d.ads.UnityAds.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
Display defaultDisplay = ((WindowManager) activity.getSystemService("window")).getDefaultDisplay();
|
||||
JSONObject jSONObject = new JSONObject();
|
||||
try {
|
||||
jSONObject.put("requestedOrientation", activity.getRequestedOrientation());
|
||||
JSONObject jSONObject2 = new JSONObject();
|
||||
jSONObject2.put("rotation", defaultDisplay.getRotation());
|
||||
if (Build.VERSION.SDK_INT >= 13) {
|
||||
Point point = new Point();
|
||||
defaultDisplay.getSize(point);
|
||||
jSONObject2.put(IMediaFormat.KEY_WIDTH, point.x);
|
||||
jSONObject2.put(IMediaFormat.KEY_HEIGHT, point.y);
|
||||
} else {
|
||||
jSONObject2.put(IMediaFormat.KEY_WIDTH, defaultDisplay.getWidth());
|
||||
jSONObject2.put(IMediaFormat.KEY_HEIGHT, defaultDisplay.getHeight());
|
||||
}
|
||||
jSONObject.put("display", jSONObject2);
|
||||
} catch (JSONException e) {
|
||||
DeviceLog.exception("JSON error while constructing show options", e);
|
||||
}
|
||||
try {
|
||||
if (AdUnitOpen.open(str, jSONObject)) {
|
||||
return;
|
||||
}
|
||||
UnityAds.handleShowError(str, UnityAdsError.INTERNAL_ERROR, "Webapp timeout, shutting down Unity Ads");
|
||||
InitializeThread.reset();
|
||||
} catch (NoSuchMethodException e2) {
|
||||
DeviceLog.exception("Could not get callback method", e2);
|
||||
UnityAds.handleShowError(str, UnityAdsError.SHOW_ERROR, "Could not get com.unity3d.ads.properties.showCallback method");
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
return;
|
||||
}
|
||||
if (!isSupported()) {
|
||||
handleShowError(str, UnityAdsError.NOT_INITIALIZED, "Unity Ads is not supported for this device");
|
||||
return;
|
||||
}
|
||||
if (!isInitialized()) {
|
||||
handleShowError(str, UnityAdsError.NOT_INITIALIZED, "Unity Ads is not initialized");
|
||||
return;
|
||||
}
|
||||
handleShowError(str, UnityAdsError.SHOW_ERROR, "Placement \"" + str + "\" is not ready");
|
||||
}
|
||||
}
|
||||
444
sources/com/unity3d/ads/adunit/AdUnitActivity.java
Normal file
444
sources/com/unity3d/ads/adunit/AdUnitActivity.java
Normal file
@@ -0,0 +1,444 @@
|
||||
package com.unity3d.ads.adunit;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import com.baidu.cloud.media.player.misc.IMediaFormat;
|
||||
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
||||
import com.unity3d.ads.api.AdUnit;
|
||||
import com.unity3d.ads.api.VideoPlayer;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.misc.ViewUtilities;
|
||||
import com.unity3d.ads.video.VideoPlayerView;
|
||||
import com.unity3d.ads.webplayer.WebPlayer;
|
||||
import com.unity3d.ads.webview.WebViewApp;
|
||||
import com.unity3d.ads.webview.WebViewEventCategory;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class AdUnitActivity extends Activity {
|
||||
public static final String EXTRA_ACTIVITY_ID = "activityId";
|
||||
public static final String EXTRA_KEEP_SCREEN_ON = "keepScreenOn";
|
||||
public static final String EXTRA_KEY_EVENT_LIST = "keyEvents";
|
||||
public static final String EXTRA_ORIENTATION = "orientation";
|
||||
public static final String EXTRA_SYSTEM_UI_VISIBILITY = "systemUiVisibility";
|
||||
public static final String EXTRA_VIEWS = "views";
|
||||
private int _activityId;
|
||||
boolean _keepScreenOn;
|
||||
private ArrayList<Integer> _keyEventList;
|
||||
protected AdUnitRelativeLayout _layout;
|
||||
private int _orientation = -1;
|
||||
private int _systemUiVisibility;
|
||||
private RelativeLayout _videoContainer;
|
||||
private String[] _views;
|
||||
private WebPlayer _webPlayer;
|
||||
|
||||
private void createVideoPlayer() {
|
||||
if (this._videoContainer == null) {
|
||||
this._videoContainer = new RelativeLayout(this);
|
||||
}
|
||||
if (VideoPlayer.getVideoPlayerView() == null) {
|
||||
VideoPlayer.setVideoPlayerView(new VideoPlayerView(this));
|
||||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -1);
|
||||
layoutParams.addRule(13);
|
||||
VideoPlayer.getVideoPlayerView().setLayoutParams(layoutParams);
|
||||
this._videoContainer.addView(VideoPlayer.getVideoPlayerView());
|
||||
}
|
||||
}
|
||||
|
||||
private void createWebPlayer() {
|
||||
if (this._webPlayer == null) {
|
||||
this._webPlayer = new WebPlayer(this, com.unity3d.ads.api.WebPlayer.getWebSettings(), com.unity3d.ads.api.WebPlayer.getWebPlayerSettings());
|
||||
this._webPlayer.setEventSettings(com.unity3d.ads.api.WebPlayer.getWebPlayerEventSettings());
|
||||
}
|
||||
}
|
||||
|
||||
private void destroyVideoPlayer() {
|
||||
if (VideoPlayer.getVideoPlayerView() != null) {
|
||||
VideoPlayer.getVideoPlayerView().stopVideoProgressTimer();
|
||||
VideoPlayer.getVideoPlayerView().stopPlayback();
|
||||
ViewUtilities.removeViewFromParent(VideoPlayer.getVideoPlayerView());
|
||||
}
|
||||
VideoPlayer.setVideoPlayerView(null);
|
||||
RelativeLayout relativeLayout = this._videoContainer;
|
||||
if (relativeLayout != null) {
|
||||
ViewUtilities.removeViewFromParent(relativeLayout);
|
||||
this._videoContainer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void destroyWebPlayer() {
|
||||
WebPlayer webPlayer = this._webPlayer;
|
||||
if (webPlayer != null) {
|
||||
ViewUtilities.removeViewFromParent(webPlayer);
|
||||
}
|
||||
this._webPlayer = null;
|
||||
}
|
||||
|
||||
private void handleViewPlacement(View view) {
|
||||
if (view.getParent() != null && view.getParent().equals(this._layout)) {
|
||||
this._layout.bringChildToFront(view);
|
||||
return;
|
||||
}
|
||||
ViewUtilities.removeViewFromParent(view);
|
||||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -1);
|
||||
layoutParams.addRule(13);
|
||||
layoutParams.setMargins(0, 0, 0, 0);
|
||||
view.setPadding(0, 0, 0, 0);
|
||||
this._layout.addView(view, layoutParams);
|
||||
}
|
||||
|
||||
protected void createLayout() {
|
||||
if (this._layout != null) {
|
||||
return;
|
||||
}
|
||||
this._layout = new AdUnitRelativeLayout(this);
|
||||
this._layout.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
|
||||
ViewUtilities.setBackground(this._layout, new ColorDrawable(-16777216));
|
||||
}
|
||||
|
||||
public AdUnitRelativeLayout getLayout() {
|
||||
return this._layout;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getViewFrame(String str) {
|
||||
if (str.equals("adunit")) {
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) this._layout.getLayoutParams();
|
||||
HashMap hashMap = new HashMap();
|
||||
hashMap.put("x", Integer.valueOf(layoutParams.leftMargin));
|
||||
hashMap.put("y", Integer.valueOf(layoutParams.topMargin));
|
||||
hashMap.put(IMediaFormat.KEY_WIDTH, Integer.valueOf(this._layout.getWidth()));
|
||||
hashMap.put(IMediaFormat.KEY_HEIGHT, Integer.valueOf(this._layout.getHeight()));
|
||||
return hashMap;
|
||||
}
|
||||
View webView = str.equals("videoplayer") ? this._videoContainer : str.equals("webview") ? WebViewApp.getCurrentApp().getWebView() : null;
|
||||
if (webView == null) {
|
||||
return null;
|
||||
}
|
||||
RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) webView.getLayoutParams();
|
||||
HashMap hashMap2 = new HashMap();
|
||||
hashMap2.put("x", Integer.valueOf(layoutParams2.leftMargin));
|
||||
hashMap2.put("y", Integer.valueOf(layoutParams2.topMargin));
|
||||
hashMap2.put(IMediaFormat.KEY_WIDTH, Integer.valueOf(webView.getWidth()));
|
||||
hashMap2.put(IMediaFormat.KEY_HEIGHT, Integer.valueOf(webView.getHeight()));
|
||||
return hashMap2;
|
||||
}
|
||||
|
||||
public String[] getViews() {
|
||||
return this._views;
|
||||
}
|
||||
|
||||
public WebPlayer getWebPlayer() {
|
||||
return this._webPlayer;
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onCreate(Bundle bundle) {
|
||||
AdUnitEvent adUnitEvent;
|
||||
super.onCreate(bundle);
|
||||
if (WebViewApp.getCurrentApp() == null) {
|
||||
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onCreate");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
AdUnit.setAdUnitActivity(this);
|
||||
createLayout();
|
||||
ViewUtilities.removeViewFromParent(this._layout);
|
||||
AdUnitRelativeLayout adUnitRelativeLayout = this._layout;
|
||||
addContentView(adUnitRelativeLayout, adUnitRelativeLayout.getLayoutParams());
|
||||
if (bundle == null) {
|
||||
this._views = getIntent().getStringArrayExtra(EXTRA_VIEWS);
|
||||
this._keyEventList = getIntent().getIntegerArrayListExtra(EXTRA_KEY_EVENT_LIST);
|
||||
if (getIntent().hasExtra(EXTRA_ORIENTATION)) {
|
||||
this._orientation = getIntent().getIntExtra(EXTRA_ORIENTATION, -1);
|
||||
}
|
||||
if (getIntent().hasExtra(EXTRA_SYSTEM_UI_VISIBILITY)) {
|
||||
this._systemUiVisibility = getIntent().getIntExtra(EXTRA_SYSTEM_UI_VISIBILITY, 0);
|
||||
}
|
||||
if (getIntent().hasExtra(EXTRA_ACTIVITY_ID)) {
|
||||
this._activityId = getIntent().getIntExtra(EXTRA_ACTIVITY_ID, -1);
|
||||
}
|
||||
adUnitEvent = AdUnitEvent.ON_CREATE;
|
||||
} else {
|
||||
this._views = bundle.getStringArray(EXTRA_VIEWS);
|
||||
this._orientation = bundle.getInt(EXTRA_ORIENTATION, -1);
|
||||
this._systemUiVisibility = bundle.getInt(EXTRA_SYSTEM_UI_VISIBILITY, 0);
|
||||
this._keyEventList = bundle.getIntegerArrayList(EXTRA_KEY_EVENT_LIST);
|
||||
this._keepScreenOn = bundle.getBoolean(EXTRA_KEEP_SCREEN_ON);
|
||||
this._activityId = bundle.getInt(EXTRA_ACTIVITY_ID, -1);
|
||||
setKeepScreenOn(this._keepScreenOn);
|
||||
adUnitEvent = AdUnitEvent.ON_RESTORE;
|
||||
}
|
||||
setOrientation(this._orientation);
|
||||
setSystemUiVisibility(this._systemUiVisibility);
|
||||
String[] strArr = this._views;
|
||||
if (strArr != null) {
|
||||
if (Arrays.asList(strArr).contains("videoplayer")) {
|
||||
createVideoPlayer();
|
||||
}
|
||||
if (Arrays.asList(this._views).contains("webplayer")) {
|
||||
createWebPlayer();
|
||||
}
|
||||
}
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.ADUNIT, adUnitEvent, Integer.valueOf(this._activityId));
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (WebViewApp.getCurrentApp() == null) {
|
||||
if (isFinishing()) {
|
||||
return;
|
||||
}
|
||||
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onDestroy");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_DESTROY, Boolean.valueOf(isFinishing()), Integer.valueOf(this._activityId));
|
||||
if (AdUnit.getCurrentAdUnitActivityId() == this._activityId) {
|
||||
AdUnit.setAdUnitActivity(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Activity, android.view.KeyEvent.Callback
|
||||
public boolean onKeyDown(int i, KeyEvent keyEvent) {
|
||||
ArrayList<Integer> arrayList = this._keyEventList;
|
||||
if (arrayList == null || !arrayList.contains(Integer.valueOf(i))) {
|
||||
return false;
|
||||
}
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.KEY_DOWN, Integer.valueOf(i), Long.valueOf(keyEvent.getEventTime()), Long.valueOf(keyEvent.getDownTime()), Integer.valueOf(keyEvent.getRepeatCount()), Integer.valueOf(this._activityId));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (WebViewApp.getCurrentApp() == null) {
|
||||
if (isFinishing()) {
|
||||
return;
|
||||
}
|
||||
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onPause");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
if (isFinishing()) {
|
||||
ViewUtilities.removeViewFromParent(WebViewApp.getCurrentApp().getWebView());
|
||||
}
|
||||
destroyVideoPlayer();
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_PAUSE, Boolean.valueOf(isFinishing()), Integer.valueOf(this._activityId));
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (WebViewApp.getCurrentApp() != null) {
|
||||
setViews(this._views);
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_RESUME, Integer.valueOf(this._activityId));
|
||||
} else {
|
||||
if (isFinishing()) {
|
||||
return;
|
||||
}
|
||||
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onResume");
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public void onSaveInstanceState(Bundle bundle) {
|
||||
super.onSaveInstanceState(bundle);
|
||||
bundle.putInt(EXTRA_ORIENTATION, this._orientation);
|
||||
bundle.putInt(EXTRA_SYSTEM_UI_VISIBILITY, this._systemUiVisibility);
|
||||
bundle.putIntegerArrayList(EXTRA_KEY_EVENT_LIST, this._keyEventList);
|
||||
bundle.putBoolean(EXTRA_KEEP_SCREEN_ON, this._keepScreenOn);
|
||||
bundle.putStringArray(EXTRA_VIEWS, this._views);
|
||||
bundle.putInt(EXTRA_ACTIVITY_ID, this._activityId);
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
if (WebViewApp.getCurrentApp() != null) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_START, Integer.valueOf(this._activityId));
|
||||
} else {
|
||||
if (isFinishing()) {
|
||||
return;
|
||||
}
|
||||
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onStart");
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
if (WebViewApp.getCurrentApp() != null) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_STOP, Integer.valueOf(this._activityId));
|
||||
} else {
|
||||
if (isFinishing()) {
|
||||
return;
|
||||
}
|
||||
DeviceLog.error("Unity Ads web app is null, closing Unity Ads activity from onStop");
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Activity, android.view.Window.Callback
|
||||
public void onWindowFocusChanged(boolean z) {
|
||||
if (z) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_FOCUS_GAINED, Integer.valueOf(this._activityId));
|
||||
} else {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.ADUNIT, AdUnitEvent.ON_FOCUS_LOST, Integer.valueOf(this._activityId));
|
||||
}
|
||||
super.onWindowFocusChanged(z);
|
||||
}
|
||||
|
||||
public boolean setKeepScreenOn(boolean z) {
|
||||
this._keepScreenOn = z;
|
||||
if (getWindow() == null) {
|
||||
return false;
|
||||
}
|
||||
if (z) {
|
||||
getWindow().addFlags(PeripheralType.SERVO);
|
||||
return true;
|
||||
}
|
||||
getWindow().clearFlags(PeripheralType.SERVO);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setKeyEventList(ArrayList<Integer> arrayList) {
|
||||
this._keyEventList = arrayList;
|
||||
}
|
||||
|
||||
public void setOrientation(int i) {
|
||||
this._orientation = i;
|
||||
setRequestedOrientation(i);
|
||||
}
|
||||
|
||||
public boolean setSystemUiVisibility(int i) {
|
||||
this._systemUiVisibility = i;
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
try {
|
||||
getWindow().getDecorView().setSystemUiVisibility(i);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error while setting SystemUIVisibility", e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:6:0x0041 */
|
||||
/* JADX WARN: Removed duplicated region for block: B:9:? A[RETURN, SYNTHETIC] */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public void setViewFrame(java.lang.String r3, int r4, int r5, int r6, int r7) {
|
||||
/*
|
||||
r2 = this;
|
||||
java.lang.String r0 = "adunit"
|
||||
boolean r0 = r3.equals(r0)
|
||||
r1 = 0
|
||||
if (r0 == 0) goto L17
|
||||
android.widget.FrameLayout$LayoutParams r3 = new android.widget.FrameLayout$LayoutParams
|
||||
r3.<init>(r6, r7)
|
||||
r3.setMargins(r4, r5, r1, r1)
|
||||
com.unity3d.ads.adunit.AdUnitRelativeLayout r0 = r2._layout
|
||||
r0.setLayoutParams(r3)
|
||||
goto L3e
|
||||
L17:
|
||||
java.lang.String r0 = "videoplayer"
|
||||
boolean r0 = r3.equals(r0)
|
||||
if (r0 == 0) goto L22
|
||||
android.widget.RelativeLayout r3 = r2._videoContainer
|
||||
goto L3f
|
||||
L22:
|
||||
java.lang.String r0 = "webview"
|
||||
boolean r0 = r3.equals(r0)
|
||||
if (r0 == 0) goto L33
|
||||
com.unity3d.ads.webview.WebViewApp r3 = com.unity3d.ads.webview.WebViewApp.getCurrentApp()
|
||||
com.unity3d.ads.webview.WebView r3 = r3.getWebView()
|
||||
goto L3f
|
||||
L33:
|
||||
java.lang.String r0 = "webplayer"
|
||||
boolean r3 = r3.equals(r0)
|
||||
if (r3 == 0) goto L3e
|
||||
com.unity3d.ads.webplayer.WebPlayer r3 = r2._webPlayer
|
||||
goto L3f
|
||||
L3e:
|
||||
r3 = 0
|
||||
L3f:
|
||||
if (r3 == 0) goto L4c
|
||||
android.widget.RelativeLayout$LayoutParams r0 = new android.widget.RelativeLayout$LayoutParams
|
||||
r0.<init>(r6, r7)
|
||||
r0.setMargins(r4, r5, r1, r1)
|
||||
r3.setLayoutParams(r0)
|
||||
L4c:
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.unity3d.ads.adunit.AdUnitActivity.setViewFrame(java.lang.String, int, int, int, int):void");
|
||||
}
|
||||
|
||||
public void setViews(String[] strArr) {
|
||||
if (strArr == null) {
|
||||
strArr = new String[0];
|
||||
}
|
||||
ArrayList arrayList = new ArrayList(Arrays.asList(strArr));
|
||||
if (this._views == null) {
|
||||
this._views = new String[0];
|
||||
}
|
||||
ArrayList arrayList2 = new ArrayList(Arrays.asList(this._views));
|
||||
arrayList2.removeAll(arrayList);
|
||||
Iterator it = arrayList2.iterator();
|
||||
while (it.hasNext()) {
|
||||
String str = (String) it.next();
|
||||
char c = 65535;
|
||||
int hashCode = str.hashCode();
|
||||
if (hashCode != -318269643) {
|
||||
if (hashCode != 1224424441) {
|
||||
if (hashCode == 1865295644 && str.equals("videoplayer")) {
|
||||
c = 0;
|
||||
}
|
||||
} else if (str.equals("webview")) {
|
||||
c = 1;
|
||||
}
|
||||
} else if (str.equals("webplayer")) {
|
||||
c = 2;
|
||||
}
|
||||
if (c == 0) {
|
||||
destroyVideoPlayer();
|
||||
} else if (c == 1) {
|
||||
ViewUtilities.removeViewFromParent(WebViewApp.getCurrentApp().getWebView());
|
||||
} else if (c == 2) {
|
||||
destroyWebPlayer();
|
||||
}
|
||||
}
|
||||
this._views = strArr;
|
||||
for (String str2 : strArr) {
|
||||
if (str2 != null) {
|
||||
if (str2.equals("videoplayer")) {
|
||||
createVideoPlayer();
|
||||
handleViewPlacement(this._videoContainer);
|
||||
} else if (str2.equals("webview")) {
|
||||
if (WebViewApp.getCurrentApp() == null) {
|
||||
DeviceLog.error("WebApp IS NULL!");
|
||||
throw new NullPointerException();
|
||||
}
|
||||
handleViewPlacement(WebViewApp.getCurrentApp().getWebView());
|
||||
} else if (str2.equals("webplayer")) {
|
||||
createWebPlayer();
|
||||
handleViewPlacement(this._webPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
16
sources/com/unity3d/ads/adunit/AdUnitError.java
Normal file
16
sources/com/unity3d/ads/adunit/AdUnitError.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.unity3d.ads.adunit;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum AdUnitError {
|
||||
ADUNIT_NULL,
|
||||
ACTIVITY_ID,
|
||||
GENERIC,
|
||||
ORIENTATION,
|
||||
SCREENVISIBILITY,
|
||||
CORRUPTED_VIEWLIST,
|
||||
CORRUPTED_KEYEVENTLIST,
|
||||
SYSTEM_UI_VISIBILITY,
|
||||
UNKNOWN_VIEW,
|
||||
LAYOUT_NULL,
|
||||
MAX_MOTION_EVENT_COUNT_REACHED
|
||||
}
|
||||
15
sources/com/unity3d/ads/adunit/AdUnitEvent.java
Normal file
15
sources/com/unity3d/ads/adunit/AdUnitEvent.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.unity3d.ads.adunit;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum AdUnitEvent {
|
||||
ON_START,
|
||||
ON_CREATE,
|
||||
ON_RESUME,
|
||||
ON_DESTROY,
|
||||
ON_PAUSE,
|
||||
KEY_DOWN,
|
||||
ON_RESTORE,
|
||||
ON_STOP,
|
||||
ON_FOCUS_GAINED,
|
||||
ON_FOCUS_LOST
|
||||
}
|
||||
68
sources/com/unity3d/ads/adunit/AdUnitMotionEvent.java
Normal file
68
sources/com/unity3d/ads/adunit/AdUnitMotionEvent.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.unity3d.ads.adunit;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class AdUnitMotionEvent {
|
||||
private int _action;
|
||||
private int _deviceId;
|
||||
private long _eventTime;
|
||||
private boolean _isObscured;
|
||||
private float _pressure;
|
||||
private float _size;
|
||||
private int _source;
|
||||
private int _toolType;
|
||||
private float _x;
|
||||
private float _y;
|
||||
|
||||
public AdUnitMotionEvent(int i, boolean z, int i2, int i3, int i4, float f, float f2, long j, float f3, float f4) {
|
||||
this._action = i;
|
||||
this._isObscured = z;
|
||||
this._toolType = i2;
|
||||
this._source = i3;
|
||||
this._deviceId = i4;
|
||||
this._x = f;
|
||||
this._y = f2;
|
||||
this._eventTime = j;
|
||||
this._pressure = f3;
|
||||
this._size = f4;
|
||||
}
|
||||
|
||||
public int getAction() {
|
||||
return this._action;
|
||||
}
|
||||
|
||||
public int getDeviceId() {
|
||||
return this._deviceId;
|
||||
}
|
||||
|
||||
public long getEventTime() {
|
||||
return this._eventTime;
|
||||
}
|
||||
|
||||
public float getPressure() {
|
||||
return this._pressure;
|
||||
}
|
||||
|
||||
public float getSize() {
|
||||
return this._size;
|
||||
}
|
||||
|
||||
public int getSource() {
|
||||
return this._source;
|
||||
}
|
||||
|
||||
public int getToolType() {
|
||||
return this._toolType;
|
||||
}
|
||||
|
||||
public float getX() {
|
||||
return this._x;
|
||||
}
|
||||
|
||||
public float getY() {
|
||||
return this._y;
|
||||
}
|
||||
|
||||
public boolean isObscured() {
|
||||
return this._isObscured;
|
||||
}
|
||||
}
|
||||
33
sources/com/unity3d/ads/adunit/AdUnitOpen.java
Normal file
33
sources/com/unity3d/ads/adunit/AdUnitOpen.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.unity3d.ads.adunit;
|
||||
|
||||
import android.os.ConditionVariable;
|
||||
import com.ubt.jimu.transport.model.TransportFile;
|
||||
import com.unity3d.ads.properties.SdkProperties;
|
||||
import com.unity3d.ads.webview.WebViewApp;
|
||||
import com.unity3d.ads.webview.bridge.CallbackStatus;
|
||||
import java.lang.reflect.Method;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class AdUnitOpen {
|
||||
private static ConditionVariable _waitShowStatus;
|
||||
|
||||
public static synchronized boolean open(String str, JSONObject jSONObject) throws NoSuchMethodException {
|
||||
boolean block;
|
||||
synchronized (AdUnitOpen.class) {
|
||||
Method method = AdUnitOpen.class.getMethod("showCallback", CallbackStatus.class);
|
||||
_waitShowStatus = new ConditionVariable();
|
||||
WebViewApp.getCurrentApp().invokeMethod("webview", TransportFile.TYPE_DIY_SHOW, method, str, jSONObject);
|
||||
block = _waitShowStatus.block(SdkProperties.getShowTimeout());
|
||||
_waitShowStatus = null;
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
||||
public static void showCallback(CallbackStatus callbackStatus) {
|
||||
if (_waitShowStatus == null || !callbackStatus.equals(CallbackStatus.OK)) {
|
||||
return;
|
||||
}
|
||||
_waitShowStatus.open();
|
||||
}
|
||||
}
|
||||
111
sources/com/unity3d/ads/adunit/AdUnitRelativeLayout.java
Normal file
111
sources/com/unity3d/ads/adunit/AdUnitRelativeLayout.java
Normal file
@@ -0,0 +1,111 @@
|
||||
package com.unity3d.ads.adunit;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseIntArray;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.RelativeLayout;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class AdUnitRelativeLayout extends RelativeLayout {
|
||||
private int _maxEvents;
|
||||
private final ArrayList<AdUnitMotionEvent> _motionEvents;
|
||||
private boolean _shouldCapture;
|
||||
|
||||
public AdUnitRelativeLayout(Context context) {
|
||||
super(context);
|
||||
this._motionEvents = new ArrayList<>();
|
||||
this._maxEvents = XStream.PRIORITY_VERY_HIGH;
|
||||
this._shouldCapture = false;
|
||||
}
|
||||
|
||||
public void clearCapture() {
|
||||
synchronized (this._motionEvents) {
|
||||
this._motionEvents.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void endCapture() {
|
||||
this._shouldCapture = false;
|
||||
}
|
||||
|
||||
public int getCurrentEventCount() {
|
||||
int size;
|
||||
synchronized (this._motionEvents) {
|
||||
size = this._motionEvents.size();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
public SparseIntArray getEventCount(ArrayList<Integer> arrayList) {
|
||||
SparseIntArray sparseIntArray = new SparseIntArray();
|
||||
synchronized (this._motionEvents) {
|
||||
Iterator<AdUnitMotionEvent> it = this._motionEvents.iterator();
|
||||
while (it.hasNext()) {
|
||||
AdUnitMotionEvent next = it.next();
|
||||
Iterator<Integer> it2 = arrayList.iterator();
|
||||
while (true) {
|
||||
if (it2.hasNext()) {
|
||||
Integer next2 = it2.next();
|
||||
if (next.getAction() == next2.intValue()) {
|
||||
sparseIntArray.put(next2.intValue(), sparseIntArray.get(next2.intValue(), 0) + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return sparseIntArray;
|
||||
}
|
||||
|
||||
public SparseArray<SparseArray<AdUnitMotionEvent>> getEvents(SparseArray<ArrayList<Integer>> sparseArray) {
|
||||
SparseIntArray sparseIntArray = new SparseIntArray();
|
||||
SparseArray<SparseArray<AdUnitMotionEvent>> sparseArray2 = new SparseArray<>();
|
||||
synchronized (this._motionEvents) {
|
||||
Iterator<AdUnitMotionEvent> it = this._motionEvents.iterator();
|
||||
while (it.hasNext()) {
|
||||
AdUnitMotionEvent next = it.next();
|
||||
ArrayList<Integer> arrayList = sparseArray.get(next.getAction());
|
||||
if (arrayList != null) {
|
||||
int intValue = arrayList.get(0).intValue();
|
||||
if (sparseIntArray.get(next.getAction(), 0) == intValue) {
|
||||
if (sparseArray2.get(next.getAction()) == null) {
|
||||
sparseArray2.put(next.getAction(), new SparseArray<>());
|
||||
}
|
||||
sparseArray2.get(next.getAction()).put(intValue, next);
|
||||
arrayList.remove(0);
|
||||
}
|
||||
sparseIntArray.put(next.getAction(), sparseIntArray.get(next.getAction()) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sparseArray2;
|
||||
}
|
||||
|
||||
public int getMaxEventCount() {
|
||||
return this._maxEvents;
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup
|
||||
@TargetApi(14)
|
||||
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
|
||||
super.onInterceptTouchEvent(motionEvent);
|
||||
if (!this._shouldCapture || this._motionEvents.size() >= this._maxEvents) {
|
||||
return false;
|
||||
}
|
||||
boolean z = (motionEvent.getFlags() & 1) != 0;
|
||||
synchronized (this._motionEvents) {
|
||||
this._motionEvents.add(new AdUnitMotionEvent(motionEvent.getActionMasked(), z, motionEvent.getToolType(0), motionEvent.getSource(), motionEvent.getDeviceId(), motionEvent.getX(0), motionEvent.getY(0), motionEvent.getEventTime(), motionEvent.getPressure(0), motionEvent.getSize(0)));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void startCapture(int i) {
|
||||
this._maxEvents = i;
|
||||
this._shouldCapture = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.unity3d.ads.adunit;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class AdUnitSoftwareActivity extends AdUnitActivity {
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.unity3d.ads.adunit;
|
||||
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import com.unity3d.ads.misc.ViewUtilities;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class AdUnitTransparentActivity extends AdUnitActivity {
|
||||
@Override // com.unity3d.ads.adunit.AdUnitActivity
|
||||
protected void createLayout() {
|
||||
super.createLayout();
|
||||
ViewUtilities.setBackground(this._layout, new ColorDrawable(0));
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.adunit.AdUnitActivity, android.app.Activity
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
ViewUtilities.setBackground(this._layout, new ColorDrawable(0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.unity3d.ads.adunit;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class AdUnitTransparentSoftwareActivity extends AdUnitTransparentActivity {
|
||||
}
|
||||
452
sources/com/unity3d/ads/api/AdUnit.java
Normal file
452
sources/com/unity3d/ads/api/AdUnit.java
Normal file
@@ -0,0 +1,452 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseIntArray;
|
||||
import com.baidu.cloud.media.player.misc.IMediaFormat;
|
||||
import com.tencent.open.SocialConstants;
|
||||
import com.unity3d.ads.adunit.AdUnitActivity;
|
||||
import com.unity3d.ads.adunit.AdUnitError;
|
||||
import com.unity3d.ads.adunit.AdUnitMotionEvent;
|
||||
import com.unity3d.ads.adunit.AdUnitSoftwareActivity;
|
||||
import com.unity3d.ads.adunit.AdUnitTransparentActivity;
|
||||
import com.unity3d.ads.adunit.AdUnitTransparentSoftwareActivity;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.misc.Utilities;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class AdUnit {
|
||||
private static AdUnitActivity _adUnitActivity = null;
|
||||
private static int _currentActivityId = -1;
|
||||
|
||||
private AdUnit() {
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void clearMotionEventCapture(WebViewCallback webViewCallback) {
|
||||
if (getAdUnitActivity() == null) {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
} else if (getAdUnitActivity().getLayout() == null) {
|
||||
webViewCallback.error(AdUnitError.LAYOUT_NULL, new Object[0]);
|
||||
} else {
|
||||
getAdUnitActivity().getLayout().clearCapture();
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void close(WebViewCallback webViewCallback) {
|
||||
if (getAdUnitActivity() == null) {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
} else {
|
||||
getAdUnitActivity().finish();
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void endMotionEventCapture(WebViewCallback webViewCallback) {
|
||||
if (getAdUnitActivity() == null) {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
} else if (getAdUnitActivity().getLayout() == null) {
|
||||
webViewCallback.error(AdUnitError.LAYOUT_NULL, new Object[0]);
|
||||
} else {
|
||||
getAdUnitActivity().getLayout().endCapture();
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public static AdUnitActivity getAdUnitActivity() {
|
||||
return _adUnitActivity;
|
||||
}
|
||||
|
||||
public static int getCurrentAdUnitActivityId() {
|
||||
return _currentActivityId;
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getCurrentMotionEventCount(WebViewCallback webViewCallback) {
|
||||
if (getAdUnitActivity() == null) {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
} else if (getAdUnitActivity().getLayout() != null) {
|
||||
webViewCallback.invoke(Integer.valueOf(getAdUnitActivity().getLayout().getCurrentEventCount()));
|
||||
} else {
|
||||
webViewCallback.error(AdUnitError.LAYOUT_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static ArrayList<Integer> getKeyEventList(JSONArray jSONArray) throws JSONException {
|
||||
ArrayList<Integer> arrayList = new ArrayList<>();
|
||||
int i = 0;
|
||||
while (true) {
|
||||
Integer valueOf = Integer.valueOf(i);
|
||||
if (valueOf.intValue() >= jSONArray.length()) {
|
||||
return arrayList;
|
||||
}
|
||||
arrayList.add(Integer.valueOf(jSONArray.getInt(valueOf.intValue())));
|
||||
i = valueOf.intValue() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getMotionEventCount(JSONArray jSONArray, WebViewCallback webViewCallback) {
|
||||
ArrayList<Integer> arrayList = new ArrayList<>();
|
||||
for (int i = 0; i < jSONArray.length(); i++) {
|
||||
try {
|
||||
arrayList.add(Integer.valueOf(jSONArray.getInt(i)));
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error retrieving int from eventTypes", e);
|
||||
}
|
||||
}
|
||||
if (getAdUnitActivity() == null) {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
return;
|
||||
}
|
||||
if (getAdUnitActivity().getLayout() == null) {
|
||||
webViewCallback.error(AdUnitError.LAYOUT_NULL, new Object[0]);
|
||||
return;
|
||||
}
|
||||
if (getAdUnitActivity().getLayout().getCurrentEventCount() >= getAdUnitActivity().getLayout().getMaxEventCount()) {
|
||||
webViewCallback.error(AdUnitError.MAX_MOTION_EVENT_COUNT_REACHED, new Object[0]);
|
||||
return;
|
||||
}
|
||||
SparseIntArray eventCount = getAdUnitActivity().getLayout().getEventCount(arrayList);
|
||||
JSONObject jSONObject = new JSONObject();
|
||||
for (int i2 = 0; i2 < eventCount.size(); i2++) {
|
||||
int keyAt = eventCount.keyAt(i2);
|
||||
try {
|
||||
jSONObject.put(Integer.toString(keyAt), eventCount.get(keyAt));
|
||||
} catch (Exception e2) {
|
||||
DeviceLog.exception("Error building response JSON", e2);
|
||||
}
|
||||
}
|
||||
webViewCallback.invoke(jSONObject);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getMotionEventData(JSONObject jSONObject, WebViewCallback webViewCallback) {
|
||||
Iterator<String> keys = jSONObject.keys();
|
||||
SparseArray<ArrayList<Integer>> sparseArray = new SparseArray<>();
|
||||
while (true) {
|
||||
if (!keys.hasNext()) {
|
||||
break;
|
||||
}
|
||||
String next = keys.next();
|
||||
int parseInt = Integer.parseInt(next);
|
||||
if (sparseArray.get(parseInt) == null) {
|
||||
sparseArray.put(parseInt, new ArrayList<>());
|
||||
}
|
||||
JSONArray jSONArray = null;
|
||||
try {
|
||||
jSONArray = jSONObject.getJSONArray(next);
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Couldn't fetch keyIndices", e);
|
||||
}
|
||||
if (jSONArray != null) {
|
||||
for (int i = 0; i < jSONArray.length(); i++) {
|
||||
try {
|
||||
sparseArray.get(parseInt).add(Integer.valueOf(jSONArray.getInt(i)));
|
||||
} catch (Exception e2) {
|
||||
DeviceLog.exception("Couldn't add value to requested infos", e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getAdUnitActivity() == null) {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
return;
|
||||
}
|
||||
if (getAdUnitActivity().getLayout() == null) {
|
||||
webViewCallback.error(AdUnitError.LAYOUT_NULL, new Object[0]);
|
||||
return;
|
||||
}
|
||||
if (getAdUnitActivity().getLayout().getCurrentEventCount() >= getAdUnitActivity().getLayout().getMaxEventCount()) {
|
||||
webViewCallback.error(AdUnitError.MAX_MOTION_EVENT_COUNT_REACHED, new Object[0]);
|
||||
return;
|
||||
}
|
||||
SparseArray<SparseArray<AdUnitMotionEvent>> events = getAdUnitActivity().getLayout().getEvents(sparseArray);
|
||||
JSONObject jSONObject2 = new JSONObject();
|
||||
for (int i2 = 0; i2 < events.size(); i2++) {
|
||||
int keyAt = events.keyAt(i2);
|
||||
SparseArray<AdUnitMotionEvent> sparseArray2 = events.get(keyAt);
|
||||
JSONObject jSONObject3 = new JSONObject();
|
||||
for (int i3 = 0; i3 < sparseArray2.size(); i3++) {
|
||||
JSONObject jSONObject4 = new JSONObject();
|
||||
int keyAt2 = sparseArray2.keyAt(i3);
|
||||
AdUnitMotionEvent adUnitMotionEvent = sparseArray2.get(keyAt2);
|
||||
try {
|
||||
jSONObject4.put("action", adUnitMotionEvent.getAction());
|
||||
jSONObject4.put("isObscured", adUnitMotionEvent.isObscured());
|
||||
jSONObject4.put("toolType", adUnitMotionEvent.getToolType());
|
||||
jSONObject4.put(SocialConstants.PARAM_SOURCE, adUnitMotionEvent.getSource());
|
||||
jSONObject4.put("deviceId", adUnitMotionEvent.getDeviceId());
|
||||
jSONObject4.put("x", adUnitMotionEvent.getX());
|
||||
jSONObject4.put("y", adUnitMotionEvent.getY());
|
||||
jSONObject4.put("eventTime", adUnitMotionEvent.getEventTime());
|
||||
jSONObject4.put("pressure", adUnitMotionEvent.getPressure());
|
||||
jSONObject4.put("size", adUnitMotionEvent.getSize());
|
||||
jSONObject3.put(Integer.toString(keyAt2), jSONObject4);
|
||||
} catch (Exception e3) {
|
||||
DeviceLog.debug("Couldn't construct event info", e3);
|
||||
}
|
||||
}
|
||||
try {
|
||||
jSONObject2.put(Integer.toString(keyAt), jSONObject3);
|
||||
} catch (Exception e4) {
|
||||
DeviceLog.debug("Couldn't construct info object", e4);
|
||||
}
|
||||
}
|
||||
webViewCallback.invoke(jSONObject2);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getOrientation(WebViewCallback webViewCallback) {
|
||||
if (getAdUnitActivity() != null) {
|
||||
webViewCallback.invoke(Integer.valueOf(getAdUnitActivity().getRequestedOrientation()));
|
||||
} else {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getViewFrame(String str, WebViewCallback webViewCallback) {
|
||||
if (getAdUnitActivity() == null) {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
} else if (getAdUnitActivity().getViewFrame(str) == null) {
|
||||
webViewCallback.error(AdUnitError.UNKNOWN_VIEW, new Object[0]);
|
||||
} else {
|
||||
Map<String, Integer> viewFrame = getAdUnitActivity().getViewFrame(str);
|
||||
webViewCallback.invoke(viewFrame.get("x"), viewFrame.get("y"), viewFrame.get(IMediaFormat.KEY_WIDTH), viewFrame.get(IMediaFormat.KEY_HEIGHT));
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static String[] getViewList(JSONArray jSONArray) throws JSONException {
|
||||
String[] strArr = new String[jSONArray.length()];
|
||||
for (int i = 0; i < jSONArray.length(); i++) {
|
||||
strArr[i] = jSONArray.getString(i);
|
||||
}
|
||||
return strArr;
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getViews(WebViewCallback webViewCallback) {
|
||||
if (getAdUnitActivity() != null) {
|
||||
webViewCallback.invoke(new JSONArray((Collection) Arrays.asList(getAdUnitActivity().getViews())));
|
||||
} else {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void open(Integer num, JSONArray jSONArray, Integer num2, WebViewCallback webViewCallback) {
|
||||
open(num, jSONArray, num2, null, webViewCallback);
|
||||
}
|
||||
|
||||
public static void setAdUnitActivity(AdUnitActivity adUnitActivity) {
|
||||
_adUnitActivity = adUnitActivity;
|
||||
}
|
||||
|
||||
public static void setCurrentAdUnitActivityId(int i) {
|
||||
_currentActivityId = i;
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setKeepScreenOn(final Boolean bool, WebViewCallback webViewCallback) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.AdUnit.3
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (AdUnit.getAdUnitActivity() != null) {
|
||||
AdUnit.getAdUnitActivity().setKeepScreenOn(bool.booleanValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
if (getAdUnitActivity() != null) {
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
} else {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setKeyEventList(JSONArray jSONArray, WebViewCallback webViewCallback) {
|
||||
if (getAdUnitActivity() == null) {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
getAdUnitActivity().setKeyEventList(getKeyEventList(jSONArray));
|
||||
webViewCallback.invoke(jSONArray);
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error parsing views from viewList", e);
|
||||
webViewCallback.error(AdUnitError.CORRUPTED_KEYEVENTLIST, jSONArray, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setOrientation(final Integer num, WebViewCallback webViewCallback) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.AdUnit.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (AdUnit.getAdUnitActivity() != null) {
|
||||
AdUnit.getAdUnitActivity().setOrientation(num.intValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
if (getAdUnitActivity() != null) {
|
||||
webViewCallback.invoke(num);
|
||||
} else {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setSystemUiVisibility(final Integer num, WebViewCallback webViewCallback) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.AdUnit.4
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (AdUnit.getAdUnitActivity() != null) {
|
||||
AdUnit.getAdUnitActivity().setSystemUiVisibility(num.intValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
if (getAdUnitActivity() != null) {
|
||||
webViewCallback.invoke(num);
|
||||
} else {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setViewFrame(final String str, final Integer num, final Integer num2, final Integer num3, final Integer num4, WebViewCallback webViewCallback) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.AdUnit.5
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (AdUnit.getAdUnitActivity() != null) {
|
||||
AdUnit.getAdUnitActivity().setViewFrame(str, num.intValue(), num2.intValue(), num3.intValue(), num4.intValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
if (getAdUnitActivity() != null) {
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
} else {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setViews(final JSONArray jSONArray, WebViewCallback webViewCallback) {
|
||||
boolean z;
|
||||
try {
|
||||
getViewList(jSONArray);
|
||||
z = false;
|
||||
} catch (JSONException unused) {
|
||||
webViewCallback.error(AdUnitError.CORRUPTED_VIEWLIST, jSONArray);
|
||||
z = true;
|
||||
}
|
||||
if (!z) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.AdUnit.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (AdUnit.getAdUnitActivity() != null) {
|
||||
try {
|
||||
AdUnit.getAdUnitActivity().setViews(AdUnit.getViewList(jSONArray));
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Corrupted viewlist", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (getAdUnitActivity() != null) {
|
||||
webViewCallback.invoke(jSONArray);
|
||||
} else {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void startMotionEventCapture(Integer num, WebViewCallback webViewCallback) {
|
||||
if (getAdUnitActivity() == null) {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
} else if (getAdUnitActivity().getLayout() == null) {
|
||||
webViewCallback.error(AdUnitError.LAYOUT_NULL, new Object[0]);
|
||||
} else {
|
||||
getAdUnitActivity().getLayout().startCapture(num.intValue());
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void open(Integer num, JSONArray jSONArray, Integer num2, JSONArray jSONArray2, WebViewCallback webViewCallback) {
|
||||
open(num, jSONArray, num2, jSONArray2, 0, true, webViewCallback);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void open(Integer num, JSONArray jSONArray, Integer num2, JSONArray jSONArray2, Integer num3, Boolean bool, WebViewCallback webViewCallback) {
|
||||
open(num, jSONArray, num2, jSONArray2, num3, bool, false, webViewCallback);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void open(Integer num, JSONArray jSONArray, Integer num2, JSONArray jSONArray2, Integer num3, Boolean bool, Boolean bool2, WebViewCallback webViewCallback) {
|
||||
android.content.Intent intent;
|
||||
if (!bool.booleanValue() && bool2.booleanValue()) {
|
||||
DeviceLog.debug("Unity Ads opening new transparent ad unit activity, hardware acceleration disabled");
|
||||
intent = new android.content.Intent(ClientProperties.getActivity(), (Class<?>) AdUnitTransparentSoftwareActivity.class);
|
||||
} else if (bool.booleanValue() && !bool2.booleanValue()) {
|
||||
DeviceLog.debug("Unity Ads opening new hardware accelerated ad unit activity");
|
||||
intent = new android.content.Intent(ClientProperties.getActivity(), (Class<?>) AdUnitActivity.class);
|
||||
} else if (bool.booleanValue() && bool2.booleanValue()) {
|
||||
DeviceLog.debug("Unity Ads opening new hardware accelerated transparent ad unit activity");
|
||||
intent = new android.content.Intent(ClientProperties.getActivity(), (Class<?>) AdUnitTransparentActivity.class);
|
||||
} else {
|
||||
DeviceLog.debug("Unity Ads opening new ad unit activity, hardware acceleration disabled");
|
||||
intent = new android.content.Intent(ClientProperties.getActivity(), (Class<?>) AdUnitSoftwareActivity.class);
|
||||
}
|
||||
intent.addFlags(268500992);
|
||||
if (num != null) {
|
||||
try {
|
||||
intent.putExtra(AdUnitActivity.EXTRA_ACTIVITY_ID, num.intValue());
|
||||
setCurrentAdUnitActivityId(num.intValue());
|
||||
try {
|
||||
intent.putExtra(AdUnitActivity.EXTRA_VIEWS, getViewList(jSONArray));
|
||||
if (jSONArray2 != null) {
|
||||
try {
|
||||
intent.putExtra(AdUnitActivity.EXTRA_KEY_EVENT_LIST, getKeyEventList(jSONArray2));
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error parsing views from viewList", e);
|
||||
webViewCallback.error(AdUnitError.CORRUPTED_KEYEVENTLIST, jSONArray2, e.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
intent.putExtra(AdUnitActivity.EXTRA_SYSTEM_UI_VISIBILITY, num3);
|
||||
intent.putExtra(AdUnitActivity.EXTRA_ORIENTATION, num2);
|
||||
ClientProperties.getActivity().startActivity(intent);
|
||||
DeviceLog.debug("Opened AdUnitActivity with: " + jSONArray.toString());
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
return;
|
||||
} catch (Exception e2) {
|
||||
DeviceLog.exception("Error parsing views from viewList", e2);
|
||||
webViewCallback.error(AdUnitError.CORRUPTED_VIEWLIST, jSONArray, e2.getMessage());
|
||||
return;
|
||||
}
|
||||
} catch (Exception e3) {
|
||||
DeviceLog.exception("Could not set activityId for intent", e3);
|
||||
webViewCallback.error(AdUnitError.ACTIVITY_ID, Integer.valueOf(num.intValue()), e3.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
DeviceLog.error("Activity ID is NULL");
|
||||
webViewCallback.error(AdUnitError.ACTIVITY_ID, "Activity ID NULL");
|
||||
}
|
||||
}
|
||||
44
sources/com/unity3d/ads/api/Broadcast.java
Normal file
44
sources/com/unity3d/ads/api/Broadcast.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import com.unity3d.ads.broadcast.BroadcastError;
|
||||
import com.unity3d.ads.broadcast.BroadcastMonitor;
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Broadcast {
|
||||
@WebViewExposed
|
||||
public static void addBroadcastListener(String str, JSONArray jSONArray, WebViewCallback webViewCallback) {
|
||||
addBroadcastListener(str, null, jSONArray, webViewCallback);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void removeAllBroadcastListeners(WebViewCallback webViewCallback) {
|
||||
BroadcastMonitor.removeAllBroadcastListeners();
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void removeBroadcastListener(String str, WebViewCallback webViewCallback) {
|
||||
BroadcastMonitor.removeBroadcastListener(str);
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void addBroadcastListener(String str, String str2, JSONArray jSONArray, WebViewCallback webViewCallback) {
|
||||
try {
|
||||
if (jSONArray.length() > 0) {
|
||||
String[] strArr = new String[jSONArray.length()];
|
||||
for (int i = 0; i < jSONArray.length(); i++) {
|
||||
strArr[i] = jSONArray.getString(i);
|
||||
}
|
||||
BroadcastMonitor.addBroadcastListener(str, str2, strArr);
|
||||
}
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
} catch (JSONException unused) {
|
||||
webViewCallback.error(BroadcastError.JSON_ERROR, new Object[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
405
sources/com/unity3d/ads/api/Cache.java
Normal file
405
sources/com/unity3d/ads/api/Cache.java
Normal file
@@ -0,0 +1,405 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.media.MediaMetadataRetriever;
|
||||
import android.util.Base64;
|
||||
import android.util.SparseArray;
|
||||
import com.ubt.jimu.controller.data.widget.JockstickDataConverter;
|
||||
import com.unity3d.ads.cache.CacheDirectory;
|
||||
import com.unity3d.ads.cache.CacheDirectoryType;
|
||||
import com.unity3d.ads.cache.CacheError;
|
||||
import com.unity3d.ads.cache.CacheThread;
|
||||
import com.unity3d.ads.device.Device;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.misc.Utilities;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
import com.unity3d.ads.properties.SdkProperties;
|
||||
import com.unity3d.ads.request.WebRequestError;
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Cache {
|
||||
@WebViewExposed
|
||||
public static void deleteFile(String str, WebViewCallback webViewCallback) {
|
||||
if (new File(fileIdToFilename(str)).delete()) {
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
} else {
|
||||
webViewCallback.error(CacheError.FILE_IO_ERROR, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void download(String str, String str2, JSONArray jSONArray, Boolean bool, WebViewCallback webViewCallback) {
|
||||
if (CacheThread.isActive()) {
|
||||
webViewCallback.error(CacheError.FILE_ALREADY_CACHING, new Object[0]);
|
||||
return;
|
||||
}
|
||||
if (!Device.isActiveNetworkConnected()) {
|
||||
webViewCallback.error(CacheError.NO_INTERNET, new Object[0]);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
CacheThread.download(str, fileIdToFilename(str2), Request.getHeadersMap(jSONArray), bool.booleanValue());
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error mapping headers for the request", e);
|
||||
webViewCallback.error(WebRequestError.MAPPING_HEADERS_FAILED, str, str2);
|
||||
}
|
||||
}
|
||||
|
||||
private static String fileIdToFilename(String str) {
|
||||
return SdkProperties.getCacheDirectory() + "/" + SdkProperties.getCacheFilePrefix() + str;
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getCacheDirectoryExists(WebViewCallback webViewCallback) {
|
||||
File cacheDirectory = SdkProperties.getCacheDirectory();
|
||||
if (cacheDirectory == null) {
|
||||
webViewCallback.error(CacheError.CACHE_DIRECTORY_NULL, new Object[0]);
|
||||
} else {
|
||||
webViewCallback.invoke(Boolean.valueOf(cacheDirectory.exists()));
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getCacheDirectoryType(WebViewCallback webViewCallback) {
|
||||
CacheDirectory cacheDirectoryObject = SdkProperties.getCacheDirectoryObject();
|
||||
if (cacheDirectoryObject == null || cacheDirectoryObject.getCacheDirectory(ClientProperties.getApplicationContext()) == null) {
|
||||
webViewCallback.error(CacheError.CACHE_DIRECTORY_NULL, new Object[0]);
|
||||
return;
|
||||
}
|
||||
if (!cacheDirectoryObject.getCacheDirectory(ClientProperties.getApplicationContext()).exists()) {
|
||||
webViewCallback.error(CacheError.CACHE_DIRECTORY_DOESNT_EXIST, new Object[0]);
|
||||
return;
|
||||
}
|
||||
CacheDirectoryType type = cacheDirectoryObject.getType();
|
||||
if (type == null) {
|
||||
webViewCallback.error(CacheError.CACHE_DIRECTORY_TYPE_NULL, new Object[0]);
|
||||
} else {
|
||||
webViewCallback.invoke(type.name());
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getFileContent(String str, String str2, WebViewCallback webViewCallback) {
|
||||
Object encodeToString;
|
||||
String fileIdToFilename = fileIdToFilename(str);
|
||||
File file = new File(fileIdToFilename);
|
||||
if (!file.exists()) {
|
||||
webViewCallback.error(CacheError.FILE_NOT_FOUND, str, fileIdToFilename);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
byte[] readFileBytes = Utilities.readFileBytes(file);
|
||||
if (str2 == null) {
|
||||
webViewCallback.error(CacheError.UNSUPPORTED_ENCODING, str, fileIdToFilename, str2);
|
||||
return;
|
||||
}
|
||||
if (str2.equals("UTF-8")) {
|
||||
encodeToString = Charset.forName("UTF-8").decode(ByteBuffer.wrap(readFileBytes)).toString();
|
||||
} else {
|
||||
if (!str2.equals("Base64")) {
|
||||
webViewCallback.error(CacheError.UNSUPPORTED_ENCODING, str, fileIdToFilename, str2);
|
||||
return;
|
||||
}
|
||||
encodeToString = Base64.encodeToString(readFileBytes, 2);
|
||||
}
|
||||
webViewCallback.invoke(encodeToString);
|
||||
} catch (IOException e) {
|
||||
webViewCallback.error(CacheError.FILE_IO_ERROR, str, fileIdToFilename, e.getMessage() + ", " + e.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getFileInfo(String str, WebViewCallback webViewCallback) {
|
||||
try {
|
||||
webViewCallback.invoke(getFileJson(str));
|
||||
} catch (JSONException e) {
|
||||
DeviceLog.exception("Error creating JSON", e);
|
||||
webViewCallback.error(CacheError.JSON_ERROR, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static JSONObject getFileJson(String str) throws JSONException {
|
||||
JSONObject jSONObject = new JSONObject();
|
||||
jSONObject.put(JockstickDataConverter.ID, str);
|
||||
File file = new File(fileIdToFilename(str));
|
||||
if (file.exists()) {
|
||||
jSONObject.put("found", true);
|
||||
jSONObject.put("size", file.length());
|
||||
jSONObject.put("mtime", file.lastModified());
|
||||
} else {
|
||||
jSONObject.put("found", false);
|
||||
}
|
||||
return jSONObject;
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getFilePath(String str, WebViewCallback webViewCallback) {
|
||||
if (new File(fileIdToFilename(str)).exists()) {
|
||||
webViewCallback.invoke(fileIdToFilename(str));
|
||||
} else {
|
||||
webViewCallback.error(CacheError.FILE_NOT_FOUND, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getFiles(WebViewCallback webViewCallback) {
|
||||
File cacheDirectory = SdkProperties.getCacheDirectory();
|
||||
if (cacheDirectory == null) {
|
||||
return;
|
||||
}
|
||||
DeviceLog.debug("Unity Ads cache: checking app directory for Unity Ads cached files");
|
||||
File[] listFiles = cacheDirectory.listFiles(new FilenameFilter() { // from class: com.unity3d.ads.api.Cache.1
|
||||
@Override // java.io.FilenameFilter
|
||||
public boolean accept(File file, String str) {
|
||||
return str.startsWith(SdkProperties.getCacheFilePrefix());
|
||||
}
|
||||
});
|
||||
if (listFiles == null || listFiles.length == 0) {
|
||||
webViewCallback.invoke(new JSONArray());
|
||||
}
|
||||
try {
|
||||
JSONArray jSONArray = new JSONArray();
|
||||
for (File file : listFiles) {
|
||||
String substring = file.getName().substring(SdkProperties.getCacheFilePrefix().length());
|
||||
DeviceLog.debug("Unity Ads cache: found " + substring + ", " + file.length() + " bytes");
|
||||
jSONArray.put(getFileJson(substring));
|
||||
}
|
||||
webViewCallback.invoke(jSONArray);
|
||||
} catch (JSONException e) {
|
||||
DeviceLog.exception("Error creating JSON", e);
|
||||
webViewCallback.error(CacheError.JSON_ERROR, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getFreeSpace(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Long.valueOf(Device.getFreeSpace(SdkProperties.getCacheDirectory())));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getHash(String str, WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Utilities.Sha256(str));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getMetaData(String str, JSONArray jSONArray, WebViewCallback webViewCallback) {
|
||||
try {
|
||||
SparseArray<String> metaData = getMetaData(fileIdToFilename(str), jSONArray);
|
||||
JSONArray jSONArray2 = new JSONArray();
|
||||
for (int i = 0; i < metaData.size(); i++) {
|
||||
JSONArray jSONArray3 = new JSONArray();
|
||||
jSONArray3.put(metaData.keyAt(i));
|
||||
jSONArray3.put(metaData.valueAt(i));
|
||||
jSONArray2.put(jSONArray3);
|
||||
}
|
||||
webViewCallback.invoke(jSONArray2);
|
||||
} catch (IOException e) {
|
||||
webViewCallback.error(CacheError.FILE_IO_ERROR, e.getMessage());
|
||||
} catch (RuntimeException e2) {
|
||||
webViewCallback.error(CacheError.INVALID_ARGUMENT, e2.getMessage());
|
||||
} catch (JSONException e3) {
|
||||
webViewCallback.error(CacheError.JSON_ERROR, e3.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getProgressInterval(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Integer.valueOf(CacheThread.getProgressInterval()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getTimeouts(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Integer.valueOf(CacheThread.getConnectTimeout()), Integer.valueOf(CacheThread.getReadTimeout()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getTotalSpace(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Long.valueOf(Device.getTotalSpace(SdkProperties.getCacheDirectory())));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void isCaching(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Boolean.valueOf(CacheThread.isActive()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void recreateCacheDirectory(WebViewCallback webViewCallback) {
|
||||
if (SdkProperties.getCacheDirectory().exists()) {
|
||||
webViewCallback.error(CacheError.CACHE_DIRECTORY_EXISTS, new Object[0]);
|
||||
return;
|
||||
}
|
||||
SdkProperties.setCacheDirectory(null);
|
||||
if (SdkProperties.getCacheDirectory() == null) {
|
||||
webViewCallback.error(CacheError.CACHE_DIRECTORY_NULL, new Object[0]);
|
||||
} else {
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:25:0x0085 */
|
||||
/* JADX WARN: Removed duplicated region for block: B:27:? A[RETURN, SYNTHETIC] */
|
||||
@com.unity3d.ads.webview.bridge.WebViewExposed
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public static void setFileContent(java.lang.String r9, java.lang.String r10, java.lang.String r11, com.unity3d.ads.webview.bridge.WebViewCallback r12) {
|
||||
/*
|
||||
java.lang.String r0 = "UTF-8"
|
||||
java.lang.String r1 = "Error closing FileOutputStream"
|
||||
java.lang.String r2 = fileIdToFilename(r9)
|
||||
r3 = 3
|
||||
r4 = 2
|
||||
r5 = 1
|
||||
r6 = 0
|
||||
byte[] r7 = r11.getBytes(r0) // Catch: java.io.UnsupportedEncodingException -> L96
|
||||
if (r10 == 0) goto L3a
|
||||
int r8 = r10.length()
|
||||
if (r8 <= 0) goto L3a
|
||||
java.lang.String r8 = "Base64"
|
||||
boolean r8 = r10.equals(r8)
|
||||
if (r8 == 0) goto L25
|
||||
byte[] r7 = android.util.Base64.decode(r11, r4)
|
||||
goto L3a
|
||||
L25:
|
||||
boolean r11 = r10.equals(r0)
|
||||
if (r11 == 0) goto L2c
|
||||
goto L3a
|
||||
L2c:
|
||||
com.unity3d.ads.cache.CacheError r11 = com.unity3d.ads.cache.CacheError.UNSUPPORTED_ENCODING
|
||||
java.lang.Object[] r0 = new java.lang.Object[r3]
|
||||
r0[r6] = r9
|
||||
r0[r5] = r2
|
||||
r0[r4] = r10
|
||||
r12.error(r11, r0)
|
||||
return
|
||||
L3a:
|
||||
r11 = 0
|
||||
java.io.FileOutputStream r0 = new java.io.FileOutputStream // Catch: java.lang.Throwable -> L56 java.io.IOException -> L58 java.io.FileNotFoundException -> L6b
|
||||
r0.<init>(r2) // Catch: java.lang.Throwable -> L56 java.io.IOException -> L58 java.io.FileNotFoundException -> L6b
|
||||
r0.write(r7) // Catch: java.lang.Throwable -> L4f java.io.IOException -> L52 java.io.FileNotFoundException -> L54
|
||||
r0.flush() // Catch: java.lang.Throwable -> L4f java.io.IOException -> L52 java.io.FileNotFoundException -> L54
|
||||
r0.close() // Catch: java.lang.Exception -> L4a
|
||||
goto L83
|
||||
L4a:
|
||||
r9 = move-exception
|
||||
com.unity3d.ads.log.DeviceLog.exception(r1, r9)
|
||||
goto L83
|
||||
L4f:
|
||||
r9 = move-exception
|
||||
r11 = r0
|
||||
goto L8b
|
||||
L52:
|
||||
r11 = r0
|
||||
goto L58
|
||||
L54:
|
||||
r11 = r0
|
||||
goto L6b
|
||||
L56:
|
||||
r9 = move-exception
|
||||
goto L8b
|
||||
L58:
|
||||
com.unity3d.ads.cache.CacheError r0 = com.unity3d.ads.cache.CacheError.FILE_IO_ERROR // Catch: java.lang.Throwable -> L56
|
||||
java.lang.Object[] r3 = new java.lang.Object[r3] // Catch: java.lang.Throwable -> L56
|
||||
r3[r6] = r9 // Catch: java.lang.Throwable -> L56
|
||||
r3[r5] = r2 // Catch: java.lang.Throwable -> L56
|
||||
r3[r4] = r10 // Catch: java.lang.Throwable -> L56
|
||||
r12.error(r0, r3) // Catch: java.lang.Throwable -> L56
|
||||
if (r11 == 0) goto L82
|
||||
r11.close() // Catch: java.lang.Exception -> L7e
|
||||
goto L82
|
||||
L6b:
|
||||
com.unity3d.ads.cache.CacheError r0 = com.unity3d.ads.cache.CacheError.FILE_NOT_FOUND // Catch: java.lang.Throwable -> L56
|
||||
java.lang.Object[] r3 = new java.lang.Object[r3] // Catch: java.lang.Throwable -> L56
|
||||
r3[r6] = r9 // Catch: java.lang.Throwable -> L56
|
||||
r3[r5] = r2 // Catch: java.lang.Throwable -> L56
|
||||
r3[r4] = r10 // Catch: java.lang.Throwable -> L56
|
||||
r12.error(r0, r3) // Catch: java.lang.Throwable -> L56
|
||||
if (r11 == 0) goto L82
|
||||
r11.close() // Catch: java.lang.Exception -> L7e
|
||||
goto L82
|
||||
L7e:
|
||||
r9 = move-exception
|
||||
com.unity3d.ads.log.DeviceLog.exception(r1, r9)
|
||||
L82:
|
||||
r5 = 0
|
||||
L83:
|
||||
if (r5 == 0) goto L8a
|
||||
java.lang.Object[] r9 = new java.lang.Object[r6]
|
||||
r12.invoke(r9)
|
||||
L8a:
|
||||
return
|
||||
L8b:
|
||||
if (r11 == 0) goto L95
|
||||
r11.close() // Catch: java.lang.Exception -> L91
|
||||
goto L95
|
||||
L91:
|
||||
r10 = move-exception
|
||||
com.unity3d.ads.log.DeviceLog.exception(r1, r10)
|
||||
L95:
|
||||
throw r9
|
||||
L96:
|
||||
com.unity3d.ads.cache.CacheError r11 = com.unity3d.ads.cache.CacheError.UNSUPPORTED_ENCODING
|
||||
java.lang.Object[] r0 = new java.lang.Object[r3]
|
||||
r0[r6] = r9
|
||||
r0[r5] = r2
|
||||
r0[r4] = r10
|
||||
r12.error(r11, r0)
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.unity3d.ads.api.Cache.setFileContent(java.lang.String, java.lang.String, java.lang.String, com.unity3d.ads.webview.bridge.WebViewCallback):void");
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setProgressInterval(Integer num, WebViewCallback webViewCallback) {
|
||||
CacheThread.setProgressInterval(num.intValue());
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setTimeouts(Integer num, Integer num2, WebViewCallback webViewCallback) {
|
||||
CacheThread.setConnectTimeout(num.intValue());
|
||||
CacheThread.setReadTimeout(num2.intValue());
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void stop(WebViewCallback webViewCallback) {
|
||||
if (!CacheThread.isActive()) {
|
||||
webViewCallback.error(CacheError.NOT_CACHING, new Object[0]);
|
||||
} else {
|
||||
CacheThread.cancel();
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(10)
|
||||
private static SparseArray<String> getMetaData(String str, JSONArray jSONArray) throws JSONException, IOException, RuntimeException {
|
||||
File file = new File(str);
|
||||
SparseArray<String> sparseArray = new SparseArray<>();
|
||||
if (file.exists()) {
|
||||
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
|
||||
mediaMetadataRetriever.setDataSource(file.getAbsolutePath());
|
||||
for (int i = 0; i < jSONArray.length(); i++) {
|
||||
int i2 = jSONArray.getInt(i);
|
||||
String extractMetadata = mediaMetadataRetriever.extractMetadata(i2);
|
||||
if (extractMetadata != null) {
|
||||
sparseArray.put(i2, extractMetadata);
|
||||
}
|
||||
}
|
||||
return sparseArray;
|
||||
}
|
||||
throw new IOException("File: " + file.getAbsolutePath() + " doesn't exist");
|
||||
}
|
||||
}
|
||||
14
sources/com/unity3d/ads/api/Connectivity.java
Normal file
14
sources/com/unity3d/ads/api/Connectivity.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import com.unity3d.ads.connectivity.ConnectivityMonitor;
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Connectivity {
|
||||
@WebViewExposed
|
||||
public static void setConnectionMonitoring(Boolean bool, WebViewCallback webViewCallback) {
|
||||
ConnectivityMonitor.setConnectionMonitoring(bool.booleanValue());
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
552
sources/com/unity3d/ads/api/DeviceInfo.java
Normal file
552
sources/com/unity3d/ads/api/DeviceInfo.java
Normal file
@@ -0,0 +1,552 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.Sensor;
|
||||
import android.util.SparseArray;
|
||||
import com.ubt.jimu.base.entities.Constant;
|
||||
import com.ubt.jimu.transport.model.TransportFile;
|
||||
import com.unity3d.ads.device.Device;
|
||||
import com.unity3d.ads.device.DeviceError;
|
||||
import com.unity3d.ads.device.IVolumeChangeListener;
|
||||
import com.unity3d.ads.device.VolumeChange;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.metadata.MediationMetaData;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
import com.unity3d.ads.webview.WebViewApp;
|
||||
import com.unity3d.ads.webview.WebViewEventCategory;
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class DeviceInfo {
|
||||
private static SparseArray<IVolumeChangeListener> _volumeChangeListeners;
|
||||
|
||||
/* renamed from: com.unity3d.ads.api.DeviceInfo$2, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass2 {
|
||||
static final /* synthetic */ int[] $SwitchMap$com$unity3d$ads$api$DeviceInfo$StorageType = new int[StorageType.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
$SwitchMap$com$unity3d$ads$api$DeviceInfo$StorageType[StorageType.INTERNAL.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$unity3d$ads$api$DeviceInfo$StorageType[StorageType.EXTERNAL.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum DeviceInfoEvent {
|
||||
VOLUME_CHANGED
|
||||
}
|
||||
|
||||
public enum StorageType {
|
||||
EXTERNAL,
|
||||
INTERNAL
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getAdvertisingTrackingId(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getAdvertisingTrackingId());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getAndroidId(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getAndroidId());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getApiLevel(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Integer.valueOf(Device.getApiLevel()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getApkDigest(WebViewCallback webViewCallback) {
|
||||
try {
|
||||
webViewCallback.invoke(Device.getApkDigest());
|
||||
} catch (Exception e) {
|
||||
webViewCallback.error(DeviceError.COULDNT_GET_DIGEST, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getBatteryLevel(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Float.valueOf(Device.getBatteryLevel()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getBatteryStatus(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Integer.valueOf(Device.getBatteryStatus()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getBoard(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getBoard());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getBootloader(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getBootloader());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getBrand(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getBrand());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getBuildId(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getBuildId());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getBuildVersionIncremental(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getBuildVersionIncremental());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getCPUCount(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Long.valueOf(Device.getCPUCount()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getCertificateFingerprint(WebViewCallback webViewCallback) {
|
||||
String certificateFingerprint = Device.getCertificateFingerprint();
|
||||
if (certificateFingerprint != null) {
|
||||
webViewCallback.invoke(certificateFingerprint);
|
||||
} else {
|
||||
webViewCallback.error(DeviceError.COULDNT_GET_FINGERPRINT, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getConnectionType(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.isUsingWifi() ? "wifi" : Device.isActiveNetworkConnected() ? "cellular" : TransportFile.TYPE_NONE);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getDevice(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getDevice());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getDeviceMaxVolume(Integer num, WebViewCallback webViewCallback) {
|
||||
int streamMaxVolume = Device.getStreamMaxVolume(num.intValue());
|
||||
if (streamMaxVolume > -1) {
|
||||
webViewCallback.invoke(Integer.valueOf(streamMaxVolume));
|
||||
return;
|
||||
}
|
||||
if (streamMaxVolume == -2) {
|
||||
webViewCallback.error(DeviceError.AUDIOMANAGER_NULL, Integer.valueOf(streamMaxVolume));
|
||||
return;
|
||||
}
|
||||
if (streamMaxVolume == -1) {
|
||||
webViewCallback.error(DeviceError.APPLICATION_CONTEXT_NULL, Integer.valueOf(streamMaxVolume));
|
||||
return;
|
||||
}
|
||||
DeviceLog.error("Unhandled deviceMaxVolume error: " + streamMaxVolume);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getDeviceVolume(Integer num, WebViewCallback webViewCallback) {
|
||||
int streamVolume = Device.getStreamVolume(num.intValue());
|
||||
if (streamVolume > -1) {
|
||||
webViewCallback.invoke(Integer.valueOf(streamVolume));
|
||||
return;
|
||||
}
|
||||
if (streamVolume == -2) {
|
||||
webViewCallback.error(DeviceError.AUDIOMANAGER_NULL, Integer.valueOf(streamVolume));
|
||||
return;
|
||||
}
|
||||
if (streamVolume == -1) {
|
||||
webViewCallback.error(DeviceError.APPLICATION_CONTEXT_NULL, Integer.valueOf(streamVolume));
|
||||
return;
|
||||
}
|
||||
DeviceLog.error("Unhandled deviceVolume error: " + streamVolume);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getElapsedRealtime(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Long.valueOf(Device.getElapsedRealtime()));
|
||||
}
|
||||
|
||||
private static File getFileForStorageType(StorageType storageType) {
|
||||
int i = AnonymousClass2.$SwitchMap$com$unity3d$ads$api$DeviceInfo$StorageType[storageType.ordinal()];
|
||||
if (i == 1) {
|
||||
return ClientProperties.getApplicationContext().getCacheDir();
|
||||
}
|
||||
if (i == 2) {
|
||||
return ClientProperties.getApplicationContext().getExternalCacheDir();
|
||||
}
|
||||
DeviceLog.error("Unhandled storagetype: " + storageType);
|
||||
return null;
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getFingerprint(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getFingerprint());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getFreeMemory(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Long.valueOf(Device.getFreeMemory()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getFreeSpace(String str, WebViewCallback webViewCallback) {
|
||||
StorageType storageTypeFromString = getStorageTypeFromString(str);
|
||||
if (storageTypeFromString == null) {
|
||||
webViewCallback.error(DeviceError.INVALID_STORAGETYPE, str);
|
||||
return;
|
||||
}
|
||||
long freeSpace = Device.getFreeSpace(getFileForStorageType(storageTypeFromString));
|
||||
if (freeSpace > -1) {
|
||||
webViewCallback.invoke(Long.valueOf(freeSpace));
|
||||
} else {
|
||||
webViewCallback.error(DeviceError.COULDNT_GET_STORAGE_LOCATION, Long.valueOf(freeSpace));
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getGLVersion(WebViewCallback webViewCallback) {
|
||||
String gLVersion = Device.getGLVersion();
|
||||
if (gLVersion != null) {
|
||||
webViewCallback.invoke(gLVersion);
|
||||
} else {
|
||||
webViewCallback.error(DeviceError.COULDNT_GET_GL_VERSION, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getHardware(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getHardware());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getHeadset(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Boolean.valueOf(Device.isWiredHeadsetOn()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getHost(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getHost());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getInstalledPackages(boolean z, WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(new JSONArray((Collection) Device.getInstalledPackages(z)));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getLimitAdTrackingFlag(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Boolean.valueOf(Device.isLimitAdTrackingEnabled()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getManufacturer(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getManufacturer());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getModel(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getModel());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getNetworkMetered(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Boolean.valueOf(Device.getNetworkMetered()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getNetworkOperator(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getNetworkOperator());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getNetworkOperatorName(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getNetworkOperatorName());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getNetworkType(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Integer.valueOf(Device.getNetworkType()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getOsVersion(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getOsVersion());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getPackageInfo(String str, WebViewCallback webViewCallback) {
|
||||
if (ClientProperties.getApplicationContext() == null) {
|
||||
webViewCallback.error(DeviceError.APPLICATION_CONTEXT_NULL, new Object[0]);
|
||||
return;
|
||||
}
|
||||
PackageManager packageManager = ClientProperties.getApplicationContext().getPackageManager();
|
||||
try {
|
||||
PackageInfo packageInfo = packageManager.getPackageInfo(str, 0);
|
||||
JSONObject jSONObject = new JSONObject();
|
||||
try {
|
||||
jSONObject.put("installer", packageManager.getInstallerPackageName(str));
|
||||
jSONObject.put("firstInstallTime", packageInfo.firstInstallTime);
|
||||
jSONObject.put("lastUpdateTime", packageInfo.lastUpdateTime);
|
||||
jSONObject.put("versionCode", packageInfo.versionCode);
|
||||
jSONObject.put("versionName", packageInfo.versionName);
|
||||
jSONObject.put(Constant.SelectRobot.PACKAGE_NAME_KEY, packageInfo.packageName);
|
||||
webViewCallback.invoke(jSONObject);
|
||||
} catch (JSONException e) {
|
||||
webViewCallback.error(DeviceError.JSON_ERROR, e.getMessage());
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException unused) {
|
||||
webViewCallback.error(DeviceError.APPLICATION_INFO_NOT_AVAILABLE, str);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getProcessInfo(WebViewCallback webViewCallback) {
|
||||
JSONObject jSONObject = new JSONObject();
|
||||
Map<String, String> processInfo = Device.getProcessInfo();
|
||||
if (processInfo != null) {
|
||||
try {
|
||||
if (processInfo.containsKey("stat")) {
|
||||
jSONObject.put("stat", processInfo.get("stat"));
|
||||
}
|
||||
if (processInfo.containsKey("uptime")) {
|
||||
jSONObject.put("uptime", processInfo.get("uptime"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error while constructing process info", e);
|
||||
}
|
||||
}
|
||||
webViewCallback.invoke(jSONObject);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getProduct(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getProduct());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getRingerMode(WebViewCallback webViewCallback) {
|
||||
int ringerMode = Device.getRingerMode();
|
||||
if (ringerMode > -1) {
|
||||
webViewCallback.invoke(Integer.valueOf(ringerMode));
|
||||
return;
|
||||
}
|
||||
if (ringerMode == -2) {
|
||||
webViewCallback.error(DeviceError.AUDIOMANAGER_NULL, Integer.valueOf(ringerMode));
|
||||
return;
|
||||
}
|
||||
if (ringerMode == -1) {
|
||||
webViewCallback.error(DeviceError.APPLICATION_CONTEXT_NULL, Integer.valueOf(ringerMode));
|
||||
return;
|
||||
}
|
||||
DeviceLog.error("Unhandled ringerMode error: " + ringerMode);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getScreenBrightness(WebViewCallback webViewCallback) {
|
||||
int screenBrightness = Device.getScreenBrightness();
|
||||
if (screenBrightness > -1) {
|
||||
webViewCallback.invoke(Integer.valueOf(screenBrightness));
|
||||
return;
|
||||
}
|
||||
if (screenBrightness == -1) {
|
||||
webViewCallback.error(DeviceError.APPLICATION_CONTEXT_NULL, Integer.valueOf(screenBrightness));
|
||||
return;
|
||||
}
|
||||
DeviceLog.error("Unhandled screenBrightness error: " + screenBrightness);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getScreenDensity(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Integer.valueOf(Device.getScreenDensity()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getScreenHeight(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Integer.valueOf(Device.getScreenHeight()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getScreenLayout(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Integer.valueOf(Device.getScreenLayout()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getScreenWidth(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Integer.valueOf(Device.getScreenWidth()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getSensorList(WebViewCallback webViewCallback) {
|
||||
JSONArray jSONArray = new JSONArray();
|
||||
List<Sensor> sensorList = Device.getSensorList();
|
||||
if (sensorList != null) {
|
||||
for (Sensor sensor : sensorList) {
|
||||
JSONObject jSONObject = new JSONObject();
|
||||
try {
|
||||
jSONObject.put(MediationMetaData.KEY_NAME, sensor.getName());
|
||||
jSONObject.put("type", sensor.getType());
|
||||
jSONObject.put("vendor", sensor.getVendor());
|
||||
jSONObject.put("maximumRange", sensor.getMaximumRange());
|
||||
jSONObject.put("power", sensor.getPower());
|
||||
jSONObject.put(MediationMetaData.KEY_VERSION, sensor.getVersion());
|
||||
jSONObject.put("resolution", sensor.getResolution());
|
||||
jSONObject.put("minDelay", sensor.getMinDelay());
|
||||
jSONArray.put(jSONObject);
|
||||
} catch (JSONException e) {
|
||||
webViewCallback.error(DeviceError.JSON_ERROR, e.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
webViewCallback.invoke(jSONArray);
|
||||
}
|
||||
|
||||
private static StorageType getStorageTypeFromString(String str) {
|
||||
try {
|
||||
return StorageType.valueOf(str);
|
||||
} catch (IllegalArgumentException e) {
|
||||
DeviceLog.exception("Illegal argument: " + str, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getSupportedAbis(WebViewCallback webViewCallback) {
|
||||
JSONArray jSONArray = new JSONArray();
|
||||
Iterator<String> it = Device.getSupportedAbis().iterator();
|
||||
while (it.hasNext()) {
|
||||
jSONArray.put(it.next());
|
||||
}
|
||||
webViewCallback.invoke(jSONArray);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getSystemLanguage(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Locale.getDefault().toString());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getSystemProperty(String str, String str2, WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getSystemProperty(str, str2));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getTimeZone(Boolean bool, WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(TimeZone.getDefault().getDisplayName(bool.booleanValue(), 0, Locale.US));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getTimeZoneOffset(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Integer.valueOf(TimeZone.getDefault().getOffset(System.currentTimeMillis()) / 1000));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getTotalMemory(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Long.valueOf(Device.getTotalMemory()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getTotalSpace(String str, WebViewCallback webViewCallback) {
|
||||
StorageType storageTypeFromString = getStorageTypeFromString(str);
|
||||
if (storageTypeFromString == null) {
|
||||
webViewCallback.error(DeviceError.INVALID_STORAGETYPE, str);
|
||||
return;
|
||||
}
|
||||
long totalSpace = Device.getTotalSpace(getFileForStorageType(storageTypeFromString));
|
||||
if (totalSpace > -1) {
|
||||
webViewCallback.invoke(Long.valueOf(totalSpace));
|
||||
} else {
|
||||
webViewCallback.error(DeviceError.COULDNT_GET_STORAGE_LOCATION, Long.valueOf(totalSpace));
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getUniqueEventId(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Device.getUniqueEventId());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getUptime(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Long.valueOf(Device.getUptime()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void isAdbEnabled(WebViewCallback webViewCallback) {
|
||||
Boolean isAdbEnabled = Device.isAdbEnabled();
|
||||
if (isAdbEnabled != null) {
|
||||
webViewCallback.invoke(isAdbEnabled);
|
||||
} else {
|
||||
webViewCallback.error(DeviceError.COULDNT_GET_ADB_STATUS, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void isAppInstalled(String str, WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Boolean.valueOf(Device.isAppInstalled(str)));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void isRooted(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Boolean.valueOf(Device.isRooted()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void isUSBConnected(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Boolean.valueOf(Device.isUSBConnected()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void registerVolumeChangeListener(final Integer num, WebViewCallback webViewCallback) {
|
||||
if (_volumeChangeListeners == null) {
|
||||
_volumeChangeListeners = new SparseArray<>();
|
||||
}
|
||||
if (_volumeChangeListeners.get(num.intValue()) == null) {
|
||||
IVolumeChangeListener iVolumeChangeListener = new IVolumeChangeListener() { // from class: com.unity3d.ads.api.DeviceInfo.1
|
||||
private int _streamType;
|
||||
|
||||
{
|
||||
this._streamType = num.intValue();
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.device.IVolumeChangeListener
|
||||
public int getStreamType() {
|
||||
return this._streamType;
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.device.IVolumeChangeListener
|
||||
public void onVolumeChanged(int i) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.DEVICEINFO, DeviceInfoEvent.VOLUME_CHANGED, Integer.valueOf(getStreamType()), Integer.valueOf(i), Integer.valueOf(Device.getStreamMaxVolume(this._streamType)));
|
||||
}
|
||||
};
|
||||
_volumeChangeListeners.append(num.intValue(), iVolumeChangeListener);
|
||||
VolumeChange.registerListener(iVolumeChangeListener);
|
||||
}
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void unregisterVolumeChangeListener(Integer num, WebViewCallback webViewCallback) {
|
||||
SparseArray<IVolumeChangeListener> sparseArray = _volumeChangeListeners;
|
||||
if (sparseArray != null && sparseArray.get(num.intValue()) != null) {
|
||||
VolumeChange.unregisterListener(_volumeChangeListeners.get(num.intValue()));
|
||||
_volumeChangeListeners.remove(num.intValue());
|
||||
}
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
234
sources/com/unity3d/ads/api/Intent.java
Normal file
234
sources/com/unity3d/ads/api/Intent.java
Normal file
@@ -0,0 +1,234 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.net.Uri;
|
||||
import com.ubt.jimu.base.entities.Constant;
|
||||
import com.ubt.jimu.controller.data.widget.JockstickDataConverter;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Intent {
|
||||
|
||||
public enum IntentError {
|
||||
COULDNT_PARSE_EXTRAS,
|
||||
COULDNT_PARSE_CATEGORIES,
|
||||
INTENT_WAS_NULL,
|
||||
JSON_EXCEPTION,
|
||||
ACTIVITY_WAS_NULL
|
||||
}
|
||||
|
||||
private static class IntentException extends Exception {
|
||||
private IntentError error;
|
||||
private Object field;
|
||||
|
||||
public IntentException(IntentError intentError, Object obj) {
|
||||
this.error = intentError;
|
||||
this.field = obj;
|
||||
}
|
||||
|
||||
public IntentError getError() {
|
||||
return this.error;
|
||||
}
|
||||
|
||||
public Object getField() {
|
||||
return this.field;
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void canOpenIntent(JSONObject jSONObject, WebViewCallback webViewCallback) {
|
||||
try {
|
||||
webViewCallback.invoke(Boolean.valueOf(checkIntentResolvable(intentFromMetadata(jSONObject))));
|
||||
} catch (IntentException e) {
|
||||
DeviceLog.exception("Couldn't resolve intent", e);
|
||||
webViewCallback.error(e.getError(), e.getField());
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void canOpenIntents(JSONArray jSONArray, WebViewCallback webViewCallback) {
|
||||
JSONObject jSONObject = new JSONObject();
|
||||
int length = jSONArray.length();
|
||||
for (int i = 0; i < length; i++) {
|
||||
JSONObject optJSONObject = jSONArray.optJSONObject(i);
|
||||
try {
|
||||
jSONObject.put(optJSONObject.optString(JockstickDataConverter.ID), checkIntentResolvable(intentFromMetadata(optJSONObject)));
|
||||
} catch (IntentException e) {
|
||||
DeviceLog.exception("Exception parsing intent", e);
|
||||
webViewCallback.error(e.getError(), e.getField());
|
||||
return;
|
||||
} catch (JSONException e2) {
|
||||
webViewCallback.error(IntentError.JSON_EXCEPTION, e2.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
webViewCallback.invoke(jSONObject);
|
||||
}
|
||||
|
||||
private static boolean checkIntentResolvable(android.content.Intent intent) {
|
||||
return ClientProperties.getApplicationContext().getPackageManager().resolveActivity(intent, 0) != null;
|
||||
}
|
||||
|
||||
private static Activity getStartingActivity() {
|
||||
if (AdUnit.getAdUnitActivity() != null) {
|
||||
return AdUnit.getAdUnitActivity();
|
||||
}
|
||||
if (ClientProperties.getActivity() != null) {
|
||||
return ClientProperties.getActivity();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static android.content.Intent intentFromMetadata(JSONObject jSONObject) throws IntentException {
|
||||
String str = (String) jSONObject.opt("className");
|
||||
String str2 = (String) jSONObject.opt(Constant.SelectRobot.PACKAGE_NAME_KEY);
|
||||
String str3 = (String) jSONObject.opt("action");
|
||||
String str4 = (String) jSONObject.opt("uri");
|
||||
String str5 = (String) jSONObject.opt("mimeType");
|
||||
JSONArray jSONArray = (JSONArray) jSONObject.opt("categories");
|
||||
Integer num = (Integer) jSONObject.opt("flags");
|
||||
JSONArray jSONArray2 = (JSONArray) jSONObject.opt("extras");
|
||||
if (str2 != null && str == null && str3 == null && str5 == null) {
|
||||
android.content.Intent launchIntentForPackage = ClientProperties.getApplicationContext().getPackageManager().getLaunchIntentForPackage(str2);
|
||||
if (launchIntentForPackage == null || num.intValue() <= -1) {
|
||||
return launchIntentForPackage;
|
||||
}
|
||||
launchIntentForPackage.addFlags(num.intValue());
|
||||
return launchIntentForPackage;
|
||||
}
|
||||
android.content.Intent intent = new android.content.Intent();
|
||||
if (str != null && str2 != null) {
|
||||
intent.setClassName(str2, str);
|
||||
}
|
||||
if (str3 != null) {
|
||||
intent.setAction(str3);
|
||||
}
|
||||
if (str4 != null) {
|
||||
intent.setData(Uri.parse(str4));
|
||||
}
|
||||
if (str5 != null) {
|
||||
intent.setType(str5);
|
||||
}
|
||||
if (num != null && num.intValue() > -1) {
|
||||
intent.setFlags(num.intValue());
|
||||
}
|
||||
if (!setCategories(intent, jSONArray)) {
|
||||
throw new IntentException(IntentError.COULDNT_PARSE_CATEGORIES, jSONArray);
|
||||
}
|
||||
if (setExtras(intent, jSONArray2)) {
|
||||
return intent;
|
||||
}
|
||||
throw new IntentException(IntentError.COULDNT_PARSE_EXTRAS, jSONArray2);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void launch(JSONObject jSONObject, WebViewCallback webViewCallback) {
|
||||
android.content.Intent intent;
|
||||
String str = (String) jSONObject.opt("className");
|
||||
String str2 = (String) jSONObject.opt(Constant.SelectRobot.PACKAGE_NAME_KEY);
|
||||
String str3 = (String) jSONObject.opt("action");
|
||||
String str4 = (String) jSONObject.opt("uri");
|
||||
String str5 = (String) jSONObject.opt("mimeType");
|
||||
JSONArray jSONArray = (JSONArray) jSONObject.opt("categories");
|
||||
Integer num = (Integer) jSONObject.opt("flags");
|
||||
JSONArray jSONArray2 = (JSONArray) jSONObject.opt("extras");
|
||||
if (str2 != null && str == null && str3 == null && str5 == null) {
|
||||
intent = ClientProperties.getApplicationContext().getPackageManager().getLaunchIntentForPackage(str2);
|
||||
if (intent != null && num.intValue() > -1) {
|
||||
intent.addFlags(num.intValue());
|
||||
}
|
||||
} else {
|
||||
android.content.Intent intent2 = new android.content.Intent();
|
||||
if (str != null && str2 != null) {
|
||||
intent2.setClassName(str2, str);
|
||||
}
|
||||
if (str3 != null) {
|
||||
intent2.setAction(str3);
|
||||
}
|
||||
if (str4 != null) {
|
||||
intent2.setData(Uri.parse(str4));
|
||||
}
|
||||
if (str5 != null) {
|
||||
intent2.setType(str5);
|
||||
}
|
||||
if (num != null && num.intValue() > -1) {
|
||||
intent2.setFlags(num.intValue());
|
||||
}
|
||||
if (!setCategories(intent2, jSONArray)) {
|
||||
webViewCallback.error(IntentError.COULDNT_PARSE_CATEGORIES, jSONArray);
|
||||
}
|
||||
if (!setExtras(intent2, jSONArray2)) {
|
||||
webViewCallback.error(IntentError.COULDNT_PARSE_EXTRAS, jSONArray2);
|
||||
}
|
||||
intent = intent2;
|
||||
}
|
||||
if (intent == null) {
|
||||
webViewCallback.error(IntentError.INTENT_WAS_NULL, new Object[0]);
|
||||
} else if (getStartingActivity() == null) {
|
||||
webViewCallback.error(IntentError.ACTIVITY_WAS_NULL, new Object[0]);
|
||||
} else {
|
||||
getStartingActivity().startActivity(intent);
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean setCategories(android.content.Intent intent, JSONArray jSONArray) {
|
||||
if (jSONArray == null || jSONArray.length() <= 0) {
|
||||
return true;
|
||||
}
|
||||
for (int i = 0; i < jSONArray.length(); i++) {
|
||||
try {
|
||||
intent.addCategory(jSONArray.getString(i));
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Couldn't parse categories for intent", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean setExtra(android.content.Intent intent, String str, Object obj) {
|
||||
if (obj instanceof String) {
|
||||
intent.putExtra(str, (String) obj);
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof Integer) {
|
||||
intent.putExtra(str, ((Integer) obj).intValue());
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof Double) {
|
||||
intent.putExtra(str, ((Double) obj).doubleValue());
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof Boolean) {
|
||||
intent.putExtra(str, ((Boolean) obj).booleanValue());
|
||||
return true;
|
||||
}
|
||||
DeviceLog.error("Unable to parse launch intent extra " + str);
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean setExtras(android.content.Intent intent, JSONArray jSONArray) {
|
||||
if (jSONArray == null) {
|
||||
return true;
|
||||
}
|
||||
for (int i = 0; i < jSONArray.length(); i++) {
|
||||
try {
|
||||
JSONObject jSONObject = jSONArray.getJSONObject(i);
|
||||
if (!setExtra(intent, jSONObject.getString("key"), jSONObject.get("value"))) {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Couldn't parse extras", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
62
sources/com/unity3d/ads/api/Lifecycle.java
Normal file
62
sources/com/unity3d/ads/api/Lifecycle.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import com.unity3d.ads.lifecycle.LifecycleError;
|
||||
import com.unity3d.ads.lifecycle.LifecycleListener;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
import java.util.ArrayList;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
@TargetApi(14)
|
||||
/* loaded from: classes2.dex */
|
||||
public class Lifecycle {
|
||||
private static LifecycleListener _listener;
|
||||
|
||||
public static LifecycleListener getLifecycleListener() {
|
||||
return _listener;
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void register(JSONArray jSONArray, WebViewCallback webViewCallback) {
|
||||
if (ClientProperties.getApplication() == null) {
|
||||
webViewCallback.error(LifecycleError.APPLICATION_NULL, new Object[0]);
|
||||
return;
|
||||
}
|
||||
if (getLifecycleListener() != null) {
|
||||
webViewCallback.error(LifecycleError.LISTENER_NOT_NULL, new Object[0]);
|
||||
return;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (int i = 0; i < jSONArray.length(); i++) {
|
||||
try {
|
||||
arrayList.add((String) jSONArray.get(i));
|
||||
} catch (JSONException unused) {
|
||||
webViewCallback.error(LifecycleError.JSON_ERROR, new Object[0]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
setLifecycleListener(new LifecycleListener(arrayList));
|
||||
ClientProperties.getApplication().registerActivityLifecycleCallbacks(getLifecycleListener());
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
public static void setLifecycleListener(LifecycleListener lifecycleListener) {
|
||||
_listener = lifecycleListener;
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void unregister(WebViewCallback webViewCallback) {
|
||||
if (ClientProperties.getApplication() == null) {
|
||||
webViewCallback.error(LifecycleError.APPLICATION_NULL, new Object[0]);
|
||||
return;
|
||||
}
|
||||
if (getLifecycleListener() != null) {
|
||||
ClientProperties.getApplication().unregisterActivityLifecycleCallbacks(getLifecycleListener());
|
||||
setLifecycleListener(null);
|
||||
}
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
90
sources/com/unity3d/ads/api/Listener.java
Normal file
90
sources/com/unity3d/ads/api/Listener.java
Normal file
@@ -0,0 +1,90 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import com.unity3d.ads.UnityAds;
|
||||
import com.unity3d.ads.mediation.IUnityAdsExtendedListener;
|
||||
import com.unity3d.ads.misc.Utilities;
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Listener {
|
||||
@WebViewExposed
|
||||
public static void sendClickEvent(final String str, WebViewCallback webViewCallback) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.Listener.4
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (UnityAds.getListener() == null || !(UnityAds.getListener() instanceof IUnityAdsExtendedListener)) {
|
||||
return;
|
||||
}
|
||||
((IUnityAdsExtendedListener) UnityAds.getListener()).onUnityAdsClick(str);
|
||||
}
|
||||
});
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void sendErrorEvent(final String str, final String str2, WebViewCallback webViewCallback) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.Listener.6
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (UnityAds.getListener() != null) {
|
||||
UnityAds.getListener().onUnityAdsError(UnityAds.UnityAdsError.valueOf(str), str2);
|
||||
}
|
||||
}
|
||||
});
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void sendFinishEvent(final String str, final String str2, WebViewCallback webViewCallback) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.Listener.3
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (UnityAds.getListener() != null) {
|
||||
UnityAds.getListener().onUnityAdsFinish(str, UnityAds.FinishState.valueOf(str2));
|
||||
}
|
||||
}
|
||||
});
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void sendPlacementStateChangedEvent(final String str, final String str2, final String str3, WebViewCallback webViewCallback) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.Listener.5
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (UnityAds.getListener() == null || !(UnityAds.getListener() instanceof IUnityAdsExtendedListener)) {
|
||||
return;
|
||||
}
|
||||
((IUnityAdsExtendedListener) UnityAds.getListener()).onUnityAdsPlacementStateChanged(str, UnityAds.PlacementState.valueOf(str2), UnityAds.PlacementState.valueOf(str3));
|
||||
}
|
||||
});
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void sendReadyEvent(final String str, WebViewCallback webViewCallback) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.Listener.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (UnityAds.getListener() != null) {
|
||||
UnityAds.getListener().onUnityAdsReady(str);
|
||||
}
|
||||
}
|
||||
});
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void sendStartEvent(final String str, WebViewCallback webViewCallback) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.Listener.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (UnityAds.getListener() != null) {
|
||||
UnityAds.getListener().onUnityAdsStart(str);
|
||||
}
|
||||
}
|
||||
});
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
19
sources/com/unity3d/ads/api/Placement.java
Normal file
19
sources/com/unity3d/ads/api/Placement.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Placement {
|
||||
@WebViewExposed
|
||||
public static void setDefaultPlacement(String str, WebViewCallback webViewCallback) {
|
||||
com.unity3d.ads.placement.Placement.setDefaultPlacement(str);
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setPlacementState(String str, String str2, WebViewCallback webViewCallback) {
|
||||
com.unity3d.ads.placement.Placement.setPlacementState(str, str2);
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
100
sources/com/unity3d/ads/api/Preferences.java
Normal file
100
sources/com/unity3d/ads/api/Preferences.java
Normal file
@@ -0,0 +1,100 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import com.unity3d.ads.preferences.AndroidPreferences;
|
||||
import com.unity3d.ads.preferences.PreferencesError;
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Preferences {
|
||||
@WebViewExposed
|
||||
public static void getBoolean(String str, String str2, WebViewCallback webViewCallback) {
|
||||
Boolean bool = AndroidPreferences.getBoolean(str, str2);
|
||||
if (bool != null) {
|
||||
webViewCallback.invoke(bool);
|
||||
} else {
|
||||
webViewCallback.error(PreferencesError.COULDNT_GET_VALUE, str, str2);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getFloat(String str, String str2, WebViewCallback webViewCallback) {
|
||||
Float f = AndroidPreferences.getFloat(str, str2);
|
||||
if (f != null) {
|
||||
webViewCallback.invoke(f);
|
||||
} else {
|
||||
webViewCallback.error(PreferencesError.COULDNT_GET_VALUE, str, str2);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getInt(String str, String str2, WebViewCallback webViewCallback) {
|
||||
Integer integer = AndroidPreferences.getInteger(str, str2);
|
||||
if (integer != null) {
|
||||
webViewCallback.invoke(integer);
|
||||
} else {
|
||||
webViewCallback.error(PreferencesError.COULDNT_GET_VALUE, str, str2);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getLong(String str, String str2, WebViewCallback webViewCallback) {
|
||||
Long l = AndroidPreferences.getLong(str, str2);
|
||||
if (l != null) {
|
||||
webViewCallback.invoke(l);
|
||||
} else {
|
||||
webViewCallback.error(PreferencesError.COULDNT_GET_VALUE, str, str2);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getString(String str, String str2, WebViewCallback webViewCallback) {
|
||||
String string = AndroidPreferences.getString(str, str2);
|
||||
if (string != null) {
|
||||
webViewCallback.invoke(string);
|
||||
} else {
|
||||
webViewCallback.error(PreferencesError.COULDNT_GET_VALUE, str, str2);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void hasKey(String str, String str2, WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Boolean.valueOf(AndroidPreferences.hasKey(str, str2)));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void removeKey(String str, String str2, WebViewCallback webViewCallback) {
|
||||
AndroidPreferences.removeKey(str, str2);
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setBoolean(String str, String str2, Boolean bool, WebViewCallback webViewCallback) {
|
||||
AndroidPreferences.setBoolean(str, str2, bool);
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setFloat(String str, String str2, Double d, WebViewCallback webViewCallback) {
|
||||
AndroidPreferences.setFloat(str, str2, d);
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setInt(String str, String str2, Integer num, WebViewCallback webViewCallback) {
|
||||
AndroidPreferences.setInteger(str, str2, num);
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setLong(String str, String str2, Long l, WebViewCallback webViewCallback) {
|
||||
AndroidPreferences.setLong(str, str2, l);
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setString(String str, String str2, String str3, WebViewCallback webViewCallback) {
|
||||
AndroidPreferences.setString(str, str2, str3);
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
88
sources/com/unity3d/ads/api/Purchasing.java
Normal file
88
sources/com/unity3d/ads/api/Purchasing.java
Normal file
@@ -0,0 +1,88 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import com.unity3d.ads.misc.Utilities;
|
||||
import com.unity3d.ads.purchasing.IPurchasing;
|
||||
import com.unity3d.ads.purchasing.PurchasingError;
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Purchasing {
|
||||
public static IPurchasing purchaseInterface;
|
||||
|
||||
@WebViewExposed
|
||||
public static void getPromoCatalog(WebViewCallback webViewCallback) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.Purchasing.3
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
IPurchasing iPurchasing = Purchasing.purchaseInterface;
|
||||
if (iPurchasing != null) {
|
||||
iPurchasing.onGetProductCatalog();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (purchaseInterface != null) {
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
} else {
|
||||
webViewCallback.error(PurchasingError.PURCHASE_INTERFACE_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getPromoVersion(WebViewCallback webViewCallback) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.Purchasing.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
IPurchasing iPurchasing = Purchasing.purchaseInterface;
|
||||
if (iPurchasing != null) {
|
||||
iPurchasing.onGetPurchasingVersion();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (purchaseInterface != null) {
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
} else {
|
||||
webViewCallback.error(PurchasingError.PURCHASE_INTERFACE_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void initializePurchasing(WebViewCallback webViewCallback) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.Purchasing.4
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
IPurchasing iPurchasing = Purchasing.purchaseInterface;
|
||||
if (iPurchasing != null) {
|
||||
iPurchasing.onInitializePurchasing();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (purchaseInterface != null) {
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
} else {
|
||||
webViewCallback.error(PurchasingError.PURCHASE_INTERFACE_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void initiatePurchasingCommand(final String str, WebViewCallback webViewCallback) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.Purchasing.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
IPurchasing iPurchasing = Purchasing.purchaseInterface;
|
||||
if (iPurchasing != null) {
|
||||
iPurchasing.onPurchasingCommand(str);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (purchaseInterface != null) {
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
} else {
|
||||
webViewCallback.error(PurchasingError.PURCHASE_INTERFACE_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setPurchasingInterface(IPurchasing iPurchasing) {
|
||||
purchaseInterface = iPurchasing;
|
||||
}
|
||||
}
|
||||
161
sources/com/unity3d/ads/api/Request.java
Normal file
161
sources/com/unity3d/ads/api/Request.java
Normal file
@@ -0,0 +1,161 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.request.IWebRequestListener;
|
||||
import com.unity3d.ads.request.WebRequest;
|
||||
import com.unity3d.ads.request.WebRequestError;
|
||||
import com.unity3d.ads.request.WebRequestEvent;
|
||||
import com.unity3d.ads.request.WebRequestThread;
|
||||
import com.unity3d.ads.webview.WebViewApp;
|
||||
import com.unity3d.ads.webview.WebViewEventCategory;
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Request {
|
||||
@WebViewExposed
|
||||
public static void get(final String str, String str2, JSONArray jSONArray, Integer num, Integer num2, WebViewCallback webViewCallback) {
|
||||
if (jSONArray != null && jSONArray.length() == 0) {
|
||||
jSONArray = null;
|
||||
}
|
||||
try {
|
||||
WebRequestThread.request(str2, WebRequest.RequestType.GET, getHeadersMap(jSONArray), null, num, num2, new IWebRequestListener() { // from class: com.unity3d.ads.api.Request.1
|
||||
@Override // com.unity3d.ads.request.IWebRequestListener
|
||||
public void onComplete(String str3, String str4, int i, Map<String, List<String>> map) {
|
||||
try {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.REQUEST, WebRequestEvent.COMPLETE, str, str3, str4, Integer.valueOf(i), Request.getResponseHeadersMap(map));
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error parsing response headers", e);
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.REQUEST, WebRequestEvent.FAILED, str, str3, "Error parsing response headers");
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.request.IWebRequestListener
|
||||
public void onFailed(String str3, String str4) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.REQUEST, WebRequestEvent.FAILED, str, str3, str4);
|
||||
}
|
||||
});
|
||||
webViewCallback.invoke(str);
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error mapping headers for the request", e);
|
||||
webViewCallback.error(WebRequestError.MAPPING_HEADERS_FAILED, str);
|
||||
}
|
||||
}
|
||||
|
||||
public static HashMap<String, List<String>> getHeadersMap(JSONArray jSONArray) throws JSONException {
|
||||
if (jSONArray == null) {
|
||||
return null;
|
||||
}
|
||||
HashMap<String, List<String>> hashMap = new HashMap<>();
|
||||
for (int i = 0; i < jSONArray.length(); i++) {
|
||||
JSONArray jSONArray2 = (JSONArray) jSONArray.get(i);
|
||||
List<String> list = hashMap.get(jSONArray2.getString(0));
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
list.add(jSONArray2.getString(1));
|
||||
hashMap.put(jSONArray2.getString(0), list);
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
public static JSONArray getResponseHeadersMap(Map<String, List<String>> map) {
|
||||
JSONArray jSONArray = new JSONArray();
|
||||
if (map != null && map.size() > 0) {
|
||||
for (String str : map.keySet()) {
|
||||
JSONArray jSONArray2 = null;
|
||||
for (String str2 : map.get(str)) {
|
||||
JSONArray jSONArray3 = new JSONArray();
|
||||
jSONArray3.put(str);
|
||||
jSONArray3.put(str2);
|
||||
jSONArray2 = jSONArray3;
|
||||
}
|
||||
jSONArray.put(jSONArray2);
|
||||
}
|
||||
}
|
||||
return jSONArray;
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void head(final String str, String str2, JSONArray jSONArray, Integer num, Integer num2, WebViewCallback webViewCallback) {
|
||||
if (jSONArray != null && jSONArray.length() == 0) {
|
||||
jSONArray = null;
|
||||
}
|
||||
try {
|
||||
WebRequestThread.request(str2, WebRequest.RequestType.HEAD, getHeadersMap(jSONArray), num, num2, new IWebRequestListener() { // from class: com.unity3d.ads.api.Request.3
|
||||
@Override // com.unity3d.ads.request.IWebRequestListener
|
||||
public void onComplete(String str3, String str4, int i, Map<String, List<String>> map) {
|
||||
try {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.REQUEST, WebRequestEvent.COMPLETE, str, str3, str4, Integer.valueOf(i), Request.getResponseHeadersMap(map));
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error parsing response headers", e);
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.REQUEST, WebRequestEvent.FAILED, str, str3, "Error parsing response headers");
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.request.IWebRequestListener
|
||||
public void onFailed(String str3, String str4) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.REQUEST, WebRequestEvent.FAILED, str, str3, str4);
|
||||
}
|
||||
});
|
||||
webViewCallback.invoke(str);
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error mapping headers for the request", e);
|
||||
webViewCallback.error(WebRequestError.MAPPING_HEADERS_FAILED, str);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void post(final String str, String str2, String str3, JSONArray jSONArray, Integer num, Integer num2, WebViewCallback webViewCallback) {
|
||||
String str4 = (str3 == null || str3.length() != 0) ? str3 : null;
|
||||
if (jSONArray != null && jSONArray.length() == 0) {
|
||||
jSONArray = null;
|
||||
}
|
||||
try {
|
||||
WebRequestThread.request(str2, WebRequest.RequestType.POST, getHeadersMap(jSONArray), str4, num, num2, new IWebRequestListener() { // from class: com.unity3d.ads.api.Request.2
|
||||
@Override // com.unity3d.ads.request.IWebRequestListener
|
||||
public void onComplete(String str5, String str6, int i, Map<String, List<String>> map) {
|
||||
try {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.REQUEST, WebRequestEvent.COMPLETE, str, str5, str6, Integer.valueOf(i), Request.getResponseHeadersMap(map));
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error parsing response headers", e);
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.REQUEST, WebRequestEvent.FAILED, str, str5, "Error parsing response headers");
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.request.IWebRequestListener
|
||||
public void onFailed(String str5, String str6) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.REQUEST, WebRequestEvent.FAILED, str, str5, str6);
|
||||
}
|
||||
});
|
||||
webViewCallback.invoke(str);
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error mapping headers for the request", e);
|
||||
webViewCallback.error(WebRequestError.MAPPING_HEADERS_FAILED, str);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setConcurrentRequestCount(Integer num, WebViewCallback webViewCallback) {
|
||||
WebRequestThread.setConcurrentRequestCount(num.intValue());
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setKeepAliveTime(Integer num, WebViewCallback webViewCallback) {
|
||||
WebRequestThread.setKeepAliveTime(num.longValue());
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setMaximumPoolSize(Integer num, WebViewCallback webViewCallback) {
|
||||
WebRequestThread.setMaximumPoolSize(num.intValue());
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
36
sources/com/unity3d/ads/api/Resolve.java
Normal file
36
sources/com/unity3d/ads/api/Resolve.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import com.unity3d.ads.request.IResolveHostListener;
|
||||
import com.unity3d.ads.request.ResolveHostError;
|
||||
import com.unity3d.ads.request.ResolveHostEvent;
|
||||
import com.unity3d.ads.request.WebRequestThread;
|
||||
import com.unity3d.ads.webview.WebViewApp;
|
||||
import com.unity3d.ads.webview.WebViewEventCategory;
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Resolve {
|
||||
@WebViewExposed
|
||||
public static void resolve(final String str, String str2, WebViewCallback webViewCallback) {
|
||||
if (WebRequestThread.resolve(str2, new IResolveHostListener() { // from class: com.unity3d.ads.api.Resolve.1
|
||||
@Override // com.unity3d.ads.request.IResolveHostListener
|
||||
public void onFailed(String str3, ResolveHostError resolveHostError, String str4) {
|
||||
if (WebViewApp.getCurrentApp() != null) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.RESOLVE, ResolveHostEvent.FAILED, str, str3, resolveHostError.name(), str4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.request.IResolveHostListener
|
||||
public void onResolve(String str3, String str4) {
|
||||
if (WebViewApp.getCurrentApp() != null) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.RESOLVE, ResolveHostEvent.COMPLETE, str, str3, str4);
|
||||
}
|
||||
}
|
||||
})) {
|
||||
webViewCallback.invoke(str);
|
||||
} else {
|
||||
webViewCallback.error(ResolveHostError.INVALID_HOST, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
75
sources/com/unity3d/ads/api/Sdk.java
Normal file
75
sources/com/unity3d/ads/api/Sdk.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import com.unity3d.ads.UnityAds;
|
||||
import com.unity3d.ads.configuration.InitializeThread;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
import com.unity3d.ads.properties.SdkProperties;
|
||||
import com.unity3d.ads.webview.WebViewApp;
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Sdk {
|
||||
@WebViewExposed
|
||||
public static void getDebugMode(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Boolean.valueOf(UnityAds.getDebugMode()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void initComplete(WebViewCallback webViewCallback) {
|
||||
DeviceLog.debug("Web Application initialized");
|
||||
SdkProperties.setInitialized(true);
|
||||
WebViewApp.getCurrentApp().setWebAppInitialized(true);
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void loadComplete(WebViewCallback webViewCallback) {
|
||||
DeviceLog.debug("Web Application loaded");
|
||||
WebViewApp.getCurrentApp().setWebAppLoaded(true);
|
||||
webViewCallback.invoke(ClientProperties.getGameId(), Boolean.valueOf(SdkProperties.isTestMode()), ClientProperties.getAppName(), ClientProperties.getAppVersion(), Integer.valueOf(SdkProperties.getVersionCode()), SdkProperties.getVersionName(), Boolean.valueOf(ClientProperties.isAppDebuggable()), WebViewApp.getCurrentApp().getConfiguration().getConfigUrl(), WebViewApp.getCurrentApp().getConfiguration().getWebViewUrl(), WebViewApp.getCurrentApp().getConfiguration().getWebViewHash(), WebViewApp.getCurrentApp().getConfiguration().getWebViewVersion(), Long.valueOf(SdkProperties.getInitializationTime()), Boolean.valueOf(SdkProperties.isReinitialized()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void logDebug(String str, WebViewCallback webViewCallback) {
|
||||
DeviceLog.debug(str);
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void logError(String str, WebViewCallback webViewCallback) {
|
||||
DeviceLog.error(str);
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void logInfo(String str, WebViewCallback webViewCallback) {
|
||||
DeviceLog.info(str);
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void logWarning(String str, WebViewCallback webViewCallback) {
|
||||
DeviceLog.warning(str);
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void reinitialize(WebViewCallback webViewCallback) {
|
||||
SdkProperties.setReinitialized(true);
|
||||
InitializeThread.initialize(WebViewApp.getCurrentApp().getConfiguration());
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setDebugMode(Boolean bool, WebViewCallback webViewCallback) {
|
||||
UnityAds.setDebugMode(bool.booleanValue());
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setShowTimeout(Integer num, WebViewCallback webViewCallback) {
|
||||
SdkProperties.setShowTimeout(num.intValue());
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
36
sources/com/unity3d/ads/api/SensorInfo.java
Normal file
36
sources/com/unity3d/ads/api/SensorInfo.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import com.unity3d.ads.sensorinfo.SensorInfoError;
|
||||
import com.unity3d.ads.sensorinfo.SensorInfoListener;
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class SensorInfo {
|
||||
@WebViewExposed
|
||||
public static void getAccelerometerData(WebViewCallback webViewCallback) {
|
||||
JSONObject accelerometerData = SensorInfoListener.getAccelerometerData();
|
||||
if (accelerometerData != null) {
|
||||
webViewCallback.invoke(accelerometerData);
|
||||
} else {
|
||||
webViewCallback.error(SensorInfoError.ACCELEROMETER_DATA_NOT_AVAILABLE, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void isAccelerometerActive(WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Boolean.valueOf(SensorInfoListener.isAccelerometerListenerActive()));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void startAccelerometerUpdates(Integer num, WebViewCallback webViewCallback) {
|
||||
webViewCallback.invoke(Boolean.valueOf(SensorInfoListener.startAccelerometerListener(num.intValue())));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void stopAccelerometerUpdates(WebViewCallback webViewCallback) {
|
||||
SensorInfoListener.stopAccelerometerListener();
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
143
sources/com/unity3d/ads/api/Storage.java
Normal file
143
sources/com/unity3d/ads/api/Storage.java
Normal file
@@ -0,0 +1,143 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import com.unity3d.ads.device.StorageError;
|
||||
import com.unity3d.ads.device.StorageManager;
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Storage {
|
||||
@WebViewExposed
|
||||
public static void clear(String str, WebViewCallback webViewCallback) {
|
||||
com.unity3d.ads.device.Storage storage = getStorage(str);
|
||||
if (storage == null) {
|
||||
webViewCallback.error(StorageError.COULDNT_GET_STORAGE, str);
|
||||
} else if (storage.clearStorage()) {
|
||||
webViewCallback.invoke(str);
|
||||
} else {
|
||||
webViewCallback.error(StorageError.COULDNT_CLEAR_STORAGE, str);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void delete(String str, String str2, WebViewCallback webViewCallback) {
|
||||
com.unity3d.ads.device.Storage storage = getStorage(str);
|
||||
if (storage == null) {
|
||||
webViewCallback.error(StorageError.COULDNT_GET_STORAGE, str);
|
||||
} else if (storage.delete(str2)) {
|
||||
webViewCallback.invoke(str);
|
||||
} else {
|
||||
webViewCallback.error(StorageError.COULDNT_DELETE_VALUE, str);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void get(String str, String str2, WebViewCallback webViewCallback) {
|
||||
com.unity3d.ads.device.Storage storage = getStorage(str);
|
||||
if (storage == null) {
|
||||
webViewCallback.error(StorageError.COULDNT_GET_STORAGE, str, str2);
|
||||
return;
|
||||
}
|
||||
Object obj = storage.get(str2);
|
||||
if (obj == null) {
|
||||
webViewCallback.error(StorageError.COULDNT_GET_VALUE, str2);
|
||||
} else {
|
||||
webViewCallback.invoke(obj);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getKeys(String str, String str2, Boolean bool, WebViewCallback webViewCallback) {
|
||||
com.unity3d.ads.device.Storage storage = getStorage(str);
|
||||
if (storage == null) {
|
||||
webViewCallback.error(StorageError.COULDNT_GET_STORAGE, str, str2);
|
||||
return;
|
||||
}
|
||||
List<String> keys = storage.getKeys(str2, bool.booleanValue());
|
||||
if (keys != null) {
|
||||
webViewCallback.invoke(new JSONArray((Collection) keys));
|
||||
} else {
|
||||
webViewCallback.invoke(new JSONArray());
|
||||
}
|
||||
}
|
||||
|
||||
private static com.unity3d.ads.device.Storage getStorage(String str) {
|
||||
return StorageManager.getStorage(StorageManager.StorageType.valueOf(str));
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void read(String str, WebViewCallback webViewCallback) {
|
||||
com.unity3d.ads.device.Storage storage = getStorage(str);
|
||||
if (storage == null) {
|
||||
webViewCallback.error(StorageError.COULDNT_GET_STORAGE, str);
|
||||
} else {
|
||||
storage.readStorage();
|
||||
webViewCallback.invoke(str);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void set(String str, String str2, Integer num, WebViewCallback webViewCallback) {
|
||||
set(str, str2, (Object) num, webViewCallback);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void write(String str, WebViewCallback webViewCallback) {
|
||||
com.unity3d.ads.device.Storage storage = getStorage(str);
|
||||
if (storage == null) {
|
||||
webViewCallback.error(StorageError.COULDNT_GET_STORAGE, str);
|
||||
} else if (storage.writeStorage()) {
|
||||
webViewCallback.invoke(str);
|
||||
} else {
|
||||
webViewCallback.error(StorageError.COULDNT_WRITE_STORAGE_TO_CACHE, str);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void set(String str, String str2, Boolean bool, WebViewCallback webViewCallback) {
|
||||
set(str, str2, (Object) bool, webViewCallback);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void set(String str, String str2, Long l, WebViewCallback webViewCallback) {
|
||||
set(str, str2, (Object) l, webViewCallback);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void set(String str, String str2, Double d, WebViewCallback webViewCallback) {
|
||||
set(str, str2, (Object) d, webViewCallback);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void set(String str, String str2, String str3, WebViewCallback webViewCallback) {
|
||||
set(str, str2, (Object) str3, webViewCallback);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void set(String str, String str2, JSONObject jSONObject, WebViewCallback webViewCallback) {
|
||||
set(str, str2, (Object) jSONObject, webViewCallback);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void set(String str, String str2, JSONArray jSONArray, WebViewCallback webViewCallback) {
|
||||
set(str, str2, (Object) jSONArray, webViewCallback);
|
||||
}
|
||||
|
||||
private static void set(String str, String str2, Object obj, WebViewCallback webViewCallback) {
|
||||
com.unity3d.ads.device.Storage storage = getStorage(str);
|
||||
if (storage != null) {
|
||||
if (storage.set(str2, obj)) {
|
||||
webViewCallback.invoke(str2, obj);
|
||||
return;
|
||||
} else {
|
||||
webViewCallback.error(StorageError.COULDNT_SET_VALUE, str2, obj);
|
||||
return;
|
||||
}
|
||||
}
|
||||
webViewCallback.error(StorageError.COULDNT_GET_STORAGE, str, str2, obj);
|
||||
}
|
||||
}
|
||||
186
sources/com/unity3d/ads/api/VideoPlayer.java
Normal file
186
sources/com/unity3d/ads/api/VideoPlayer.java
Normal file
@@ -0,0 +1,186 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import android.os.Build;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.misc.Utilities;
|
||||
import com.unity3d.ads.video.VideoPlayerError;
|
||||
import com.unity3d.ads.video.VideoPlayerEvent;
|
||||
import com.unity3d.ads.video.VideoPlayerView;
|
||||
import com.unity3d.ads.webview.WebViewEventCategory;
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class VideoPlayer {
|
||||
private static VideoPlayerView _videoPlayerView;
|
||||
|
||||
@WebViewExposed
|
||||
public static void getCurrentPosition(WebViewCallback webViewCallback) {
|
||||
if (getVideoPlayerView() != null) {
|
||||
webViewCallback.invoke(Integer.valueOf(getVideoPlayerView().getCurrentPosition()));
|
||||
} else {
|
||||
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getProgressEventInterval(WebViewCallback webViewCallback) {
|
||||
if (getVideoPlayerView() != null) {
|
||||
webViewCallback.invoke(Integer.valueOf(getVideoPlayerView().getProgressEventInterval()));
|
||||
} else {
|
||||
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public static VideoPlayerView getVideoPlayerView() {
|
||||
return _videoPlayerView;
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getVolume(WebViewCallback webViewCallback) {
|
||||
if (getVideoPlayerView() != null) {
|
||||
webViewCallback.invoke(Float.valueOf(getVideoPlayerView().getVolume()));
|
||||
} else {
|
||||
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void pause(WebViewCallback webViewCallback) {
|
||||
DeviceLog.debug("Pausing current video");
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.VideoPlayer.4
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (VideoPlayer.getVideoPlayerView() != null) {
|
||||
VideoPlayer.getVideoPlayerView().pause();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (getVideoPlayerView() != null) {
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
} else {
|
||||
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void play(WebViewCallback webViewCallback) {
|
||||
DeviceLog.debug("Starting playback of prepared video");
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.VideoPlayer.3
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (VideoPlayer.getVideoPlayerView() != null) {
|
||||
VideoPlayer.getVideoPlayerView().play();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (getVideoPlayerView() != null) {
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
} else {
|
||||
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void prepare(String str, Double d, WebViewCallback webViewCallback) {
|
||||
prepare(str, d, 0, webViewCallback);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void seekTo(final Integer num, WebViewCallback webViewCallback) {
|
||||
DeviceLog.debug("Seeking video to time: " + num);
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.VideoPlayer.6
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (VideoPlayer.getVideoPlayerView() != null) {
|
||||
VideoPlayer.getVideoPlayerView().seekTo(num.intValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
if (getVideoPlayerView() != null) {
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
} else {
|
||||
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setInfoListenerEnabled(boolean z, WebViewCallback webViewCallback) {
|
||||
if (Build.VERSION.SDK_INT <= 16) {
|
||||
webViewCallback.error(VideoPlayerError.API_LEVEL_ERROR, Integer.valueOf(Build.VERSION.SDK_INT), Boolean.valueOf(z));
|
||||
} else if (getVideoPlayerView() == null) {
|
||||
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
|
||||
} else {
|
||||
getVideoPlayerView().setInfoListenerEnabled(z);
|
||||
webViewCallback.invoke(WebViewEventCategory.VIDEOPLAYER, VideoPlayerEvent.INFO, Boolean.valueOf(z));
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setProgressEventInterval(final Integer num, WebViewCallback webViewCallback) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.VideoPlayer.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (VideoPlayer.getVideoPlayerView() != null) {
|
||||
VideoPlayer.getVideoPlayerView().setProgressEventInterval(num.intValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
if (getVideoPlayerView() != null) {
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
} else {
|
||||
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setVideoPlayerView(VideoPlayerView videoPlayerView) {
|
||||
_videoPlayerView = videoPlayerView;
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setVolume(Double d, WebViewCallback webViewCallback) {
|
||||
DeviceLog.debug("Setting video volume: " + d);
|
||||
if (getVideoPlayerView() == null) {
|
||||
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
|
||||
} else {
|
||||
getVideoPlayerView().setVolume(Float.valueOf(d.floatValue()));
|
||||
webViewCallback.invoke(d);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void stop(WebViewCallback webViewCallback) {
|
||||
DeviceLog.debug("Stopping current video");
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.VideoPlayer.5
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (VideoPlayer.getVideoPlayerView() != null) {
|
||||
VideoPlayer.getVideoPlayerView().stop();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (getVideoPlayerView() != null) {
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
} else {
|
||||
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void prepare(final String str, final Double d, final Integer num, WebViewCallback webViewCallback) {
|
||||
DeviceLog.debug("Preparing video for playback: " + str);
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.VideoPlayer.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (VideoPlayer.getVideoPlayerView() != null) {
|
||||
VideoPlayer.getVideoPlayerView().prepare(str, d.floatValue(), num.intValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
if (getVideoPlayerView() != null) {
|
||||
webViewCallback.invoke(str);
|
||||
} else {
|
||||
webViewCallback.error(VideoPlayerError.VIDEOVIEW_NULL, new Object[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
145
sources/com/unity3d/ads/api/WebPlayer.java
Normal file
145
sources/com/unity3d/ads/api/WebPlayer.java
Normal file
@@ -0,0 +1,145 @@
|
||||
package com.unity3d.ads.api;
|
||||
|
||||
import com.unity3d.ads.adunit.AdUnitError;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.misc.Utilities;
|
||||
import com.unity3d.ads.webplayer.WebPlayerError;
|
||||
import com.unity3d.ads.webview.bridge.WebViewCallback;
|
||||
import com.unity3d.ads.webview.bridge.WebViewExposed;
|
||||
import java.util.Map;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class WebPlayer {
|
||||
private static JSONObject _webPlayerEventSettings;
|
||||
private static JSONObject _webPlayerSettings;
|
||||
private static JSONObject _webSettings;
|
||||
|
||||
@WebViewExposed
|
||||
public static void clearSettings(WebViewCallback webViewCallback) {
|
||||
_webSettings = null;
|
||||
_webPlayerSettings = null;
|
||||
_webPlayerEventSettings = null;
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void getErroredSettings(WebViewCallback webViewCallback) {
|
||||
if (AdUnit.getAdUnitActivity() == null) {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
return;
|
||||
}
|
||||
if (AdUnit.getAdUnitActivity().getWebPlayer() == null) {
|
||||
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
|
||||
return;
|
||||
}
|
||||
Map<String, String> erroredSettings = AdUnit.getAdUnitActivity().getWebPlayer().getErroredSettings();
|
||||
JSONObject jSONObject = new JSONObject();
|
||||
try {
|
||||
for (Map.Entry<String, String> entry : erroredSettings.entrySet()) {
|
||||
jSONObject.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error forming JSON object", e);
|
||||
}
|
||||
webViewCallback.invoke(jSONObject);
|
||||
}
|
||||
|
||||
public static JSONObject getWebPlayerEventSettings() {
|
||||
return _webPlayerEventSettings;
|
||||
}
|
||||
|
||||
public static JSONObject getWebPlayerSettings() {
|
||||
return _webPlayerSettings;
|
||||
}
|
||||
|
||||
public static JSONObject getWebSettings() {
|
||||
return _webSettings;
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void sendEvent(JSONArray jSONArray, WebViewCallback webViewCallback) {
|
||||
if (AdUnit.getAdUnitActivity() == null) {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
} else if (AdUnit.getAdUnitActivity().getWebPlayer() == null) {
|
||||
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
|
||||
} else {
|
||||
AdUnit.getAdUnitActivity().getWebPlayer().sendEvent(jSONArray);
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setData(final String str, final String str2, final String str3, WebViewCallback webViewCallback) {
|
||||
if (AdUnit.getAdUnitActivity() == null) {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
} else if (AdUnit.getAdUnitActivity().getWebPlayer() == null) {
|
||||
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
|
||||
} else {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.WebPlayer.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (AdUnit.getAdUnitActivity().getWebPlayer() != null) {
|
||||
AdUnit.getAdUnitActivity().getWebPlayer().loadData(str, str2, str3);
|
||||
}
|
||||
}
|
||||
});
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setDataWithUrl(final String str, final String str2, final String str3, final String str4, WebViewCallback webViewCallback) {
|
||||
if (AdUnit.getAdUnitActivity() == null) {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
} else if (AdUnit.getAdUnitActivity().getWebPlayer() == null) {
|
||||
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
|
||||
} else {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.WebPlayer.3
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (AdUnit.getAdUnitActivity().getWebPlayer() != null) {
|
||||
AdUnit.getAdUnitActivity().getWebPlayer().loadDataWithBaseURL(str, str2, str3, str4, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setEventSettings(JSONObject jSONObject, WebViewCallback webViewCallback) {
|
||||
_webPlayerEventSettings = jSONObject;
|
||||
if (AdUnit.getAdUnitActivity() != null && AdUnit.getAdUnitActivity().getWebPlayer() != null) {
|
||||
AdUnit.getAdUnitActivity().getWebPlayer().setEventSettings(jSONObject);
|
||||
}
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setSettings(JSONObject jSONObject, JSONObject jSONObject2, WebViewCallback webViewCallback) {
|
||||
_webSettings = jSONObject;
|
||||
_webPlayerSettings = jSONObject2;
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
|
||||
@WebViewExposed
|
||||
public static void setUrl(final String str, WebViewCallback webViewCallback) {
|
||||
if (AdUnit.getAdUnitActivity() == null) {
|
||||
webViewCallback.error(AdUnitError.ADUNIT_NULL, new Object[0]);
|
||||
} else if (AdUnit.getAdUnitActivity().getWebPlayer() == null) {
|
||||
webViewCallback.error(WebPlayerError.WEBPLAYER_NULL, new Object[0]);
|
||||
} else {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.api.WebPlayer.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (AdUnit.getAdUnitActivity().getWebPlayer() != null) {
|
||||
AdUnit.getAdUnitActivity().getWebPlayer().loadUrl(str);
|
||||
}
|
||||
}
|
||||
});
|
||||
webViewCallback.invoke(new Object[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
6
sources/com/unity3d/ads/broadcast/BroadcastError.java
Normal file
6
sources/com/unity3d/ads/broadcast/BroadcastError.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package com.unity3d.ads.broadcast;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum BroadcastError {
|
||||
JSON_ERROR
|
||||
}
|
||||
6
sources/com/unity3d/ads/broadcast/BroadcastEvent.java
Normal file
6
sources/com/unity3d/ads/broadcast/BroadcastEvent.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package com.unity3d.ads.broadcast;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum BroadcastEvent {
|
||||
ACTION
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.unity3d.ads.broadcast;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.webview.WebViewApp;
|
||||
import com.unity3d.ads.webview.WebViewEventCategory;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class BroadcastEventReceiver extends BroadcastReceiver {
|
||||
private String _name;
|
||||
|
||||
public BroadcastEventReceiver(String str) {
|
||||
this._name = str;
|
||||
}
|
||||
|
||||
@Override // android.content.BroadcastReceiver
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action == null) {
|
||||
return;
|
||||
}
|
||||
String dataString = intent.getDataString() != null ? intent.getDataString() : "";
|
||||
JSONObject jSONObject = new JSONObject();
|
||||
try {
|
||||
if (intent.getExtras() != null) {
|
||||
Bundle extras = intent.getExtras();
|
||||
for (String str : extras.keySet()) {
|
||||
jSONObject.put(str, extras.get(str));
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
DeviceLog.debug("JSONException when composing extras for broadcast action " + action + ": " + e.getMessage());
|
||||
}
|
||||
WebViewApp currentApp = WebViewApp.getCurrentApp();
|
||||
if (currentApp == null || !currentApp.isWebAppLoaded()) {
|
||||
return;
|
||||
}
|
||||
currentApp.sendEvent(WebViewEventCategory.BROADCAST, BroadcastEvent.ACTION, this._name, action, dataString, jSONObject);
|
||||
}
|
||||
}
|
||||
49
sources/com/unity3d/ads/broadcast/BroadcastMonitor.java
Normal file
49
sources/com/unity3d/ads/broadcast/BroadcastMonitor.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package com.unity3d.ads.broadcast;
|
||||
|
||||
import android.content.IntentFilter;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class BroadcastMonitor {
|
||||
private static Map<String, BroadcastEventReceiver> _eventReceivers;
|
||||
|
||||
public static void addBroadcastListener(String str, String str2, String[] strArr) {
|
||||
removeBroadcastListener(str);
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
for (String str3 : strArr) {
|
||||
intentFilter.addAction(str3);
|
||||
}
|
||||
if (str2 != null) {
|
||||
intentFilter.addDataScheme(str2);
|
||||
}
|
||||
if (_eventReceivers == null) {
|
||||
_eventReceivers = new HashMap();
|
||||
}
|
||||
BroadcastEventReceiver broadcastEventReceiver = new BroadcastEventReceiver(str);
|
||||
_eventReceivers.put(str, broadcastEventReceiver);
|
||||
ClientProperties.getApplicationContext().registerReceiver(broadcastEventReceiver, intentFilter);
|
||||
}
|
||||
|
||||
public static void removeAllBroadcastListeners() {
|
||||
Map<String, BroadcastEventReceiver> map = _eventReceivers;
|
||||
if (map != null) {
|
||||
Iterator<String> it = map.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
ClientProperties.getApplicationContext().unregisterReceiver(_eventReceivers.get(it.next()));
|
||||
}
|
||||
_eventReceivers = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeBroadcastListener(String str) {
|
||||
Map<String, BroadcastEventReceiver> map = _eventReceivers;
|
||||
if (map == null || !map.containsKey(str)) {
|
||||
return;
|
||||
}
|
||||
ClientProperties.getApplicationContext().unregisterReceiver(_eventReceivers.get(str));
|
||||
_eventReceivers.remove(str);
|
||||
}
|
||||
}
|
||||
106
sources/com/unity3d/ads/cache/CacheDirectory.java
vendored
Normal file
106
sources/com/unity3d/ads/cache/CacheDirectory.java
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
package com.unity3d.ads.cache;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class CacheDirectory {
|
||||
private static final String TEST_FILE_NAME = "UnityAdsTest.txt";
|
||||
private String _cacheDirName;
|
||||
private boolean _initialized = false;
|
||||
private File _cacheDirectory = null;
|
||||
private CacheDirectoryType _type = null;
|
||||
|
||||
public CacheDirectory(String str) {
|
||||
this._cacheDirName = str;
|
||||
}
|
||||
|
||||
public File createCacheDirectory(File file, String str) {
|
||||
if (file == null) {
|
||||
return null;
|
||||
}
|
||||
File file2 = new File(file, str);
|
||||
file2.mkdirs();
|
||||
if (file2.isDirectory()) {
|
||||
return file2;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public File getCacheDirectory(Context context) {
|
||||
File file;
|
||||
if (this._initialized) {
|
||||
return this._cacheDirectory;
|
||||
}
|
||||
this._initialized = true;
|
||||
if (Build.VERSION.SDK_INT > 18) {
|
||||
if ("mounted".equals(Environment.getExternalStorageState())) {
|
||||
try {
|
||||
file = createCacheDirectory(context.getExternalCacheDir(), this._cacheDirName);
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Creating external cache directory failed", e);
|
||||
file = null;
|
||||
}
|
||||
if (testCacheDirectory(file)) {
|
||||
this._cacheDirectory = file;
|
||||
this._type = CacheDirectoryType.EXTERNAL;
|
||||
DeviceLog.debug("Unity Ads is using external cache directory: " + file.getAbsolutePath());
|
||||
return this._cacheDirectory;
|
||||
}
|
||||
} else {
|
||||
DeviceLog.debug("External media not mounted");
|
||||
}
|
||||
}
|
||||
File filesDir = context.getFilesDir();
|
||||
if (!testCacheDirectory(filesDir)) {
|
||||
DeviceLog.error("Unity Ads failed to initialize cache directory");
|
||||
return null;
|
||||
}
|
||||
this._cacheDirectory = filesDir;
|
||||
this._type = CacheDirectoryType.INTERNAL;
|
||||
DeviceLog.debug("Unity Ads is using internal cache directory: " + filesDir.getAbsolutePath());
|
||||
return this._cacheDirectory;
|
||||
}
|
||||
|
||||
public CacheDirectoryType getType() {
|
||||
return this._type;
|
||||
}
|
||||
|
||||
public boolean testCacheDirectory(File file) {
|
||||
if (file != null && file.isDirectory()) {
|
||||
try {
|
||||
byte[] bytes = "test".getBytes("UTF-8");
|
||||
byte[] bArr = new byte[bytes.length];
|
||||
File file2 = new File(file, TEST_FILE_NAME);
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file2);
|
||||
fileOutputStream.write(bytes);
|
||||
fileOutputStream.flush();
|
||||
fileOutputStream.close();
|
||||
FileInputStream fileInputStream = new FileInputStream(file2);
|
||||
int read = fileInputStream.read(bArr, 0, bArr.length);
|
||||
fileInputStream.close();
|
||||
if (!file2.delete()) {
|
||||
DeviceLog.debug("Failed to delete testfile " + file2.getAbsoluteFile());
|
||||
return false;
|
||||
}
|
||||
if (read != bArr.length) {
|
||||
DeviceLog.debug("Read buffer size mismatch");
|
||||
return false;
|
||||
}
|
||||
if (new String(bArr, "UTF-8").equals("test")) {
|
||||
return true;
|
||||
}
|
||||
DeviceLog.debug("Read buffer content mismatch");
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
DeviceLog.debug("Unity Ads exception while testing cache directory " + file.getAbsolutePath() + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
7
sources/com/unity3d/ads/cache/CacheDirectoryType.java
vendored
Normal file
7
sources/com/unity3d/ads/cache/CacheDirectoryType.java
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.unity3d.ads.cache;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum CacheDirectoryType {
|
||||
EXTERNAL,
|
||||
INTERNAL
|
||||
}
|
||||
21
sources/com/unity3d/ads/cache/CacheError.java
vendored
Normal file
21
sources/com/unity3d/ads/cache/CacheError.java
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.unity3d.ads.cache;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum CacheError {
|
||||
FILE_IO_ERROR,
|
||||
FILE_NOT_FOUND,
|
||||
FILE_ALREADY_CACHING,
|
||||
NOT_CACHING,
|
||||
JSON_ERROR,
|
||||
NO_INTERNET,
|
||||
MALFORMED_URL,
|
||||
NETWORK_ERROR,
|
||||
ILLEGAL_STATE,
|
||||
INVALID_ARGUMENT,
|
||||
UNSUPPORTED_ENCODING,
|
||||
FILE_STATE_WRONG,
|
||||
CACHE_DIRECTORY_NULL,
|
||||
CACHE_DIRECTORY_TYPE_NULL,
|
||||
CACHE_DIRECTORY_EXISTS,
|
||||
CACHE_DIRECTORY_DOESNT_EXIST
|
||||
}
|
||||
10
sources/com/unity3d/ads/cache/CacheEvent.java
vendored
Normal file
10
sources/com/unity3d/ads/cache/CacheEvent.java
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.unity3d.ads.cache;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum CacheEvent {
|
||||
DOWNLOAD_STARTED,
|
||||
DOWNLOAD_PROGRESS,
|
||||
DOWNLOAD_END,
|
||||
DOWNLOAD_STOPPED,
|
||||
DOWNLOAD_ERROR
|
||||
}
|
||||
109
sources/com/unity3d/ads/cache/CacheThread.java
vendored
Normal file
109
sources/com/unity3d/ads/cache/CacheThread.java
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
package com.unity3d.ads.cache;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import com.tencent.open.SocialConstants;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class CacheThread extends Thread {
|
||||
public static final int MSG_DOWNLOAD = 1;
|
||||
private static int _connectTimeout = 30000;
|
||||
private static CacheThreadHandler _handler = null;
|
||||
private static int _progressInterval = 0;
|
||||
private static int _readTimeout = 30000;
|
||||
private static boolean _ready = false;
|
||||
private static final Object _readyLock = new Object();
|
||||
|
||||
public static void cancel() {
|
||||
if (_ready) {
|
||||
_handler.removeMessages(1);
|
||||
_handler.setCancelStatus(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void download(String str, String str2, HashMap<String, List<String>> hashMap, boolean z) {
|
||||
synchronized (CacheThread.class) {
|
||||
if (!_ready) {
|
||||
init();
|
||||
}
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(SocialConstants.PARAM_SOURCE, str);
|
||||
bundle.putString("target", str2);
|
||||
bundle.putInt("connectTimeout", _connectTimeout);
|
||||
bundle.putInt("readTimeout", _readTimeout);
|
||||
bundle.putInt("progressInterval", _progressInterval);
|
||||
bundle.putBoolean("append", z);
|
||||
if (hashMap != null) {
|
||||
for (String str3 : hashMap.keySet()) {
|
||||
bundle.putStringArray(str3, (String[]) hashMap.get(str3).toArray(new String[hashMap.get(str3).size()]));
|
||||
}
|
||||
}
|
||||
Message message = new Message();
|
||||
message.what = 1;
|
||||
message.setData(bundle);
|
||||
_handler.setCancelStatus(false);
|
||||
_handler.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getConnectTimeout() {
|
||||
return _connectTimeout;
|
||||
}
|
||||
|
||||
public static int getProgressInterval() {
|
||||
return _progressInterval;
|
||||
}
|
||||
|
||||
public static int getReadTimeout() {
|
||||
return _readTimeout;
|
||||
}
|
||||
|
||||
private static void init() {
|
||||
CacheThread cacheThread = new CacheThread();
|
||||
cacheThread.setName("UnityAdsCacheThread");
|
||||
cacheThread.start();
|
||||
while (!_ready) {
|
||||
try {
|
||||
synchronized (_readyLock) {
|
||||
_readyLock.wait();
|
||||
}
|
||||
} catch (InterruptedException unused) {
|
||||
DeviceLog.debug("Couldn't synchronize thread");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isActive() {
|
||||
if (_ready) {
|
||||
return _handler.isActive();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void setConnectTimeout(int i) {
|
||||
_connectTimeout = i;
|
||||
}
|
||||
|
||||
public static void setProgressInterval(int i) {
|
||||
_progressInterval = i;
|
||||
}
|
||||
|
||||
public static void setReadTimeout(int i) {
|
||||
_readTimeout = i;
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
Looper.prepare();
|
||||
_handler = new CacheThreadHandler();
|
||||
_ready = true;
|
||||
synchronized (_readyLock) {
|
||||
_readyLock.notify();
|
||||
}
|
||||
Looper.loop();
|
||||
}
|
||||
}
|
||||
183
sources/com/unity3d/ads/cache/CacheThreadHandler.java
vendored
Normal file
183
sources/com/unity3d/ads/cache/CacheThreadHandler.java
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
package com.unity3d.ads.cache;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import com.tencent.open.SocialConstants;
|
||||
import com.unity3d.ads.api.Request;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.request.WebRequest;
|
||||
import com.unity3d.ads.webview.WebViewApp;
|
||||
import com.unity3d.ads.webview.WebViewEventCategory;
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class CacheThreadHandler extends Handler {
|
||||
private WebRequest _currentRequest = null;
|
||||
private boolean _canceled = false;
|
||||
private boolean _active = false;
|
||||
|
||||
CacheThreadHandler() {
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
/* JADX WARN: Removed duplicated region for block: B:101:? A[SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:94:0x0319 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Type inference failed for: r0v16, types: [com.unity3d.ads.webview.WebViewApp] */
|
||||
/* JADX WARN: Type inference failed for: r0v20, types: [com.unity3d.ads.webview.WebViewApp] */
|
||||
/* JADX WARN: Type inference failed for: r0v24, types: [com.unity3d.ads.webview.WebViewApp] */
|
||||
/* JADX WARN: Type inference failed for: r0v28, types: [com.unity3d.ads.webview.WebViewApp] */
|
||||
/* JADX WARN: Type inference failed for: r0v32, types: [com.unity3d.ads.webview.WebViewApp] */
|
||||
/* JADX WARN: Type inference failed for: r14v10, types: [com.unity3d.ads.request.WebRequest] */
|
||||
/* JADX WARN: Type inference failed for: r14v11, types: [com.unity3d.ads.request.WebRequest] */
|
||||
/* JADX WARN: Type inference failed for: r14v12, types: [com.unity3d.ads.request.WebRequest] */
|
||||
/* JADX WARN: Type inference failed for: r14v13, types: [com.unity3d.ads.request.WebRequest] */
|
||||
/* JADX WARN: Type inference failed for: r14v15, types: [com.unity3d.ads.request.WebRequest] */
|
||||
/* JADX WARN: Type inference failed for: r14v2 */
|
||||
/* JADX WARN: Type inference failed for: r14v3 */
|
||||
/* JADX WARN: Type inference failed for: r14v30 */
|
||||
/* JADX WARN: Type inference failed for: r14v4 */
|
||||
/* JADX WARN: Type inference failed for: r14v47 */
|
||||
/* JADX WARN: Type inference failed for: r14v49 */
|
||||
/* JADX WARN: Type inference failed for: r14v5 */
|
||||
/* JADX WARN: Type inference failed for: r14v51 */
|
||||
/* JADX WARN: Type inference failed for: r14v53 */
|
||||
/* JADX WARN: Type inference failed for: r14v55 */
|
||||
/* JADX WARN: Type inference failed for: r14v56 */
|
||||
/* JADX WARN: Type inference failed for: r14v6 */
|
||||
/* JADX WARN: Type inference failed for: r14v9, types: [com.unity3d.ads.request.WebRequest] */
|
||||
/* JADX WARN: Type inference failed for: r3v14, types: [java.lang.StringBuilder] */
|
||||
/* JADX WARN: Type inference failed for: r4v0, types: [java.lang.String] */
|
||||
/* JADX WARN: Type inference failed for: r4v13, types: [java.lang.Object[]] */
|
||||
/* JADX WARN: Type inference failed for: r4v15, types: [java.lang.Object[]] */
|
||||
/* JADX WARN: Type inference failed for: r4v17, types: [java.lang.Object[]] */
|
||||
/* JADX WARN: Type inference failed for: r4v19, types: [java.lang.Object[]] */
|
||||
/* JADX WARN: Type inference failed for: r4v22, types: [java.lang.Object[]] */
|
||||
/* JADX WARN: Type inference failed for: r4v47, types: [java.lang.String] */
|
||||
/* JADX WARN: Type inference failed for: r6v1 */
|
||||
/* JADX WARN: Type inference failed for: r6v10, types: [boolean] */
|
||||
/* JADX WARN: Type inference failed for: r6v11, types: [boolean] */
|
||||
/* JADX WARN: Type inference failed for: r6v12, types: [boolean] */
|
||||
/* JADX WARN: Type inference failed for: r6v13, types: [boolean] */
|
||||
/* JADX WARN: Type inference failed for: r6v14 */
|
||||
/* JADX WARN: Type inference failed for: r6v15, types: [boolean] */
|
||||
/* JADX WARN: Type inference failed for: r6v2 */
|
||||
/* JADX WARN: Type inference failed for: r6v3 */
|
||||
/* JADX WARN: Type inference failed for: r6v37, types: [long] */
|
||||
/* JADX WARN: Type inference failed for: r6v38 */
|
||||
/* JADX WARN: Type inference failed for: r6v39 */
|
||||
/* JADX WARN: Type inference failed for: r6v4 */
|
||||
/* JADX WARN: Type inference failed for: r6v40 */
|
||||
/* JADX WARN: Type inference failed for: r6v41 */
|
||||
/* JADX WARN: Type inference failed for: r6v42 */
|
||||
/* JADX WARN: Type inference failed for: r6v43 */
|
||||
/* JADX WARN: Type inference failed for: r6v44 */
|
||||
/* JADX WARN: Type inference failed for: r6v45 */
|
||||
/* JADX WARN: Type inference failed for: r6v46 */
|
||||
/* JADX WARN: Type inference failed for: r6v47 */
|
||||
/* JADX WARN: Type inference failed for: r6v48 */
|
||||
/* JADX WARN: Type inference failed for: r6v49 */
|
||||
/* JADX WARN: Type inference failed for: r6v5 */
|
||||
/* JADX WARN: Type inference failed for: r6v50 */
|
||||
/* JADX WARN: Type inference failed for: r6v51 */
|
||||
/* JADX WARN: Type inference failed for: r6v52 */
|
||||
/* JADX WARN: Type inference failed for: r6v53 */
|
||||
/* JADX WARN: Type inference failed for: r6v54 */
|
||||
/* JADX WARN: Type inference failed for: r6v55 */
|
||||
/* JADX WARN: Type inference failed for: r6v56 */
|
||||
/* JADX WARN: Type inference failed for: r6v57 */
|
||||
/* JADX WARN: Type inference failed for: r6v6 */
|
||||
/* JADX WARN: Type inference failed for: r6v7 */
|
||||
/* JADX WARN: Type inference failed for: r6v8 */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
private void downloadFile(java.lang.String r24, java.lang.String r25, int r26, int r27, final int r28, java.util.HashMap<java.lang.String, java.util.List<java.lang.String>> r29, boolean r30) {
|
||||
/*
|
||||
Method dump skipped, instructions count: 829
|
||||
To view this dump change 'Code comments level' option to 'DEBUG'
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.unity3d.ads.cache.CacheThreadHandler.downloadFile(java.lang.String, java.lang.String, int, int, int, java.util.HashMap, boolean):void");
|
||||
}
|
||||
|
||||
private WebRequest getWebRequest(String str, int i, int i2, HashMap<String, List<String>> hashMap) throws MalformedURLException {
|
||||
HashMap hashMap2 = new HashMap();
|
||||
if (hashMap != null) {
|
||||
hashMap2.putAll(hashMap);
|
||||
}
|
||||
return new WebRequest(str, "GET", hashMap2, i, i2);
|
||||
}
|
||||
|
||||
private void postProcessDownload(long j, String str, File file, long j2, long j3, boolean z, int i, Map<String, List<String>> map) {
|
||||
long elapsedRealtime = SystemClock.elapsedRealtime() - j;
|
||||
if (!file.setReadable(true, false)) {
|
||||
DeviceLog.debug("Unity Ads cache: could not set file readable!");
|
||||
}
|
||||
if (z) {
|
||||
DeviceLog.debug("Unity Ads cache: downloading of " + str + " stopped");
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.CACHE, CacheEvent.DOWNLOAD_STOPPED, str, Long.valueOf(j2), Long.valueOf(j3), Long.valueOf(elapsedRealtime), Integer.valueOf(i), Request.getResponseHeadersMap(map));
|
||||
return;
|
||||
}
|
||||
DeviceLog.debug("Unity Ads cache: File " + file.getName() + " of " + j2 + " bytes downloaded in " + elapsedRealtime + "ms");
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.CACHE, CacheEvent.DOWNLOAD_END, str, Long.valueOf(j2), Long.valueOf(j3), Long.valueOf(elapsedRealtime), Integer.valueOf(i), Request.getResponseHeadersMap(map));
|
||||
}
|
||||
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message message) {
|
||||
HashMap<String, List<String>> hashMap;
|
||||
Bundle data = message.getData();
|
||||
String string = data.getString(SocialConstants.PARAM_SOURCE);
|
||||
data.remove(SocialConstants.PARAM_SOURCE);
|
||||
String string2 = data.getString("target");
|
||||
data.remove("target");
|
||||
int i = data.getInt("connectTimeout");
|
||||
data.remove("connectTimeout");
|
||||
int i2 = data.getInt("readTimeout");
|
||||
data.remove("readTimeout");
|
||||
int i3 = data.getInt("progressInterval");
|
||||
data.remove("progressInterval");
|
||||
boolean z = data.getBoolean("append", false);
|
||||
data.remove("append");
|
||||
if (data.size() > 0) {
|
||||
DeviceLog.debug("There are headers left in data, reading them");
|
||||
HashMap<String, List<String>> hashMap2 = new HashMap<>();
|
||||
for (String str : data.keySet()) {
|
||||
hashMap2.put(str, Arrays.asList(data.getStringArray(str)));
|
||||
}
|
||||
hashMap = hashMap2;
|
||||
} else {
|
||||
hashMap = null;
|
||||
}
|
||||
File file = new File(string2);
|
||||
if ((z && !file.exists()) || (!z && file.exists())) {
|
||||
this._active = false;
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.CACHE, CacheEvent.DOWNLOAD_ERROR, CacheError.FILE_STATE_WRONG, string, string2, Boolean.valueOf(z), Boolean.valueOf(file.exists()));
|
||||
} else {
|
||||
if (message.what != 1) {
|
||||
return;
|
||||
}
|
||||
downloadFile(string, string2, i, i2, i3, hashMap, z);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return this._active;
|
||||
}
|
||||
|
||||
public void setCancelStatus(boolean z) {
|
||||
WebRequest webRequest;
|
||||
this._canceled = z;
|
||||
if (!z || (webRequest = this._currentRequest) == null) {
|
||||
return;
|
||||
}
|
||||
this._active = false;
|
||||
webRequest.cancel();
|
||||
}
|
||||
}
|
||||
96
sources/com/unity3d/ads/configuration/Configuration.java
Normal file
96
sources/com/unity3d/ads/configuration/Configuration.java
Normal file
@@ -0,0 +1,96 @@
|
||||
package com.unity3d.ads.configuration;
|
||||
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.metadata.MediationMetaData;
|
||||
import com.unity3d.ads.properties.SdkProperties;
|
||||
import com.unity3d.ads.request.NetworkIOException;
|
||||
import com.unity3d.ads.request.WebRequest;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Configuration {
|
||||
private String _url;
|
||||
private Class[] _webAppApiClassList;
|
||||
private String _webViewData;
|
||||
private String _webViewHash;
|
||||
private String _webViewUrl;
|
||||
private String _webViewVersion;
|
||||
|
||||
public Configuration() {
|
||||
}
|
||||
|
||||
protected String buildQueryString() {
|
||||
return "?ts=" + System.currentTimeMillis() + "&sdkVersion=" + SdkProperties.getVersionCode() + "&sdkVersionName=" + SdkProperties.getVersionName();
|
||||
}
|
||||
|
||||
public String getConfigUrl() {
|
||||
return this._url;
|
||||
}
|
||||
|
||||
public Class[] getWebAppApiClassList() {
|
||||
return this._webAppApiClassList;
|
||||
}
|
||||
|
||||
public String getWebViewData() {
|
||||
return this._webViewData;
|
||||
}
|
||||
|
||||
public String getWebViewHash() {
|
||||
return this._webViewHash;
|
||||
}
|
||||
|
||||
public String getWebViewUrl() {
|
||||
return this._webViewUrl;
|
||||
}
|
||||
|
||||
public String getWebViewVersion() {
|
||||
return this._webViewVersion;
|
||||
}
|
||||
|
||||
protected void makeRequest() throws IOException, JSONException, IllegalStateException, NetworkIOException {
|
||||
if (this._url == null) {
|
||||
throw new MalformedURLException("Base URL is null");
|
||||
}
|
||||
String str = this._url + buildQueryString();
|
||||
DeviceLog.debug("Requesting configuration with: " + str);
|
||||
JSONObject jSONObject = new JSONObject(new WebRequest(str, "GET", null).makeRequest());
|
||||
this._webViewUrl = jSONObject.getString("url");
|
||||
if (!jSONObject.isNull("hash")) {
|
||||
this._webViewHash = jSONObject.getString("hash");
|
||||
}
|
||||
if (jSONObject.has(MediationMetaData.KEY_VERSION)) {
|
||||
this._webViewVersion = jSONObject.getString(MediationMetaData.KEY_VERSION);
|
||||
}
|
||||
String str2 = this._webViewUrl;
|
||||
if (str2 == null || str2.isEmpty()) {
|
||||
throw new MalformedURLException("Invalid data. Web view URL is null or empty");
|
||||
}
|
||||
}
|
||||
|
||||
public void setConfigUrl(String str) {
|
||||
this._url = str;
|
||||
}
|
||||
|
||||
public void setWebAppApiClassList(Class[] clsArr) {
|
||||
this._webAppApiClassList = clsArr;
|
||||
}
|
||||
|
||||
public void setWebViewData(String str) {
|
||||
this._webViewData = str;
|
||||
}
|
||||
|
||||
public void setWebViewHash(String str) {
|
||||
this._webViewHash = str;
|
||||
}
|
||||
|
||||
public void setWebViewUrl(String str) {
|
||||
this._webViewUrl = str;
|
||||
}
|
||||
|
||||
public Configuration(String str) {
|
||||
this._url = str;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.unity3d.ads.configuration;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum ConfigurationFailure {
|
||||
NETWORK_FAILURE,
|
||||
INVALID_DATA
|
||||
}
|
||||
62
sources/com/unity3d/ads/configuration/EnvironmentCheck.java
Normal file
62
sources/com/unity3d/ads/configuration/EnvironmentCheck.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package com.unity3d.ads.configuration;
|
||||
|
||||
import android.os.Build;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.properties.SdkProperties;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class EnvironmentCheck {
|
||||
private static boolean hasJavascriptInterface(Method method) {
|
||||
if (Build.VERSION.SDK_INT < 17) {
|
||||
return true;
|
||||
}
|
||||
Annotation[] annotations = method.getAnnotations();
|
||||
if (annotations != null) {
|
||||
for (Annotation annotation : annotations) {
|
||||
if (annotation instanceof JavascriptInterface) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEnvironmentOk() {
|
||||
return testProGuard() && testCacheDirectory();
|
||||
}
|
||||
|
||||
public static boolean testCacheDirectory() {
|
||||
if (SdkProperties.getCacheDirectory() != null) {
|
||||
DeviceLog.debug("Unity Ads cache directory check OK");
|
||||
return true;
|
||||
}
|
||||
DeviceLog.error("Unity Ads cache directory check fail: no working cache directory available");
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean testProGuard() {
|
||||
try {
|
||||
Class<?> cls = Class.forName("com.unity3d.ads.webview.bridge.WebViewBridgeInterface");
|
||||
Method method = cls.getMethod("handleInvocation", String.class);
|
||||
Method method2 = cls.getMethod("handleCallback", String.class, String.class, String.class);
|
||||
if (hasJavascriptInterface(method) && hasJavascriptInterface(method2)) {
|
||||
DeviceLog.debug("Unity Ads ProGuard check OK");
|
||||
return true;
|
||||
}
|
||||
DeviceLog.error("Unity Ads ProGuard check fail: missing @JavascriptInterface annotations in Unity Ads web bridge");
|
||||
return false;
|
||||
} catch (ClassNotFoundException e) {
|
||||
DeviceLog.exception("Unity Ads ProGuard check fail: Unity Ads web bridge class not found", e);
|
||||
return false;
|
||||
} catch (NoSuchMethodException e2) {
|
||||
DeviceLog.exception("Unity Ads ProGuard check fail: Unity Ads web bridge methods not found", e2);
|
||||
return false;
|
||||
} catch (Exception e3) {
|
||||
DeviceLog.exception("Unknown exception during Unity Ads ProGuard check: " + e3.getMessage(), e3);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
478
sources/com/unity3d/ads/configuration/InitializeThread.java
Normal file
478
sources/com/unity3d/ads/configuration/InitializeThread.java
Normal file
@@ -0,0 +1,478 @@
|
||||
package com.unity3d.ads.configuration;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.os.Build;
|
||||
import android.os.ConditionVariable;
|
||||
import com.unity3d.ads.IUnityAdsListener;
|
||||
import com.unity3d.ads.UnityAds;
|
||||
import com.unity3d.ads.api.Lifecycle;
|
||||
import com.unity3d.ads.broadcast.BroadcastMonitor;
|
||||
import com.unity3d.ads.cache.CacheThread;
|
||||
import com.unity3d.ads.connectivity.ConnectivityMonitor;
|
||||
import com.unity3d.ads.connectivity.IConnectivityListener;
|
||||
import com.unity3d.ads.device.AdvertisingId;
|
||||
import com.unity3d.ads.device.StorageManager;
|
||||
import com.unity3d.ads.device.VolumeChange;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.misc.Utilities;
|
||||
import com.unity3d.ads.placement.Placement;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
import com.unity3d.ads.properties.SdkProperties;
|
||||
import com.unity3d.ads.request.WebRequest;
|
||||
import com.unity3d.ads.request.WebRequestThread;
|
||||
import com.unity3d.ads.webview.WebViewApp;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class InitializeThread extends Thread {
|
||||
private static InitializeThread _thread;
|
||||
private InitializeState _state;
|
||||
private boolean _stopThread = false;
|
||||
|
||||
private static abstract class InitializeState {
|
||||
private InitializeState() {
|
||||
}
|
||||
|
||||
public abstract InitializeState execute();
|
||||
}
|
||||
|
||||
public static class InitializeStateAdBlockerCheck extends InitializeState {
|
||||
private InetAddress _address;
|
||||
private Configuration _configuration;
|
||||
|
||||
public InitializeStateAdBlockerCheck(Configuration configuration) {
|
||||
super();
|
||||
this._configuration = configuration;
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.configuration.InitializeThread.InitializeState
|
||||
public InitializeState execute() {
|
||||
InetAddress inetAddress;
|
||||
DeviceLog.debug("Unity Ads init: checking for ad blockers");
|
||||
try {
|
||||
final String host = new URL(this._configuration.getConfigUrl()).getHost();
|
||||
final ConditionVariable conditionVariable = new ConditionVariable();
|
||||
new Thread() { // from class: com.unity3d.ads.configuration.InitializeThread.InitializeStateAdBlockerCheck.1
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
try {
|
||||
InitializeStateAdBlockerCheck.this._address = InetAddress.getByName(host);
|
||||
conditionVariable.open();
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Couldn't get address. Host: " + host, e);
|
||||
conditionVariable.open();
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
if (!conditionVariable.block(2000L) || (inetAddress = this._address) == null || !inetAddress.isLoopbackAddress()) {
|
||||
return new InitializeStateConfig(this._configuration);
|
||||
}
|
||||
DeviceLog.error("Unity Ads init: halting init because Unity Ads config resolves to loopback address (due to ad blocker?)");
|
||||
final IUnityAdsListener listener = UnityAds.getListener();
|
||||
if (listener == null) {
|
||||
return null;
|
||||
}
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.configuration.InitializeThread.InitializeStateAdBlockerCheck.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
listener.onUnityAdsError(UnityAds.UnityAdsError.AD_BLOCKER_DETECTED, "Unity Ads config server resolves to loopback address (due to ad blocker?)");
|
||||
}
|
||||
});
|
||||
return null;
|
||||
} catch (MalformedURLException unused) {
|
||||
return new InitializeStateConfig(this._configuration);
|
||||
}
|
||||
}
|
||||
|
||||
public Configuration getConfiguration() {
|
||||
return this._configuration;
|
||||
}
|
||||
}
|
||||
|
||||
public static class InitializeStateComplete extends InitializeState {
|
||||
public InitializeStateComplete() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.configuration.InitializeThread.InitializeState
|
||||
public InitializeState execute() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class InitializeStateConfig extends InitializeState {
|
||||
private Configuration _configuration;
|
||||
private int _maxRetries;
|
||||
private int _retries;
|
||||
private int _retryDelay;
|
||||
|
||||
public InitializeStateConfig(Configuration configuration) {
|
||||
super();
|
||||
this._retries = 0;
|
||||
this._maxRetries = 6;
|
||||
this._retryDelay = 5;
|
||||
this._configuration = configuration;
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.configuration.InitializeThread.InitializeState
|
||||
public InitializeState execute() {
|
||||
DeviceLog.info("Unity Ads init: load configuration from " + SdkProperties.getConfigUrl());
|
||||
try {
|
||||
this._configuration.makeRequest();
|
||||
return new InitializeStateLoadCache(this._configuration);
|
||||
} catch (Exception e) {
|
||||
int i = this._retries;
|
||||
if (i >= this._maxRetries) {
|
||||
return new InitializeStateNetworkError(e, this);
|
||||
}
|
||||
this._retryDelay *= 2;
|
||||
this._retries = i + 1;
|
||||
return new InitializeStateRetry(this, this._retryDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class InitializeStateCreate extends InitializeState {
|
||||
private Configuration _configuration;
|
||||
private String _webViewData;
|
||||
|
||||
public InitializeStateCreate(Configuration configuration, String str) {
|
||||
super();
|
||||
this._configuration = configuration;
|
||||
this._webViewData = str;
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.configuration.InitializeThread.InitializeState
|
||||
public InitializeState execute() {
|
||||
DeviceLog.debug("Unity Ads init: creating webapp");
|
||||
Configuration configuration = this._configuration;
|
||||
configuration.setWebViewData(this._webViewData);
|
||||
try {
|
||||
if (WebViewApp.create(configuration)) {
|
||||
return new InitializeStateComplete();
|
||||
}
|
||||
DeviceLog.error("Unity Ads WebApp creation failed!");
|
||||
return new InitializeStateError("create webapp", new Exception("Creation of WebApp failed!"));
|
||||
} catch (IllegalThreadStateException e) {
|
||||
DeviceLog.exception("Illegal Thread", e);
|
||||
return new InitializeStateError("create webapp", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Configuration getConfiguration() {
|
||||
return this._configuration;
|
||||
}
|
||||
|
||||
public String getWebData() {
|
||||
return this._webViewData;
|
||||
}
|
||||
}
|
||||
|
||||
public static class InitializeStateError extends InitializeState {
|
||||
Exception _exception;
|
||||
String _state;
|
||||
|
||||
public InitializeStateError(String str, Exception exc) {
|
||||
super();
|
||||
this._state = str;
|
||||
this._exception = exc;
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.configuration.InitializeThread.InitializeState
|
||||
public InitializeState execute() {
|
||||
DeviceLog.error("Unity Ads init: halting init in " + this._state + ": " + this._exception.getMessage());
|
||||
final IUnityAdsListener listener = UnityAds.getListener();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Init failed in ");
|
||||
sb.append(this._state);
|
||||
final String sb2 = sb.toString();
|
||||
if (UnityAds.getListener() == null) {
|
||||
return null;
|
||||
}
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.configuration.InitializeThread.InitializeStateError.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
listener.onUnityAdsError(UnityAds.UnityAdsError.INITIALIZE_FAILED, sb2);
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class InitializeStateForceReset extends InitializeStateReset {
|
||||
public InitializeStateForceReset() {
|
||||
super(new Configuration());
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.configuration.InitializeThread.InitializeStateReset, com.unity3d.ads.configuration.InitializeThread.InitializeState
|
||||
public InitializeState execute() {
|
||||
super.execute();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class InitializeStateLoadCache extends InitializeState {
|
||||
private Configuration _configuration;
|
||||
|
||||
public InitializeStateLoadCache(Configuration configuration) {
|
||||
super();
|
||||
this._configuration = configuration;
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.configuration.InitializeThread.InitializeState
|
||||
public InitializeState execute() {
|
||||
DeviceLog.debug("Unity Ads init: check if webapp can be loaded from local cache");
|
||||
try {
|
||||
byte[] readFileBytes = Utilities.readFileBytes(new File(SdkProperties.getLocalWebViewFile()));
|
||||
String Sha256 = Utilities.Sha256(readFileBytes);
|
||||
if (Sha256 == null || !Sha256.equals(this._configuration.getWebViewHash())) {
|
||||
return new InitializeStateLoadWeb(this._configuration);
|
||||
}
|
||||
try {
|
||||
String str = new String(readFileBytes, "UTF-8");
|
||||
DeviceLog.info("Unity Ads init: webapp loaded from local cache");
|
||||
return new InitializeStateCreate(this._configuration, str);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return new InitializeStateError("load cache", e);
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
DeviceLog.debug("Unity Ads init: webapp not found in local cache: " + e2.getMessage());
|
||||
return new InitializeStateLoadWeb(this._configuration);
|
||||
}
|
||||
}
|
||||
|
||||
public Configuration getConfiguration() {
|
||||
return this._configuration;
|
||||
}
|
||||
}
|
||||
|
||||
public static class InitializeStateLoadWeb extends InitializeState {
|
||||
private Configuration _configuration;
|
||||
private int _maxRetries;
|
||||
private int _retries;
|
||||
private int _retryDelay;
|
||||
|
||||
public InitializeStateLoadWeb(Configuration configuration) {
|
||||
super();
|
||||
this._retries = 0;
|
||||
this._maxRetries = 6;
|
||||
this._retryDelay = 5;
|
||||
this._configuration = configuration;
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.configuration.InitializeThread.InitializeState
|
||||
public InitializeState execute() {
|
||||
DeviceLog.info("Unity Ads init: loading webapp from " + this._configuration.getWebViewUrl());
|
||||
try {
|
||||
try {
|
||||
String makeRequest = new WebRequest(this._configuration.getWebViewUrl(), "GET", null).makeRequest();
|
||||
String webViewHash = this._configuration.getWebViewHash();
|
||||
if (webViewHash != null && !Utilities.Sha256(makeRequest).equals(webViewHash)) {
|
||||
return new InitializeStateError("load web", new Exception("Invalid webViewHash"));
|
||||
}
|
||||
if (webViewHash != null) {
|
||||
Utilities.writeFile(new File(SdkProperties.getLocalWebViewFile()), makeRequest);
|
||||
}
|
||||
return new InitializeStateCreate(this._configuration, makeRequest);
|
||||
} catch (Exception e) {
|
||||
int i = this._retries;
|
||||
if (i >= this._maxRetries) {
|
||||
return new InitializeStateNetworkError(e, this);
|
||||
}
|
||||
this._retryDelay *= 2;
|
||||
this._retries = i + 1;
|
||||
return new InitializeStateRetry(this, this._retryDelay);
|
||||
}
|
||||
} catch (MalformedURLException e2) {
|
||||
DeviceLog.exception("Malformed URL", e2);
|
||||
return new InitializeStateError("make webrequest", e2);
|
||||
}
|
||||
}
|
||||
|
||||
public Configuration getConfiguration() {
|
||||
return this._configuration;
|
||||
}
|
||||
}
|
||||
|
||||
public static class InitializeStateNetworkError extends InitializeStateError implements IConnectivityListener {
|
||||
protected static final int CONNECTED_EVENT_THRESHOLD_MS = 10000;
|
||||
protected static final int MAX_CONNECTED_EVENTS = 500;
|
||||
private static long _lastConnectedEventTimeMs;
|
||||
private static int _receivedConnectedEvents;
|
||||
private ConditionVariable _conditionVariable;
|
||||
private InitializeState _erroredState;
|
||||
|
||||
public InitializeStateNetworkError(Exception exc, InitializeState initializeState) {
|
||||
super("network error", exc);
|
||||
this._erroredState = initializeState;
|
||||
}
|
||||
|
||||
private boolean shouldHandleConnectedEvent() {
|
||||
return System.currentTimeMillis() - _lastConnectedEventTimeMs >= 10000 && _receivedConnectedEvents <= 500;
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.configuration.InitializeThread.InitializeStateError, com.unity3d.ads.configuration.InitializeThread.InitializeState
|
||||
public InitializeState execute() {
|
||||
DeviceLog.error("Unity Ads init: network error, waiting for connection events");
|
||||
this._conditionVariable = new ConditionVariable();
|
||||
ConnectivityMonitor.addListener(this);
|
||||
if (this._conditionVariable.block(600000L)) {
|
||||
ConnectivityMonitor.removeListener(this);
|
||||
return this._erroredState;
|
||||
}
|
||||
ConnectivityMonitor.removeListener(this);
|
||||
return new InitializeStateError("network error", new Exception("No connected events within the timeout!"));
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.connectivity.IConnectivityListener
|
||||
public void onConnected() {
|
||||
_receivedConnectedEvents++;
|
||||
DeviceLog.debug("Unity Ads init got connected event");
|
||||
if (shouldHandleConnectedEvent()) {
|
||||
this._conditionVariable.open();
|
||||
}
|
||||
if (_receivedConnectedEvents > 500) {
|
||||
ConnectivityMonitor.removeListener(this);
|
||||
}
|
||||
_lastConnectedEventTimeMs = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.connectivity.IConnectivityListener
|
||||
public void onDisconnected() {
|
||||
DeviceLog.debug("Unity Ads init got disconnected event");
|
||||
}
|
||||
}
|
||||
|
||||
public static class InitializeStateReset extends InitializeState {
|
||||
private Configuration _configuration;
|
||||
|
||||
public InitializeStateReset(Configuration configuration) {
|
||||
super();
|
||||
this._configuration = configuration;
|
||||
}
|
||||
|
||||
@TargetApi(14)
|
||||
private void unregisterLifecycleCallbacks() {
|
||||
if (Lifecycle.getLifecycleListener() != null) {
|
||||
if (ClientProperties.getApplication() != null) {
|
||||
ClientProperties.getApplication().unregisterActivityLifecycleCallbacks(Lifecycle.getLifecycleListener());
|
||||
}
|
||||
Lifecycle.setLifecycleListener(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.configuration.InitializeThread.InitializeState
|
||||
public InitializeState execute() {
|
||||
boolean z;
|
||||
DeviceLog.debug("Unity Ads init: starting init");
|
||||
final ConditionVariable conditionVariable = new ConditionVariable();
|
||||
final WebViewApp currentApp = WebViewApp.getCurrentApp();
|
||||
if (currentApp != null) {
|
||||
currentApp.setWebAppLoaded(false);
|
||||
currentApp.setWebAppInitialized(false);
|
||||
if (currentApp.getWebView() != null) {
|
||||
Utilities.runOnUiThread(new Runnable() { // from class: com.unity3d.ads.configuration.InitializeThread.InitializeStateReset.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
currentApp.getWebView().destroy();
|
||||
currentApp.setWebView(null);
|
||||
conditionVariable.open();
|
||||
}
|
||||
});
|
||||
z = conditionVariable.block(10000L);
|
||||
} else {
|
||||
z = true;
|
||||
}
|
||||
if (!z) {
|
||||
return new InitializeStateError("reset webapp", new Exception("Reset failed on opening ConditionVariable"));
|
||||
}
|
||||
}
|
||||
if (Build.VERSION.SDK_INT > 13) {
|
||||
unregisterLifecycleCallbacks();
|
||||
}
|
||||
SdkProperties.setCacheDirectory(null);
|
||||
if (SdkProperties.getCacheDirectory() == null) {
|
||||
return new InitializeStateError("reset webapp", new Exception("Cache directory is NULL"));
|
||||
}
|
||||
SdkProperties.setInitialized(false);
|
||||
Placement.reset();
|
||||
BroadcastMonitor.removeAllBroadcastListeners();
|
||||
CacheThread.cancel();
|
||||
WebRequestThread.cancel();
|
||||
ConnectivityMonitor.stopAll();
|
||||
StorageManager.init(ClientProperties.getApplicationContext());
|
||||
AdvertisingId.init(ClientProperties.getApplicationContext());
|
||||
VolumeChange.clearAllListeners();
|
||||
this._configuration.setConfigUrl(SdkProperties.getConfigUrl());
|
||||
return new InitializeStateAdBlockerCheck(this._configuration);
|
||||
}
|
||||
}
|
||||
|
||||
public static class InitializeStateRetry extends InitializeState {
|
||||
int _delay;
|
||||
InitializeState _state;
|
||||
|
||||
public InitializeStateRetry(InitializeState initializeState, int i) {
|
||||
super();
|
||||
this._state = initializeState;
|
||||
this._delay = i;
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.configuration.InitializeThread.InitializeState
|
||||
public InitializeState execute() {
|
||||
DeviceLog.debug("Unity Ads init: retrying in " + this._delay + " seconds");
|
||||
try {
|
||||
Thread.sleep(this._delay * 1000);
|
||||
} catch (InterruptedException e) {
|
||||
DeviceLog.exception("Init retry interrupted", e);
|
||||
}
|
||||
return this._state;
|
||||
}
|
||||
}
|
||||
|
||||
private InitializeThread(InitializeState initializeState) {
|
||||
this._state = initializeState;
|
||||
}
|
||||
|
||||
public static synchronized void initialize(Configuration configuration) {
|
||||
synchronized (InitializeThread.class) {
|
||||
if (_thread == null) {
|
||||
_thread = new InitializeThread(new InitializeStateReset(configuration));
|
||||
_thread.setName("UnityAdsInitializeThread");
|
||||
_thread.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void reset() {
|
||||
synchronized (InitializeThread.class) {
|
||||
if (_thread == null) {
|
||||
_thread = new InitializeThread(new InitializeStateForceReset());
|
||||
_thread.setName("UnityAdsResetThread");
|
||||
_thread.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void quit() {
|
||||
this._stopThread = true;
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
while (true) {
|
||||
InitializeState initializeState = this._state;
|
||||
if (initializeState == null || (initializeState instanceof InitializeStateComplete) || this._stopThread) {
|
||||
break;
|
||||
} else {
|
||||
this._state = initializeState.execute();
|
||||
}
|
||||
}
|
||||
_thread = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.unity3d.ads.connectivity;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class ConnectivityChangeReceiver extends BroadcastReceiver {
|
||||
private static ConnectivityChangeReceiver _receiver;
|
||||
|
||||
public static void register() {
|
||||
if (_receiver == null) {
|
||||
_receiver = new ConnectivityChangeReceiver();
|
||||
ClientProperties.getApplicationContext().registerReceiver(_receiver, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));
|
||||
}
|
||||
}
|
||||
|
||||
public static void unregister() {
|
||||
if (_receiver != null) {
|
||||
ClientProperties.getApplicationContext().unregisterReceiver(_receiver);
|
||||
_receiver = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.content.BroadcastReceiver
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
NetworkInfo activeNetworkInfo;
|
||||
if (intent.getBooleanExtra("noConnectivity", false)) {
|
||||
ConnectivityMonitor.disconnected();
|
||||
return;
|
||||
}
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
|
||||
if (connectivityManager == null || (activeNetworkInfo = connectivityManager.getActiveNetworkInfo()) == null || !activeNetworkInfo.isConnected()) {
|
||||
return;
|
||||
}
|
||||
ConnectivityMonitor.connected();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.unity3d.ads.connectivity;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum ConnectivityEvent {
|
||||
CONNECTED,
|
||||
DISCONNECTED,
|
||||
NETWORK_CHANGE
|
||||
}
|
||||
197
sources/com/unity3d/ads/connectivity/ConnectivityMonitor.java
Normal file
197
sources/com/unity3d/ads/connectivity/ConnectivityMonitor.java
Normal file
@@ -0,0 +1,197 @@
|
||||
package com.unity3d.ads.connectivity;
|
||||
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.telephony.TelephonyManager;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
import com.unity3d.ads.webview.WebViewApp;
|
||||
import com.unity3d.ads.webview.WebViewEventCategory;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class ConnectivityMonitor {
|
||||
private static int _connected = -1;
|
||||
private static HashSet<IConnectivityListener> _listeners = null;
|
||||
private static boolean _listening = false;
|
||||
private static int _networkType = -1;
|
||||
private static boolean _webappMonitoring = false;
|
||||
private static boolean _wifi = false;
|
||||
|
||||
/* renamed from: com.unity3d.ads.connectivity.ConnectivityMonitor$1, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass1 {
|
||||
static final /* synthetic */ int[] $SwitchMap$com$unity3d$ads$connectivity$ConnectivityEvent = new int[ConnectivityEvent.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
$SwitchMap$com$unity3d$ads$connectivity$ConnectivityEvent[ConnectivityEvent.CONNECTED.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$unity3d$ads$connectivity$ConnectivityEvent[ConnectivityEvent.DISCONNECTED.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$unity3d$ads$connectivity$ConnectivityEvent[ConnectivityEvent.NETWORK_CHANGE.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError unused3) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void addListener(IConnectivityListener iConnectivityListener) {
|
||||
if (_listeners == null) {
|
||||
_listeners = new HashSet<>();
|
||||
}
|
||||
_listeners.add(iConnectivityListener);
|
||||
updateListeningStatus();
|
||||
}
|
||||
|
||||
public static void connected() {
|
||||
if (_connected == 1) {
|
||||
return;
|
||||
}
|
||||
DeviceLog.debug("Unity Ads connectivity change: connected");
|
||||
initConnectionStatus();
|
||||
HashSet<IConnectivityListener> hashSet = _listeners;
|
||||
if (hashSet != null) {
|
||||
Iterator<IConnectivityListener> it = hashSet.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().onConnected();
|
||||
}
|
||||
}
|
||||
sendToWebview(ConnectivityEvent.CONNECTED, _wifi, _networkType);
|
||||
}
|
||||
|
||||
public static void connectionStatusChanged() {
|
||||
NetworkInfo activeNetworkInfo;
|
||||
if (_connected == 1 && (activeNetworkInfo = ((ConnectivityManager) ClientProperties.getApplicationContext().getSystemService("connectivity")).getActiveNetworkInfo()) != null && activeNetworkInfo.isConnected()) {
|
||||
boolean z = activeNetworkInfo.getType() == 1;
|
||||
int networkType = ((TelephonyManager) ClientProperties.getApplicationContext().getSystemService("phone")).getNetworkType();
|
||||
boolean z2 = _wifi;
|
||||
if (z == z2 && (networkType == _networkType || z2)) {
|
||||
return;
|
||||
}
|
||||
_wifi = z;
|
||||
_networkType = networkType;
|
||||
DeviceLog.debug("Unity Ads connectivity change: network change");
|
||||
sendToWebview(ConnectivityEvent.NETWORK_CHANGE, z, networkType);
|
||||
}
|
||||
}
|
||||
|
||||
public static void disconnected() {
|
||||
if (_connected == 0) {
|
||||
return;
|
||||
}
|
||||
_connected = 0;
|
||||
DeviceLog.debug("Unity Ads connectivity change: disconnected");
|
||||
HashSet<IConnectivityListener> hashSet = _listeners;
|
||||
if (hashSet != null) {
|
||||
Iterator<IConnectivityListener> it = hashSet.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().onDisconnected();
|
||||
}
|
||||
}
|
||||
sendToWebview(ConnectivityEvent.DISCONNECTED, false, 0);
|
||||
}
|
||||
|
||||
private static void initConnectionStatus() {
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) ClientProperties.getApplicationContext().getSystemService("connectivity");
|
||||
if (connectivityManager == null) {
|
||||
return;
|
||||
}
|
||||
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
||||
if (activeNetworkInfo == null || !activeNetworkInfo.isConnected()) {
|
||||
_connected = 0;
|
||||
return;
|
||||
}
|
||||
_connected = 1;
|
||||
_wifi = activeNetworkInfo.getType() == 1;
|
||||
if (_wifi) {
|
||||
return;
|
||||
}
|
||||
_networkType = ((TelephonyManager) ClientProperties.getApplicationContext().getSystemService("phone")).getNetworkType();
|
||||
}
|
||||
|
||||
public static void removeListener(IConnectivityListener iConnectivityListener) {
|
||||
HashSet<IConnectivityListener> hashSet = _listeners;
|
||||
if (hashSet == null) {
|
||||
return;
|
||||
}
|
||||
hashSet.remove(iConnectivityListener);
|
||||
updateListeningStatus();
|
||||
}
|
||||
|
||||
private static void sendToWebview(ConnectivityEvent connectivityEvent, boolean z, int i) {
|
||||
WebViewApp currentApp;
|
||||
if (_webappMonitoring && (currentApp = WebViewApp.getCurrentApp()) != null && currentApp.isWebAppLoaded()) {
|
||||
int i2 = AnonymousClass1.$SwitchMap$com$unity3d$ads$connectivity$ConnectivityEvent[connectivityEvent.ordinal()];
|
||||
if (i2 == 1) {
|
||||
if (z) {
|
||||
currentApp.sendEvent(WebViewEventCategory.CONNECTIVITY, ConnectivityEvent.CONNECTED, Boolean.valueOf(z), 0);
|
||||
return;
|
||||
} else {
|
||||
currentApp.sendEvent(WebViewEventCategory.CONNECTIVITY, ConnectivityEvent.CONNECTED, Boolean.valueOf(z), Integer.valueOf(i));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (i2 == 2) {
|
||||
currentApp.sendEvent(WebViewEventCategory.CONNECTIVITY, ConnectivityEvent.DISCONNECTED, new Object[0]);
|
||||
} else {
|
||||
if (i2 != 3) {
|
||||
return;
|
||||
}
|
||||
if (z) {
|
||||
currentApp.sendEvent(WebViewEventCategory.CONNECTIVITY, ConnectivityEvent.NETWORK_CHANGE, Boolean.valueOf(z), 0);
|
||||
} else {
|
||||
currentApp.sendEvent(WebViewEventCategory.CONNECTIVITY, ConnectivityEvent.NETWORK_CHANGE, Boolean.valueOf(z), Integer.valueOf(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void setConnectionMonitoring(boolean z) {
|
||||
_webappMonitoring = z;
|
||||
updateListeningStatus();
|
||||
}
|
||||
|
||||
private static void startListening() {
|
||||
if (_listening) {
|
||||
return;
|
||||
}
|
||||
_listening = true;
|
||||
initConnectionStatus();
|
||||
if (Build.VERSION.SDK_INT < 21) {
|
||||
ConnectivityChangeReceiver.register();
|
||||
} else {
|
||||
ConnectivityNetworkCallback.register();
|
||||
}
|
||||
}
|
||||
|
||||
public static void stopAll() {
|
||||
_listeners = null;
|
||||
_webappMonitoring = false;
|
||||
updateListeningStatus();
|
||||
}
|
||||
|
||||
private static void stopListening() {
|
||||
if (_listening) {
|
||||
_listening = false;
|
||||
if (Build.VERSION.SDK_INT < 21) {
|
||||
ConnectivityChangeReceiver.unregister();
|
||||
} else {
|
||||
ConnectivityNetworkCallback.unregister();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateListeningStatus() {
|
||||
HashSet<IConnectivityListener> hashSet;
|
||||
if (_webappMonitoring || !((hashSet = _listeners) == null || hashSet.isEmpty())) {
|
||||
startListening();
|
||||
} else {
|
||||
stopListening();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.unity3d.ads.connectivity;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.LinkProperties;
|
||||
import android.net.Network;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkRequest;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
|
||||
@TargetApi(21)
|
||||
/* loaded from: classes2.dex */
|
||||
public class ConnectivityNetworkCallback extends ConnectivityManager.NetworkCallback {
|
||||
private static ConnectivityNetworkCallback _impl;
|
||||
|
||||
public static void register() {
|
||||
if (_impl == null) {
|
||||
_impl = new ConnectivityNetworkCallback();
|
||||
((ConnectivityManager) ClientProperties.getApplicationContext().getSystemService("connectivity")).registerNetworkCallback(new NetworkRequest.Builder().build(), _impl);
|
||||
}
|
||||
}
|
||||
|
||||
public static void unregister() {
|
||||
if (_impl != null) {
|
||||
((ConnectivityManager) ClientProperties.getApplicationContext().getSystemService("connectivity")).unregisterNetworkCallback(_impl);
|
||||
_impl = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.net.ConnectivityManager.NetworkCallback
|
||||
public void onAvailable(Network network) {
|
||||
ConnectivityMonitor.connected();
|
||||
}
|
||||
|
||||
@Override // android.net.ConnectivityManager.NetworkCallback
|
||||
public void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities) {
|
||||
ConnectivityMonitor.connectionStatusChanged();
|
||||
}
|
||||
|
||||
@Override // android.net.ConnectivityManager.NetworkCallback
|
||||
public void onLinkPropertiesChanged(Network network, LinkProperties linkProperties) {
|
||||
ConnectivityMonitor.connectionStatusChanged();
|
||||
}
|
||||
|
||||
@Override // android.net.ConnectivityManager.NetworkCallback
|
||||
public void onLost(Network network) {
|
||||
ConnectivityMonitor.disconnected();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.unity3d.ads.connectivity;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface IConnectivityListener {
|
||||
void onConnected();
|
||||
|
||||
void onDisconnected();
|
||||
}
|
||||
191
sources/com/unity3d/ads/device/AdvertisingId.java
Normal file
191
sources/com/unity3d/ads/device/AdvertisingId.java
Normal file
@@ -0,0 +1,191 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.IInterface;
|
||||
import android.os.Parcel;
|
||||
import android.os.RemoteException;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
@TargetApi(9)
|
||||
/* loaded from: classes2.dex */
|
||||
public class AdvertisingId {
|
||||
private static final String ADVERTISING_ID_SERVICE_NAME = "com.google.android.gms.ads.identifier.internal.IAdvertisingIdService";
|
||||
private static AdvertisingId instance;
|
||||
private String advertisingIdentifier = null;
|
||||
private boolean limitedAdvertisingTracking = false;
|
||||
|
||||
private interface GoogleAdvertisingInfo extends IInterface {
|
||||
|
||||
public static abstract class GoogleAdvertisingInfoBinder extends Binder implements GoogleAdvertisingInfo {
|
||||
|
||||
private static class GoogleAdvertisingInfoImplementation implements GoogleAdvertisingInfo {
|
||||
private final IBinder _binder;
|
||||
|
||||
GoogleAdvertisingInfoImplementation(IBinder iBinder) {
|
||||
this._binder = iBinder;
|
||||
}
|
||||
|
||||
@Override // android.os.IInterface
|
||||
public IBinder asBinder() {
|
||||
return this._binder;
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.device.AdvertisingId.GoogleAdvertisingInfo
|
||||
public boolean getEnabled(boolean z) throws RemoteException {
|
||||
Parcel obtain = Parcel.obtain();
|
||||
Parcel obtain2 = Parcel.obtain();
|
||||
try {
|
||||
obtain.writeInterfaceToken(AdvertisingId.ADVERTISING_ID_SERVICE_NAME);
|
||||
obtain.writeInt(z ? 1 : 0);
|
||||
this._binder.transact(2, obtain, obtain2, 0);
|
||||
obtain2.readException();
|
||||
return obtain2.readInt() != 0;
|
||||
} finally {
|
||||
obtain2.recycle();
|
||||
obtain.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.device.AdvertisingId.GoogleAdvertisingInfo
|
||||
public String getId() throws RemoteException {
|
||||
Parcel obtain = Parcel.obtain();
|
||||
Parcel obtain2 = Parcel.obtain();
|
||||
try {
|
||||
obtain.writeInterfaceToken(AdvertisingId.ADVERTISING_ID_SERVICE_NAME);
|
||||
this._binder.transact(1, obtain, obtain2, 0);
|
||||
obtain2.readException();
|
||||
return obtain2.readString();
|
||||
} finally {
|
||||
obtain2.recycle();
|
||||
obtain.recycle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static GoogleAdvertisingInfo create(IBinder iBinder) {
|
||||
if (iBinder == null) {
|
||||
return null;
|
||||
}
|
||||
IInterface queryLocalInterface = iBinder.queryLocalInterface(AdvertisingId.ADVERTISING_ID_SERVICE_NAME);
|
||||
return (queryLocalInterface == null || !(queryLocalInterface instanceof GoogleAdvertisingInfo)) ? new GoogleAdvertisingInfoImplementation(iBinder) : (GoogleAdvertisingInfo) queryLocalInterface;
|
||||
}
|
||||
|
||||
@Override // android.os.Binder
|
||||
public boolean onTransact(int i, Parcel parcel, Parcel parcel2, int i2) throws RemoteException {
|
||||
if (i == 1) {
|
||||
parcel.enforceInterface(AdvertisingId.ADVERTISING_ID_SERVICE_NAME);
|
||||
String id = getId();
|
||||
parcel2.writeNoException();
|
||||
parcel2.writeString(id);
|
||||
return true;
|
||||
}
|
||||
if (i != 2) {
|
||||
return super.onTransact(i, parcel, parcel2, i2);
|
||||
}
|
||||
parcel.enforceInterface(AdvertisingId.ADVERTISING_ID_SERVICE_NAME);
|
||||
boolean enabled = getEnabled(parcel.readInt() != 0);
|
||||
parcel2.writeNoException();
|
||||
parcel2.writeInt(enabled ? 1 : 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
boolean getEnabled(boolean z) throws RemoteException;
|
||||
|
||||
String getId() throws RemoteException;
|
||||
}
|
||||
|
||||
private class GoogleAdvertisingServiceConnection implements ServiceConnection {
|
||||
private final BlockingQueue<IBinder> _binderQueue;
|
||||
boolean _consumed;
|
||||
|
||||
private GoogleAdvertisingServiceConnection() {
|
||||
this._consumed = false;
|
||||
this._binderQueue = new LinkedBlockingQueue();
|
||||
}
|
||||
|
||||
public IBinder getBinder() throws InterruptedException {
|
||||
if (this._consumed) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
this._consumed = true;
|
||||
return this._binderQueue.take();
|
||||
}
|
||||
|
||||
@Override // android.content.ServiceConnection
|
||||
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
||||
try {
|
||||
this._binderQueue.put(iBinder);
|
||||
} catch (InterruptedException unused) {
|
||||
DeviceLog.debug("Couldn't put service to binder que");
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.content.ServiceConnection
|
||||
public void onServiceDisconnected(ComponentName componentName) {
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchAdvertisingId(Context context) {
|
||||
boolean z;
|
||||
GoogleAdvertisingServiceConnection googleAdvertisingServiceConnection = new GoogleAdvertisingServiceConnection();
|
||||
Intent intent = new Intent("com.google.android.gms.ads.identifier.service.START");
|
||||
intent.setPackage("com.google.android.gms");
|
||||
try {
|
||||
z = context.bindService(intent, googleAdvertisingServiceConnection, 1);
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Couldn't bind to identifier service intent", e);
|
||||
z = false;
|
||||
}
|
||||
try {
|
||||
if (z) {
|
||||
try {
|
||||
GoogleAdvertisingInfo create = GoogleAdvertisingInfo.GoogleAdvertisingInfoBinder.create(googleAdvertisingServiceConnection.getBinder());
|
||||
this.advertisingIdentifier = create.getId();
|
||||
this.limitedAdvertisingTracking = create.getEnabled(true);
|
||||
} catch (Exception e2) {
|
||||
DeviceLog.exception("Couldn't get advertising info", e2);
|
||||
if (!z) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!z) {
|
||||
return;
|
||||
}
|
||||
context.unbindService(googleAdvertisingServiceConnection);
|
||||
} catch (Throwable th) {
|
||||
if (z) {
|
||||
context.unbindService(googleAdvertisingServiceConnection);
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getAdvertisingTrackingId() {
|
||||
return getInstance().advertisingIdentifier;
|
||||
}
|
||||
|
||||
private static AdvertisingId getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new AdvertisingId();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static boolean getLimitedAdTracking() {
|
||||
return getInstance().limitedAdvertisingTracking;
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
getInstance().fetchAdvertisingId(context);
|
||||
}
|
||||
}
|
||||
634
sources/com/unity3d/ads/device/Device.java
Normal file
634
sources/com/unity3d/ads/device/Device.java
Normal file
@@ -0,0 +1,634 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ConfigurationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.Signature;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorManager;
|
||||
import android.media.AudioManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.os.SystemClock;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.TelephonyManager;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.metadata.MediationMetaData;
|
||||
import com.unity3d.ads.misc.Utilities;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Device {
|
||||
|
||||
/* renamed from: com.unity3d.ads.device.Device$1, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass1 {
|
||||
static final /* synthetic */ int[] $SwitchMap$com$unity3d$ads$device$Device$MemoryInfoType = new int[MemoryInfoType.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
$SwitchMap$com$unity3d$ads$device$Device$MemoryInfoType[MemoryInfoType.TOTAL_MEMORY.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$unity3d$ads$device$Device$MemoryInfoType[MemoryInfoType.FREE_MEMORY.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum MemoryInfoType {
|
||||
TOTAL_MEMORY,
|
||||
FREE_MEMORY
|
||||
}
|
||||
|
||||
public static String getAdvertisingTrackingId() {
|
||||
return AdvertisingId.getAdvertisingTrackingId();
|
||||
}
|
||||
|
||||
@SuppressLint({"DefaultLocale"})
|
||||
public static String getAndroidId() {
|
||||
try {
|
||||
return Settings.Secure.getString(ClientProperties.getApplicationContext().getContentResolver(), "android_id");
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Problems fetching androidId", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getApiLevel() {
|
||||
return Build.VERSION.SDK_INT;
|
||||
}
|
||||
|
||||
public static String getApkDigest() throws Exception {
|
||||
FileInputStream fileInputStream;
|
||||
FileInputStream fileInputStream2 = null;
|
||||
try {
|
||||
fileInputStream = new FileInputStream(new File(ClientProperties.getApplicationContext().getPackageCodePath()));
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
}
|
||||
try {
|
||||
String Sha256 = Utilities.Sha256(fileInputStream);
|
||||
try {
|
||||
fileInputStream.close();
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
return Sha256;
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
fileInputStream2 = fileInputStream;
|
||||
if (fileInputStream2 != null) {
|
||||
try {
|
||||
fileInputStream2.close();
|
||||
} catch (IOException unused2) {
|
||||
}
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
public static float getBatteryLevel() {
|
||||
Intent registerReceiver;
|
||||
if (ClientProperties.getApplicationContext() == null || (registerReceiver = ClientProperties.getApplicationContext().registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"))) == null) {
|
||||
return -1.0f;
|
||||
}
|
||||
return registerReceiver.getIntExtra("level", -1) / registerReceiver.getIntExtra("scale", -1);
|
||||
}
|
||||
|
||||
public static int getBatteryStatus() {
|
||||
Intent registerReceiver;
|
||||
if (ClientProperties.getApplicationContext() == null || (registerReceiver = ClientProperties.getApplicationContext().registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"))) == null) {
|
||||
return -1;
|
||||
}
|
||||
return registerReceiver.getIntExtra(FileDownloadModel.STATUS, -1);
|
||||
}
|
||||
|
||||
public static String getBoard() {
|
||||
return Build.BOARD;
|
||||
}
|
||||
|
||||
public static String getBootloader() {
|
||||
return Build.BOOTLOADER;
|
||||
}
|
||||
|
||||
public static String getBrand() {
|
||||
return Build.BRAND;
|
||||
}
|
||||
|
||||
public static String getBuildId() {
|
||||
return Build.ID;
|
||||
}
|
||||
|
||||
public static String getBuildVersionIncremental() {
|
||||
return Build.VERSION.INCREMENTAL;
|
||||
}
|
||||
|
||||
public static long getCPUCount() {
|
||||
return Runtime.getRuntime().availableProcessors();
|
||||
}
|
||||
|
||||
public static String getCertificateFingerprint() {
|
||||
try {
|
||||
Signature[] signatureArr = ClientProperties.getApplicationContext().getPackageManager().getPackageInfo(ClientProperties.getApplicationContext().getPackageName(), 64).signatures;
|
||||
if (signatureArr == null || signatureArr.length < 1) {
|
||||
return null;
|
||||
}
|
||||
return Utilities.toHexString(MessageDigest.getInstance("SHA-1").digest(((X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(signatureArr[0].toByteArray()))).getEncoded()));
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Exception when signing certificate fingerprint", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDevice() {
|
||||
return Build.DEVICE;
|
||||
}
|
||||
|
||||
public static long getElapsedRealtime() {
|
||||
return SystemClock.elapsedRealtime();
|
||||
}
|
||||
|
||||
public static String getFingerprint() {
|
||||
return Build.FINGERPRINT;
|
||||
}
|
||||
|
||||
public static long getFreeMemory() {
|
||||
return getMemoryInfo(MemoryInfoType.FREE_MEMORY);
|
||||
}
|
||||
|
||||
public static long getFreeSpace(File file) {
|
||||
if (file == null || !file.exists()) {
|
||||
return -1L;
|
||||
}
|
||||
return Math.round(file.getFreeSpace() / 1024);
|
||||
}
|
||||
|
||||
public static String getGLVersion() {
|
||||
ActivityManager activityManager;
|
||||
ConfigurationInfo deviceConfigurationInfo;
|
||||
if (ClientProperties.getApplicationContext() == null || (activityManager = (ActivityManager) ClientProperties.getApplicationContext().getSystemService("activity")) == null || (deviceConfigurationInfo = activityManager.getDeviceConfigurationInfo()) == null) {
|
||||
return null;
|
||||
}
|
||||
return deviceConfigurationInfo.getGlEsVersion();
|
||||
}
|
||||
|
||||
public static String getHardware() {
|
||||
return Build.HARDWARE;
|
||||
}
|
||||
|
||||
public static String getHost() {
|
||||
return Build.HOST;
|
||||
}
|
||||
|
||||
public static List<Map<String, Object>> getInstalledPackages(boolean z) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
PackageManager packageManager = ClientProperties.getApplicationContext().getPackageManager();
|
||||
for (PackageInfo packageInfo : packageManager.getInstalledPackages(0)) {
|
||||
HashMap hashMap = new HashMap();
|
||||
if (z) {
|
||||
hashMap.put(MediationMetaData.KEY_NAME, Utilities.Sha256(packageInfo.packageName));
|
||||
} else {
|
||||
hashMap.put(MediationMetaData.KEY_NAME, packageInfo.packageName);
|
||||
}
|
||||
long j = packageInfo.firstInstallTime;
|
||||
if (j > 0) {
|
||||
hashMap.put("time", Long.valueOf(j));
|
||||
}
|
||||
String installerPackageName = packageManager.getInstallerPackageName(packageInfo.packageName);
|
||||
if (installerPackageName != null && !installerPackageName.isEmpty()) {
|
||||
hashMap.put("installer", installerPackageName);
|
||||
}
|
||||
arrayList.add(hashMap);
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public static String getManufacturer() {
|
||||
return Build.MANUFACTURER;
|
||||
}
|
||||
|
||||
private static long getMemoryInfo(MemoryInfoType memoryInfoType) {
|
||||
int i = AnonymousClass1.$SwitchMap$com$unity3d$ads$device$Device$MemoryInfoType[memoryInfoType.ordinal()];
|
||||
int i2 = 2;
|
||||
if (i == 1) {
|
||||
i2 = 1;
|
||||
} else if (i != 2) {
|
||||
i2 = -1;
|
||||
}
|
||||
RandomAccessFile randomAccessFile = null;
|
||||
String str = null;
|
||||
RandomAccessFile randomAccessFile2 = null;
|
||||
try {
|
||||
try {
|
||||
RandomAccessFile randomAccessFile3 = new RandomAccessFile("/proc/meminfo", "r");
|
||||
for (int i3 = 0; i3 < i2; i3++) {
|
||||
try {
|
||||
str = randomAccessFile3.readLine();
|
||||
} catch (IOException e) {
|
||||
e = e;
|
||||
randomAccessFile = randomAccessFile3;
|
||||
DeviceLog.exception("Error while reading memory info: " + memoryInfoType, e);
|
||||
try {
|
||||
randomAccessFile.close();
|
||||
return -1L;
|
||||
} catch (IOException e2) {
|
||||
DeviceLog.exception("Error closing RandomAccessFile", e2);
|
||||
return -1L;
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
randomAccessFile2 = randomAccessFile3;
|
||||
try {
|
||||
randomAccessFile2.close();
|
||||
} catch (IOException e3) {
|
||||
DeviceLog.exception("Error closing RandomAccessFile", e3);
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
long memoryValueFromString = getMemoryValueFromString(str);
|
||||
try {
|
||||
randomAccessFile3.close();
|
||||
} catch (IOException e4) {
|
||||
DeviceLog.exception("Error closing RandomAccessFile", e4);
|
||||
}
|
||||
return memoryValueFromString;
|
||||
} catch (IOException e5) {
|
||||
e = e5;
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
}
|
||||
}
|
||||
|
||||
private static long getMemoryValueFromString(String str) {
|
||||
if (str == null) {
|
||||
return -1L;
|
||||
}
|
||||
Matcher matcher = Pattern.compile("(\\d+)").matcher(str);
|
||||
String str2 = "";
|
||||
while (matcher.find()) {
|
||||
str2 = matcher.group(1);
|
||||
}
|
||||
return Long.parseLong(str2);
|
||||
}
|
||||
|
||||
public static String getModel() {
|
||||
return Build.MODEL;
|
||||
}
|
||||
|
||||
public static boolean getNetworkMetered() {
|
||||
ConnectivityManager connectivityManager;
|
||||
if (ClientProperties.getApplicationContext() == null || Build.VERSION.SDK_INT < 16 || (connectivityManager = (ConnectivityManager) ClientProperties.getApplicationContext().getSystemService("connectivity")) == null) {
|
||||
return false;
|
||||
}
|
||||
return connectivityManager.isActiveNetworkMetered();
|
||||
}
|
||||
|
||||
public static String getNetworkOperator() {
|
||||
return ClientProperties.getApplicationContext() != null ? ((TelephonyManager) ClientProperties.getApplicationContext().getSystemService("phone")).getNetworkOperator() : "";
|
||||
}
|
||||
|
||||
public static String getNetworkOperatorName() {
|
||||
return ClientProperties.getApplicationContext() != null ? ((TelephonyManager) ClientProperties.getApplicationContext().getSystemService("phone")).getNetworkOperatorName() : "";
|
||||
}
|
||||
|
||||
public static int getNetworkType() {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
return ((TelephonyManager) ClientProperties.getApplicationContext().getSystemService("phone")).getNetworkType();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
private static ArrayList<String> getNewAbiList() {
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
arrayList.addAll(Arrays.asList(Build.SUPPORTED_ABIS));
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private static ArrayList<String> getOldAbiList() {
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
arrayList.add(Build.CPU_ABI);
|
||||
arrayList.add(Build.CPU_ABI2);
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public static String getOsVersion() {
|
||||
return Build.VERSION.RELEASE;
|
||||
}
|
||||
|
||||
/* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:49:0x0021 -> B:7:0x0034). Please report as a decompilation issue!!! */
|
||||
public static Map<String, String> getProcessInfo() {
|
||||
RandomAccessFile randomAccessFile;
|
||||
IOException e;
|
||||
RandomAccessFile randomAccessFile2;
|
||||
HashMap hashMap = new HashMap();
|
||||
try {
|
||||
try {
|
||||
randomAccessFile = new RandomAccessFile("/proc/self/stat", "r");
|
||||
} catch (IOException e2) {
|
||||
randomAccessFile = null;
|
||||
e = e2;
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
randomAccessFile = null;
|
||||
try {
|
||||
randomAccessFile.close();
|
||||
} catch (IOException e3) {
|
||||
DeviceLog.exception("Error closing RandomAccessFile", e3);
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
} catch (IOException e4) {
|
||||
DeviceLog.exception("Error closing RandomAccessFile", e4);
|
||||
}
|
||||
try {
|
||||
try {
|
||||
hashMap.put("stat", randomAccessFile.readLine());
|
||||
randomAccessFile.close();
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
randomAccessFile.close();
|
||||
throw th;
|
||||
}
|
||||
} catch (IOException e5) {
|
||||
e = e5;
|
||||
DeviceLog.exception("Error while reading processor info: ", e);
|
||||
randomAccessFile.close();
|
||||
try {
|
||||
try {
|
||||
randomAccessFile2 = new RandomAccessFile("/proc/uptime", "r");
|
||||
try {
|
||||
hashMap.put("uptime", randomAccessFile2.readLine());
|
||||
randomAccessFile2.close();
|
||||
} catch (IOException e6) {
|
||||
e = e6;
|
||||
randomAccessFile = randomAccessFile2;
|
||||
DeviceLog.exception("Error while reading processor info: ", e);
|
||||
randomAccessFile.close();
|
||||
return hashMap;
|
||||
} catch (Throwable th3) {
|
||||
th = th3;
|
||||
randomAccessFile = randomAccessFile2;
|
||||
try {
|
||||
randomAccessFile.close();
|
||||
} catch (IOException e7) {
|
||||
DeviceLog.exception("Error closing RandomAccessFile", e7);
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
} catch (Throwable th4) {
|
||||
th = th4;
|
||||
}
|
||||
} catch (IOException e8) {
|
||||
e = e8;
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
try {
|
||||
randomAccessFile2 = new RandomAccessFile("/proc/uptime", "r");
|
||||
hashMap.put("uptime", randomAccessFile2.readLine());
|
||||
randomAccessFile2.close();
|
||||
} catch (IOException e9) {
|
||||
DeviceLog.exception("Error closing RandomAccessFile", e9);
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
public static String getProduct() {
|
||||
return Build.PRODUCT;
|
||||
}
|
||||
|
||||
public static int getRingerMode() {
|
||||
if (ClientProperties.getApplicationContext() == null) {
|
||||
return -1;
|
||||
}
|
||||
AudioManager audioManager = (AudioManager) ClientProperties.getApplicationContext().getSystemService("audio");
|
||||
if (audioManager != null) {
|
||||
return audioManager.getRingerMode();
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
|
||||
public static int getScreenBrightness() {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
return Settings.System.getInt(ClientProperties.getApplicationContext().getContentResolver(), "screen_brightness", -1);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getScreenDensity() {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
return ClientProperties.getApplicationContext().getResources().getDisplayMetrics().densityDpi;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getScreenHeight() {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
return ClientProperties.getApplicationContext().getResources().getDisplayMetrics().heightPixels;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getScreenLayout() {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
return ClientProperties.getApplicationContext().getResources().getConfiguration().screenLayout;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getScreenWidth() {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
return ClientProperties.getApplicationContext().getResources().getDisplayMetrics().widthPixels;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static List<Sensor> getSensorList() {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
return ((SensorManager) ClientProperties.getApplicationContext().getSystemService("sensor")).getSensorList(-1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getStreamMaxVolume(int i) {
|
||||
if (ClientProperties.getApplicationContext() == null) {
|
||||
return -1;
|
||||
}
|
||||
AudioManager audioManager = (AudioManager) ClientProperties.getApplicationContext().getSystemService("audio");
|
||||
if (audioManager != null) {
|
||||
return audioManager.getStreamMaxVolume(i);
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
|
||||
public static int getStreamVolume(int i) {
|
||||
if (ClientProperties.getApplicationContext() == null) {
|
||||
return -1;
|
||||
}
|
||||
AudioManager audioManager = (AudioManager) ClientProperties.getApplicationContext().getSystemService("audio");
|
||||
if (audioManager != null) {
|
||||
return audioManager.getStreamVolume(i);
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
|
||||
public static ArrayList<String> getSupportedAbis() {
|
||||
return getApiLevel() < 21 ? getOldAbiList() : getNewAbiList();
|
||||
}
|
||||
|
||||
public static String getSystemProperty(String str, String str2) {
|
||||
return str2 != null ? System.getProperty(str, str2) : System.getProperty(str);
|
||||
}
|
||||
|
||||
public static long getTotalMemory() {
|
||||
return getMemoryInfo(MemoryInfoType.TOTAL_MEMORY);
|
||||
}
|
||||
|
||||
public static long getTotalSpace(File file) {
|
||||
if (file == null || !file.exists()) {
|
||||
return -1L;
|
||||
}
|
||||
return Math.round(file.getTotalSpace() / 1024);
|
||||
}
|
||||
|
||||
public static String getUniqueEventId() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public static long getUptime() {
|
||||
return SystemClock.uptimeMillis();
|
||||
}
|
||||
|
||||
public static boolean isActiveNetworkConnected() {
|
||||
ConnectivityManager connectivityManager;
|
||||
NetworkInfo activeNetworkInfo;
|
||||
return (ClientProperties.getApplicationContext() == null || (connectivityManager = (ConnectivityManager) ClientProperties.getApplicationContext().getSystemService("connectivity")) == null || (activeNetworkInfo = connectivityManager.getActiveNetworkInfo()) == null || !activeNetworkInfo.isConnected()) ? false : true;
|
||||
}
|
||||
|
||||
public static Boolean isAdbEnabled() {
|
||||
return getApiLevel() < 17 ? oldAdbStatus() : newAdbStatus();
|
||||
}
|
||||
|
||||
public static boolean isAppInstalled(String str) {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
try {
|
||||
PackageInfo packageInfo = ClientProperties.getApplicationContext().getPackageManager().getPackageInfo(str, 0);
|
||||
if (packageInfo != null && packageInfo.packageName != null) {
|
||||
if (str.equals(packageInfo.packageName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException unused) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isLimitAdTrackingEnabled() {
|
||||
return AdvertisingId.getLimitedAdTracking();
|
||||
}
|
||||
|
||||
public static boolean isRooted() {
|
||||
try {
|
||||
return searchPathForBinary("su");
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Rooted check failed", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isUSBConnected() {
|
||||
Intent registerReceiver;
|
||||
if (ClientProperties.getApplicationContext() == null || (registerReceiver = ClientProperties.getApplicationContext().registerReceiver(null, new IntentFilter("android.hardware.usb.action.USB_STATE"))) == null) {
|
||||
return false;
|
||||
}
|
||||
return registerReceiver.getBooleanExtra("connected", false);
|
||||
}
|
||||
|
||||
public static boolean isUsingWifi() {
|
||||
ConnectivityManager connectivityManager;
|
||||
if (ClientProperties.getApplicationContext() == null || (connectivityManager = (ConnectivityManager) ClientProperties.getApplicationContext().getSystemService("connectivity")) == null) {
|
||||
return false;
|
||||
}
|
||||
TelephonyManager telephonyManager = (TelephonyManager) ClientProperties.getApplicationContext().getSystemService("phone");
|
||||
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
||||
return activeNetworkInfo != null && connectivityManager.getBackgroundDataSetting() && connectivityManager.getActiveNetworkInfo().isConnected() && telephonyManager != null && activeNetworkInfo.getType() == 1 && activeNetworkInfo.isConnected();
|
||||
}
|
||||
|
||||
public static boolean isWiredHeadsetOn() {
|
||||
if (ClientProperties.getApplicationContext() != null) {
|
||||
return ((AudioManager) ClientProperties.getApplicationContext().getSystemService("audio")).isWiredHeadsetOn();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@TargetApi(17)
|
||||
private static Boolean newAdbStatus() {
|
||||
try {
|
||||
boolean z = true;
|
||||
if (1 != Settings.Global.getInt(ClientProperties.getApplicationContext().getContentResolver(), "adb_enabled", 0)) {
|
||||
z = false;
|
||||
}
|
||||
return Boolean.valueOf(z);
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Problems fetching adb enabled status", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Boolean oldAdbStatus() {
|
||||
try {
|
||||
boolean z = true;
|
||||
if (1 != Settings.Secure.getInt(ClientProperties.getApplicationContext().getContentResolver(), "adb_enabled", 0)) {
|
||||
z = false;
|
||||
}
|
||||
return Boolean.valueOf(z);
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Problems fetching adb enabled status", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean searchPathForBinary(String str) {
|
||||
File[] listFiles;
|
||||
for (String str2 : System.getenv("PATH").split(":")) {
|
||||
File file = new File(str2);
|
||||
if (file.exists() && file.isDirectory() && (listFiles = file.listFiles()) != null) {
|
||||
for (File file2 : listFiles) {
|
||||
if (file2.getName().equals(str)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
15
sources/com/unity3d/ads/device/DeviceError.java
Normal file
15
sources/com/unity3d/ads/device/DeviceError.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum DeviceError {
|
||||
APPLICATION_CONTEXT_NULL,
|
||||
APPLICATION_INFO_NOT_AVAILABLE,
|
||||
AUDIOMANAGER_NULL,
|
||||
INVALID_STORAGETYPE,
|
||||
COULDNT_GET_STORAGE_LOCATION,
|
||||
COULDNT_GET_GL_VERSION,
|
||||
JSON_ERROR,
|
||||
COULDNT_GET_DIGEST,
|
||||
COULDNT_GET_FINGERPRINT,
|
||||
COULDNT_GET_ADB_STATUS
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface IVolumeChangeListener {
|
||||
int getStreamType();
|
||||
|
||||
void onVolumeChanged(int i);
|
||||
}
|
||||
68
sources/com/unity3d/ads/device/Storage.java
Normal file
68
sources/com/unity3d/ads/device/Storage.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
import com.unity3d.ads.device.StorageManager;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.misc.JsonStorage;
|
||||
import com.unity3d.ads.misc.Utilities;
|
||||
import com.unity3d.ads.webview.WebViewApp;
|
||||
import com.unity3d.ads.webview.WebViewEventCategory;
|
||||
import java.io.File;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Storage extends JsonStorage {
|
||||
private String _targetFileName;
|
||||
private StorageManager.StorageType _type;
|
||||
|
||||
public Storage(String str, StorageManager.StorageType storageType) {
|
||||
this._targetFileName = str;
|
||||
this._type = storageType;
|
||||
}
|
||||
|
||||
public synchronized boolean clearStorage() {
|
||||
clearData();
|
||||
return new File(this._targetFileName).delete();
|
||||
}
|
||||
|
||||
public StorageManager.StorageType getType() {
|
||||
return this._type;
|
||||
}
|
||||
|
||||
public synchronized boolean initStorage() {
|
||||
readStorage();
|
||||
super.initData();
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized boolean readStorage() {
|
||||
File file = new File(this._targetFileName);
|
||||
if (Utilities.readFile(file) == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
setData(new JSONObject(Utilities.readFile(file)));
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error creating storage JSON", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void sendEvent(StorageEvent storageEvent, Object obj) {
|
||||
if (!(WebViewApp.getCurrentApp() != null ? WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.STORAGE, storageEvent, this._type.name(), obj) : false)) {
|
||||
DeviceLog.debug("Couldn't send storage event to WebApp");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized boolean storageFileExists() {
|
||||
return new File(this._targetFileName).exists();
|
||||
}
|
||||
|
||||
public synchronized boolean writeStorage() {
|
||||
File file = new File(this._targetFileName);
|
||||
if (getData() == null) {
|
||||
return false;
|
||||
}
|
||||
return Utilities.writeFile(file, getData().toString());
|
||||
}
|
||||
}
|
||||
11
sources/com/unity3d/ads/device/StorageError.java
Normal file
11
sources/com/unity3d/ads/device/StorageError.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum StorageError {
|
||||
COULDNT_SET_VALUE,
|
||||
COULDNT_GET_VALUE,
|
||||
COULDNT_WRITE_STORAGE_TO_CACHE,
|
||||
COULDNT_CLEAR_STORAGE,
|
||||
COULDNT_GET_STORAGE,
|
||||
COULDNT_DELETE_VALUE
|
||||
}
|
||||
11
sources/com/unity3d/ads/device/StorageEvent.java
Normal file
11
sources/com/unity3d/ads/device/StorageEvent.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum StorageEvent {
|
||||
SET,
|
||||
DELETE,
|
||||
CLEAR,
|
||||
WRITE,
|
||||
READ,
|
||||
INIT
|
||||
}
|
||||
108
sources/com/unity3d/ads/device/StorageManager.java
Normal file
108
sources/com/unity3d/ads/device/StorageManager.java
Normal file
@@ -0,0 +1,108 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
import android.content.Context;
|
||||
import com.unity3d.ads.properties.SdkProperties;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class StorageManager {
|
||||
protected static final Map<StorageType, String> _storageFileMap = new HashMap();
|
||||
protected static final List<Storage> _storages = new ArrayList();
|
||||
|
||||
public enum StorageType {
|
||||
PRIVATE,
|
||||
PUBLIC
|
||||
}
|
||||
|
||||
public static synchronized void addStorageLocation(StorageType storageType, String str) {
|
||||
synchronized (StorageManager.class) {
|
||||
if (!_storageFileMap.containsKey(storageType)) {
|
||||
_storageFileMap.put(storageType, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Storage getStorage(StorageType storageType) {
|
||||
List<Storage> list = _storages;
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
for (Storage storage : list) {
|
||||
if (storage.getType().equals(storageType)) {
|
||||
return storage;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean hasStorage(StorageType storageType) {
|
||||
List<Storage> list = _storages;
|
||||
if (list == null) {
|
||||
return false;
|
||||
}
|
||||
Iterator<Storage> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (it.next().getType().equals(storageType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean init(Context context) {
|
||||
File filesDir;
|
||||
if (context == null || (filesDir = context.getFilesDir()) == null) {
|
||||
return false;
|
||||
}
|
||||
addStorageLocation(StorageType.PUBLIC, filesDir + "/" + SdkProperties.getLocalStorageFilePrefix() + "public-data.json");
|
||||
if (!setupStorage(StorageType.PUBLIC)) {
|
||||
return false;
|
||||
}
|
||||
addStorageLocation(StorageType.PRIVATE, filesDir + "/" + SdkProperties.getLocalStorageFilePrefix() + "private-data.json");
|
||||
return setupStorage(StorageType.PRIVATE);
|
||||
}
|
||||
|
||||
public static void initStorage(StorageType storageType) {
|
||||
if (hasStorage(storageType)) {
|
||||
Storage storage = getStorage(storageType);
|
||||
if (storage != null) {
|
||||
storage.initStorage();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (_storageFileMap.containsKey(storageType)) {
|
||||
Storage storage2 = new Storage(_storageFileMap.get(storageType), storageType);
|
||||
storage2.initStorage();
|
||||
_storages.add(storage2);
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void removeStorage(StorageType storageType) {
|
||||
synchronized (StorageManager.class) {
|
||||
if (getStorage(storageType) != null) {
|
||||
_storages.remove(getStorage(storageType));
|
||||
}
|
||||
if (_storageFileMap != null) {
|
||||
_storageFileMap.remove(storageType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean setupStorage(StorageType storageType) {
|
||||
if (hasStorage(storageType)) {
|
||||
return true;
|
||||
}
|
||||
initStorage(storageType);
|
||||
Storage storage = getStorage(storageType);
|
||||
if (storage != null && !storage.storageFileExists()) {
|
||||
storage.writeStorage();
|
||||
}
|
||||
return storage != null;
|
||||
}
|
||||
}
|
||||
93
sources/com/unity3d/ads/device/VolumeChange.java
Normal file
93
sources/com/unity3d/ads/device/VolumeChange.java
Normal file
@@ -0,0 +1,93 @@
|
||||
package com.unity3d.ads.device;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class VolumeChange {
|
||||
private static ContentObserver _contentObserver;
|
||||
private static ArrayList<IVolumeChangeListener> _listeners;
|
||||
|
||||
public static void clearAllListeners() {
|
||||
ArrayList<IVolumeChangeListener> arrayList = _listeners;
|
||||
if (arrayList != null) {
|
||||
arrayList.clear();
|
||||
}
|
||||
stopObservering();
|
||||
_listeners = null;
|
||||
}
|
||||
|
||||
public static void registerListener(IVolumeChangeListener iVolumeChangeListener) {
|
||||
if (_listeners == null) {
|
||||
_listeners = new ArrayList<>();
|
||||
}
|
||||
if (_listeners.contains(iVolumeChangeListener)) {
|
||||
return;
|
||||
}
|
||||
startObserving();
|
||||
_listeners.add(iVolumeChangeListener);
|
||||
}
|
||||
|
||||
public static void startObserving() {
|
||||
ContentResolver contentResolver;
|
||||
if (_contentObserver == null) {
|
||||
_contentObserver = new ContentObserver(new Handler(Looper.getMainLooper())) { // from class: com.unity3d.ads.device.VolumeChange.1
|
||||
@Override // android.database.ContentObserver
|
||||
public boolean deliverSelfNotifications() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // android.database.ContentObserver
|
||||
public void onChange(boolean z, Uri uri) {
|
||||
VolumeChange.triggerListeners();
|
||||
}
|
||||
};
|
||||
Context applicationContext = ClientProperties.getApplicationContext();
|
||||
if (applicationContext == null || (contentResolver = applicationContext.getContentResolver()) == null) {
|
||||
return;
|
||||
}
|
||||
contentResolver.registerContentObserver(Settings.System.CONTENT_URI, true, _contentObserver);
|
||||
}
|
||||
}
|
||||
|
||||
public static void stopObservering() {
|
||||
ContentResolver contentResolver;
|
||||
if (_contentObserver != null) {
|
||||
Context applicationContext = ClientProperties.getApplicationContext();
|
||||
if (applicationContext != null && (contentResolver = applicationContext.getContentResolver()) != null) {
|
||||
contentResolver.unregisterContentObserver(_contentObserver);
|
||||
}
|
||||
_contentObserver = null;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static void triggerListeners() {
|
||||
ArrayList<IVolumeChangeListener> arrayList = _listeners;
|
||||
if (arrayList != null) {
|
||||
Iterator<IVolumeChangeListener> it = arrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
IVolumeChangeListener next = it.next();
|
||||
next.onVolumeChanged(Device.getStreamVolume(next.getStreamType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void unregisterListener(IVolumeChangeListener iVolumeChangeListener) {
|
||||
if (_listeners.contains(iVolumeChangeListener)) {
|
||||
_listeners.remove(iVolumeChangeListener);
|
||||
}
|
||||
ArrayList<IVolumeChangeListener> arrayList = _listeners;
|
||||
if (arrayList == null || arrayList.size() == 0) {
|
||||
stopObservering();
|
||||
}
|
||||
}
|
||||
}
|
||||
8
sources/com/unity3d/ads/lifecycle/LifecycleError.java
Normal file
8
sources/com/unity3d/ads/lifecycle/LifecycleError.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.unity3d.ads.lifecycle;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum LifecycleError {
|
||||
APPLICATION_NULL,
|
||||
LISTENER_NOT_NULL,
|
||||
JSON_ERROR
|
||||
}
|
||||
12
sources/com/unity3d/ads/lifecycle/LifecycleEvent.java
Normal file
12
sources/com/unity3d/ads/lifecycle/LifecycleEvent.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.unity3d.ads.lifecycle;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum LifecycleEvent {
|
||||
CREATED,
|
||||
STARTED,
|
||||
RESUMED,
|
||||
PAUSED,
|
||||
STOPPED,
|
||||
SAVE_INSTANCE_STATE,
|
||||
DESTROYED
|
||||
}
|
||||
75
sources/com/unity3d/ads/lifecycle/LifecycleListener.java
Normal file
75
sources/com/unity3d/ads/lifecycle/LifecycleListener.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package com.unity3d.ads.lifecycle;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.os.Bundle;
|
||||
import com.unity3d.ads.webview.WebViewApp;
|
||||
import com.unity3d.ads.webview.WebViewEventCategory;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@TargetApi(14)
|
||||
/* loaded from: classes2.dex */
|
||||
public class LifecycleListener implements Application.ActivityLifecycleCallbacks {
|
||||
private ArrayList<String> _events;
|
||||
|
||||
public LifecycleListener(ArrayList<String> arrayList) {
|
||||
this._events = arrayList;
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityCreated(Activity activity, Bundle bundle) {
|
||||
if (!this._events.contains("onActivityCreated") || WebViewApp.getCurrentApp() == null) {
|
||||
return;
|
||||
}
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.LIFECYCLE, LifecycleEvent.CREATED, activity.getClass().getName());
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
if (!this._events.contains("onActivityDestroyed") || WebViewApp.getCurrentApp() == null) {
|
||||
return;
|
||||
}
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.LIFECYCLE, LifecycleEvent.DESTROYED, activity.getClass().getName());
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityPaused(Activity activity) {
|
||||
if (!this._events.contains("onActivityPaused") || WebViewApp.getCurrentApp() == null) {
|
||||
return;
|
||||
}
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.LIFECYCLE, LifecycleEvent.PAUSED, activity.getClass().getName());
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityResumed(Activity activity) {
|
||||
if (!this._events.contains("onActivityResumed") || WebViewApp.getCurrentApp() == null) {
|
||||
return;
|
||||
}
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.LIFECYCLE, LifecycleEvent.RESUMED, activity.getClass().getName());
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
|
||||
if (!this._events.contains("onActivitySaveInstanceState") || WebViewApp.getCurrentApp() == null) {
|
||||
return;
|
||||
}
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.LIFECYCLE, LifecycleEvent.SAVE_INSTANCE_STATE, activity.getClass().getName());
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityStarted(Activity activity) {
|
||||
if (!this._events.contains("onActivityStarted") || WebViewApp.getCurrentApp() == null) {
|
||||
return;
|
||||
}
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.LIFECYCLE, LifecycleEvent.STARTED, activity.getClass().getName());
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityStopped(Activity activity) {
|
||||
if (!this._events.contains("onActivityStopped") || WebViewApp.getCurrentApp() == null) {
|
||||
return;
|
||||
}
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.LIFECYCLE, LifecycleEvent.STOPPED, activity.getClass().getName());
|
||||
}
|
||||
}
|
||||
222
sources/com/unity3d/ads/log/DeviceLog.java
Normal file
222
sources/com/unity3d/ads/log/DeviceLog.java
Normal file
@@ -0,0 +1,222 @@
|
||||
package com.unity3d.ads.log;
|
||||
|
||||
import android.util.Log;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class DeviceLog {
|
||||
private static boolean FORCE_DEBUG_LOG = false;
|
||||
public static final int LOGLEVEL_DEBUG = 8;
|
||||
private static final int LOGLEVEL_ERROR = 1;
|
||||
public static final int LOGLEVEL_INFO = 4;
|
||||
private static final int LOGLEVEL_WARNING = 2;
|
||||
private static boolean LOG_DEBUG = true;
|
||||
private static boolean LOG_ERROR = true;
|
||||
private static boolean LOG_INFO = true;
|
||||
private static boolean LOG_WARNING = true;
|
||||
private static final int MAX_DEBUG_MSG_LENGTH = 3072;
|
||||
private static final HashMap<UnityAdsLogLevel, DeviceLogLevel> _deviceLogLevel = new HashMap<>();
|
||||
|
||||
/* renamed from: com.unity3d.ads.log.DeviceLog$1, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass1 {
|
||||
static final /* synthetic */ int[] $SwitchMap$com$unity3d$ads$log$DeviceLog$UnityAdsLogLevel = new int[UnityAdsLogLevel.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
$SwitchMap$com$unity3d$ads$log$DeviceLog$UnityAdsLogLevel[UnityAdsLogLevel.INFO.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$unity3d$ads$log$DeviceLog$UnityAdsLogLevel[UnityAdsLogLevel.DEBUG.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$unity3d$ads$log$DeviceLog$UnityAdsLogLevel[UnityAdsLogLevel.WARNING.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError unused3) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$unity3d$ads$log$DeviceLog$UnityAdsLogLevel[UnityAdsLogLevel.ERROR.ordinal()] = 4;
|
||||
} catch (NoSuchFieldError unused4) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum UnityAdsLogLevel {
|
||||
INFO,
|
||||
DEBUG,
|
||||
WARNING,
|
||||
ERROR
|
||||
}
|
||||
|
||||
static {
|
||||
if (_deviceLogLevel.size() == 0) {
|
||||
_deviceLogLevel.put(UnityAdsLogLevel.INFO, new DeviceLogLevel("i"));
|
||||
_deviceLogLevel.put(UnityAdsLogLevel.DEBUG, new DeviceLogLevel("d"));
|
||||
_deviceLogLevel.put(UnityAdsLogLevel.WARNING, new DeviceLogLevel("w"));
|
||||
_deviceLogLevel.put(UnityAdsLogLevel.ERROR, new DeviceLogLevel("e"));
|
||||
}
|
||||
if (new File("/data/local/tmp/UnityAdsForceDebugMode").exists()) {
|
||||
FORCE_DEBUG_LOG = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static String checkMessage(String str) {
|
||||
return (str == null || str.length() == 0) ? "DO NOT USE EMPTY MESSAGES, use DeviceLog.entered() instead" : str;
|
||||
}
|
||||
|
||||
private static DeviceLogEntry createLogEntry(UnityAdsLogLevel unityAdsLogLevel, String str) {
|
||||
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||
DeviceLogLevel logLevel = getLogLevel(unityAdsLogLevel);
|
||||
if (logLevel == null) {
|
||||
return null;
|
||||
}
|
||||
int i = 0;
|
||||
boolean z = false;
|
||||
while (i < stackTrace.length) {
|
||||
StackTraceElement stackTraceElement = stackTrace[i];
|
||||
if (stackTraceElement.getClassName().equals(DeviceLog.class.getName())) {
|
||||
z = true;
|
||||
}
|
||||
if (!stackTraceElement.getClassName().equals(DeviceLog.class.getName()) && z) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
StackTraceElement stackTraceElement2 = i < stackTrace.length ? stackTrace[i] : null;
|
||||
if (stackTraceElement2 != null) {
|
||||
return new DeviceLogEntry(logLevel, str, stackTraceElement2);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void debug(String str) {
|
||||
if (LOG_DEBUG || FORCE_DEBUG_LOG) {
|
||||
if (str.length() <= MAX_DEBUG_MSG_LENGTH) {
|
||||
write(UnityAdsLogLevel.DEBUG, checkMessage(str));
|
||||
return;
|
||||
}
|
||||
debug(str.substring(0, MAX_DEBUG_MSG_LENGTH));
|
||||
if (str.length() < 30720) {
|
||||
debug(str.substring(MAX_DEBUG_MSG_LENGTH));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void entered() {
|
||||
debug("ENTERED METHOD");
|
||||
}
|
||||
|
||||
public static void error(String str) {
|
||||
write(UnityAdsLogLevel.ERROR, checkMessage(str));
|
||||
}
|
||||
|
||||
public static void exception(String str, Exception exc) {
|
||||
String str2 = "";
|
||||
if (str != null) {
|
||||
str2 = "" + str;
|
||||
}
|
||||
if (exc != null) {
|
||||
str2 = str2 + ": " + exc.getMessage();
|
||||
}
|
||||
if (exc != null && exc.getCause() != null) {
|
||||
str2 = str2 + ": " + exc.getCause().getMessage();
|
||||
}
|
||||
write(UnityAdsLogLevel.ERROR, str2);
|
||||
}
|
||||
|
||||
private static DeviceLogLevel getLogLevel(UnityAdsLogLevel unityAdsLogLevel) {
|
||||
return _deviceLogLevel.get(unityAdsLogLevel);
|
||||
}
|
||||
|
||||
public static void info(String str) {
|
||||
write(UnityAdsLogLevel.INFO, checkMessage(str));
|
||||
}
|
||||
|
||||
public static void setLogLevel(int i) {
|
||||
if (i >= 8) {
|
||||
LOG_ERROR = true;
|
||||
LOG_WARNING = true;
|
||||
LOG_INFO = true;
|
||||
LOG_DEBUG = true;
|
||||
return;
|
||||
}
|
||||
if (i >= 4) {
|
||||
LOG_ERROR = true;
|
||||
LOG_WARNING = true;
|
||||
LOG_INFO = true;
|
||||
LOG_DEBUG = false;
|
||||
return;
|
||||
}
|
||||
if (i >= 2) {
|
||||
LOG_ERROR = true;
|
||||
LOG_WARNING = true;
|
||||
LOG_INFO = false;
|
||||
LOG_DEBUG = false;
|
||||
return;
|
||||
}
|
||||
if (i >= 1) {
|
||||
LOG_ERROR = true;
|
||||
LOG_WARNING = false;
|
||||
LOG_INFO = false;
|
||||
LOG_DEBUG = false;
|
||||
return;
|
||||
}
|
||||
LOG_ERROR = false;
|
||||
LOG_WARNING = false;
|
||||
LOG_INFO = false;
|
||||
LOG_DEBUG = false;
|
||||
}
|
||||
|
||||
public static void warning(String str) {
|
||||
write(UnityAdsLogLevel.WARNING, checkMessage(str));
|
||||
}
|
||||
|
||||
private static void write(UnityAdsLogLevel unityAdsLogLevel, String str) {
|
||||
int i = AnonymousClass1.$SwitchMap$com$unity3d$ads$log$DeviceLog$UnityAdsLogLevel[unityAdsLogLevel.ordinal()];
|
||||
boolean z = i != 1 ? i != 2 ? i != 3 ? i != 4 ? true : LOG_ERROR : LOG_WARNING : LOG_DEBUG : LOG_INFO;
|
||||
if (FORCE_DEBUG_LOG) {
|
||||
z = true;
|
||||
}
|
||||
if (z) {
|
||||
writeToLog(createLogEntry(unityAdsLogLevel, str));
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeToLog(DeviceLogEntry deviceLogEntry) {
|
||||
Method method;
|
||||
if (deviceLogEntry == null || deviceLogEntry.getLogLevel() == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
method = Log.class.getMethod(deviceLogEntry.getLogLevel().getReceivingMethodName(), String.class, String.class);
|
||||
} catch (Exception e) {
|
||||
Log.e("UnityAds", "Writing to log failed!", e);
|
||||
method = null;
|
||||
}
|
||||
if (method != null) {
|
||||
try {
|
||||
method.invoke(null, deviceLogEntry.getLogLevel().getLogTag(), deviceLogEntry.getParsedMessage());
|
||||
} catch (Exception e2) {
|
||||
Log.e("UnityAds", "Writing to log failed!", e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void error(String str, Object... objArr) {
|
||||
error(String.format(str, objArr));
|
||||
}
|
||||
|
||||
public static void info(String str, Object... objArr) {
|
||||
info(String.format(str, objArr));
|
||||
}
|
||||
|
||||
public static void warning(String str, Object... objArr) {
|
||||
warning(String.format(str, objArr));
|
||||
}
|
||||
|
||||
public static void debug(String str, Object... objArr) {
|
||||
debug(String.format(str, objArr));
|
||||
}
|
||||
}
|
||||
45
sources/com/unity3d/ads/log/DeviceLogEntry.java
Normal file
45
sources/com/unity3d/ads/log/DeviceLogEntry.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.unity3d.ads.log;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class DeviceLogEntry {
|
||||
private DeviceLogLevel _logLevel;
|
||||
private String _originalMessage;
|
||||
private StackTraceElement _stackTraceElement;
|
||||
|
||||
public DeviceLogEntry(DeviceLogLevel deviceLogLevel, String str, StackTraceElement stackTraceElement) {
|
||||
this._logLevel = null;
|
||||
this._originalMessage = null;
|
||||
this._stackTraceElement = null;
|
||||
this._logLevel = deviceLogLevel;
|
||||
this._originalMessage = str;
|
||||
this._stackTraceElement = stackTraceElement;
|
||||
}
|
||||
|
||||
public DeviceLogLevel getLogLevel() {
|
||||
return this._logLevel;
|
||||
}
|
||||
|
||||
public String getParsedMessage() {
|
||||
String str;
|
||||
String str2;
|
||||
int i;
|
||||
String str3 = this._originalMessage;
|
||||
StackTraceElement stackTraceElement = this._stackTraceElement;
|
||||
if (stackTraceElement != null) {
|
||||
str = stackTraceElement.getClassName();
|
||||
str2 = this._stackTraceElement.getMethodName();
|
||||
i = this._stackTraceElement.getLineNumber();
|
||||
} else {
|
||||
str = "UnknownClass";
|
||||
str2 = "unknownMethod";
|
||||
i = -1;
|
||||
}
|
||||
if (str3 != null && !str3.isEmpty()) {
|
||||
str3 = " :: " + str3;
|
||||
}
|
||||
if (str3 == null) {
|
||||
str3 = "";
|
||||
}
|
||||
return str + "." + str2 + "()" + (" (line:" + i + ")") + str3;
|
||||
}
|
||||
}
|
||||
20
sources/com/unity3d/ads/log/DeviceLogLevel.java
Normal file
20
sources/com/unity3d/ads/log/DeviceLogLevel.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.unity3d.ads.log;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class DeviceLogLevel {
|
||||
private static final String LOG_TAG = "UnityAds";
|
||||
private String _receivingMethodName;
|
||||
|
||||
public DeviceLogLevel(String str) {
|
||||
this._receivingMethodName = null;
|
||||
this._receivingMethodName = str;
|
||||
}
|
||||
|
||||
public String getLogTag() {
|
||||
return LOG_TAG;
|
||||
}
|
||||
|
||||
public String getReceivingMethodName() {
|
||||
return this._receivingMethodName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.unity3d.ads.mediation;
|
||||
|
||||
import com.unity3d.ads.IUnityAdsListener;
|
||||
import com.unity3d.ads.UnityAds;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface IUnityAdsExtendedListener extends IUnityAdsListener {
|
||||
void onUnityAdsClick(String str);
|
||||
|
||||
void onUnityAdsPlacementStateChanged(String str, UnityAds.PlacementState placementState, UnityAds.PlacementState placementState2);
|
||||
}
|
||||
99
sources/com/unity3d/ads/metadata/InAppPurchaseMetaData.java
Normal file
99
sources/com/unity3d/ads/metadata/InAppPurchaseMetaData.java
Normal file
@@ -0,0 +1,99 @@
|
||||
package com.unity3d.ads.metadata;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class InAppPurchaseMetaData extends MetaData {
|
||||
public static final String IAP_KEY = "iap";
|
||||
public static final String KEY_CURRENCY = "currency";
|
||||
public static final String KEY_PRICE = "price";
|
||||
public static final String KEY_PRODUCT_ID = "productId";
|
||||
public static final String KEY_RECEIPT_PURCHASE_DATA = "receiptPurchaseData";
|
||||
public static final String KEY_SIGNATURE = "signature";
|
||||
|
||||
public InAppPurchaseMetaData(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:10:0x002a */
|
||||
@Override // com.unity3d.ads.metadata.MetaData
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public void commit() {
|
||||
/*
|
||||
r7 = this;
|
||||
android.content.Context r0 = r7._context
|
||||
boolean r0 = com.unity3d.ads.device.StorageManager.init(r0)
|
||||
if (r0 == 0) goto L55
|
||||
com.unity3d.ads.device.StorageManager$StorageType r0 = com.unity3d.ads.device.StorageManager.StorageType.PUBLIC
|
||||
com.unity3d.ads.device.Storage r0 = com.unity3d.ads.device.StorageManager.getStorage(r0)
|
||||
org.json.JSONObject r1 = r7.getData()
|
||||
if (r1 == 0) goto L5a
|
||||
if (r0 == 0) goto L5a
|
||||
java.lang.String r1 = "iap.purchases"
|
||||
java.lang.Object r2 = r0.get(r1)
|
||||
r3 = 0
|
||||
if (r2 == 0) goto L27
|
||||
org.json.JSONArray r2 = (org.json.JSONArray) r2 // Catch: java.lang.Exception -> L22
|
||||
goto L28
|
||||
L22:
|
||||
java.lang.String r2 = "Invalid object type for purchases"
|
||||
com.unity3d.ads.log.DeviceLog.error(r2)
|
||||
L27:
|
||||
r2 = r3
|
||||
L28:
|
||||
if (r2 != 0) goto L2f
|
||||
org.json.JSONArray r2 = new org.json.JSONArray
|
||||
r2.<init>()
|
||||
L2f:
|
||||
org.json.JSONObject r3 = r7.getData()
|
||||
java.lang.String r4 = "ts"
|
||||
long r5 = java.lang.System.currentTimeMillis() // Catch: org.json.JSONException -> L4f
|
||||
r3.put(r4, r5) // Catch: org.json.JSONException -> L4f
|
||||
r2.put(r3)
|
||||
r0.set(r1, r2)
|
||||
r0.writeStorage()
|
||||
com.unity3d.ads.device.StorageEvent r2 = com.unity3d.ads.device.StorageEvent.SET
|
||||
java.lang.Object r1 = r0.get(r1)
|
||||
r0.sendEvent(r2, r1)
|
||||
goto L5a
|
||||
L4f:
|
||||
java.lang.String r0 = "Error constructing purchase object"
|
||||
com.unity3d.ads.log.DeviceLog.error(r0)
|
||||
return
|
||||
L55:
|
||||
java.lang.String r0 = "Unity Ads could not commit metadata due to storage error or the data is null"
|
||||
com.unity3d.ads.log.DeviceLog.error(r0)
|
||||
L5a:
|
||||
return
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.unity3d.ads.metadata.InAppPurchaseMetaData.commit():void");
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.metadata.MetaData, com.unity3d.ads.misc.JsonStorage
|
||||
public synchronized boolean set(String str, Object obj) {
|
||||
return setRaw(str, obj);
|
||||
}
|
||||
|
||||
public void setCurrency(String str) {
|
||||
set(KEY_CURRENCY, str);
|
||||
}
|
||||
|
||||
public void setPrice(Double d) {
|
||||
set(KEY_PRICE, d);
|
||||
}
|
||||
|
||||
public void setProductId(String str) {
|
||||
set(KEY_PRODUCT_ID, str);
|
||||
}
|
||||
|
||||
public void setReceiptPurchaseData(String str) {
|
||||
set(KEY_RECEIPT_PURCHASE_DATA, str);
|
||||
}
|
||||
|
||||
public void setSignature(String str) {
|
||||
set(KEY_SIGNATURE, str);
|
||||
}
|
||||
}
|
||||
32
sources/com/unity3d/ads/metadata/MediationMetaData.java
Normal file
32
sources/com/unity3d/ads/metadata/MediationMetaData.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.unity3d.ads.metadata;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class MediationMetaData extends MetaData {
|
||||
public static final String KEY_MISSED_IMPRESSION_ORDINAL = "missedImpressionOrdinal";
|
||||
public static final String KEY_NAME = "name";
|
||||
public static final String KEY_ORDINAL = "ordinal";
|
||||
public static final String KEY_VERSION = "version";
|
||||
|
||||
public MediationMetaData(Context context) {
|
||||
super(context);
|
||||
setCategory("mediation");
|
||||
}
|
||||
|
||||
public void setMissedImpressionOrdinal(int i) {
|
||||
set(KEY_MISSED_IMPRESSION_ORDINAL, Integer.valueOf(i));
|
||||
}
|
||||
|
||||
public void setName(String str) {
|
||||
set(KEY_NAME, str);
|
||||
}
|
||||
|
||||
public void setOrdinal(int i) {
|
||||
set(KEY_ORDINAL, Integer.valueOf(i));
|
||||
}
|
||||
|
||||
public void setVersion(String str) {
|
||||
set(KEY_VERSION, str);
|
||||
}
|
||||
}
|
||||
80
sources/com/unity3d/ads/metadata/MetaData.java
Normal file
80
sources/com/unity3d/ads/metadata/MetaData.java
Normal file
@@ -0,0 +1,80 @@
|
||||
package com.unity3d.ads.metadata;
|
||||
|
||||
import android.content.Context;
|
||||
import com.unity3d.ads.device.Storage;
|
||||
import com.unity3d.ads.device.StorageEvent;
|
||||
import com.unity3d.ads.device.StorageManager;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.misc.JsonStorage;
|
||||
import com.unity3d.ads.misc.Utilities;
|
||||
import java.util.Iterator;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class MetaData extends JsonStorage {
|
||||
private String _category;
|
||||
protected Context _context;
|
||||
|
||||
public MetaData(Context context) {
|
||||
this._context = context.getApplicationContext();
|
||||
}
|
||||
|
||||
private String getActualKey(String str) {
|
||||
if (getCategory() == null) {
|
||||
return str;
|
||||
}
|
||||
return getCategory() + "." + str;
|
||||
}
|
||||
|
||||
public void commit() {
|
||||
if (!StorageManager.init(this._context)) {
|
||||
DeviceLog.error("Unity Ads could not commit metadata due to storage error");
|
||||
return;
|
||||
}
|
||||
Storage storage = StorageManager.getStorage(StorageManager.StorageType.PUBLIC);
|
||||
if (getData() == null || storage == null) {
|
||||
return;
|
||||
}
|
||||
Iterator<String> keys = getData().keys();
|
||||
while (keys.hasNext()) {
|
||||
String next = keys.next();
|
||||
Object obj = get(next);
|
||||
if (storage.get(next) != null && (storage.get(next) instanceof JSONObject) && (get(next) instanceof JSONObject)) {
|
||||
try {
|
||||
obj = Utilities.mergeJsonObjects((JSONObject) obj, (JSONObject) storage.get(next));
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Exception merging JSONs", e);
|
||||
}
|
||||
}
|
||||
storage.set(next, obj);
|
||||
}
|
||||
storage.writeStorage();
|
||||
storage.sendEvent(StorageEvent.SET, getData());
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return this._category;
|
||||
}
|
||||
|
||||
@Override // com.unity3d.ads.misc.JsonStorage
|
||||
public synchronized boolean set(String str, Object obj) {
|
||||
boolean z;
|
||||
initData();
|
||||
z = false;
|
||||
if (super.set(getActualKey(str) + ".value", obj)) {
|
||||
if (super.set(getActualKey(str) + ".ts", Long.valueOf(System.currentTimeMillis()))) {
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setCategory(String str) {
|
||||
this._category = str;
|
||||
}
|
||||
|
||||
protected synchronized boolean setRaw(String str, Object obj) {
|
||||
initData();
|
||||
return super.set(getActualKey(str), obj);
|
||||
}
|
||||
}
|
||||
17
sources/com/unity3d/ads/metadata/PlayerMetaData.java
Normal file
17
sources/com/unity3d/ads/metadata/PlayerMetaData.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.unity3d.ads.metadata;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class PlayerMetaData extends MetaData {
|
||||
public static final String KEY_SERVER_ID = "server_id";
|
||||
|
||||
public PlayerMetaData(Context context) {
|
||||
super(context);
|
||||
setCategory("player");
|
||||
}
|
||||
|
||||
public void setServerId(String str) {
|
||||
set(KEY_SERVER_ID, str);
|
||||
}
|
||||
}
|
||||
176
sources/com/unity3d/ads/misc/JsonStorage.java
Normal file
176
sources/com/unity3d/ads/misc/JsonStorage.java
Normal file
@@ -0,0 +1,176 @@
|
||||
package com.unity3d.ads.misc;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class JsonStorage {
|
||||
private JSONObject _data;
|
||||
|
||||
private synchronized void createObjectTree(String str) {
|
||||
String[] split = str.split("\\.");
|
||||
JSONObject jSONObject = this._data;
|
||||
if (str.length() == 0) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
if (jSONObject.has(split[i])) {
|
||||
try {
|
||||
jSONObject = jSONObject.getJSONObject(split[i]);
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Couldn't get existing JSONObject", e);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
jSONObject = jSONObject.put(split[i], new JSONObject()).getJSONObject(split[i]);
|
||||
} catch (Exception e2) {
|
||||
DeviceLog.exception("Couldn't create new JSONObject", e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized Object findObject(String str) {
|
||||
String[] split = str.split("\\.");
|
||||
JSONObject jSONObject = this._data;
|
||||
if (str.length() == 0) {
|
||||
return jSONObject;
|
||||
}
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
if (!jSONObject.has(split[i])) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
jSONObject = jSONObject.getJSONObject(split[i]);
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Couldn't read JSONObject: " + split[i], e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return jSONObject;
|
||||
}
|
||||
|
||||
private synchronized String getParentObjectTreeFor(String str) {
|
||||
ArrayList arrayList;
|
||||
arrayList = new ArrayList(Arrays.asList(str.split("\\.")));
|
||||
arrayList.remove(arrayList.size() - 1);
|
||||
return TextUtils.join(".", arrayList.toArray());
|
||||
}
|
||||
|
||||
public synchronized void clearData() {
|
||||
this._data = null;
|
||||
}
|
||||
|
||||
public synchronized boolean delete(String str) {
|
||||
JSONObject jSONObject;
|
||||
if (this._data == null) {
|
||||
DeviceLog.error("Data is NULL, readStorage probably not called");
|
||||
return false;
|
||||
}
|
||||
String[] split = str.split("\\.");
|
||||
return (!(findObject(getParentObjectTreeFor(str)) instanceof JSONObject) || (jSONObject = (JSONObject) findObject(getParentObjectTreeFor(str))) == null || jSONObject.remove(split[split.length - 1]) == null) ? false : true;
|
||||
}
|
||||
|
||||
public synchronized Object get(String str) {
|
||||
JSONObject jSONObject;
|
||||
Object obj = null;
|
||||
if (this._data == null) {
|
||||
DeviceLog.error("Data is NULL, readStorage probably not called");
|
||||
return null;
|
||||
}
|
||||
String[] split = str.split("\\.");
|
||||
if (!(findObject(getParentObjectTreeFor(str)) instanceof JSONObject) || (jSONObject = (JSONObject) findObject(getParentObjectTreeFor(str))) == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
if (jSONObject.has(split[split.length - 1])) {
|
||||
obj = jSONObject.get(split[split.length - 1]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error getting data", e);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
public synchronized JSONObject getData() {
|
||||
return this._data;
|
||||
}
|
||||
|
||||
public synchronized List<String> getKeys(String str, boolean z) {
|
||||
List<String> list;
|
||||
if (!(get(str) instanceof JSONObject)) {
|
||||
return null;
|
||||
}
|
||||
JSONObject jSONObject = (JSONObject) get(str);
|
||||
ArrayList arrayList = new ArrayList();
|
||||
if (jSONObject != null) {
|
||||
Iterator<String> keys = jSONObject.keys();
|
||||
while (keys.hasNext()) {
|
||||
String next = keys.next();
|
||||
if (z) {
|
||||
list = getKeys(str + "." + next, z);
|
||||
} else {
|
||||
list = null;
|
||||
}
|
||||
arrayList.add(next);
|
||||
if (list != null) {
|
||||
Iterator<String> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
arrayList.add(next + "." + it.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public synchronized boolean hasData() {
|
||||
if (this._data != null) {
|
||||
if (this._data.length() > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public synchronized boolean initData() {
|
||||
if (this._data != null) {
|
||||
return false;
|
||||
}
|
||||
this._data = new JSONObject();
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized boolean set(String str, Object obj) {
|
||||
if (this._data != null && str != null && str.length() != 0 && obj != null) {
|
||||
createObjectTree(getParentObjectTreeFor(str));
|
||||
if (!(findObject(getParentObjectTreeFor(str)) instanceof JSONObject)) {
|
||||
DeviceLog.debug("Cannot set subvalue to an object that is not JSONObject");
|
||||
return false;
|
||||
}
|
||||
JSONObject jSONObject = (JSONObject) findObject(getParentObjectTreeFor(str));
|
||||
String[] split = str.split("\\.");
|
||||
if (jSONObject != null) {
|
||||
try {
|
||||
jSONObject.put(split[split.length - 1], obj);
|
||||
} catch (JSONException e) {
|
||||
DeviceLog.exception("Couldn't set value", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
DeviceLog.error("Storage not properly initialized or incorrect parameters:" + this._data + ", " + str + ", " + obj);
|
||||
return false;
|
||||
}
|
||||
|
||||
public synchronized void setData(JSONObject jSONObject) {
|
||||
this._data = jSONObject;
|
||||
}
|
||||
}
|
||||
276
sources/com/unity3d/ads/misc/Utilities.java
Normal file
276
sources/com/unity3d/ads/misc/Utilities.java
Normal file
@@ -0,0 +1,276 @@
|
||||
package com.unity3d.ads.misc;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import com.ubt.jimu.base.util.FileUtil;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Iterator;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Utilities {
|
||||
public static String Sha256(String str) {
|
||||
return Sha256(str.getBytes());
|
||||
}
|
||||
|
||||
public static JSONObject mergeJsonObjects(JSONObject jSONObject, JSONObject jSONObject2) throws JSONException {
|
||||
if (jSONObject == null) {
|
||||
return jSONObject2;
|
||||
}
|
||||
if (jSONObject2 == null) {
|
||||
return jSONObject;
|
||||
}
|
||||
JSONObject jSONObject3 = new JSONObject();
|
||||
Iterator<String> keys = jSONObject2.keys();
|
||||
while (keys.hasNext()) {
|
||||
String next = keys.next();
|
||||
jSONObject3.put(next, jSONObject2.get(next));
|
||||
}
|
||||
Iterator<String> keys2 = jSONObject.keys();
|
||||
while (keys2.hasNext()) {
|
||||
String next2 = keys2.next();
|
||||
if (jSONObject3.has(next2) && (jSONObject3.get(next2) instanceof JSONObject) && (jSONObject.get(next2) instanceof JSONObject)) {
|
||||
jSONObject3.put(next2, mergeJsonObjects(jSONObject.getJSONObject(next2), jSONObject3.getJSONObject(next2)));
|
||||
} else {
|
||||
jSONObject3.put(next2, jSONObject.get(next2));
|
||||
}
|
||||
}
|
||||
return jSONObject3;
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:24:0x0044 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:29:0x0038 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public static java.lang.String readFile(java.io.File r4) {
|
||||
/*
|
||||
r0 = 0
|
||||
if (r4 != 0) goto L4
|
||||
return r0
|
||||
L4:
|
||||
boolean r1 = r4.exists()
|
||||
if (r1 == 0) goto L4f
|
||||
boolean r1 = r4.canRead()
|
||||
if (r1 == 0) goto L4f
|
||||
java.io.FileReader r1 = new java.io.FileReader // Catch: java.lang.Exception -> L2e
|
||||
r1.<init>(r4) // Catch: java.lang.Exception -> L2e
|
||||
java.io.BufferedReader r4 = new java.io.BufferedReader // Catch: java.lang.Exception -> L2b
|
||||
r4.<init>(r1) // Catch: java.lang.Exception -> L2b
|
||||
java.lang.String r2 = ""
|
||||
L1c:
|
||||
java.lang.String r3 = r4.readLine() // Catch: java.lang.Exception -> L29
|
||||
if (r3 == 0) goto L27
|
||||
java.lang.String r2 = r2.concat(r3) // Catch: java.lang.Exception -> L29
|
||||
goto L1c
|
||||
L27:
|
||||
r0 = r2
|
||||
goto L36
|
||||
L29:
|
||||
r2 = move-exception
|
||||
goto L31
|
||||
L2b:
|
||||
r2 = move-exception
|
||||
r4 = r0
|
||||
goto L31
|
||||
L2e:
|
||||
r2 = move-exception
|
||||
r4 = r0
|
||||
r1 = r4
|
||||
L31:
|
||||
java.lang.String r3 = "Problem reading file"
|
||||
com.unity3d.ads.log.DeviceLog.exception(r3, r2)
|
||||
L36:
|
||||
if (r4 == 0) goto L42
|
||||
r4.close() // Catch: java.lang.Exception -> L3c
|
||||
goto L42
|
||||
L3c:
|
||||
r4 = move-exception
|
||||
java.lang.String r2 = "Couldn't close BufferedReader"
|
||||
com.unity3d.ads.log.DeviceLog.exception(r2, r4)
|
||||
L42:
|
||||
if (r1 == 0) goto L4e
|
||||
r1.close() // Catch: java.lang.Exception -> L48
|
||||
goto L4e
|
||||
L48:
|
||||
r4 = move-exception
|
||||
java.lang.String r1 = "Couldn't close FileReader"
|
||||
com.unity3d.ads.log.DeviceLog.exception(r1, r4)
|
||||
L4e:
|
||||
return r0
|
||||
L4f:
|
||||
java.lang.String r4 = "File did not exist or couldn't be read"
|
||||
com.unity3d.ads.log.DeviceLog.error(r4)
|
||||
return r0
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.unity3d.ads.misc.Utilities.readFile(java.io.File):java.lang.String");
|
||||
}
|
||||
|
||||
public static byte[] readFileBytes(File file) throws IOException {
|
||||
if (file == null) {
|
||||
return null;
|
||||
}
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
byte[] bArr = new byte[(int) file.length()];
|
||||
int i = 0;
|
||||
int i2 = FileUtil.ZIP_BUFFER_SIZE;
|
||||
long length = file.length();
|
||||
long j = FileUtil.ZIP_BUFFER_SIZE;
|
||||
if (length < j) {
|
||||
i2 = (int) file.length();
|
||||
}
|
||||
while (true) {
|
||||
int read = fileInputStream.read(bArr, i, i2);
|
||||
if (read <= 0) {
|
||||
fileInputStream.close();
|
||||
return bArr;
|
||||
}
|
||||
i += read;
|
||||
if (file.length() - i < j) {
|
||||
i2 = ((int) file.length()) - i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void runOnUiThread(Runnable runnable) {
|
||||
runOnUiThread(runnable, 0L);
|
||||
}
|
||||
|
||||
public static String toHexString(byte[] bArr) {
|
||||
String str = "";
|
||||
for (byte b : bArr) {
|
||||
int i = b & 255;
|
||||
if (i <= 15) {
|
||||
str = str + "0";
|
||||
}
|
||||
str = str + Integer.toHexString(i);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:15:0x003b */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public static boolean writeFile(java.io.File r5, java.lang.String r6) {
|
||||
/*
|
||||
java.lang.String r0 = "Error closing FileOutputStream"
|
||||
r1 = 0
|
||||
if (r5 != 0) goto L6
|
||||
return r1
|
||||
L6:
|
||||
r2 = 0
|
||||
r3 = 1
|
||||
java.io.FileOutputStream r4 = new java.io.FileOutputStream // Catch: java.lang.Throwable -> L27 java.lang.Exception -> L29
|
||||
r4.<init>(r5) // Catch: java.lang.Throwable -> L27 java.lang.Exception -> L29
|
||||
byte[] r6 = r6.getBytes() // Catch: java.lang.Throwable -> L21 java.lang.Exception -> L24
|
||||
r4.write(r6) // Catch: java.lang.Throwable -> L21 java.lang.Exception -> L24
|
||||
r4.flush() // Catch: java.lang.Throwable -> L21 java.lang.Exception -> L24
|
||||
r4.close() // Catch: java.lang.Exception -> L1b
|
||||
goto L1f
|
||||
L1b:
|
||||
r6 = move-exception
|
||||
com.unity3d.ads.log.DeviceLog.exception(r0, r6)
|
||||
L1f:
|
||||
r1 = 1
|
||||
goto L39
|
||||
L21:
|
||||
r5 = move-exception
|
||||
r2 = r4
|
||||
goto L54
|
||||
L24:
|
||||
r6 = move-exception
|
||||
r2 = r4
|
||||
goto L2a
|
||||
L27:
|
||||
r5 = move-exception
|
||||
goto L54
|
||||
L29:
|
||||
r6 = move-exception
|
||||
L2a:
|
||||
java.lang.String r3 = "Could not write file"
|
||||
com.unity3d.ads.log.DeviceLog.exception(r3, r6) // Catch: java.lang.Throwable -> L27
|
||||
if (r2 == 0) goto L39
|
||||
r2.close() // Catch: java.lang.Exception -> L35
|
||||
goto L39
|
||||
L35:
|
||||
r6 = move-exception
|
||||
com.unity3d.ads.log.DeviceLog.exception(r0, r6)
|
||||
L39:
|
||||
if (r1 == 0) goto L53
|
||||
java.lang.StringBuilder r6 = new java.lang.StringBuilder
|
||||
r6.<init>()
|
||||
java.lang.String r0 = "Wrote file: "
|
||||
r6.append(r0)
|
||||
java.lang.String r5 = r5.getAbsolutePath()
|
||||
r6.append(r5)
|
||||
java.lang.String r5 = r6.toString()
|
||||
com.unity3d.ads.log.DeviceLog.debug(r5)
|
||||
L53:
|
||||
return r1
|
||||
L54:
|
||||
if (r2 == 0) goto L5e
|
||||
r2.close() // Catch: java.lang.Exception -> L5a
|
||||
goto L5e
|
||||
L5a:
|
||||
r6 = move-exception
|
||||
com.unity3d.ads.log.DeviceLog.exception(r0, r6)
|
||||
L5e:
|
||||
throw r5
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.unity3d.ads.misc.Utilities.writeFile(java.io.File, java.lang.String):boolean");
|
||||
}
|
||||
|
||||
public static String Sha256(byte[] bArr) {
|
||||
if (bArr == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
|
||||
messageDigest.update(bArr, 0, bArr.length);
|
||||
return toHexString(messageDigest.digest());
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
DeviceLog.exception("SHA-256 algorithm not found", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void runOnUiThread(Runnable runnable, long j) {
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
if (j > 0) {
|
||||
handler.postDelayed(runnable, j);
|
||||
} else {
|
||||
handler.post(runnable);
|
||||
}
|
||||
}
|
||||
|
||||
public static String Sha256(InputStream inputStream) throws IOException {
|
||||
if (inputStream == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
|
||||
byte[] bArr = new byte[FileUtil.ZIP_BUFFER_SIZE];
|
||||
while (true) {
|
||||
int read = inputStream.read(bArr);
|
||||
if (read != -1) {
|
||||
messageDigest.update(bArr, 0, read);
|
||||
} else {
|
||||
return toHexString(messageDigest.digest());
|
||||
}
|
||||
}
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
DeviceLog.exception("SHA-256 algorithm not found", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
30
sources/com/unity3d/ads/misc/ViewUtilities.java
Normal file
30
sources/com/unity3d/ads/misc/ViewUtilities.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.unity3d.ads.misc;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class ViewUtilities {
|
||||
public static void removeViewFromParent(View view) {
|
||||
if (view == null || view.getParent() == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
((ViewGroup) view.getParent()).removeView(view);
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error while removing view from it's parent", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setBackground(View view, Drawable drawable) {
|
||||
String str = Build.VERSION.SDK_INT < 16 ? "setBackgroundDrawable" : "setBackground";
|
||||
try {
|
||||
View.class.getMethod(str, Drawable.class).invoke(view, drawable);
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Couldn't run" + str, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
52
sources/com/unity3d/ads/placement/Placement.java
Normal file
52
sources/com/unity3d/ads/placement/Placement.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package com.unity3d.ads.placement;
|
||||
|
||||
import com.unity3d.ads.UnityAds;
|
||||
import java.util.HashMap;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Placement {
|
||||
private static String _defaultPlacement;
|
||||
private static HashMap<String, UnityAds.PlacementState> _placementReadyMap;
|
||||
|
||||
private static UnityAds.PlacementState currentState(String str) {
|
||||
HashMap<String, UnityAds.PlacementState> hashMap = _placementReadyMap;
|
||||
return (hashMap == null || !hashMap.containsKey(str)) ? UnityAds.PlacementState.NOT_AVAILABLE : _placementReadyMap.get(str);
|
||||
}
|
||||
|
||||
public static String getDefaultPlacement() {
|
||||
return _defaultPlacement;
|
||||
}
|
||||
|
||||
public static UnityAds.PlacementState getPlacementState(String str) {
|
||||
return currentState(str);
|
||||
}
|
||||
|
||||
public static boolean isReady(String str) {
|
||||
return getPlacementState(str) == UnityAds.PlacementState.READY;
|
||||
}
|
||||
|
||||
public static void reset() {
|
||||
_placementReadyMap = null;
|
||||
_defaultPlacement = null;
|
||||
}
|
||||
|
||||
public static void setDefaultPlacement(String str) {
|
||||
_defaultPlacement = str;
|
||||
}
|
||||
|
||||
public static void setPlacementState(String str, String str2) {
|
||||
if (_placementReadyMap == null) {
|
||||
_placementReadyMap = new HashMap<>();
|
||||
}
|
||||
_placementReadyMap.put(str, UnityAds.PlacementState.valueOf(str2));
|
||||
}
|
||||
|
||||
public static UnityAds.PlacementState getPlacementState() {
|
||||
String str = _defaultPlacement;
|
||||
return str == null ? UnityAds.PlacementState.NOT_AVAILABLE : getPlacementState(str);
|
||||
}
|
||||
|
||||
public static boolean isReady() {
|
||||
return getPlacementState() == UnityAds.PlacementState.READY;
|
||||
}
|
||||
}
|
||||
127
sources/com/unity3d/ads/preferences/AndroidPreferences.java
Normal file
127
sources/com/unity3d/ads/preferences/AndroidPreferences.java
Normal file
@@ -0,0 +1,127 @@
|
||||
package com.unity3d.ads.preferences;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class AndroidPreferences {
|
||||
public static Boolean getBoolean(String str, String str2) {
|
||||
SharedPreferences sharedPreferences = ClientProperties.getApplicationContext().getSharedPreferences(str, 0);
|
||||
if (sharedPreferences != null && sharedPreferences.contains(str2)) {
|
||||
try {
|
||||
return Boolean.valueOf(sharedPreferences.getBoolean(str2, false));
|
||||
} catch (ClassCastException e) {
|
||||
DeviceLog.error("Unity Ads failed to cast " + str2 + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Float getFloat(String str, String str2) {
|
||||
SharedPreferences sharedPreferences = ClientProperties.getApplicationContext().getSharedPreferences(str, 0);
|
||||
if (sharedPreferences != null && sharedPreferences.contains(str2)) {
|
||||
try {
|
||||
return Float.valueOf(sharedPreferences.getFloat(str2, Float.NaN));
|
||||
} catch (ClassCastException e) {
|
||||
DeviceLog.error("Unity Ads failed to cast " + str2 + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Integer getInteger(String str, String str2) {
|
||||
SharedPreferences sharedPreferences = ClientProperties.getApplicationContext().getSharedPreferences(str, 0);
|
||||
if (sharedPreferences != null && sharedPreferences.contains(str2)) {
|
||||
try {
|
||||
return Integer.valueOf(sharedPreferences.getInt(str2, -1));
|
||||
} catch (ClassCastException e) {
|
||||
DeviceLog.error("Unity Ads failed to cast " + str2 + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Long getLong(String str, String str2) {
|
||||
SharedPreferences sharedPreferences = ClientProperties.getApplicationContext().getSharedPreferences(str, 0);
|
||||
if (sharedPreferences != null && sharedPreferences.contains(str2)) {
|
||||
try {
|
||||
return Long.valueOf(sharedPreferences.getLong(str2, -1L));
|
||||
} catch (ClassCastException e) {
|
||||
DeviceLog.error("Unity Ads failed to cast " + str2 + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getString(String str, String str2) {
|
||||
SharedPreferences sharedPreferences = ClientProperties.getApplicationContext().getSharedPreferences(str, 0);
|
||||
if (sharedPreferences != null && sharedPreferences.contains(str2)) {
|
||||
try {
|
||||
return sharedPreferences.getString(str2, "");
|
||||
} catch (ClassCastException e) {
|
||||
DeviceLog.error("Unity Ads failed to cast " + str2 + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean hasKey(String str, String str2) {
|
||||
SharedPreferences sharedPreferences = ClientProperties.getApplicationContext().getSharedPreferences(str, 0);
|
||||
return sharedPreferences != null && sharedPreferences.contains(str2);
|
||||
}
|
||||
|
||||
public static void removeKey(String str, String str2) {
|
||||
SharedPreferences sharedPreferences = ClientProperties.getApplicationContext().getSharedPreferences(str, 0);
|
||||
if (sharedPreferences != null) {
|
||||
SharedPreferences.Editor edit = sharedPreferences.edit();
|
||||
edit.remove(str2);
|
||||
edit.commit();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setBoolean(String str, String str2, Boolean bool) {
|
||||
SharedPreferences sharedPreferences = ClientProperties.getApplicationContext().getSharedPreferences(str, 0);
|
||||
if (sharedPreferences != null) {
|
||||
SharedPreferences.Editor edit = sharedPreferences.edit();
|
||||
edit.putBoolean(str2, bool.booleanValue());
|
||||
edit.commit();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setFloat(String str, String str2, Double d) {
|
||||
SharedPreferences sharedPreferences = ClientProperties.getApplicationContext().getSharedPreferences(str, 0);
|
||||
if (sharedPreferences != null) {
|
||||
SharedPreferences.Editor edit = sharedPreferences.edit();
|
||||
edit.putFloat(str2, d.floatValue());
|
||||
edit.commit();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setInteger(String str, String str2, Integer num) {
|
||||
SharedPreferences sharedPreferences = ClientProperties.getApplicationContext().getSharedPreferences(str, 0);
|
||||
if (sharedPreferences != null) {
|
||||
SharedPreferences.Editor edit = sharedPreferences.edit();
|
||||
edit.putInt(str2, num.intValue());
|
||||
edit.commit();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setLong(String str, String str2, Long l) {
|
||||
SharedPreferences sharedPreferences = ClientProperties.getApplicationContext().getSharedPreferences(str, 0);
|
||||
if (sharedPreferences != null) {
|
||||
SharedPreferences.Editor edit = sharedPreferences.edit();
|
||||
edit.putLong(str2, l.longValue());
|
||||
edit.commit();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setString(String str, String str2, String str3) {
|
||||
SharedPreferences sharedPreferences = ClientProperties.getApplicationContext().getSharedPreferences(str, 0);
|
||||
if (sharedPreferences != null) {
|
||||
SharedPreferences.Editor edit = sharedPreferences.edit();
|
||||
edit.putString(str2, str3);
|
||||
edit.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.unity3d.ads.preferences;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum PreferencesError {
|
||||
COULDNT_GET_VALUE
|
||||
}
|
||||
113
sources/com/unity3d/ads/properties/ClientProperties.java
Normal file
113
sources/com/unity3d/ads/properties/ClientProperties.java
Normal file
@@ -0,0 +1,113 @@
|
||||
package com.unity3d.ads.properties;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.Signature;
|
||||
import com.unity3d.ads.IUnityAdsListener;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.X509Certificate;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class ClientProperties {
|
||||
private static final X500Principal DEBUG_CERT = new X500Principal("CN=Android Debug,O=Android,C=US");
|
||||
private static WeakReference<Activity> _activity;
|
||||
private static Application _application;
|
||||
private static Context _applicationContext;
|
||||
private static String _gameId;
|
||||
private static IUnityAdsListener _listener;
|
||||
|
||||
public static Activity getActivity() {
|
||||
return _activity.get();
|
||||
}
|
||||
|
||||
public static String getAppName() {
|
||||
return _applicationContext.getPackageName();
|
||||
}
|
||||
|
||||
public static String getAppVersion() {
|
||||
try {
|
||||
return getApplicationContext().getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0).versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
DeviceLog.exception("Error getting package info", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Application getApplication() {
|
||||
return _application;
|
||||
}
|
||||
|
||||
public static Context getApplicationContext() {
|
||||
return _applicationContext;
|
||||
}
|
||||
|
||||
public static String getGameId() {
|
||||
return _gameId;
|
||||
}
|
||||
|
||||
public static IUnityAdsListener getListener() {
|
||||
return _listener;
|
||||
}
|
||||
|
||||
public static boolean isAppDebuggable() {
|
||||
boolean z;
|
||||
if (getApplicationContext() == null) {
|
||||
return false;
|
||||
}
|
||||
PackageManager packageManager = getApplicationContext().getPackageManager();
|
||||
String packageName = getApplicationContext().getPackageName();
|
||||
try {
|
||||
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, 0);
|
||||
int i = applicationInfo.flags & 2;
|
||||
applicationInfo.flags = i;
|
||||
z = i != 0;
|
||||
r4 = false;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
DeviceLog.exception("Could not find name", e);
|
||||
z = false;
|
||||
}
|
||||
if (r4) {
|
||||
try {
|
||||
for (Signature signature : packageManager.getPackageInfo(packageName, 64).signatures) {
|
||||
z = ((X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(signature.toByteArray()))).getSubjectX500Principal().equals(DEBUG_CERT);
|
||||
if (z) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e2) {
|
||||
DeviceLog.exception("Could not find name", e2);
|
||||
} catch (CertificateException e3) {
|
||||
DeviceLog.exception("Certificate exception", e3);
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
public static void setActivity(Activity activity) {
|
||||
_activity = new WeakReference<>(activity);
|
||||
}
|
||||
|
||||
public static void setApplication(Application application) {
|
||||
_application = application;
|
||||
}
|
||||
|
||||
public static void setApplicationContext(Context context) {
|
||||
_applicationContext = context;
|
||||
}
|
||||
|
||||
public static void setGameId(String str) {
|
||||
_gameId = str;
|
||||
}
|
||||
|
||||
public static void setListener(IUnityAdsListener iUnityAdsListener) {
|
||||
_listener = iUnityAdsListener;
|
||||
}
|
||||
}
|
||||
129
sources/com/unity3d/ads/properties/SdkProperties.java
Normal file
129
sources/com/unity3d/ads/properties/SdkProperties.java
Normal file
@@ -0,0 +1,129 @@
|
||||
package com.unity3d.ads.properties;
|
||||
|
||||
import android.content.Context;
|
||||
import com.unity3d.ads.BuildConfig;
|
||||
import com.unity3d.ads.cache.CacheDirectory;
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class SdkProperties {
|
||||
private static final String CACHE_DIR_NAME = "UnityAdsCache";
|
||||
private static final String LOCAL_CACHE_FILE_PREFIX = "UnityAdsCache-";
|
||||
private static final String LOCAL_STORAGE_FILE_PREFIX = "UnityAdsStorage-";
|
||||
private static String _configUrl = getDefaultConfigUrl("release");
|
||||
private static CacheDirectory _cacheDirectory = null;
|
||||
private static int _showTimeout = 5000;
|
||||
private static long _initializationTime = 0;
|
||||
private static boolean _initialized = false;
|
||||
private static boolean _reinitialized = false;
|
||||
private static boolean _testMode = false;
|
||||
|
||||
public static File getCacheDirectory() {
|
||||
return getCacheDirectory(ClientProperties.getApplicationContext());
|
||||
}
|
||||
|
||||
public static String getCacheDirectoryName() {
|
||||
return CACHE_DIR_NAME;
|
||||
}
|
||||
|
||||
public static CacheDirectory getCacheDirectoryObject() {
|
||||
return _cacheDirectory;
|
||||
}
|
||||
|
||||
public static String getCacheFilePrefix() {
|
||||
return LOCAL_CACHE_FILE_PREFIX;
|
||||
}
|
||||
|
||||
public static String getConfigUrl() {
|
||||
return _configUrl;
|
||||
}
|
||||
|
||||
public static String getDefaultConfigUrl(String str) {
|
||||
return "https://config.unityads.unity3d.com/webview/" + getWebViewBranch() + "/" + str + "/config.json";
|
||||
}
|
||||
|
||||
public static long getInitializationTime() {
|
||||
return _initializationTime;
|
||||
}
|
||||
|
||||
public static String getLocalStorageFilePrefix() {
|
||||
return LOCAL_STORAGE_FILE_PREFIX;
|
||||
}
|
||||
|
||||
public static String getLocalWebViewFile() {
|
||||
return getCacheDirectory().getAbsolutePath() + "/UnityAdsWebApp.html";
|
||||
}
|
||||
|
||||
public static int getShowTimeout() {
|
||||
return _showTimeout;
|
||||
}
|
||||
|
||||
public static int getVersionCode() {
|
||||
return BuildConfig.VERSION_CODE;
|
||||
}
|
||||
|
||||
public static String getVersionName() {
|
||||
return "2.3.0";
|
||||
}
|
||||
|
||||
private static String getWebViewBranch() {
|
||||
return getVersionName();
|
||||
}
|
||||
|
||||
public static boolean isInitialized() {
|
||||
return _initialized;
|
||||
}
|
||||
|
||||
public static boolean isReinitialized() {
|
||||
return _reinitialized;
|
||||
}
|
||||
|
||||
public static boolean isTestMode() {
|
||||
return _testMode;
|
||||
}
|
||||
|
||||
public static void setCacheDirectory(CacheDirectory cacheDirectory) {
|
||||
_cacheDirectory = cacheDirectory;
|
||||
}
|
||||
|
||||
public static void setConfigUrl(String str) throws URISyntaxException, MalformedURLException {
|
||||
if (str == null) {
|
||||
throw new MalformedURLException();
|
||||
}
|
||||
if (!str.startsWith("http://") && !str.startsWith("https://")) {
|
||||
throw new MalformedURLException();
|
||||
}
|
||||
new URL(str).toURI();
|
||||
_configUrl = str;
|
||||
}
|
||||
|
||||
public static void setInitializationTime(long j) {
|
||||
_initializationTime = j;
|
||||
}
|
||||
|
||||
public static void setInitialized(boolean z) {
|
||||
_initialized = z;
|
||||
}
|
||||
|
||||
public static void setReinitialized(boolean z) {
|
||||
_reinitialized = z;
|
||||
}
|
||||
|
||||
public static void setShowTimeout(int i) {
|
||||
_showTimeout = i;
|
||||
}
|
||||
|
||||
public static void setTestMode(boolean z) {
|
||||
_testMode = z;
|
||||
}
|
||||
|
||||
public static File getCacheDirectory(Context context) {
|
||||
if (_cacheDirectory == null) {
|
||||
setCacheDirectory(new CacheDirectory(CACHE_DIR_NAME));
|
||||
}
|
||||
return _cacheDirectory.getCacheDirectory(context);
|
||||
}
|
||||
}
|
||||
12
sources/com/unity3d/ads/purchasing/IPurchasing.java
Normal file
12
sources/com/unity3d/ads/purchasing/IPurchasing.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.unity3d.ads.purchasing;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface IPurchasing {
|
||||
void onGetProductCatalog();
|
||||
|
||||
void onGetPurchasingVersion();
|
||||
|
||||
void onInitializePurchasing();
|
||||
|
||||
void onPurchasingCommand(String str);
|
||||
}
|
||||
28
sources/com/unity3d/ads/purchasing/Purchasing.java
Normal file
28
sources/com/unity3d/ads/purchasing/Purchasing.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.unity3d.ads.purchasing;
|
||||
|
||||
import com.unity3d.ads.webview.WebViewApp;
|
||||
import com.unity3d.ads.webview.WebViewEventCategory;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Purchasing {
|
||||
|
||||
public enum UnityAdsPurchasingEvent {
|
||||
COMMAND,
|
||||
VERSION,
|
||||
CATALOG,
|
||||
INITIALIZATION,
|
||||
EVENT
|
||||
}
|
||||
|
||||
public static void dispatchReturnEvent(int i, String str) {
|
||||
WebViewApp currentApp = WebViewApp.getCurrentApp();
|
||||
if (currentApp == null || !currentApp.isWebAppLoaded()) {
|
||||
return;
|
||||
}
|
||||
currentApp.sendEvent(WebViewEventCategory.PURCHASING, UnityAdsPurchasingEvent.values()[i], str);
|
||||
}
|
||||
|
||||
public static void initialize(IPurchasing iPurchasing) {
|
||||
com.unity3d.ads.api.Purchasing.setPurchasingInterface(iPurchasing);
|
||||
}
|
||||
}
|
||||
6
sources/com/unity3d/ads/purchasing/PurchasingError.java
Normal file
6
sources/com/unity3d/ads/purchasing/PurchasingError.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package com.unity3d.ads.purchasing;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum PurchasingError {
|
||||
PURCHASE_INTERFACE_NULL
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.unity3d.ads.request;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class CancelableThreadPoolExecutor extends ThreadPoolExecutor {
|
||||
private final List<Runnable> _activeRunnable;
|
||||
|
||||
public CancelableThreadPoolExecutor(int i, int i2, long j, TimeUnit timeUnit, LinkedBlockingQueue<Runnable> linkedBlockingQueue) {
|
||||
super(i, i2, j, timeUnit, linkedBlockingQueue);
|
||||
this._activeRunnable = new LinkedList();
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.ThreadPoolExecutor
|
||||
protected synchronized void afterExecute(Runnable runnable, Throwable th) {
|
||||
super.afterExecute(runnable, th);
|
||||
this._activeRunnable.remove(runnable);
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.ThreadPoolExecutor
|
||||
protected synchronized void beforeExecute(Thread thread, Runnable runnable) {
|
||||
super.beforeExecute(thread, runnable);
|
||||
this._activeRunnable.add(runnable);
|
||||
}
|
||||
|
||||
public synchronized void cancel() {
|
||||
for (Runnable runnable : this._activeRunnable) {
|
||||
if (runnable instanceof WebRequestRunnable) {
|
||||
((WebRequestRunnable) runnable).setCancelStatus(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.unity3d.ads.request;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface IResolveHostListener {
|
||||
void onFailed(String str, ResolveHostError resolveHostError, String str2);
|
||||
|
||||
void onResolve(String str, String str2);
|
||||
}
|
||||
11
sources/com/unity3d/ads/request/IWebRequestListener.java
Normal file
11
sources/com/unity3d/ads/request/IWebRequestListener.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.unity3d.ads.request;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface IWebRequestListener {
|
||||
void onComplete(String str, String str2, int i, Map<String, List<String>> map);
|
||||
|
||||
void onFailed(String str, String str2);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.unity3d.ads.request;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface IWebRequestProgressListener {
|
||||
void onRequestProgress(String str, long j, long j2);
|
||||
|
||||
void onRequestStart(String str, long j, int i, Map<String, List<String>> map);
|
||||
}
|
||||
8
sources/com/unity3d/ads/request/NetworkIOException.java
Normal file
8
sources/com/unity3d/ads/request/NetworkIOException.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.unity3d.ads.request;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class NetworkIOException extends Exception {
|
||||
public NetworkIOException(String str) {
|
||||
super(str);
|
||||
}
|
||||
}
|
||||
9
sources/com/unity3d/ads/request/ResolveHostError.java
Normal file
9
sources/com/unity3d/ads/request/ResolveHostError.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.unity3d.ads.request;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum ResolveHostError {
|
||||
INVALID_HOST,
|
||||
UNKNOWN_HOST,
|
||||
UNEXPECTED_EXCEPTION,
|
||||
TIMEOUT
|
||||
}
|
||||
7
sources/com/unity3d/ads/request/ResolveHostEvent.java
Normal file
7
sources/com/unity3d/ads/request/ResolveHostEvent.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.unity3d.ads.request;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum ResolveHostEvent {
|
||||
COMPLETE,
|
||||
FAILED
|
||||
}
|
||||
258
sources/com/unity3d/ads/request/WebRequest.java
Normal file
258
sources/com/unity3d/ads/request/WebRequest.java
Normal file
@@ -0,0 +1,258 @@
|
||||
package com.unity3d.ads.request;
|
||||
|
||||
import com.tencent.bugly.BuglyStrategy;
|
||||
import com.ubt.jimu.base.util.FileUtil;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.ProtocolException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class WebRequest {
|
||||
private String _body;
|
||||
private boolean _canceled;
|
||||
private int _connectTimeout;
|
||||
private long _contentLength;
|
||||
private Map<String, List<String>> _headers;
|
||||
private IWebRequestProgressListener _progressListener;
|
||||
private int _readTimeout;
|
||||
private String _requestType;
|
||||
private int _responseCode;
|
||||
private Map<String, List<String>> _responseHeaders;
|
||||
private URL _url;
|
||||
|
||||
public enum RequestType {
|
||||
POST,
|
||||
GET,
|
||||
HEAD
|
||||
}
|
||||
|
||||
public WebRequest(String str, String str2, Map<String, List<String>> map) throws MalformedURLException {
|
||||
this(str, str2, map, BuglyStrategy.a.MAX_USERDATA_VALUE_LENGTH, BuglyStrategy.a.MAX_USERDATA_VALUE_LENGTH);
|
||||
}
|
||||
|
||||
private HttpURLConnection getHttpUrlConnectionWithHeaders() throws NetworkIOException {
|
||||
HttpURLConnection httpURLConnection;
|
||||
if (getUrl().toString().startsWith("https://")) {
|
||||
try {
|
||||
httpURLConnection = (HttpsURLConnection) getUrl().openConnection();
|
||||
} catch (IOException e) {
|
||||
throw new NetworkIOException("Open HTTPS connection: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
httpURLConnection = (HttpURLConnection) getUrl().openConnection();
|
||||
} catch (IOException e2) {
|
||||
throw new NetworkIOException("Open HTTP connection: " + e2.getMessage());
|
||||
}
|
||||
}
|
||||
httpURLConnection.setInstanceFollowRedirects(false);
|
||||
httpURLConnection.setConnectTimeout(getConnectTimeout());
|
||||
httpURLConnection.setReadTimeout(getReadTimeout());
|
||||
try {
|
||||
httpURLConnection.setRequestMethod(getRequestType());
|
||||
if (getHeaders() != null && getHeaders().size() > 0) {
|
||||
for (String str : getHeaders().keySet()) {
|
||||
for (String str2 : getHeaders().get(str)) {
|
||||
DeviceLog.debug("Setting header: " + str + "=" + str2);
|
||||
httpURLConnection.setRequestProperty(str, str2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return httpURLConnection;
|
||||
} catch (ProtocolException e3) {
|
||||
throw new NetworkIOException("Set Request Method: " + getRequestType() + ", " + e3.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
this._canceled = true;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return this._body;
|
||||
}
|
||||
|
||||
public int getConnectTimeout() {
|
||||
return this._connectTimeout;
|
||||
}
|
||||
|
||||
public long getContentLength() {
|
||||
return this._contentLength;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getHeaders() {
|
||||
return this._headers;
|
||||
}
|
||||
|
||||
public String getQuery() {
|
||||
URL url = this._url;
|
||||
if (url != null) {
|
||||
return url.getQuery();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getReadTimeout() {
|
||||
return this._readTimeout;
|
||||
}
|
||||
|
||||
public String getRequestType() {
|
||||
return this._requestType;
|
||||
}
|
||||
|
||||
public int getResponseCode() {
|
||||
return this._responseCode;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getResponseHeaders() {
|
||||
return this._responseHeaders;
|
||||
}
|
||||
|
||||
public URL getUrl() {
|
||||
return this._url;
|
||||
}
|
||||
|
||||
public boolean isCanceled() {
|
||||
return this._canceled;
|
||||
}
|
||||
|
||||
public String makeRequest() throws NetworkIOException, IOException, IllegalStateException {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
makeStreamRequest(byteArrayOutputStream);
|
||||
return byteArrayOutputStream.toString("UTF-8");
|
||||
}
|
||||
|
||||
public long makeStreamRequest(OutputStream outputStream) throws NetworkIOException, IOException, IllegalStateException {
|
||||
InputStream errorStream;
|
||||
HttpURLConnection httpUrlConnectionWithHeaders = getHttpUrlConnectionWithHeaders();
|
||||
httpUrlConnectionWithHeaders.setDoInput(true);
|
||||
if (getRequestType().equals(RequestType.POST.name())) {
|
||||
httpUrlConnectionWithHeaders.setDoOutput(true);
|
||||
PrintWriter printWriter = null;
|
||||
try {
|
||||
try {
|
||||
PrintWriter printWriter2 = new PrintWriter((Writer) new OutputStreamWriter(httpUrlConnectionWithHeaders.getOutputStream(), "UTF-8"), true);
|
||||
try {
|
||||
if (getBody() == null) {
|
||||
printWriter2.print(getQuery());
|
||||
} else {
|
||||
printWriter2.print(getBody());
|
||||
}
|
||||
printWriter2.flush();
|
||||
try {
|
||||
printWriter2.close();
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error closing writer", e);
|
||||
throw e;
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
e = e2;
|
||||
printWriter = printWriter2;
|
||||
DeviceLog.exception("Error while writing POST params", e);
|
||||
throw new NetworkIOException("Error writing POST params: " + e.getMessage());
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
printWriter = printWriter2;
|
||||
if (printWriter != null) {
|
||||
try {
|
||||
printWriter.close();
|
||||
} catch (Exception e3) {
|
||||
DeviceLog.exception("Error closing writer", e3);
|
||||
throw e3;
|
||||
}
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
}
|
||||
} catch (IOException e4) {
|
||||
e = e4;
|
||||
}
|
||||
}
|
||||
try {
|
||||
this._responseCode = httpUrlConnectionWithHeaders.getResponseCode();
|
||||
this._contentLength = httpUrlConnectionWithHeaders.getContentLength();
|
||||
if (httpUrlConnectionWithHeaders.getHeaderFields() != null) {
|
||||
this._responseHeaders = httpUrlConnectionWithHeaders.getHeaderFields();
|
||||
}
|
||||
try {
|
||||
errorStream = httpUrlConnectionWithHeaders.getInputStream();
|
||||
} catch (IOException e5) {
|
||||
errorStream = httpUrlConnectionWithHeaders.getErrorStream();
|
||||
if (errorStream == null) {
|
||||
throw new NetworkIOException("Can't open error stream: " + e5.getMessage());
|
||||
}
|
||||
}
|
||||
IWebRequestProgressListener iWebRequestProgressListener = this._progressListener;
|
||||
if (iWebRequestProgressListener != null) {
|
||||
iWebRequestProgressListener.onRequestStart(getUrl().toString(), this._contentLength, this._responseCode, this._responseHeaders);
|
||||
}
|
||||
BufferedInputStream bufferedInputStream = new BufferedInputStream(errorStream);
|
||||
byte[] bArr = new byte[FileUtil.ZIP_BUFFER_SIZE];
|
||||
long j = 0;
|
||||
int i = 0;
|
||||
while (!isCanceled() && i != -1) {
|
||||
try {
|
||||
i = bufferedInputStream.read(bArr);
|
||||
if (i > 0) {
|
||||
outputStream.write(bArr, 0, i);
|
||||
j += i;
|
||||
IWebRequestProgressListener iWebRequestProgressListener2 = this._progressListener;
|
||||
if (iWebRequestProgressListener2 != null) {
|
||||
iWebRequestProgressListener2.onRequestProgress(getUrl().toString(), j, this._contentLength);
|
||||
}
|
||||
}
|
||||
} catch (IOException e6) {
|
||||
throw new NetworkIOException("Network exception: " + e6.getMessage());
|
||||
}
|
||||
}
|
||||
httpUrlConnectionWithHeaders.disconnect();
|
||||
outputStream.flush();
|
||||
return j;
|
||||
} catch (IOException | RuntimeException e7) {
|
||||
throw new NetworkIOException("Response code: " + e7.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void setBody(String str) {
|
||||
this._body = str;
|
||||
}
|
||||
|
||||
public void setConnectTimeout(int i) {
|
||||
this._connectTimeout = i;
|
||||
}
|
||||
|
||||
public void setProgressListener(IWebRequestProgressListener iWebRequestProgressListener) {
|
||||
this._progressListener = iWebRequestProgressListener;
|
||||
}
|
||||
|
||||
public void setReadTimeout(int i) {
|
||||
this._readTimeout = i;
|
||||
}
|
||||
|
||||
public WebRequest(String str, String str2, Map<String, List<String>> map, int i, int i2) throws MalformedURLException {
|
||||
this._requestType = RequestType.GET.name();
|
||||
this._responseCode = -1;
|
||||
this._contentLength = -1L;
|
||||
this._canceled = false;
|
||||
this._url = new URL(str);
|
||||
this._requestType = str2;
|
||||
this._headers = map;
|
||||
this._connectTimeout = i;
|
||||
this._readTimeout = i2;
|
||||
}
|
||||
}
|
||||
6
sources/com/unity3d/ads/request/WebRequestError.java
Normal file
6
sources/com/unity3d/ads/request/WebRequestError.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package com.unity3d.ads.request;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum WebRequestError {
|
||||
MAPPING_HEADERS_FAILED
|
||||
}
|
||||
7
sources/com/unity3d/ads/request/WebRequestEvent.java
Normal file
7
sources/com/unity3d/ads/request/WebRequestEvent.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.unity3d.ads.request;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum WebRequestEvent {
|
||||
COMPLETE,
|
||||
FAILED
|
||||
}
|
||||
107
sources/com/unity3d/ads/request/WebRequestRunnable.java
Normal file
107
sources/com/unity3d/ads/request/WebRequestRunnable.java
Normal file
@@ -0,0 +1,107 @@
|
||||
package com.unity3d.ads.request;
|
||||
|
||||
import android.os.Bundle;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class WebRequestRunnable implements Runnable {
|
||||
private final String _body;
|
||||
private boolean _canceled = false;
|
||||
private final int _connectTimeout;
|
||||
private WebRequest _currentRequest;
|
||||
private final Map<String, List<String>> _headers;
|
||||
private final IWebRequestListener _listener;
|
||||
private final int _readTimeout;
|
||||
private final String _type;
|
||||
private final String _url;
|
||||
|
||||
public WebRequestRunnable(String str, String str2, String str3, int i, int i2, Map<String, List<String>> map, IWebRequestListener iWebRequestListener) {
|
||||
this._url = str;
|
||||
this._type = str2;
|
||||
this._body = str3;
|
||||
this._connectTimeout = i;
|
||||
this._readTimeout = i2;
|
||||
this._headers = map;
|
||||
this._listener = iWebRequestListener;
|
||||
}
|
||||
|
||||
private Map<String, List<String>> getResponseHeaders(Bundle bundle) {
|
||||
if (bundle.size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
HashMap hashMap = new HashMap();
|
||||
for (String str : bundle.keySet()) {
|
||||
String[] stringArray = bundle.getStringArray(str);
|
||||
if (stringArray != null) {
|
||||
hashMap.put(str, new ArrayList(Arrays.asList(stringArray)));
|
||||
}
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
private void makeRequest(String str, String str2, Map<String, List<String>> map, String str3, int i, int i2) throws MalformedURLException {
|
||||
if (this._canceled) {
|
||||
return;
|
||||
}
|
||||
this._currentRequest = new WebRequest(str, str2, map, i, i2);
|
||||
if (str3 != null) {
|
||||
this._currentRequest.setBody(str3);
|
||||
}
|
||||
try {
|
||||
String makeRequest = this._currentRequest.makeRequest();
|
||||
if (this._currentRequest.isCanceled()) {
|
||||
onFailed("Canceled");
|
||||
return;
|
||||
}
|
||||
Bundle bundle = new Bundle();
|
||||
for (String str4 : this._currentRequest.getResponseHeaders().keySet()) {
|
||||
if (str4 != null && !str4.contentEquals("null")) {
|
||||
String[] strArr = new String[this._currentRequest.getResponseHeaders().get(str4).size()];
|
||||
for (int i3 = 0; i3 < this._currentRequest.getResponseHeaders().get(str4).size(); i3++) {
|
||||
strArr[i3] = this._currentRequest.getResponseHeaders().get(str4).get(i3);
|
||||
}
|
||||
bundle.putStringArray(str4, strArr);
|
||||
}
|
||||
}
|
||||
onSucceed(makeRequest, this._currentRequest.getResponseCode(), getResponseHeaders(bundle));
|
||||
} catch (NetworkIOException | IOException | IllegalStateException e) {
|
||||
DeviceLog.exception("Error completing request", e);
|
||||
onFailed(e.getClass().getName() + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void onFailed(String str) {
|
||||
this._listener.onFailed(this._url, str);
|
||||
}
|
||||
|
||||
private void onSucceed(String str, int i, Map<String, List<String>> map) {
|
||||
this._listener.onComplete(this._url, str, i, map);
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
DeviceLog.debug("Handling request message: " + this._url + " type=" + this._type);
|
||||
try {
|
||||
makeRequest(this._url, this._type, this._headers, this._body, this._connectTimeout, this._readTimeout);
|
||||
} catch (MalformedURLException e) {
|
||||
DeviceLog.exception("Malformed URL", e);
|
||||
onFailed("Malformed URL");
|
||||
}
|
||||
}
|
||||
|
||||
public void setCancelStatus(boolean z) {
|
||||
WebRequest webRequest;
|
||||
this._canceled = z;
|
||||
if (!this._canceled || (webRequest = this._currentRequest) == null) {
|
||||
return;
|
||||
}
|
||||
webRequest.cancel();
|
||||
}
|
||||
}
|
||||
187
sources/com/unity3d/ads/request/WebRequestThread.java
Normal file
187
sources/com/unity3d/ads/request/WebRequestThread.java
Normal file
@@ -0,0 +1,187 @@
|
||||
package com.unity3d.ads.request;
|
||||
|
||||
import android.os.ConditionVariable;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.request.WebRequest;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class WebRequestThread {
|
||||
private static int _corePoolSize = 1;
|
||||
private static long _keepAliveTime = 1000;
|
||||
private static int _maximumPoolSize = 1;
|
||||
private static CancelableThreadPoolExecutor _pool = null;
|
||||
private static LinkedBlockingQueue<Runnable> _queue = null;
|
||||
private static boolean _ready = false;
|
||||
private static final Object _readyLock = new Object();
|
||||
|
||||
public static synchronized void cancel() {
|
||||
synchronized (WebRequestThread.class) {
|
||||
if (_pool != null) {
|
||||
_pool.cancel();
|
||||
Iterator<Runnable> it = _queue.iterator();
|
||||
while (it.hasNext()) {
|
||||
Runnable next = it.next();
|
||||
if (next instanceof WebRequestRunnable) {
|
||||
((WebRequestRunnable) next).setCancelStatus(true);
|
||||
}
|
||||
}
|
||||
_queue.clear();
|
||||
_pool.purge();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static synchronized void init() {
|
||||
synchronized (WebRequestThread.class) {
|
||||
_queue = new LinkedBlockingQueue<>();
|
||||
_pool = new CancelableThreadPoolExecutor(_corePoolSize, _maximumPoolSize, _keepAliveTime, TimeUnit.MILLISECONDS, _queue);
|
||||
_pool.prestartAllCoreThreads();
|
||||
_queue.add(new Runnable() { // from class: com.unity3d.ads.request.WebRequestThread.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
boolean unused = WebRequestThread._ready = true;
|
||||
synchronized (WebRequestThread._readyLock) {
|
||||
WebRequestThread._readyLock.notify();
|
||||
}
|
||||
}
|
||||
});
|
||||
while (!_ready) {
|
||||
try {
|
||||
synchronized (_readyLock) {
|
||||
_readyLock.wait();
|
||||
}
|
||||
} catch (InterruptedException unused) {
|
||||
DeviceLog.debug("Couldn't synchronize thread");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void request(String str, WebRequest.RequestType requestType, Map<String, List<String>> map, Integer num, Integer num2, IWebRequestListener iWebRequestListener) {
|
||||
synchronized (WebRequestThread.class) {
|
||||
request(str, requestType, map, null, num, num2, iWebRequestListener);
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void reset() {
|
||||
synchronized (WebRequestThread.class) {
|
||||
cancel();
|
||||
if (_pool != null) {
|
||||
_pool.shutdown();
|
||||
try {
|
||||
_pool.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
|
||||
} catch (InterruptedException unused) {
|
||||
}
|
||||
_queue.clear();
|
||||
_pool = null;
|
||||
_queue = null;
|
||||
_ready = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized boolean resolve(final String str, final IResolveHostListener iResolveHostListener) {
|
||||
synchronized (WebRequestThread.class) {
|
||||
if (str != null) {
|
||||
if (str.length() >= 3) {
|
||||
new Thread(new Runnable() { // from class: com.unity3d.ads.request.WebRequestThread.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
final ConditionVariable conditionVariable = new ConditionVariable();
|
||||
Thread thread = null;
|
||||
try {
|
||||
Thread thread2 = new Thread(new Runnable() { // from class: com.unity3d.ads.request.WebRequestThread.2.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
try {
|
||||
iResolveHostListener.onResolve(str, InetAddress.getByName(str).getHostAddress());
|
||||
} catch (UnknownHostException e) {
|
||||
DeviceLog.exception("Unknown host", e);
|
||||
AnonymousClass2 anonymousClass2 = AnonymousClass2.this;
|
||||
iResolveHostListener.onFailed(str, ResolveHostError.UNKNOWN_HOST, e.getMessage());
|
||||
}
|
||||
conditionVariable.open();
|
||||
}
|
||||
});
|
||||
try {
|
||||
thread2.start();
|
||||
thread = thread2;
|
||||
} catch (Exception e) {
|
||||
e = e;
|
||||
thread = thread2;
|
||||
DeviceLog.exception("Exception while resolving host", e);
|
||||
iResolveHostListener.onFailed(str, ResolveHostError.UNEXPECTED_EXCEPTION, e.getMessage());
|
||||
if (conditionVariable.block(20000L)) {
|
||||
return;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
e = e2;
|
||||
}
|
||||
if (conditionVariable.block(20000L) || thread == null) {
|
||||
return;
|
||||
}
|
||||
thread.interrupt();
|
||||
iResolveHostListener.onFailed(str, ResolveHostError.TIMEOUT, "Timeout");
|
||||
}
|
||||
}).start();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
iResolveHostListener.onFailed(str, ResolveHostError.INVALID_HOST, "Host is NULL");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void setConcurrentRequestCount(int i) {
|
||||
synchronized (WebRequestThread.class) {
|
||||
_corePoolSize = i;
|
||||
_maximumPoolSize = _corePoolSize;
|
||||
if (_pool != null) {
|
||||
_pool.setCorePoolSize(_corePoolSize);
|
||||
_pool.setMaximumPoolSize(_maximumPoolSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void setKeepAliveTime(long j) {
|
||||
synchronized (WebRequestThread.class) {
|
||||
_keepAliveTime = j;
|
||||
if (_pool != null) {
|
||||
_pool.setKeepAliveTime(_keepAliveTime, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void setMaximumPoolSize(int i) {
|
||||
synchronized (WebRequestThread.class) {
|
||||
_maximumPoolSize = i;
|
||||
if (_pool != null) {
|
||||
_pool.setMaximumPoolSize(_maximumPoolSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void request(String str, WebRequest.RequestType requestType, Map<String, List<String>> map, String str2, Integer num, Integer num2, IWebRequestListener iWebRequestListener) {
|
||||
synchronized (WebRequestThread.class) {
|
||||
if (!_ready) {
|
||||
init();
|
||||
}
|
||||
if (str != null && str.length() >= 3) {
|
||||
_queue.add(new WebRequestRunnable(str, requestType.name(), str2, num.intValue(), num2.intValue(), map, iWebRequestListener));
|
||||
return;
|
||||
}
|
||||
iWebRequestListener.onFailed(str, "Request is NULL or too short");
|
||||
}
|
||||
}
|
||||
}
|
||||
6
sources/com/unity3d/ads/sensorinfo/SensorInfoError.java
Normal file
6
sources/com/unity3d/ads/sensorinfo/SensorInfoError.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package com.unity3d.ads.sensorinfo;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum SensorInfoError {
|
||||
ACCELEROMETER_DATA_NOT_AVAILABLE
|
||||
}
|
||||
64
sources/com/unity3d/ads/sensorinfo/SensorInfoListener.java
Normal file
64
sources/com/unity3d/ads/sensorinfo/SensorInfoListener.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package com.unity3d.ads.sensorinfo;
|
||||
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.properties.ClientProperties;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class SensorInfoListener implements SensorEventListener {
|
||||
private static SensorInfoListener _accelerometerListener;
|
||||
private static Sensor _accelerometerSensor;
|
||||
private static SensorEvent _latestAccelerometerEvent;
|
||||
|
||||
public static JSONObject getAccelerometerData() {
|
||||
if (_latestAccelerometerEvent == null) {
|
||||
return null;
|
||||
}
|
||||
JSONObject jSONObject = new JSONObject();
|
||||
try {
|
||||
jSONObject.put("x", _latestAccelerometerEvent.values[0]);
|
||||
jSONObject.put("y", _latestAccelerometerEvent.values[1]);
|
||||
jSONObject.put("z", _latestAccelerometerEvent.values[2]);
|
||||
return jSONObject;
|
||||
} catch (JSONException e) {
|
||||
DeviceLog.exception("JSON error while constructing accelerometer data", e);
|
||||
return jSONObject;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isAccelerometerListenerActive() {
|
||||
return _accelerometerListener != null;
|
||||
}
|
||||
|
||||
public static boolean startAccelerometerListener(int i) {
|
||||
if (_accelerometerListener == null) {
|
||||
_accelerometerListener = new SensorInfoListener();
|
||||
}
|
||||
SensorManager sensorManager = (SensorManager) ClientProperties.getApplicationContext().getSystemService("sensor");
|
||||
_accelerometerSensor = sensorManager.getDefaultSensor(1);
|
||||
return sensorManager.registerListener(_accelerometerListener, _accelerometerSensor, i);
|
||||
}
|
||||
|
||||
public static void stopAccelerometerListener() {
|
||||
if (_accelerometerListener != null) {
|
||||
((SensorManager) ClientProperties.getApplicationContext().getSystemService("sensor")).unregisterListener(_accelerometerListener);
|
||||
_accelerometerListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.hardware.SensorEventListener
|
||||
public void onAccuracyChanged(Sensor sensor, int i) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.SensorEventListener
|
||||
public void onSensorChanged(SensorEvent sensorEvent) {
|
||||
if (sensorEvent.sensor.getType() == 1) {
|
||||
_latestAccelerometerEvent = sensorEvent;
|
||||
}
|
||||
}
|
||||
}
|
||||
8
sources/com/unity3d/ads/video/VideoPlayerError.java
Normal file
8
sources/com/unity3d/ads/video/VideoPlayerError.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.unity3d.ads.video;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum VideoPlayerError {
|
||||
VIDEOVIEW_NULL,
|
||||
PREPARE,
|
||||
API_LEVEL_ERROR
|
||||
}
|
||||
19
sources/com/unity3d/ads/video/VideoPlayerEvent.java
Normal file
19
sources/com/unity3d/ads/video/VideoPlayerEvent.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.unity3d.ads.video;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum VideoPlayerEvent {
|
||||
GENERIC_ERROR,
|
||||
PROGRESS,
|
||||
INFO,
|
||||
COMPLETED,
|
||||
PREPARED,
|
||||
PREPARE_ERROR,
|
||||
PREPARE_TIMEOUT,
|
||||
PLAY,
|
||||
PAUSE_ERROR,
|
||||
PAUSE,
|
||||
SEEKTO_ERROR,
|
||||
SEEKTO,
|
||||
STOP,
|
||||
ILLEGAL_STATE
|
||||
}
|
||||
218
sources/com/unity3d/ads/video/VideoPlayerView.java
Normal file
218
sources/com/unity3d/ads/video/VideoPlayerView.java
Normal file
@@ -0,0 +1,218 @@
|
||||
package com.unity3d.ads.video;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.MediaPlayer;
|
||||
import android.os.Build;
|
||||
import android.widget.VideoView;
|
||||
import com.ubt.jimu.base.mvp.SingleClickListener;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.webview.WebViewApp;
|
||||
import com.unity3d.ads.webview.WebViewEventCategory;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class VideoPlayerView extends VideoView {
|
||||
private boolean _infoListenerEnabled;
|
||||
private MediaPlayer _mediaPlayer;
|
||||
private Timer _prepareTimer;
|
||||
private int _progressEventInterval;
|
||||
private Timer _videoTimer;
|
||||
private String _videoUrl;
|
||||
private Float _volume;
|
||||
|
||||
public VideoPlayerView(Context context) {
|
||||
super(context);
|
||||
this._progressEventInterval = SingleClickListener.FAST_CLICK_DELAY_TIME;
|
||||
this._mediaPlayer = null;
|
||||
this._volume = null;
|
||||
this._infoListenerEnabled = true;
|
||||
}
|
||||
|
||||
private void startPrepareTimer(long j) {
|
||||
this._prepareTimer = new Timer();
|
||||
this._prepareTimer.schedule(new TimerTask() { // from class: com.unity3d.ads.video.VideoPlayerView.2
|
||||
@Override // java.util.TimerTask, java.lang.Runnable
|
||||
public void run() {
|
||||
if (VideoPlayerView.this.isPlaying()) {
|
||||
return;
|
||||
}
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.VIDEOPLAYER, VideoPlayerEvent.PREPARE_TIMEOUT, VideoPlayerView.this._videoUrl);
|
||||
DeviceLog.error("Video player prepare timeout: " + VideoPlayerView.this._videoUrl);
|
||||
}
|
||||
}, j);
|
||||
}
|
||||
|
||||
private void startVideoProgressTimer() {
|
||||
this._videoTimer = new Timer();
|
||||
Timer timer = this._videoTimer;
|
||||
TimerTask timerTask = new TimerTask() { // from class: com.unity3d.ads.video.VideoPlayerView.1
|
||||
@Override // java.util.TimerTask, java.lang.Runnable
|
||||
public void run() {
|
||||
boolean z;
|
||||
try {
|
||||
z = VideoPlayerView.this.isPlaying();
|
||||
} catch (IllegalStateException e) {
|
||||
e = e;
|
||||
z = false;
|
||||
}
|
||||
try {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.VIDEOPLAYER, VideoPlayerEvent.PROGRESS, Integer.valueOf(VideoPlayerView.this.getCurrentPosition()));
|
||||
} catch (IllegalStateException e2) {
|
||||
e = e2;
|
||||
DeviceLog.exception("Exception while sending current position to webapp", e);
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.VIDEOPLAYER, VideoPlayerEvent.ILLEGAL_STATE, VideoPlayerEvent.PROGRESS, VideoPlayerView.this._videoUrl, Boolean.valueOf(z));
|
||||
}
|
||||
}
|
||||
};
|
||||
int i = this._progressEventInterval;
|
||||
timer.scheduleAtFixedRate(timerTask, i, i);
|
||||
}
|
||||
|
||||
public int getProgressEventInterval() {
|
||||
return this._progressEventInterval;
|
||||
}
|
||||
|
||||
public float getVolume() {
|
||||
return this._volume.floatValue();
|
||||
}
|
||||
|
||||
@Override // android.widget.VideoView, android.widget.MediaController.MediaPlayerControl
|
||||
public void pause() {
|
||||
try {
|
||||
super.pause();
|
||||
stopVideoProgressTimer();
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.VIDEOPLAYER, VideoPlayerEvent.PAUSE, this._videoUrl);
|
||||
} catch (Exception e) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.VIDEOPLAYER, VideoPlayerEvent.PAUSE_ERROR, this._videoUrl);
|
||||
DeviceLog.exception("Error pausing video", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void play() {
|
||||
DeviceLog.entered();
|
||||
setOnCompletionListener(new MediaPlayer.OnCompletionListener() { // from class: com.unity3d.ads.video.VideoPlayerView.5
|
||||
@Override // android.media.MediaPlayer.OnCompletionListener
|
||||
public void onCompletion(MediaPlayer mediaPlayer) {
|
||||
if (mediaPlayer != null) {
|
||||
VideoPlayerView.this._mediaPlayer = mediaPlayer;
|
||||
}
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.VIDEOPLAYER, VideoPlayerEvent.COMPLETED, VideoPlayerView.this._videoUrl);
|
||||
VideoPlayerView.this.stopVideoProgressTimer();
|
||||
}
|
||||
});
|
||||
start();
|
||||
stopVideoProgressTimer();
|
||||
startVideoProgressTimer();
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.VIDEOPLAYER, VideoPlayerEvent.PLAY, this._videoUrl);
|
||||
}
|
||||
|
||||
public boolean prepare(String str, final float f, int i) {
|
||||
DeviceLog.entered();
|
||||
this._videoUrl = str;
|
||||
setOnPreparedListener(new MediaPlayer.OnPreparedListener() { // from class: com.unity3d.ads.video.VideoPlayerView.3
|
||||
@Override // android.media.MediaPlayer.OnPreparedListener
|
||||
public void onPrepared(MediaPlayer mediaPlayer) {
|
||||
VideoPlayerView.this.stopPrepareTimer();
|
||||
if (mediaPlayer != null) {
|
||||
VideoPlayerView.this._mediaPlayer = mediaPlayer;
|
||||
}
|
||||
VideoPlayerView.this.setVolume(Float.valueOf(f));
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.VIDEOPLAYER, VideoPlayerEvent.PREPARED, VideoPlayerView.this._videoUrl, Integer.valueOf(mediaPlayer.getDuration()), Integer.valueOf(mediaPlayer.getVideoWidth()), Integer.valueOf(mediaPlayer.getVideoHeight()));
|
||||
}
|
||||
});
|
||||
setOnErrorListener(new MediaPlayer.OnErrorListener() { // from class: com.unity3d.ads.video.VideoPlayerView.4
|
||||
@Override // android.media.MediaPlayer.OnErrorListener
|
||||
public boolean onError(MediaPlayer mediaPlayer, int i2, int i3) {
|
||||
VideoPlayerView.this.stopPrepareTimer();
|
||||
if (mediaPlayer != null) {
|
||||
VideoPlayerView.this._mediaPlayer = mediaPlayer;
|
||||
}
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.VIDEOPLAYER, VideoPlayerEvent.GENERIC_ERROR, VideoPlayerView.this._videoUrl, Integer.valueOf(i2), Integer.valueOf(i3));
|
||||
VideoPlayerView.this.stopVideoProgressTimer();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
setInfoListenerEnabled(this._infoListenerEnabled);
|
||||
if (i > 0) {
|
||||
startPrepareTimer(i);
|
||||
}
|
||||
try {
|
||||
setVideoPath(this._videoUrl);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.VIDEOPLAYER, VideoPlayerEvent.PREPARE_ERROR, this._videoUrl);
|
||||
DeviceLog.exception("Error preparing video: " + this._videoUrl, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.widget.VideoView, android.widget.MediaController.MediaPlayerControl
|
||||
public void seekTo(int i) {
|
||||
try {
|
||||
super.seekTo(i);
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.VIDEOPLAYER, VideoPlayerEvent.SEEKTO, this._videoUrl);
|
||||
} catch (Exception e) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.VIDEOPLAYER, VideoPlayerEvent.SEEKTO_ERROR, this._videoUrl);
|
||||
DeviceLog.exception("Error seeking video", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setInfoListenerEnabled(boolean z) {
|
||||
this._infoListenerEnabled = z;
|
||||
if (Build.VERSION.SDK_INT > 16) {
|
||||
if (this._infoListenerEnabled) {
|
||||
setOnInfoListener(new MediaPlayer.OnInfoListener() { // from class: com.unity3d.ads.video.VideoPlayerView.6
|
||||
@Override // android.media.MediaPlayer.OnInfoListener
|
||||
public boolean onInfo(MediaPlayer mediaPlayer, int i, int i2) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.VIDEOPLAYER, VideoPlayerEvent.INFO, VideoPlayerView.this._videoUrl, Integer.valueOf(i), Integer.valueOf(i2));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
setOnInfoListener(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setProgressEventInterval(int i) {
|
||||
this._progressEventInterval = i;
|
||||
if (this._videoTimer != null) {
|
||||
stopVideoProgressTimer();
|
||||
startVideoProgressTimer();
|
||||
}
|
||||
}
|
||||
|
||||
public void setVolume(Float f) {
|
||||
try {
|
||||
this._mediaPlayer.setVolume(f.floatValue(), f.floatValue());
|
||||
this._volume = f;
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("MediaPlayer generic error", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
stopPlayback();
|
||||
stopVideoProgressTimer();
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.VIDEOPLAYER, VideoPlayerEvent.STOP, this._videoUrl);
|
||||
}
|
||||
|
||||
public void stopPrepareTimer() {
|
||||
Timer timer = this._prepareTimer;
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
this._prepareTimer.purge();
|
||||
this._prepareTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void stopVideoProgressTimer() {
|
||||
Timer timer = this._videoTimer;
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
this._videoTimer.purge();
|
||||
this._videoTimer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
687
sources/com/unity3d/ads/webplayer/WebPlayer.java
Normal file
687
sources/com/unity3d/ads/webplayer/WebPlayer.java
Normal file
@@ -0,0 +1,687 @@
|
||||
package com.unity3d.ads.webplayer;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.net.Uri;
|
||||
import android.net.http.SslError;
|
||||
import android.os.Build;
|
||||
import android.os.Message;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.webkit.ClientCertRequest;
|
||||
import android.webkit.ConsoleMessage;
|
||||
import android.webkit.DownloadListener;
|
||||
import android.webkit.GeolocationPermissions;
|
||||
import android.webkit.HttpAuthHandler;
|
||||
import android.webkit.JsPromptResult;
|
||||
import android.webkit.JsResult;
|
||||
import android.webkit.PermissionRequest;
|
||||
import android.webkit.SslErrorHandler;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebResourceError;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebResourceResponse;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import com.unity3d.ads.log.DeviceLog;
|
||||
import com.unity3d.ads.misc.Utilities;
|
||||
import com.unity3d.ads.misc.ViewUtilities;
|
||||
import com.unity3d.ads.webview.WebViewApp;
|
||||
import com.unity3d.ads.webview.WebViewEventCategory;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class WebPlayer extends WebView {
|
||||
private Map<String, String> _erroredSettings;
|
||||
private Method _evaluateJavascript;
|
||||
private JSONObject _eventSettings;
|
||||
|
||||
private class JavaScriptInvocation implements Runnable {
|
||||
private String _jsString;
|
||||
private WebView _webView;
|
||||
|
||||
public JavaScriptInvocation(String str, WebView webView) {
|
||||
this._jsString = null;
|
||||
this._webView = null;
|
||||
this._jsString = str;
|
||||
this._webView = webView;
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
String str = this._jsString;
|
||||
if (str == null) {
|
||||
DeviceLog.error("Could not process JavaScript, the string is NULL");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
WebPlayer.this._evaluateJavascript.invoke(this._webView, this._jsString, null);
|
||||
} else {
|
||||
WebPlayer.this.loadUrl(str);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error while processing JavaScriptString", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(21)
|
||||
private class WebPlayerChromeClient extends WebChromeClient {
|
||||
private WebPlayerChromeClient() {
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public void onCloseWindow(WebView webView) {
|
||||
if (WebPlayer.this.shouldCallSuper("onCloseWindow")) {
|
||||
super.onCloseWindow(webView);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onCloseWindow")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.CLOSE_WINDOW, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
|
||||
Boolean valueOf = WebPlayer.this.shouldCallSuper("onConsoleMessage") ? Boolean.valueOf(super.onConsoleMessage(consoleMessage)) : false;
|
||||
if (WebPlayer.this.shouldSendEvent("onConsoleMessage")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.CONSOLE_MESSAGE, consoleMessage != null ? consoleMessage.message() : "");
|
||||
}
|
||||
if (WebPlayer.this.hasReturnValue("onConsoleMessage")) {
|
||||
valueOf = (Boolean) WebPlayer.this.getReturnValue("onConsoleMessage", Boolean.class, true);
|
||||
}
|
||||
return valueOf.booleanValue();
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public boolean onCreateWindow(WebView webView, boolean z, boolean z2, Message message) {
|
||||
Boolean valueOf = WebPlayer.this.shouldCallSuper("onCreateWindow") ? Boolean.valueOf(super.onCreateWindow(webView, z, z2, message)) : false;
|
||||
if (WebPlayer.this.shouldSendEvent("onCreateWindow")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.CREATE_WINDOW, Boolean.valueOf(z), Boolean.valueOf(z2), message);
|
||||
}
|
||||
if (WebPlayer.this.hasReturnValue("onCreateWindow")) {
|
||||
valueOf = (Boolean) WebPlayer.this.getReturnValue("onCreateWindow", Boolean.class, false);
|
||||
}
|
||||
return valueOf.booleanValue();
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public void onGeolocationPermissionsShowPrompt(String str, GeolocationPermissions.Callback callback) {
|
||||
if (WebPlayer.this.shouldCallSuper("onGeolocationPermissionsShowPrompt")) {
|
||||
super.onGeolocationPermissionsShowPrompt(str, callback);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onGeolocationPermissionsShowPrompt")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.GEOLOCATION_PERMISSIONS_SHOW, str);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public void onHideCustomView() {
|
||||
if (WebPlayer.this.shouldCallSuper("onHideCustomView")) {
|
||||
super.onHideCustomView();
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onHideCustomView")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.HIDE_CUSTOM_VIEW, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public boolean onJsAlert(WebView webView, String str, String str2, JsResult jsResult) {
|
||||
Boolean valueOf = WebPlayer.this.shouldCallSuper("onJsAlert") ? Boolean.valueOf(super.onJsAlert(webView, str, str2, jsResult)) : false;
|
||||
if (WebPlayer.this.shouldSendEvent("onJsAlert")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.JS_ALERT, str, str2, jsResult);
|
||||
}
|
||||
if (WebPlayer.this.hasReturnValue("onJsAlert")) {
|
||||
valueOf = (Boolean) WebPlayer.this.getReturnValue("onJsAlert", Boolean.class, true);
|
||||
}
|
||||
return valueOf.booleanValue();
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public boolean onJsConfirm(WebView webView, String str, String str2, JsResult jsResult) {
|
||||
Boolean valueOf = WebPlayer.this.shouldCallSuper("onJsConfirm") ? Boolean.valueOf(super.onJsConfirm(webView, str, str2, jsResult)) : false;
|
||||
if (WebPlayer.this.shouldSendEvent("onJsConfirm")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.JS_CONFIRM, str, str2);
|
||||
}
|
||||
if (WebPlayer.this.hasReturnValue("onJsConfirm")) {
|
||||
valueOf = (Boolean) WebPlayer.this.getReturnValue("onJsConfirm", Boolean.class, true);
|
||||
}
|
||||
return valueOf.booleanValue();
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public boolean onJsPrompt(WebView webView, String str, String str2, String str3, JsPromptResult jsPromptResult) {
|
||||
Boolean valueOf = WebPlayer.this.shouldCallSuper("onJsPrompt") ? Boolean.valueOf(super.onJsPrompt(webView, str, str2, str3, jsPromptResult)) : false;
|
||||
if (WebPlayer.this.shouldSendEvent("onJsPrompt")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.JS_PROMPT, str, str2, str3);
|
||||
}
|
||||
if (WebPlayer.this.hasReturnValue("onJsPrompt")) {
|
||||
valueOf = (Boolean) WebPlayer.this.getReturnValue("onJsPrompt", Boolean.class, true);
|
||||
}
|
||||
return valueOf.booleanValue();
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public void onPermissionRequest(PermissionRequest permissionRequest) {
|
||||
if (WebPlayer.this.shouldCallSuper("onPermissionRequest")) {
|
||||
super.onPermissionRequest(permissionRequest);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onPermissionRequest")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.PERMISSION_REQUEST, (permissionRequest == null || permissionRequest.getOrigin() == null) ? "" : permissionRequest.getOrigin().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public void onProgressChanged(WebView webView, int i) {
|
||||
if (WebPlayer.this.shouldCallSuper("onProgressChanged")) {
|
||||
super.onProgressChanged(webView, i);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onProgressChanged")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.PROGRESS_CHANGED, Integer.valueOf(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public void onReceivedIcon(WebView webView, Bitmap bitmap) {
|
||||
if (WebPlayer.this.shouldCallSuper("onReceivedIcon")) {
|
||||
super.onReceivedIcon(webView, bitmap);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onReceivedIcon")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.RECEIVED_ICON, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public void onReceivedTitle(WebView webView, String str) {
|
||||
if (WebPlayer.this.shouldCallSuper("onReceivedTitle")) {
|
||||
super.onReceivedTitle(webView, str);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onReceivedTitle")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.RECEIVED_TITLE, str);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public void onReceivedTouchIconUrl(WebView webView, String str, boolean z) {
|
||||
if (WebPlayer.this.shouldCallSuper("onReceivedTouchIconUrl")) {
|
||||
super.onReceivedTouchIconUrl(webView, str, z);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onReceivedTouchIconUrl")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.RECEIVED_TOUCH_ICON_URL, str, Boolean.valueOf(z));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public void onRequestFocus(WebView webView) {
|
||||
if (WebPlayer.this.shouldCallSuper("onRequestFocus")) {
|
||||
super.onRequestFocus(webView);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onRequestFocus")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.REQUEST_FOCUS, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public void onShowCustomView(View view, WebChromeClient.CustomViewCallback customViewCallback) {
|
||||
if (WebPlayer.this.shouldCallSuper("onShowCustomView")) {
|
||||
super.onShowCustomView(view, customViewCallback);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onShowCustomView")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SHOW_CUSTOM_VIEW, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> valueCallback, WebChromeClient.FileChooserParams fileChooserParams) {
|
||||
Boolean valueOf = WebPlayer.this.shouldCallSuper("onShowFileChooser") ? Boolean.valueOf(super.onShowFileChooser(webView, valueCallback, fileChooserParams)) : false;
|
||||
if (WebPlayer.this.shouldSendEvent("onShowFileChooser")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SHOW_FILE_CHOOSER, new Object[0]);
|
||||
}
|
||||
if (WebPlayer.this.hasReturnValue("onShowFileChooser")) {
|
||||
valueOf = (Boolean) WebPlayer.this.getReturnValue("onShowFileChooser", Boolean.class, true);
|
||||
if (valueOf.booleanValue()) {
|
||||
valueCallback.onReceiveValue(null);
|
||||
}
|
||||
}
|
||||
return valueOf.booleanValue();
|
||||
}
|
||||
}
|
||||
|
||||
private class WebPlayerDownloadListener implements DownloadListener {
|
||||
private WebPlayerDownloadListener() {
|
||||
}
|
||||
|
||||
@Override // android.webkit.DownloadListener
|
||||
public void onDownloadStart(String str, String str2, String str3, String str4, long j) {
|
||||
if (WebPlayer.this.shouldSendEvent("onDownloadStart")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.DOWNLOAD_START, str, str2, str3, str4, Long.valueOf(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public WebPlayer(Context context) {
|
||||
super(context);
|
||||
this._evaluateJavascript = null;
|
||||
}
|
||||
|
||||
private void addErroredSetting(String str, String str2) {
|
||||
if (this._erroredSettings == null) {
|
||||
this._erroredSettings = new HashMap();
|
||||
}
|
||||
this._erroredSettings.put(str, str2);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public <T> T getReturnValue(String str, Class<T> cls, T t) {
|
||||
try {
|
||||
if (this._eventSettings != null && this._eventSettings.has(str) && this._eventSettings.getJSONObject(str).has("returnValue")) {
|
||||
return cls.cast(this._eventSettings.getJSONObject(str).get("returnValue"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error getting default return value", e);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
private Class<?>[] getTypes(JSONArray jSONArray) throws JSONException, ClassNotFoundException {
|
||||
if (jSONArray == null) {
|
||||
return null;
|
||||
}
|
||||
Class<?>[] clsArr = new Class[jSONArray.length()];
|
||||
if (jSONArray != null) {
|
||||
for (int i = 0; i < jSONArray.length(); i++) {
|
||||
if (jSONArray.get(i) instanceof JSONObject) {
|
||||
Class<?> cls = Class.forName(((JSONObject) jSONArray.get(i)).getString("className"));
|
||||
if (cls != null) {
|
||||
clsArr[i] = cls;
|
||||
}
|
||||
} else {
|
||||
clsArr[i] = getPrimitiveClass(jSONArray.get(i).getClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
return clsArr;
|
||||
}
|
||||
|
||||
private Object[] getValues(JSONArray jSONArray) throws JSONException, ClassNotFoundException, NoSuchMethodException {
|
||||
Class<?> cls;
|
||||
if (jSONArray == null) {
|
||||
return null;
|
||||
}
|
||||
Object[] objArr = new Object[jSONArray.length()];
|
||||
Object[] objArr2 = new Object[jSONArray.length()];
|
||||
for (int i = 0; i < jSONArray.length(); i++) {
|
||||
if (jSONArray.get(i) instanceof JSONObject) {
|
||||
JSONObject jSONObject = (JSONObject) jSONArray.get(i);
|
||||
Object obj = jSONObject.get("value");
|
||||
String string = jSONObject.getString("type");
|
||||
String string2 = jSONObject.has("className") ? jSONObject.getString("className") : null;
|
||||
if (string2 != null && string.equals("Enum") && (cls = Class.forName(string2)) != null) {
|
||||
objArr2[i] = Enum.valueOf(cls, (String) obj);
|
||||
}
|
||||
} else {
|
||||
objArr2[i] = jSONArray.get(i);
|
||||
}
|
||||
}
|
||||
if (jSONArray != null) {
|
||||
System.arraycopy(objArr2, 0, objArr, 0, jSONArray.length());
|
||||
}
|
||||
return objArr;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean hasReturnValue(String str) {
|
||||
try {
|
||||
if (this._eventSettings == null || !this._eventSettings.has(str)) {
|
||||
return false;
|
||||
}
|
||||
return this._eventSettings.getJSONObject(str).has("returnValue");
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error getting default return value", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private Object setTargetSettings(Object obj, JSONObject jSONObject) {
|
||||
if (jSONObject != null) {
|
||||
Iterator<String> keys = jSONObject.keys();
|
||||
while (keys.hasNext()) {
|
||||
String next = keys.next();
|
||||
try {
|
||||
JSONArray jSONArray = jSONObject.getJSONArray(next);
|
||||
obj.getClass().getMethod(next, getTypes(jSONArray)).invoke(obj, getValues(jSONArray));
|
||||
} catch (Exception e) {
|
||||
addErroredSetting(next, e.getMessage());
|
||||
DeviceLog.exception("Setting errored", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean shouldCallSuper(String str) {
|
||||
try {
|
||||
if (this._eventSettings != null && this._eventSettings.has(str) && this._eventSettings.getJSONObject(str).has("callSuper")) {
|
||||
return this._eventSettings.getJSONObject(str).getBoolean("callSuper");
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error getting super call status", e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean shouldSendEvent(String str) {
|
||||
try {
|
||||
if (this._eventSettings != null && this._eventSettings.has(str) && this._eventSettings.getJSONObject(str).has("sendEvent")) {
|
||||
return this._eventSettings.getJSONObject(str).getBoolean("sendEvent");
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
DeviceLog.exception("Error getting send event status", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getErroredSettings() {
|
||||
return this._erroredSettings;
|
||||
}
|
||||
|
||||
public Class<?> getPrimitiveClass(Class<?> cls) {
|
||||
String name = cls.getName();
|
||||
return name.equals("java.lang.Byte") ? Byte.TYPE : name.equals("java.lang.Short") ? Short.TYPE : name.equals("java.lang.Integer") ? Integer.TYPE : name.equals("java.lang.Long") ? Long.TYPE : name.equals("java.lang.Character") ? Character.TYPE : name.equals("java.lang.Float") ? Float.TYPE : name.equals("java.lang.Double") ? Double.TYPE : name.equals("java.lang.Boolean") ? Boolean.TYPE : name.equals("java.lang.Void") ? Void.TYPE : cls;
|
||||
}
|
||||
|
||||
public void invokeJavascript(String str) {
|
||||
Utilities.runOnUiThread(new JavaScriptInvocation(str, this));
|
||||
}
|
||||
|
||||
public void sendEvent(JSONArray jSONArray) {
|
||||
invokeJavascript("javascript:window.nativebridge.receiveEvent(" + jSONArray.toString() + ")");
|
||||
}
|
||||
|
||||
public void setEventSettings(JSONObject jSONObject) {
|
||||
this._eventSettings = jSONObject;
|
||||
}
|
||||
|
||||
public void setSettings(JSONObject jSONObject, JSONObject jSONObject2) {
|
||||
Map<String, String> map = this._erroredSettings;
|
||||
if (map != null) {
|
||||
map.clear();
|
||||
}
|
||||
setTargetSettings(getSettings(), jSONObject);
|
||||
setTargetSettings(this, jSONObject2);
|
||||
}
|
||||
|
||||
public WebPlayer(Context context, JSONObject jSONObject, JSONObject jSONObject2) {
|
||||
super(context);
|
||||
this._evaluateJavascript = null;
|
||||
WebSettings settings = getSettings();
|
||||
if (Build.VERSION.SDK_INT >= 16) {
|
||||
settings.setAllowFileAccessFromFileURLs(false);
|
||||
settings.setAllowUniversalAccessFromFileURLs(false);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
try {
|
||||
this._evaluateJavascript = WebView.class.getMethod("evaluateJavascript", String.class, ValueCallback.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
DeviceLog.exception("Method evaluateJavascript not found", e);
|
||||
this._evaluateJavascript = null;
|
||||
}
|
||||
}
|
||||
settings.setAppCacheEnabled(false);
|
||||
settings.setCacheMode(2);
|
||||
settings.setDatabaseEnabled(false);
|
||||
settings.setDomStorageEnabled(false);
|
||||
settings.setGeolocationEnabled(false);
|
||||
settings.setJavaScriptEnabled(true);
|
||||
settings.setLoadsImagesAutomatically(true);
|
||||
settings.setPluginState(WebSettings.PluginState.OFF);
|
||||
settings.setRenderPriority(WebSettings.RenderPriority.NORMAL);
|
||||
settings.setSaveFormData(false);
|
||||
settings.setSavePassword(false);
|
||||
setHorizontalScrollBarEnabled(false);
|
||||
setVerticalScrollBarEnabled(false);
|
||||
setInitialScale(0);
|
||||
setBackgroundColor(0);
|
||||
ViewUtilities.setBackground(this, new ColorDrawable(0));
|
||||
setBackgroundResource(0);
|
||||
setSettings(jSONObject, jSONObject2);
|
||||
setWebViewClient(new WebPlayerClient());
|
||||
setWebChromeClient(new WebPlayerChromeClient());
|
||||
setDownloadListener(new WebPlayerDownloadListener());
|
||||
addJavascriptInterface(new WebPlayerBridgeInterface(), "webplayerbridge");
|
||||
}
|
||||
|
||||
private class WebPlayerClient extends WebViewClient {
|
||||
private WebPlayerClient() {
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onFormResubmission(WebView webView, Message message, Message message2) {
|
||||
if (WebPlayer.this.shouldCallSuper("onFormResubmission")) {
|
||||
super.onFormResubmission(webView, message, message2);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onFormResubmission")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.FORM_RESUBMISSION, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onLoadResource(WebView webView, String str) {
|
||||
if (WebPlayer.this.shouldCallSuper("onLoadResource")) {
|
||||
super.onLoadResource(webView, str);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onLoadResource")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.LOAD_RESOUCE, str);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onPageCommitVisible(WebView webView, String str) {
|
||||
if (WebPlayer.this.shouldCallSuper("onPageCommitVisible")) {
|
||||
super.onPageCommitVisible(webView, str);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onPageCommitVisible")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.PAGE_COMMIT_VISIBLE, str);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onPageFinished(WebView webView, String str) {
|
||||
if (WebPlayer.this.shouldCallSuper("onPageFinished")) {
|
||||
super.onPageFinished(webView, str);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onPageFinished")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.PAGE_FINISHED, str);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
|
||||
if (WebPlayer.this.shouldCallSuper("onPageStarted")) {
|
||||
super.onPageStarted(webView, str, bitmap);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onPageStarted")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.PAGE_STARTED, str);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
@TargetApi(21)
|
||||
public void onReceivedClientCertRequest(WebView webView, ClientCertRequest clientCertRequest) {
|
||||
String str;
|
||||
int i;
|
||||
if (WebPlayer.this.shouldCallSuper("onReceivedClientCertRequest")) {
|
||||
super.onReceivedClientCertRequest(webView, clientCertRequest);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onReceivedClientCertRequest")) {
|
||||
if (clientCertRequest != null) {
|
||||
str = clientCertRequest.getHost();
|
||||
i = clientCertRequest.getPort();
|
||||
} else {
|
||||
str = "";
|
||||
i = -1;
|
||||
}
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.CLIENT_CERT_REQUEST, str, Integer.valueOf(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onReceivedError(WebView webView, int i, String str, String str2) {
|
||||
if (WebPlayer.this.shouldCallSuper("onReceivedError")) {
|
||||
super.onReceivedError(webView, i, str, str2);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onReceivedError")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.ERROR, str2, str);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onReceivedHttpAuthRequest(WebView webView, HttpAuthHandler httpAuthHandler, String str, String str2) {
|
||||
if (WebPlayer.this.shouldCallSuper("onReceivedHttpAuthRequest")) {
|
||||
super.onReceivedHttpAuthRequest(webView, httpAuthHandler, str, str2);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onReceivedHttpAuthRequest")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.HTTP_AUTH_REQUEST, str, str2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
@TargetApi(21)
|
||||
public void onReceivedHttpError(WebView webView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse) {
|
||||
if (WebPlayer.this.shouldCallSuper("onReceivedHttpError")) {
|
||||
super.onReceivedHttpError(webView, webResourceRequest, webResourceResponse);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onReceivedHttpError")) {
|
||||
String str = "";
|
||||
String uri = (webResourceRequest == null || webResourceRequest.getUrl() == null) ? "" : webResourceRequest.getUrl().toString();
|
||||
int i = -1;
|
||||
if (webResourceResponse != null) {
|
||||
i = webResourceResponse.getStatusCode();
|
||||
str = webResourceResponse.getReasonPhrase();
|
||||
}
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.HTTP_ERROR, uri, str, Integer.valueOf(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onReceivedLoginRequest(WebView webView, String str, String str2, String str3) {
|
||||
if (WebPlayer.this.shouldCallSuper("onReceivedLoginRequest")) {
|
||||
super.onReceivedLoginRequest(webView, str, str2, str3);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onReceivedLoginRequest")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.LOGIN_REQUEST, str, str2, str3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
@TargetApi(14)
|
||||
public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
|
||||
if (WebPlayer.this.shouldCallSuper("onReceivedSslError")) {
|
||||
super.onReceivedSslError(webView, sslErrorHandler, sslError);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onReceivedSslError")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SSL_ERROR, sslError != null ? sslError.getUrl() : "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onScaleChanged(WebView webView, float f, float f2) {
|
||||
if (WebPlayer.this.shouldCallSuper("onScaleChanged")) {
|
||||
super.onScaleChanged(webView, f, f2);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onScaleChanged")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SCALE_CHANGED, Float.valueOf(f), Float.valueOf(f2));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onUnhandledKeyEvent(WebView webView, KeyEvent keyEvent) {
|
||||
if (WebPlayer.this.shouldCallSuper("onUnhandledKeyEvent")) {
|
||||
super.onUnhandledKeyEvent(webView, keyEvent);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onUnhandledKeyEvent")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.UNHANDLED_KEY_EVENT, Integer.valueOf(keyEvent.getKeyCode()), Integer.valueOf(keyEvent.getAction()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
@TargetApi(21)
|
||||
public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
|
||||
WebResourceResponse shouldInterceptRequest = WebPlayer.this.shouldCallSuper("shouldInterceptRequest") ? super.shouldInterceptRequest(webView, webResourceRequest) : null;
|
||||
if (WebPlayer.this.shouldSendEvent("shouldInterceptRequest")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SHOULD_INTERCEPT_REQUEST, webResourceRequest.getUrl().toString());
|
||||
}
|
||||
return shouldInterceptRequest;
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public boolean shouldOverrideKeyEvent(WebView webView, KeyEvent keyEvent) {
|
||||
Boolean valueOf = WebPlayer.this.shouldCallSuper("shouldOverrideKeyEvent") ? Boolean.valueOf(super.shouldOverrideKeyEvent(webView, keyEvent)) : false;
|
||||
if (WebPlayer.this.shouldSendEvent("shouldOverrideKeyEvent")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SHOULD_OVERRIDE_KEY_EVENT, Integer.valueOf(keyEvent.getKeyCode()), Integer.valueOf(keyEvent.getAction()));
|
||||
}
|
||||
if (WebPlayer.this.hasReturnValue("shouldOverrideKeyEvent")) {
|
||||
valueOf = (Boolean) WebPlayer.this.getReturnValue("shouldOverrideKeyEvent", Boolean.class, true);
|
||||
}
|
||||
return valueOf.booleanValue();
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
@TargetApi(21)
|
||||
public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
|
||||
Boolean valueOf = WebPlayer.this.shouldCallSuper("shouldOverrideUrlLoading") ? Boolean.valueOf(super.shouldOverrideUrlLoading(webView, webResourceRequest)) : false;
|
||||
if (WebPlayer.this.shouldSendEvent("shouldOverrideUrlLoading")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SHOULD_OVERRIDE_URL_LOADING, webResourceRequest.getUrl().toString(), webResourceRequest.getMethod());
|
||||
}
|
||||
if (WebPlayer.this.hasReturnValue("shouldOverrideUrlLoading")) {
|
||||
valueOf = (Boolean) WebPlayer.this.getReturnValue("shouldOverrideUrlLoading", Boolean.class, true);
|
||||
}
|
||||
return valueOf.booleanValue();
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
@TargetApi(25)
|
||||
public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
|
||||
if (WebPlayer.this.shouldCallSuper("onReceivedError")) {
|
||||
super.onReceivedError(webView, webResourceRequest, webResourceError);
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("onReceivedError")) {
|
||||
String str = "";
|
||||
String charSequence = (webResourceError == null || webResourceError.getDescription() == null) ? "" : webResourceError.getDescription().toString();
|
||||
if (webResourceRequest != null && webResourceRequest.getUrl() != null) {
|
||||
str = webResourceRequest.getUrl().toString();
|
||||
}
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.ERROR, str, charSequence);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
|
||||
Boolean bool = false;
|
||||
if (WebPlayer.this.shouldCallSuper("shouldOverrideUrlLoading")) {
|
||||
bool = Boolean.valueOf(super.shouldOverrideUrlLoading(webView, str));
|
||||
}
|
||||
if (WebPlayer.this.shouldSendEvent("shouldOverrideUrlLoading")) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SHOULD_OVERRIDE_URL_LOADING, str);
|
||||
}
|
||||
if (WebPlayer.this.hasReturnValue("shouldOverrideUrlLoading")) {
|
||||
bool = (Boolean) WebPlayer.this.getReturnValue("shouldOverrideUrlLoading", Boolean.class, true);
|
||||
}
|
||||
return bool.booleanValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.unity3d.ads.webplayer;
|
||||
|
||||
import android.webkit.JavascriptInterface;
|
||||
import com.unity3d.ads.webview.WebViewApp;
|
||||
import com.unity3d.ads.webview.WebViewEventCategory;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class WebPlayerBridgeInterface {
|
||||
@JavascriptInterface
|
||||
public void handleEvent(String str) {
|
||||
if (WebViewApp.getCurrentApp() != null) {
|
||||
WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.WEBPLAYER_EVENT, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user