正在查看: Vi App v10.18.0 应用的 MPConfig.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Vi App v10.18.0 应用的 MPConfig.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mixpanel.android.mpmetrics;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle;
import com.google.protobuf.ByteString;
import com.heanoria.library.reactnative.locationenabler.AndroidLocationEnablerModule;
import com.mixpanel.android.util.MPLog;
import com.mixpanel.android.util.OfflineMode;
import com.onmobile.rbtsdkui.http.Configuration;
import java.security.GeneralSecurityException;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
public class MPConfig {
public static boolean DEBUG = false;
private static MPConfig sInstance;
private static final Object sInstanceLock = new Object();
private final int mBulkUploadLimit;
private final long mDataExpiration;
private final boolean mDisableAppOpenEvent;
private final boolean mDisableExceptionHandler;
private String mEventsEndpoint;
private int mFlushBatchSize;
private final int mFlushInterval;
private final boolean mFlushOnBackground;
private String mGroupsEndpoint;
private int mMaximumDatabaseLimit;
private final int mMinSessionDuration;
private final int mMinimumDatabaseLimit;
private OfflineMode mOfflineMode;
private String mPeopleEndpoint;
private final boolean mRemoveLegacyResidualFiles;
private final String mResourcePackageName;
private SSLSocketFactory mSSLSocketFactory;
private final int mSessionTimeoutDuration;
private boolean mTrackAutomaticEvents = true;
private boolean mUseIpAddressForGeolocation;
public MPConfig(Bundle bundle, Context context) {
long floatValue;
SSLSocketFactory sSLSocketFactory = null;
try {
SSLContext sSLContext = SSLContext.getInstance("TLS");
sSLContext.init(null, null, null);
sSLSocketFactory = sSLContext.getSocketFactory();
} catch (GeneralSecurityException e) {
MPLog.i("MixpanelAPI.Conf", "System has no SSL support. Built-in events editor will not be available", e);
}
this.mSSLSocketFactory = sSLSocketFactory;
boolean z = bundle.getBoolean("com.mixpanel.android.MPConfig.EnableDebugLogging", false);
DEBUG = z;
if (z) {
MPLog.setLevel(2);
}
if (bundle.containsKey("com.mixpanel.android.MPConfig.DebugFlushInterval")) {
MPLog.w("MixpanelAPI.Conf", "We do not support com.mixpanel.android.MPConfig.DebugFlushInterval anymore. There will only be one flush interval. Please, update your AndroidManifest.xml.");
}
this.mBulkUploadLimit = bundle.getInt("com.mixpanel.android.MPConfig.BulkUploadLimit", 40);
this.mFlushInterval = bundle.getInt("com.mixpanel.android.MPConfig.FlushInterval", 60000);
this.mFlushBatchSize = bundle.getInt("com.mixpanel.android.MPConfig.FlushBatchSize", 50);
this.mFlushOnBackground = bundle.getBoolean("com.mixpanel.android.MPConfig.FlushOnBackground", true);
this.mMinimumDatabaseLimit = bundle.getInt("com.mixpanel.android.MPConfig.MinimumDatabaseLimit", 20971520);
this.mMaximumDatabaseLimit = bundle.getInt("com.mixpanel.android.MPConfig.MaximumDatabaseLimit", Integer.MAX_VALUE);
this.mResourcePackageName = bundle.getString("com.mixpanel.android.MPConfig.ResourcePackageName");
this.mDisableAppOpenEvent = bundle.getBoolean("com.mixpanel.android.MPConfig.DisableAppOpenEvent", true);
this.mDisableExceptionHandler = bundle.getBoolean("com.mixpanel.android.MPConfig.DisableExceptionHandler", false);
this.mMinSessionDuration = bundle.getInt("com.mixpanel.android.MPConfig.MinimumSessionDuration", AndroidLocationEnablerModule.DEFAULT_INTERVAL_DURATION);
this.mSessionTimeoutDuration = bundle.getInt("com.mixpanel.android.MPConfig.SessionTimeoutDuration", Integer.MAX_VALUE);
this.mUseIpAddressForGeolocation = bundle.getBoolean("com.mixpanel.android.MPConfig.UseIpAddressForGeolocation", true);
this.mRemoveLegacyResidualFiles = bundle.getBoolean("com.mixpanel.android.MPConfig.RemoveLegacyResidualFiles", false);
Object obj = bundle.get("com.mixpanel.android.MPConfig.DataExpiration");
long j = 432000000;
if (obj != null) {
try {
if (obj instanceof Integer) {
floatValue = ((Integer) obj).intValue();
} else {
if (!(obj instanceof Float)) {
throw new NumberFormatException(obj.toString() + " is not a number.");
}
floatValue = (long) ((Float) obj).floatValue();
}
j = floatValue;
} catch (Exception e2) {
MPLog.e("MixpanelAPI.Conf", "Error parsing com.mixpanel.android.MPConfig.DataExpiration meta-data value", e2);
}
}
this.mDataExpiration = j;
boolean containsKey = true ^ bundle.containsKey("com.mixpanel.android.MPConfig.UseIpAddressForGeolocation");
String string = bundle.getString("com.mixpanel.android.MPConfig.EventsEndpoint");
if (string != null) {
setEventsEndpoint(containsKey ? string : getEndPointWithIpTrackingParam(string, getUseIpAddressForGeolocation()));
} else {
setEventsEndpointWithBaseURL("https://api.mixpanel.com");
}
String string2 = bundle.getString("com.mixpanel.android.MPConfig.PeopleEndpoint");
if (string2 != null) {
setPeopleEndpoint(containsKey ? string2 : getEndPointWithIpTrackingParam(string2, getUseIpAddressForGeolocation()));
} else {
setPeopleEndpointWithBaseURL("https://api.mixpanel.com");
}
String string3 = bundle.getString("com.mixpanel.android.MPConfig.GroupsEndpoint");
if (string3 != null) {
setGroupsEndpoint(containsKey ? string3 : getEndPointWithIpTrackingParam(string3, getUseIpAddressForGeolocation()));
} else {
setGroupsEndpointWithBaseURL("https://api.mixpanel.com");
}
MPLog.v("MixpanelAPI.Conf", toString());
}
private String getEndPointWithIpTrackingParam(String str, boolean z) {
boolean contains = str.contains("?ip=");
String str2 = Configuration.RETAIL_PRICE_ID;
if (contains) {
StringBuilder sb = new StringBuilder();
sb.append(str.substring(0, str.indexOf("?ip=")));
sb.append("?ip=");
if (!z) {
str2 = "0";
}
sb.append(str2);
return sb.toString();
}
StringBuilder sb2 = new StringBuilder();
sb2.append(str);
sb2.append("?ip=");
if (!z) {
str2 = "0";
}
sb2.append(str2);
return sb2.toString();
}
public static MPConfig getInstance(Context context) {
synchronized (sInstanceLock) {
if (sInstance == null) {
sInstance = readConfig(context.getApplicationContext());
}
}
return sInstance;
}
private boolean getUseIpAddressForGeolocation() {
return this.mUseIpAddressForGeolocation;
}
public static MPConfig readConfig(Context context) {
String packageName = context.getPackageName();
try {
Bundle bundle = context.getPackageManager().getApplicationInfo(packageName, ByteString.CONCATENATE_BY_COPY_SIZE).metaData;
if (bundle == null) {
bundle = new Bundle();
}
return new MPConfig(bundle, context);
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException("Can't configure Mixpanel with package name " + packageName, e);
}
}
private void setEventsEndpoint(String str) {
this.mEventsEndpoint = str;
}
private void setEventsEndpointWithBaseURL(String str) {
setEventsEndpoint(getEndPointWithIpTrackingParam(str + "/track/", getUseIpAddressForGeolocation()));
}
private void setGroupsEndpoint(String str) {
this.mGroupsEndpoint = str;
}
private void setGroupsEndpointWithBaseURL(String str) {
setGroupsEndpoint(getEndPointWithIpTrackingParam(str + "/groups/", getUseIpAddressForGeolocation()));
}
private void setPeopleEndpoint(String str) {
this.mPeopleEndpoint = str;
}
private void setPeopleEndpointWithBaseURL(String str) {
setPeopleEndpoint(getEndPointWithIpTrackingParam(str + "/engage/", getUseIpAddressForGeolocation()));
}
public int getBulkUploadLimit() {
return this.mBulkUploadLimit;
}
public long getDataExpiration() {
return this.mDataExpiration;
}
public boolean getDisableAppOpenEvent() {
return this.mDisableAppOpenEvent;
}
public boolean getDisableExceptionHandler() {
return this.mDisableExceptionHandler;
}
public String getEventsEndpoint() {
return this.mEventsEndpoint;
}
public int getFlushBatchSize() {
return this.mFlushBatchSize;
}
public int getFlushInterval() {
return this.mFlushInterval;
}
public boolean getFlushOnBackground() {
return this.mFlushOnBackground;
}
public String getGroupsEndpoint() {
return this.mGroupsEndpoint;
}
public int getMaximumDatabaseLimit() {
return this.mMaximumDatabaseLimit;
}
public int getMinimumDatabaseLimit() {
return this.mMinimumDatabaseLimit;
}
public int getMinimumSessionDuration() {
return this.mMinSessionDuration;
}
public synchronized OfflineMode getOfflineMode() {
return this.mOfflineMode;
}
public String getPeopleEndpoint() {
return this.mPeopleEndpoint;
}
public synchronized SSLSocketFactory getSSLSocketFactory() {
return this.mSSLSocketFactory;
}
public int getSessionTimeoutDuration() {
return this.mSessionTimeoutDuration;
}
public boolean getTrackAutomaticEvents() {
return this.mTrackAutomaticEvents;
}
public String toString() {
return "Mixpanel (7.3.1) configured with:\n TrackAutomaticEvents: " + getTrackAutomaticEvents() + "\n BulkUploadLimit " + getBulkUploadLimit() + "\n FlushInterval " + getFlushInterval() + "\n FlushInterval " + getFlushBatchSize() + "\n DataExpiration " + getDataExpiration() + "\n MinimumDatabaseLimit " + getMinimumDatabaseLimit() + "\n MaximumDatabaseLimit " + getMaximumDatabaseLimit() + "\n DisableAppOpenEvent " + getDisableAppOpenEvent() + "\n EnableDebugLogging " + DEBUG + "\n EventsEndpoint " + getEventsEndpoint() + "\n PeopleEndpoint " + getPeopleEndpoint() + "\n MinimumSessionDuration: " + getMinimumSessionDuration() + "\n SessionTimeoutDuration: " + getSessionTimeoutDuration() + "\n DisableExceptionHandler: " + getDisableExceptionHandler() + "\n FlushOnBackground: " + getFlushOnBackground();
}
}