package com.tapjoy; import android.content.Context; import android.content.SharedPreferences; import android.text.TextUtils; /* loaded from: classes4.dex */ public class TapjoyAppSettings { public static final String TAG = "TapjoyAppSettings"; public static TapjoyAppSettings c; public final SharedPreferences a; public String b; public TapjoyAppSettings(Context context) { SharedPreferences sharedPreferences = context.getSharedPreferences(TapjoyConstants.TJC_PREFERENCE, 0); this.a = sharedPreferences; String string = sharedPreferences.getString(TapjoyConstants.PREF_LOG_LEVEL, null); this.b = string; if (TextUtils.isEmpty(string)) { return; } TapjoyLog.d(TAG, "restoreLoggingLevel from sharedPref -- loggingLevel=" + this.b); TapjoyLog.a(this.b, true); } public static TapjoyAppSettings getInstance() { return c; } public static void init(Context context) { TapjoyLog.d(TAG, "initializing app settings"); c = new TapjoyAppSettings(context); } public void clearLoggingLevel() { SharedPreferences.Editor edit = this.a.edit(); edit.remove(TapjoyConstants.PREF_LOG_LEVEL); edit.apply(); this.b = null; boolean isLoggingEnabled = TapjoyLog.isLoggingEnabled(); TapjoyLog.i(TAG, "Tapjoy remote device debugging 'Disabled'. The SDK Debug-setting is: ".concat(isLoggingEnabled ? "'Enabled'" : "'Disabled'")); TapjoyLog.setDebugEnabled(isLoggingEnabled); } public String getConnectResult(String str, long j) { String string = this.a.getString(TapjoyConstants.PREF_LAST_CONNECT_RESULT, null); if (!TextUtils.isEmpty(string) && !TextUtils.isEmpty(str) && str.equals(this.a.getString(TapjoyConstants.PREF_LAST_CONNECT_PARAMS_HASH, null))) { long j2 = this.a.getLong(TapjoyConstants.PREF_LAST_CONNECT_RESULT_EXPIRES, -1L); if (j2 < 0 || j2 >= j) { return string; } } return null; } public void removeConnectResult() { if (this.a.getString(TapjoyConstants.PREF_LAST_CONNECT_PARAMS_HASH, null) != null) { SharedPreferences.Editor edit = this.a.edit(); edit.remove(TapjoyConstants.PREF_LAST_CONNECT_RESULT); edit.remove(TapjoyConstants.PREF_LAST_CONNECT_PARAMS_HASH); edit.remove(TapjoyConstants.PREF_LAST_CONNECT_RESULT_EXPIRES); TapjoyLog.i(TAG, "Removed connect result"); edit.apply(); } } public void saveConnectResultAndParams(String str, String str2, long j) { if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) { return; } SharedPreferences.Editor edit = this.a.edit(); edit.putString(TapjoyConstants.PREF_LAST_CONNECT_RESULT, str); edit.putString(TapjoyConstants.PREF_LAST_CONNECT_PARAMS_HASH, str2); if (j >= 0) { edit.putLong(TapjoyConstants.PREF_LAST_CONNECT_RESULT_EXPIRES, j); } else { edit.remove(TapjoyConstants.PREF_LAST_CONNECT_RESULT_EXPIRES); } TapjoyLog.i(TAG, "Stored connect result"); edit.apply(); } public void saveLoggingLevel(String str) { if (TextUtils.isEmpty(str)) { TapjoyLog.d(TAG, "saveLoggingLevel -- server logging level is NULL or Empty string"); return; } String str2 = TAG; TapjoyLog.d(str2, "saveLoggingLevel -- currentLevel=" + this.b + ";newLevel=" + str); if (TextUtils.isEmpty(this.b) || !this.b.equals(str)) { SharedPreferences.Editor edit = this.a.edit(); edit.putString(TapjoyConstants.PREF_LOG_LEVEL, str); edit.apply(); this.b = str; TapjoyLog.a(str, true); } boolean isLoggingEnabled = TapjoyLog.isLoggingEnabled(); StringBuilder sb = new StringBuilder("Tapjoy remote device debugging set to '"); sb.append(str); sb.append("'. The SDK Debug-setting is: "); sb.append(isLoggingEnabled ? "'Enabled'" : "'Disabled'"); TapjoyLog.i(str2, sb.toString()); } }