Initial commit
This commit is contained in:
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]);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user