13Poker by gametower unlimited gems v0.4版本的 MD5 值为:51324fc0f195c34821074948ab266846
以下内容为反编译后的 HandShake.java 源代码,内容仅作参考
package com.millennialmedia.android;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.support.v4.view.accessibility.AccessibilityEventCompat;
import android.text.TextUtils;
import android.view.WindowManager;
import android.webkit.URLUtil;
import android.widget.Toast;
import com.adsdk.sdk.Const;
import com.millennialmedia.android.MMSDK;
import com.millennialmedia.android.Utils;
import com.millennialmedia.google.gson.Gson;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.apache.http.HttpResponse;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class HandShake {
static final String BASE_URL = "http://androidsdk.ads.mp.mydas.mobi/";
static final String BASE_URL_PATH = "getAd.php5?";
private static final String HANDSHAKE_FALLBACK_URL = "http://ads.mp.mydas.mobi/appConfigServlet?apid=";
private static final String HANDSHAKE_HTTPS_SCHEME = "https://";
private static final String HANDSHAKE_HTTP_SCHEME = "http://";
private static final String HANDSHAKE_URL_HOST = "ads.mp.mydas.mobi/";
private static final String HANDSHAKE_URL_OVERRIDE_PARMS = "?apid=";
private static final String HANDSHAKE_URL_PARMS = "appConfigServlet?apid=";
private static final String KEY_CACHED_VIDEOS = "handshake_cachedvideos5.0";
private static boolean forceRefresh;
private static HandShake sharedInstance;
long adRefreshSecs;
private WeakReference<Context> appContextRef;
DTOCachedVideo[] cachedVideos;
private WeakReference<Context> contextRef;
String endSessionURL;
boolean hardwareAccelerationEnabled;
private long lastHandShake;
String mmdid;
String mmjsUrl;
private String noVideosToCacheURL;
NuanceCredentials nuanceCredentials;
private String schemesList;
String startSessionURL;
static String apid = MMSDK.DEFAULT_BANNER_APID;
private static String handShakeURL = "https://ads.mp.mydas.mobi/appConfigServlet?apid=";
private static String adUrl = "http://androidsdk.ads.mp.mydas.mobi/getAd.php5?";
private final Handler handler = new Handler(Looper.getMainLooper());
private LinkedHashMap<String, AdTypeHandShake> adTypeHandShakes = new LinkedHashMap<>();
private ArrayList<Scheme> schemes = new ArrayList<>();
private long deferredViewTimeout = 3600000;
boolean kill = false;
private long handShakeCallback = 86400000;
long creativeCacheTimeout = 259200000;
private Runnable updateHandShakeRunnable = new Runnable() {
@Override
public void run() {
Context context = (Context) HandShake.this.contextRef.get();
if (context == null) {
context = (Context) HandShake.this.appContextRef.get();
}
if (context != null) {
HandShake.sharedHandShake(context);
}
}
};
static void setAdUrl(Context context, String url) {
if (!TextUtils.isEmpty(url)) {
if (!url.endsWith("/")) {
adUrl = url + "/" + BASE_URL_PATH;
} else {
adUrl = url + BASE_URL_PATH;
}
}
}
public static String getAdUrl() {
return (TextUtils.isEmpty(adUrl) || !URLUtil.isHttpUrl(adUrl.replace(BASE_URL_PATH, ""))) ? "http://androidsdk.ads.mp.mydas.mobi/getAd.php5?" : adUrl;
}
public static synchronized HandShake sharedHandShake(Context context) {
HandShake handShake;
synchronized (HandShake.class) {
if (apid == null) {
MMSDK.Log.e("No apid set for the handshake.");
handShake = null;
} else {
if (sharedInstance == null) {
sharedInstance = new HandShake(context);
} else if (System.currentTimeMillis() - sharedInstance.lastHandShake > sharedInstance.handShakeCallback) {
MMSDK.Log.d("Handshake expired, requesting new handshake from the server.");
sharedInstance = new HandShake(context);
}
handShake = sharedInstance;
}
}
return handShake;
}
static synchronized void setHandShakeURL(Context context, String url) {
synchronized (HandShake.class) {
if (!TextUtils.isEmpty(url)) {
if (url.startsWith(HANDSHAKE_HTTP_SCHEME)) {
url = url.replaceFirst(HANDSHAKE_HTTP_SCHEME, HANDSHAKE_HTTPS_SCHEME);
}
handShakeURL = url + HANDSHAKE_URL_OVERRIDE_PARMS;
forceRefresh = true;
sharedInstance = new HandShake(context);
}
}
}
public synchronized boolean canRequestVideo(Context context, String adType) {
AdTypeHandShake adTypeHandShake;
adTypeHandShake = this.adTypeHandShakes.get(adType);
return adTypeHandShake != null ? adTypeHandShake.canRequestVideo(context) : true;
}
public synchronized boolean canDisplayCachedAd(String adType, long cachedTime) {
AdTypeHandShake adTypeHandShake;
adTypeHandShake = this.adTypeHandShakes.get(adType);
return adTypeHandShake != null ? adTypeHandShake.canDisplayCachedAd(cachedTime) : true;
}
public synchronized void updateLastVideoViewedTime(Context context, String adType) {
AdTypeHandShake adTypeHandShake = this.adTypeHandShakes.get(adType);
if (adTypeHandShake != null) {
adTypeHandShake.updateLastVideoViewedTime(context, adType);
}
}
public synchronized boolean isAdTypeDownloading(String adType) {
AdTypeHandShake adTypeHandShake;
adTypeHandShake = this.adTypeHandShakes.get(adType);
return adTypeHandShake != null ? adTypeHandShake.downloading : false;
}
public synchronized void lockAdTypeDownload(String adType) {
AdTypeHandShake adTypeHandShake = this.adTypeHandShakes.get(adType);
if (adTypeHandShake != null) {
adTypeHandShake.downloading = true;
}
}
public synchronized void unlockAdTypeDownload(String adType) {
AdTypeHandShake adTypeHandShake = this.adTypeHandShakes.get(adType);
if (adTypeHandShake != null) {
adTypeHandShake.downloading = false;
}
}
public void setMMdid(Context context, String newMMdid) {
setMMdid(context, newMMdid, true);
}
synchronized void setMMdid(Context context, String newMMdid, boolean persist) {
if (newMMdid != null) {
if (newMMdid.length() == 0 || newMMdid.equals("NULL")) {
this.mmdid = null;
MMSDK.setMMdid(this.mmdid);
if (persist) {
SharedPreferences settings = context.getSharedPreferences("MillennialMediaSettings", 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("handshake_mmdid", this.mmdid);
editor.commit();
}
}
}
this.mmdid = newMMdid;
MMSDK.setMMdid(this.mmdid);
if (persist) {
}
}
private HandShake() {
}
private HandShake(Context context) {
this.contextRef = new WeakReference<>(context);
this.appContextRef = new WeakReference<>(context.getApplicationContext());
if (forceRefresh || !loadHandShake(context) || System.currentTimeMillis() - this.lastHandShake > this.handShakeCallback) {
forceRefresh = false;
this.lastHandShake = System.currentTimeMillis();
requestHandshake(false);
}
}
private void requestHandshake(final boolean isInitialize) {
Utils.ThreadUtils.execute(new Runnable() {
@Override
public void run() {
Context tempContext = (Context) HandShake.this.contextRef.get();
if (tempContext == null) {
tempContext = (Context) HandShake.this.appContextRef.get();
}
if (tempContext == null) {
return;
}
boolean isFirstLaunch = false;
try {
try {
try {
StringBuilder handshakeUrlBuilder = new StringBuilder();
Map<String, String> deviceValuesMap = new TreeMap<>();
deviceValuesMap.put("ua", "Android:" + Build.MODEL);
isFirstLaunch = HandShake.this.isFirstLaunch(tempContext);
if (isFirstLaunch) {
deviceValuesMap.put("firstlaunch", "1");
}
if (isInitialize) {
deviceValuesMap.put("init", "1");
}
MMSDK.insertUrlCommonValues(tempContext, deviceValuesMap);
for (Map.Entry<String, String> entry : deviceValuesMap.entrySet()) {
handshakeUrlBuilder.append(String.format("&%s=%s", entry.getKey(), URLEncoder.encode(entry.getValue(), Const.ENCODING)));
}
String handshakeUrl = HandShake.handShakeURL + HandShake.apid + handshakeUrlBuilder.toString();
MMSDK.Log.v("Performing handshake: %s", handshakeUrl);
HttpResponse httpResponse = null;
try {
httpResponse = new HttpGetRequest(3000).get(handshakeUrl);
} catch (IOException ioe) {
MMSDK.Log.e("Could not get a handshake. %s", ioe.getMessage());
}
if (httpResponse == null || httpResponse.getStatusLine().getStatusCode() != 200) {
try {
String unused = HandShake.handShakeURL = HandShake.handShakeURL.replaceFirst(HandShake.HANDSHAKE_HTTPS_SCHEME, HandShake.HANDSHAKE_HTTP_SCHEME);
String handshakeUrl2 = HandShake.handShakeURL + HandShake.apid + handshakeUrlBuilder.toString();
MMSDK.Log.v("Performing handshake (HTTP Fallback): %s", handshakeUrl2);
httpResponse = new HttpGetRequest().get(handshakeUrl2);
} catch (IOException ioe2) {
MMSDK.Log.e("Could not get a handshake. %s", ioe2.getMessage());
}
}
if (httpResponse == null || httpResponse.getStatusLine().getStatusCode() != 200) {
try {
String handshakeUrl3 = HandShake.HANDSHAKE_FALLBACK_URL + HandShake.apid + handshakeUrlBuilder.toString();
MMSDK.Log.v("Performing handshake (HTTP Fallback Original): %s", handshakeUrl3);
httpResponse = new HttpGetRequest().get(handshakeUrl3);
} catch (IOException ioe3) {
MMSDK.Log.e("Could not get a handshake. %s", ioe3.getMessage());
}
}
if (httpResponse == null || httpResponse.getStatusLine().getStatusCode() != 200) {
isFirstLaunch = false;
} else {
HandShake.this.deserializeFromObj(HandShake.this.parseJson(HttpGetRequest.convertStreamToString(httpResponse.getEntity().getContent())));
HandShake.this.saveHandShake(tempContext);
HandShake.this.handler.postDelayed(HandShake.this.updateHandShakeRunnable, HandShake.this.handShakeCallback);
MMSDK.Log.v("Obtained a new handshake");
}
if (isFirstLaunch) {
HandShake.this.sentFirstLaunch(tempContext);
}
} catch (IOException ioe4) {
MMSDK.Log.e("Could not get a handshake. %s", ioe4.getMessage());
if (0 != 0) {
HandShake.this.sentFirstLaunch(tempContext);
}
}
} catch (Exception e) {
MMSDK.Log.e("Could not get a handshake. %s", e.getMessage());
if (0 != 0) {
HandShake.this.sentFirstLaunch(tempContext);
}
}
} catch (Throwable th) {
if (isFirstLaunch) {
HandShake.this.sentFirstLaunch(tempContext);
}
throw th;
}
}
});
}
public void sendInitRequest() {
requestHandshake(true);
}
public boolean isFirstLaunch(Context tempContext) {
if (tempContext == null) {
return false;
}
SharedPreferences settings = tempContext.getSharedPreferences("MillennialMediaSettings", 0);
return settings.getBoolean("firstlaunchHandshake", true);
}
public void sentFirstLaunch(Context tempContext) {
if (tempContext != null) {
SharedPreferences settings = tempContext.getSharedPreferences("MillennialMediaSettings", 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("firstlaunchHandshake", false);
editor.commit();
}
}
public synchronized String getSchemesList(Context context) {
if (this.schemesList == null && this.schemes.size() > 0) {
StringBuilder stringBuilder = new StringBuilder();
Iterator i$ = this.schemes.iterator();
while (i$.hasNext()) {
Scheme scheme = i$.next();
if (scheme.checkAvailability(context)) {
if (stringBuilder.length() > 0) {
stringBuilder.append("," + scheme.id);
} else {
stringBuilder.append(Integer.toString(scheme.id));
}
}
}
if (stringBuilder.length() > 0) {
this.schemesList = stringBuilder.toString();
}
}
return this.schemesList;
}
public synchronized JSONArray getSchemesJSONArray(Context context) {
JSONArray array;
array = new JSONArray();
if (this.schemes.size() > 0) {
Iterator i$ = this.schemes.iterator();
while (i$.hasNext()) {
Scheme scheme = i$.next();
if (scheme.checkAvailability(context)) {
try {
JSONObject schemeObject = new JSONObject();
schemeObject.put("scheme", scheme.scheme);
schemeObject.put("schemeid", scheme.id);
array.put(schemeObject);
} catch (JSONException e) {
}
}
}
}
return array;
}
public static class NuanceCredentials {
String appID;
String appKey;
int port;
String server;
String sessionID;
private NuanceCredentials() {
}
public String toString() {
return "Credentials: appid=" + this.appID + " server=" + this.server + " port=" + this.port + " appKey=" + this.appKey + "sessionID=" + this.sessionID;
}
}
public class Scheme {
int id;
String scheme;
Scheme() {
}
Scheme(String scheme, int id) {
this.scheme = scheme;
this.id = id;
}
boolean checkAvailability(Context context) {
Intent intent;
if (this.scheme.contains("://")) {
intent = new Intent("android.intent.action.VIEW", Uri.parse(this.scheme));
} else {
intent = new Intent("android.intent.action.VIEW", Uri.parse(this.scheme + "://"));
}
List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED);
return list.size() > 0;
}
void deserializeFromObj(JSONObject schemeObject) {
if (schemeObject != null) {
this.scheme = schemeObject.optString("scheme", null);
this.id = schemeObject.optInt("schemeid");
}
}
}
public class AdTypeHandShake {
boolean downloading;
long lastVideo = 0;
long videoInterval = 0;
AdTypeHandShake() {
}
boolean canRequestVideo(Context context) {
MMSDK.Log.d("canRequestVideo() Current Time: %d Last Video: %d Diff: %d Video interval: %d", Long.valueOf(System.currentTimeMillis()), Long.valueOf(this.lastVideo / 1000), Long.valueOf((System.currentTimeMillis() - this.lastVideo) / 1000), Long.valueOf(this.videoInterval / 1000));
return System.currentTimeMillis() - this.lastVideo > this.videoInterval;
}
boolean canDisplayCachedAd(long cachedTime) {
return System.currentTimeMillis() - cachedTime < HandShake.this.deferredViewTimeout;
}
void updateLastVideoViewedTime(Context context, String adType) {
this.lastVideo = System.currentTimeMillis();
save(context, adType);
}
void deserializeFromObj(JSONObject adTypeObject) {
if (adTypeObject != null) {
this.videoInterval = adTypeObject.optLong("videointerval") * 1000;
}
}
boolean load(SharedPreferences settings, String adType) {
boolean settingsFound = false;
if (settings.contains("handshake_lastvideo_" + adType)) {
this.lastVideo = settings.getLong("handshake_lastvideo_" + adType, this.lastVideo);
settingsFound = true;
}
if (settings.contains("handshake_videointerval_" + adType)) {
this.videoInterval = settings.getLong("handshake_videointerval_" + adType, this.videoInterval);
return true;
}
return settingsFound;
}
void loadLastVideo(Context context, String adType) {
SharedPreferences settings = context.getSharedPreferences("MillennialMediaSettings", 0);
if (settings != null && settings.contains("handshake_lastvideo_" + adType)) {
this.lastVideo = settings.getLong("handshake_lastvideo_" + adType, this.lastVideo);
}
}
void save(SharedPreferences.Editor editor, String adType) {
editor.putLong("handshake_lastvideo_" + adType, this.lastVideo);
editor.putLong("handshake_videointerval_" + adType, this.videoInterval);
}
void save(Context context, String adType) {
SharedPreferences settings = context.getSharedPreferences("MillennialMediaSettings", 0);
SharedPreferences.Editor editor = settings.edit();
save(editor, adType);
editor.commit();
}
}
public JSONObject parseJson(String jsonString) {
MMSDK.Log.d("JSON String: %s", jsonString);
if (jsonString != null) {
try {
JSONObject jsonObject = new JSONObject(jsonString);
MMSDK.Log.v(jsonObject.toString());
if (jsonObject.has("mmishake")) {
return jsonObject.getJSONObject("mmishake");
}
} catch (JSONException e) {
e.printStackTrace();
}
}
return null;
}
public void deserializeFromObj(JSONObject handShakeObject) {
final Context context = this.contextRef.get();
if (handShakeObject != null) {
try {
JSONArray jsonArray = handShakeObject.optJSONArray("errors");
if (jsonArray != null) {
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.optJSONObject(i);
if (jsonObject != null) {
final String message = jsonObject.optString("message", null);
String type = jsonObject.optString("type", null);
if (message != null && type != null) {
if (type.equalsIgnoreCase("log")) {
MMSDK.Log.e(message);
} else if (type.equalsIgnoreCase("prompt")) {
this.handler.post(new Runnable() {
@Override
public void run() {
try {
Toast.makeText(context, "Error: " + message, 1).show();
} catch (WindowManager.BadTokenException e) {
e.printStackTrace();
}
}
});
}
}
}
}
}
JSONObject jsonObject2 = handShakeObject.optJSONObject("adtypes");
if (jsonObject2 != null) {
String[] adTypes = MMAdImpl.getAdTypes();
for (int i2 = 0; i2 < adTypes.length; i2++) {
JSONObject adTypeObject = jsonObject2.optJSONObject(adTypes[i2]);
if (adTypeObject != null) {
AdTypeHandShake adTypeHandShake = new AdTypeHandShake();
adTypeHandShake.deserializeFromObj(adTypeObject);
adTypeHandShake.loadLastVideo(context, adTypes[i2]);
this.adTypeHandShakes.put(adTypes[i2], adTypeHandShake);
}
}
}
synchronized (this) {
JSONArray jsonArray2 = handShakeObject.optJSONArray("schemes");
if (jsonArray2 != null) {
if (this.schemes != null && this.schemes.size() > 0) {
this.schemes.removeAll(this.schemes);
}
for (int i3 = 0; i3 < jsonArray2.length(); i3++) {
JSONObject jsonObject3 = jsonArray2.optJSONObject(i3);
if (jsonObject3 != null) {
Scheme scheme = new Scheme();
scheme.deserializeFromObj(jsonObject3);
this.schemes.add(scheme);
}
}
}
}
this.adRefreshSecs = handShakeObject.optLong("adrefresh", 0L);
this.deferredViewTimeout = handShakeObject.optLong("deferredviewtimeout", 3600L) * 1000;
this.kill = handShakeObject.optBoolean("kill");
setAdUrl(context, handShakeObject.optString("baseURL"));
this.handShakeCallback = handShakeObject.optLong("handshakecallback", 86400L) * 1000;
this.creativeCacheTimeout = handShakeObject.optLong("creativeCacheTimeout", 259200L) * 1000;
this.hardwareAccelerationEnabled = handShakeObject.optBoolean("hardwareAccelerationEnabled");
this.startSessionURL = handShakeObject.optString("startSessionURL");
this.endSessionURL = handShakeObject.optString("endSessionURL");
String gsonNuance = handShakeObject.optString("nuanceCredentials");
this.nuanceCredentials = (NuanceCredentials) new Gson().fromJson(gsonNuance, (Class<Object>) NuanceCredentials.class);
this.mmjsUrl = handShakeObject.optString("mmjs");
handleCachedVideos(handShakeObject, context);
if (!TextUtils.isEmpty(this.mmjsUrl) && !MRaid.isMRaidUpdated(context, this.mmjsUrl)) {
MRaid.downloadMraidJs(this.appContextRef.get(), this.mmjsUrl);
} else {
MMSDK.Log.w("Not downloading MMJS - (" + this.mmjsUrl + ")");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
private void handleCachedVideos(JSONObject handShakeObject, Context context) {
JSONArray jsonArray = handShakeObject.optJSONArray("cachedVideos");
if (jsonArray != null) {
this.cachedVideos = (DTOCachedVideo[]) new Gson().fromJson(jsonArray.toString(), (Class<Object>) DTOCachedVideo[].class);
MMSDK.Log.d(this.cachedVideos.toString());
}
this.noVideosToCacheURL = handShakeObject.optString("noVideosToCacheURL");
if (this.cachedVideos != null) {
PreCacheWorker.preCacheVideos(this.cachedVideos, context, this.noVideosToCacheURL);
}
}
private boolean loadHandShake(Context context) {
boolean settingsFound = false;
SharedPreferences settings = context.getSharedPreferences("MillennialMediaSettings", 0);
if (settings == null) {
return false;
}
if (settings.contains("handshake_deferredviewtimeout")) {
this.deferredViewTimeout = settings.getLong("handshake_deferredviewtimeout", this.deferredViewTimeout);
settingsFound = true;
}
if (settings.contains("handshake_baseUrl")) {
adUrl = settings.getString("handshake_baseUrl", adUrl);
settingsFound = true;
}
if (settings.contains("handshake_callback")) {
this.handShakeCallback = settings.getLong("handshake_callback", this.handShakeCallback);
settingsFound = true;
}
if (settings.contains("handshake_hardwareAccelerationEnabled")) {
this.hardwareAccelerationEnabled = settings.getBoolean("handshake_hardwareAccelerationEnabled", false);
settingsFound = true;
}
if (settings.contains("handshake_startSessionURL")) {
this.startSessionURL = settings.getString("handshake_startSessionURL", "");
settingsFound = true;
}
if (settings.contains("handshake_endSessionURL")) {
this.endSessionURL = settings.getString("handshake_endSessionURL", "");
settingsFound = true;
}
if (settings.contains("handshake_nuanceCredentials")) {
String gsonNuance = settings.getString("handshake_nuanceCredentials", "");
this.nuanceCredentials = (NuanceCredentials) new Gson().fromJson(gsonNuance, (Class<Object>) NuanceCredentials.class);
settingsFound = true;
}
if (settings.contains("handshake_mmdid")) {
setMMdid(context, settings.getString("handshake_mmdid", this.mmdid), false);
settingsFound = true;
}
if (settings.contains("handshake_creativecachetimeout")) {
this.creativeCacheTimeout = settings.getLong("handshake_creativecachetimeout", this.creativeCacheTimeout);
settingsFound = true;
}
if (settings.contains("handshake_mmjs")) {
this.mmjsUrl = settings.getString("handshake_mmjs", this.mmjsUrl);
settingsFound = true;
}
String[] adTypes = MMAdImpl.getAdTypes();
for (int i = 0; i < adTypes.length; i++) {
AdTypeHandShake adTypeHandShake = new AdTypeHandShake();
if (adTypeHandShake.load(settings, adTypes[i])) {
settingsFound = true;
this.adTypeHandShakes.put(adTypes[i], adTypeHandShake);
}
}
synchronized (this) {
if (settings.contains("handshake_schemes")) {
String schemesStr = settings.getString("handshake_schemes", "");
if (schemesStr.length() > 0) {
String[] schemeStrings = schemesStr.split("\n");
for (String str : schemeStrings) {
String[] parts = str.split("\t");
if (parts.length >= 2) {
Scheme scheme = new Scheme(parts[0], Integer.parseInt(parts[1]));
this.schemes.add(scheme);
}
}
settingsFound = true;
}
}
}
if (settings.contains(KEY_CACHED_VIDEOS)) {
String savedVideos = settings.getString(KEY_CACHED_VIDEOS, "");
if (savedVideos.length() > 0) {
this.cachedVideos = (DTOCachedVideo[]) new Gson().fromJson(savedVideos, (Class<Object>) DTOCachedVideo[].class);
}
}
if (settings.contains("handshake_lasthandshake")) {
this.lastHandShake = settings.getLong("handshake_lasthandshake", this.lastHandShake);
settingsFound = true;
}
if (settingsFound) {
MMSDK.Log.d("Handshake successfully loaded from shared preferences.");
if (System.currentTimeMillis() - this.lastHandShake < this.handShakeCallback) {
this.handler.postDelayed(this.updateHandShakeRunnable, this.handShakeCallback - (System.currentTimeMillis() - this.lastHandShake));
}
this.noVideosToCacheURL = settings.getString("handshake_novideostocacheurl", "");
if (this.cachedVideos != null) {
PreCacheWorker.preCacheVideos(this.cachedVideos, context, this.noVideosToCacheURL);
}
}
return settingsFound;
}
public void saveHandShake(Context context) {
SharedPreferences settings = context.getSharedPreferences("MillennialMediaSettings", 0);
SharedPreferences.Editor editor = settings.edit();
editor.putLong("handshake_deferredviewtimeout", this.deferredViewTimeout);
editor.putBoolean("handshake_kill", this.kill);
editor.putString("handshake_baseUrl", adUrl);
editor.putLong("handshake_callback", this.handShakeCallback);
editor.putBoolean("handshake_hardwareAccelerationEnabled", this.hardwareAccelerationEnabled);
editor.putString("handshake_startSessionURL", this.startSessionURL);
if (this.nuanceCredentials != null) {
editor.putString("handshake_nuanceCredentials", new Gson().toJson(this.nuanceCredentials));
}
editor.putString("handshake_endSessionURL", this.endSessionURL);
editor.putLong("handshake_creativecaetimeout", this.creativeCacheTimeout);
editor.putString("handshake_mmjs", this.mmjsUrl);
for (String adType : this.adTypeHandShakes.keySet()) {
AdTypeHandShake adTypeHandShake = this.adTypeHandShakes.get(adType);
adTypeHandShake.save(editor, adType);
}
synchronized (this) {
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < this.schemes.size(); i++) {
Scheme scheme = this.schemes.get(i);
if (i > 0) {
stringBuilder.append("\n");
}
stringBuilder.append(scheme.scheme + "\t" + scheme.id);
}
editor.putString("handshake_schemes", stringBuilder.toString());
}
if (this.cachedVideos != null) {
editor.putString(KEY_CACHED_VIDEOS, new Gson().toJson(this.cachedVideos));
}
editor.putString("handshake_novideostocacheurl", this.noVideosToCacheURL);
editor.putLong("handshake_lasthandshake", this.lastHandShake);
editor.commit();
}
public void startSession() {
if (!TextUtils.isEmpty(this.startSessionURL)) {
Utils.HttpUtils.executeUrl(this.startSessionURL);
}
}
void endSession() {
if (!TextUtils.isEmpty(this.endSessionURL)) {
Utils.HttpUtils.executeUrl(this.endSessionURL);
}
}
}