正在查看: bbinstant v6.24.0 应用的 RemoteConfigurationManager.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: bbinstant v6.24.0 应用的 RemoteConfigurationManager.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.amazonaws.mobileconnectors.remoteconfiguration;
import android.content.Context;
import android.content.SharedPreferences;
import com.amazonaws.mobileconnectors.remoteconfiguration.exceptions.MalformedAppConfigIdException;
import com.amazonaws.mobileconnectors.remoteconfiguration.internal.ArcusThrottler;
import com.amazonaws.mobileconnectors.remoteconfiguration.internal.Arn;
import com.amazonaws.mobileconnectors.remoteconfiguration.internal.AttributesImpl;
import com.amazonaws.mobileconnectors.remoteconfiguration.internal.ConfigurationDb;
import com.amazonaws.mobileconnectors.remoteconfiguration.internal.ConfigurationImpl;
import com.amazonaws.mobileconnectors.remoteconfiguration.internal.gear.Checks;
import com.amazonaws.mobileconnectors.remoteconfiguration.internal.gear.LocalConfigInstanceIdGenerationHelper;
import com.amazonaws.mobileconnectors.remoteconfiguration.internal.model.RemoteConfiguration;
import com.amazonaws.mobileconnectors.remoteconfiguration.internal.model.RemoteConfigurationImpl;
import com.amazonaws.mobileconnectors.remoteconfiguration.internal.net.AndroidRemoteConfigurationFetcher;
import com.amazonaws.mobileconnectors.remoteconfiguration.internal.net.RemoteConfigurationFetcher;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.json.JSONObject;
public class RemoteConfigurationManager {
public final String f505a;
public final ConfigurationDb f506b;
public final RemoteConfigurationFetcher f507c;
public final Attributes d;
public final SharedPreferences e;
public int f;
public final ArcusThrottler g;
public RemoteConfigurationManager(Builder builder) {
this(builder.f509b, builder.f508a, builder.f510c, builder.d);
}
public static void b(String str) {
try {
Arn.fromArn(str);
} catch (IllegalArgumentException e) {
throw new MalformedAppConfigIdException("Invalid appConfigId ARN.", e);
}
}
public static Builder forAppId(Context context, String str) {
return new Builder(context, str);
}
public static RemoteConfigurationManager getInstance(String str) {
Checks.checkNotNull(str, "The App Configuration ID may not be null");
return Builder.e.get(str);
}
public Attributes openAttributes() {
return this.d;
}
public Configuration openConfiguration() {
return this.f506b.readConfiguration();
}
public void overwriteConfiguration(JSONObject jSONObject) {
Checks.checkNotNull(jSONObject, "The Configuration cannot be null");
this.f506b.saveConfiguration(new RemoteConfigurationImpl(new ConfigurationImpl(jSONObject.toString(), new Date()), this.f505a, 3, null, false));
}
public void setRampingKey(String str) {
if (str == null) {
throw new NullPointerException("The ramping key cannot be null.");
}
if (str.isEmpty() || str.length() > 64) {
throw new IllegalArgumentException("The ramping key cannot be empty and its length is limited to 64 characters.");
}
String generateLocalConfigInstanceId = LocalConfigInstanceIdGenerationHelper.generateLocalConfigInstanceId(str);
SharedPreferences.Editor edit = this.e.edit();
edit.putString("localConfigurationInstanceId", generateLocalConfigInstanceId);
edit.apply();
}
public void sync(ConfigurationSyncCallback configurationSyncCallback) {
Checks.checkNotNull(configurationSyncCallback, "ConfigurationSyncCallback cannot be null");
b(configurationSyncCallback);
}
public RemoteConfigurationManager(Context context, String str, JSONObject jSONObject, boolean z) {
this(context, str, jSONObject, ConfigurationDb.getOrCreateInstance(context, str), "https://arcus-uswest.amazon.com", z);
}
public static void a(String str) {
try {
Arn.fromArn(str);
} catch (IllegalArgumentException e) {
throw new MalformedAppConfigIdException("Invalid appConfigId ARN.", e);
}
}
public static Builder forAppId(Context context, String str, boolean z) {
return new Builder(context, str, z);
}
public final void b(final ConfigurationSyncCallback configurationSyncCallback) {
ExecutorService newSingleThreadExecutor = Executors.newSingleThreadExecutor();
newSingleThreadExecutor.submit(new Runnable() {
@Override
public final void run() {
RemoteConfigurationManager.this.a(configurationSyncCallback);
}
});
newSingleThreadExecutor.shutdown();
}
public RemoteConfigurationManager(Context context, String str, JSONObject jSONObject, ConfigurationDb configurationDb, String str2, boolean z) {
this.g = new ArcusThrottler();
Checks.checkNotNull(context, "appContext cannot be null");
Checks.checkNotNull(str, "appConfigId cannot be null");
b(str);
context = z ? context : context.getApplicationContext();
try {
URL url = new URL(str2);
this.f505a = str;
this.e = context.getSharedPreferences(a(), 0);
AttributesImpl attributesImpl = new AttributesImpl(context);
this.d = attributesImpl;
this.f = attributesImpl.hashCode();
this.f506b = configurationDb;
this.f507c = new AndroidRemoteConfigurationFetcher(context, url);
if (jSONObject != null) {
RemoteConfiguration readRemoteConfiguration = configurationDb.readRemoteConfiguration(str);
if (readRemoteConfiguration == null || readRemoteConfiguration.getOrigin() == 1) {
configurationDb.saveConfiguration(new RemoteConfigurationImpl(new ConfigurationImpl(jSONObject.toString(), new Date()), str, 1, null, false));
}
}
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Invalid endpoint", e);
}
}
public void a(com.amazonaws.mobileconnectors.remoteconfiguration.ConfigurationSyncCallback r10) {
throw new UnsupportedOperationException("Method not decompiled: com.amazonaws.mobileconnectors.remoteconfiguration.RemoteConfigurationManager.a(com.amazonaws.mobileconnectors.remoteconfiguration.ConfigurationSyncCallback):void");
}
public static class Builder {
public static final ConcurrentHashMap<String, RemoteConfigurationManager> e = new ConcurrentHashMap<>();
public final String f508a;
public final Context f509b;
public JSONObject f510c;
public boolean d;
public Builder(Context context, String str) {
this.f510c = new JSONObject();
this.d = false;
if (context == null) {
throw new NullPointerException("The Context may not be null");
}
if (str == null) {
throw new NullPointerException("The App Configuration ID may not be null");
}
RemoteConfigurationManager.a(str);
this.f509b = context;
this.f508a = str;
}
public RemoteConfigurationManager createOrGet() {
String str = this.f508a;
if (str == null) {
throw new IllegalStateException("An App Configuration ID must be specified");
}
ConcurrentHashMap<String, RemoteConfigurationManager> concurrentHashMap = e;
if (!concurrentHashMap.containsKey(str)) {
if (this.f509b == null) {
throw new IllegalStateException("The Context may not be null");
}
String str2 = this.f508a;
if (str2 == null) {
throw new IllegalStateException("The App Configuration ID may not be null");
}
if (this.f510c == null) {
throw new IllegalStateException("The default configuration may not be null");
}
concurrentHashMap.putIfAbsent(str2, new RemoteConfigurationManager(this));
}
return concurrentHashMap.get(this.f508a);
}
public Builder withDefaultConfiguration(JSONObject jSONObject) {
if (jSONObject == null) {
throw new NullPointerException("The default configuration may not be null");
}
this.f510c = jSONObject;
return this;
}
public Builder(Context context, String str, boolean z) {
this(context, str);
this.d = z;
}
}
public final String a() {
return this.f505a + Attributes.PREDEFINED_ATTRIBUTE_PREFIX + "configuration.prefs";
}
}