QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 FeatureToggleImpl.java 源代码,内容仅作参考
package com.tencent.common.featuretoggle.impl;
import android.content.Context;
import android.os.Process;
import android.text.TextUtils;
import android.util.SparseArray;
import com.tencent.common.featuretoggle.FeatureToggle;
import com.tencent.common.featuretoggle.LocalFeatureToggle;
import com.tencent.common.featuretoggle.log.ILogger;
import com.tencent.common.featuretoggle.log.Logger;
import com.tencent.common.featuretoggle.reporter.IPlatformStatReporter;
import com.tencent.common.featuretoggle.reporter.PlatformStatReporter;
import com.tencent.ft.Toggle;
import com.tencent.ft.ToggleConfig;
import com.tencent.ft.ToggleListener;
import com.tencent.ft.ToggleSetting;
import com.tencent.ft.cache.MMKVPersistence;
import com.tencent.ft.cache.TogglePreference;
import com.tencent.mtt.apkplugin.impl.IAPInjectService;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class FeatureToggleImpl {
private static IFeatureToggleOnline f9411a;
private static SparseArray<IFeatureToggleStrategy> f9412b = new SparseArray<>();
private static ConcurrentHashMap<String, Boolean> f9413c = new ConcurrentHashMap<>();
private static Hashtable<String, FeatureToggle.ToggleFromType> f9414d = new Hashtable<>();
private static ConcurrentHashMap<String, String> e;
private static FeatureToggleProductInfo f;
private static int g;
private static volatile boolean h;
public static class FeatureToggleProductInfo {
private boolean f9417a;
private String f9418b;
private String f9419c;
private String f9420d;
public FeatureToggleProductInfo(boolean z, String str, String str2, String str3) {
this.f9417a = z;
this.f9418b = str;
this.f9419c = str2;
this.f9420d = str3;
}
}
static {
f();
d();
e();
g();
}
public static synchronized FeatureToggle.ToggleFromType a(String str) {
FeatureToggle.ToggleFromType g2;
synchronized (FeatureToggleImpl.class) {
if (!TextUtils.isEmpty(str)) {
String upperCase = str.toUpperCase();
return (!h(upperCase) || (g2 = g(upperCase)) == null) ? FeatureToggle.ToggleFromType.UNKNOWN : g2;
}
Logger.a("FeatureToggle", "toggleKey:" + str + ", empty, return:ToggleFromType.UNKNOWN");
return FeatureToggle.ToggleFromType.UNKNOWN;
}
}
private static IFeatureToggleStrategy a(Integer num) {
return f9412b.get(num.intValue());
}
private static void a(Context context) {
final MMKVPersistence mMKVPersistence = new MMKVPersistence();
MMKVPersistence.a(ToggleSetting.a().l());
mMKVPersistence.a(context, "FEATURE_TOGGLE_LOCAL");
LocalFeatureToggle.a(new IFeatureTogglePreference() {
@Override
public long a(String str) {
return MMKVPersistence.this.a(str);
}
@Override
public void a(String str, long j) {
MMKVPersistence.this.a(str, j);
}
@Override
public boolean b(String str) {
return MMKVPersistence.this.d(str);
}
@Override
public void c(String str) {
MMKVPersistence.this.c(str);
}
});
}
public static synchronized void a(Context context, IPlatformStatReporter iPlatformStatReporter, ILogger iLogger) {
synchronized (FeatureToggleImpl.class) {
ToggleSetting.a().a(context);
a(context);
Logger.a(iLogger);
PlatformStatReporter.a(iPlatformStatReporter);
}
}
public static synchronized void a(Context context, String str, String str2, String str3, String str4) {
synchronized (FeatureToggleImpl.class) {
Logger.b("FeatureToggle", "init versionName:" + str + ",qimei:" + str2 + ",guid:" + str3 + ",channel:" + str4 + ",sIsInitialized:" + h);
if (h) {
return;
}
ToggleSetting.a().a(86400000L);
ToggleSetting.a().d(false);
ToggleSetting.a().b(str2);
ToggleSetting.a().a(str3);
ToggleSetting.a().a(3);
ToggleSetting.a().e(true);
ToggleSetting.a().b(f.f9417a ? 1 : 0);
final ToggleConfig a2 = new ToggleConfig.Builder().a(f.f9418b).c(f.f9419c).b(f.f9420d).d(str4).f(str).a(new HashMap()).e("").a();
Toggle.a(context, a2);
Toggle.a(new ToggleListener() {
@Override
public void a() {
FeatureToggleImpl.a(true);
Map<String, String> a3 = Toggle.a(ToggleConfig.this.a(), ToggleConfig.this.c());
StringBuilder sb = new StringBuilder();
sb.append("toggle init success size:");
sb.append(a3 != null ? Integer.valueOf(a3.size()) : IAPInjectService.EP_NULL);
sb.append(",processId:");
sb.append(FeatureToggleImpl.g);
Logger.b("FeatureToggle", sb.toString());
if (a3 != null) {
for (String str5 : a3.keySet()) {
Logger.b("FeatureToggle", "toggle init key:" + str5 + ",value:" + a3.get(str5) + ",processId:" + FeatureToggleImpl.g);
}
}
}
@Override
public void b() {
Logger.b("FeatureToggle", "toggle fail");
}
}, a2.a(), a2.c());
h = true;
Logger.a("FeatureToggle", "init end");
}
}
private static void a(String str, FeatureToggle.ToggleFromType toggleFromType) {
f9414d.put(str, toggleFromType);
}
private static void a(String str, IFeatureToggleStrategy iFeatureToggleStrategy) {
FeatureToggle.ToggleFromType toggleFromType;
if (iFeatureToggleStrategy instanceof StrategySupportOnlineStrategy) {
if (((StrategySupportOnlineStrategy) iFeatureToggleStrategy).a(f9411a, str)) {
toggleFromType = FeatureToggle.ToggleFromType.SERVER;
}
toggleFromType = FeatureToggle.ToggleFromType.DEFAULT;
} else {
if (iFeatureToggleStrategy instanceof StrategyDeveloping) {
toggleFromType = FeatureToggle.ToggleFromType.DEVELOPING;
}
toggleFromType = FeatureToggle.ToggleFromType.DEFAULT;
}
a(str, toggleFromType);
}
private static void a(String str, boolean z) {
f9413c.put(str, Boolean.valueOf(z));
}
public static synchronized void a(boolean z) {
synchronized (FeatureToggleImpl.class) {
boolean z2 = true;
if (e == null) {
e = new ConcurrentHashMap<>();
} else if (!z) {
z2 = false;
}
if (z2) {
TogglePreference togglePreference = new TogglePreference(f.f9418b + f.f9419c);
List<String> arrayList = new ArrayList<>();
try {
arrayList = togglePreference.h();
} catch (Exception unused) {
}
e.clear();
for (String str : arrayList) {
e.put(str, str);
}
}
}
}
private static void b(String str, boolean z) {
StringBuilder sb;
String str2;
if (z) {
sb = new StringBuilder();
sb.append(str.toUpperCase());
str2 = "_ON";
} else {
sb = new StringBuilder();
sb.append(str.toUpperCase());
str2 = "_OFF";
}
sb.append(str2);
PlatformStatReporter.a(sb.toString());
}
public static boolean b(String str) {
if (TextUtils.isEmpty(str)) {
Logger.a("FeatureToggle", "toggleKey:" + str + ", empty, return:false");
return false;
}
String upperCase = str.toUpperCase();
boolean f2 = f(upperCase);
boolean c2 = c(upperCase);
if (!f2) {
b(upperCase, c2);
Logger.b("FeatureToggle", "toggleKey:" + upperCase + ",result:" + c2 + ",toggleFromType:" + a(upperCase) + ",processId:" + g);
}
return c2;
}
private static boolean c(String str) {
if (!BuildConfigHelper.a(str)) {
Logger.a("FeatureToggle", "toggleKey:" + str + " unknown, result:false");
a(str, false);
if (!BuildConfigHelper.b()) {
return false;
}
throw new RuntimeException("featureToggle key:" + str + " isn't register(this crash on debug mode), please refer to the doc:https://iwiki.woa.com/pages/viewpage.action?pageId=665572806");
}
if (LocalFeatureToggle.b(str)) {
boolean c2 = LocalFeatureToggle.c(str);
Logger.a("FeatureToggle", "toggleKey:" + str + " local, result:" + c2);
a(str, c2);
a(str, FeatureToggle.ToggleFromType.LOCAL_MANUAL);
return c2;
}
if (!f(str)) {
return d(str);
}
Boolean e2 = e(str);
Logger.a("FeatureToggle", "toggleKey:" + str + " cached, result:" + e2);
if (e2 != null) {
return e2.booleanValue();
}
return false;
}
private static void d() {
f9412b.put(1, new StrategyDeveloping());
f9412b.put(2, new StrategyDone());
f9412b.put(3, new StrategyForceOn());
f9412b.put(4, new StrategyForceOff());
f9412b.put(5, new StrategyDoneDefaultOn());
}
private static boolean d(String str) {
Integer b2 = BuildConfigHelper.b(str);
IFeatureToggleStrategy a2 = a(b2);
synchronized (FeatureToggle.class) {
if (a2 == null) {
Logger.a("FeatureToggle", "toggleKey:" + str + " unknown strategy " + b2 + ", result:false");
a(str, false);
a(str, FeatureToggle.ToggleFromType.UNKNOWN);
return false;
}
boolean b3 = a2.b(f9411a, str);
Logger.a("FeatureToggle", "toggleKey:" + str + " strategy: " + b2 + ", result:" + b3);
a(str, b3);
a(str, a2);
return b3;
}
}
private static Boolean e(String str) {
return f9413c.get(str);
}
private static void e() {
f9411a = new IFeatureToggleOnline() {
@Override
public boolean a(String str) {
return Toggle.a(str, false, FeatureToggleImpl.f.f9418b, FeatureToggleImpl.f.f9419c);
}
@Override
public boolean b(String str) {
FeatureToggleImpl.a(false);
return FeatureToggleImpl.e.containsKey(str);
}
};
}
private static void f() {
f = new FeatureToggleProductInfo(false, "b82fcc68-2f31-4722-b73a-a42b5af40ba1", "220", "qqbrowser");
}
private static boolean f(String str) {
return f9413c.containsKey(str);
}
private static FeatureToggle.ToggleFromType g(String str) {
return f9414d.get(str);
}
private static void g() {
g = Process.myPid();
}
private static boolean h(String str) {
return f9414d.containsKey(str);
}
}