@ -146,9 +146,10 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
intent . putExtra ( "secret" , secret ) ;
intent . putExtra ( "secret" , secret ) ;
}
}
public static SharedPreferences get Preferences( String name ) {
public static SharedPreferences get Shared Preferences( String name ) {
// encryptedSharedPreferences is used
// encryptedSharedPreferences is used
Context mContext = getINSTANCE ( ) ;
Context mContext = getINSTANCE ( ) ;
name = name + "x" ;
if ( mSharedPrefs = = null ) {
if ( mSharedPrefs = = null ) {
Timber . d ( "Creating shared prefs map" ) ;
Timber . d ( "Creating shared prefs map" ) ;
mSharedPrefs = new HashMap < > ( ) ;
mSharedPrefs = new HashMap < > ( ) ;
@ -202,50 +203,50 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
// convert from String to boolean
// convert from String to boolean
return Boolean . parseBoolean ( SHOWCASE_MODE_TRUE ) ;
return Boolean . parseBoolean ( SHOWCASE_MODE_TRUE ) ;
}
}
boolean showcaseMode = get Preferences( "mmm" ) . getBoolean ( "pref_showcase_mode" , false ) ;
boolean showcaseMode = get Shared Preferences( "mmm" ) . getBoolean ( "pref_showcase_mode" , false ) ;
SHOWCASE_MODE_TRUE = String . valueOf ( showcaseMode ) ;
SHOWCASE_MODE_TRUE = String . valueOf ( showcaseMode ) ;
return showcaseMode ;
return showcaseMode ;
}
}
public static boolean shouldPreventReboot ( ) {
public static boolean shouldPreventReboot ( ) {
return get Preferences( "mmm" ) . getBoolean ( "pref_prevent_reboot" , true ) ;
return get Shared Preferences( "mmm" ) . getBoolean ( "pref_prevent_reboot" , true ) ;
}
}
public static boolean isShowIncompatibleModules ( ) {
public static boolean isShowIncompatibleModules ( ) {
return get Preferences( "mmm" ) . getBoolean ( "pref_show_incompatible" , false ) ;
return get Shared Preferences( "mmm" ) . getBoolean ( "pref_show_incompatible" , false ) ;
}
}
public static boolean isForceDarkTerminal ( ) {
public static boolean isForceDarkTerminal ( ) {
return get Preferences( "mmm" ) . getBoolean ( "pref_force_dark_terminal" , false ) ;
return get Shared Preferences( "mmm" ) . getBoolean ( "pref_force_dark_terminal" , false ) ;
}
}
public static boolean isTextWrapEnabled ( ) {
public static boolean isTextWrapEnabled ( ) {
return get Preferences( "mmm" ) . getBoolean ( "pref_wrap_text" , false ) ;
return get Shared Preferences( "mmm" ) . getBoolean ( "pref_wrap_text" , false ) ;
}
}
public static boolean isDohEnabled ( ) {
public static boolean isDohEnabled ( ) {
return get Preferences( "mmm" ) . getBoolean ( "pref_dns_over_https" , true ) ;
return get Shared Preferences( "mmm" ) . getBoolean ( "pref_dns_over_https" , true ) ;
}
}
public static boolean isMonetEnabled ( ) {
public static boolean isMonetEnabled ( ) {
return Build . VERSION . SDK_INT > = Build . VERSION_CODES . S & & get Preferences( "mmm" ) . getBoolean ( "pref_enable_monet" , true ) ;
return Build . VERSION . SDK_INT > = Build . VERSION_CODES . S & & get Shared Preferences( "mmm" ) . getBoolean ( "pref_enable_monet" , true ) ;
}
}
public static boolean isBlurEnabled ( ) {
public static boolean isBlurEnabled ( ) {
return get Preferences( "mmm" ) . getBoolean ( "pref_enable_blur" , false ) ;
return get Shared Preferences( "mmm" ) . getBoolean ( "pref_enable_blur" , false ) ;
}
}
public static boolean isDeveloper ( ) {
public static boolean isDeveloper ( ) {
if ( BuildConfig . DEBUG ) return true ;
if ( BuildConfig . DEBUG ) return true ;
return get Preferences( "mmm" ) . getBoolean ( "developer" , false ) ;
return get Shared Preferences( "mmm" ) . getBoolean ( "developer" , false ) ;
}
}
public static boolean isDisableLowQualityModuleFilter ( ) {
public static boolean isDisableLowQualityModuleFilter ( ) {
return get Preferences( "mmm" ) . getBoolean ( "pref_disable_low_quality_module_filter" , false ) & & isDeveloper ( ) ;
return get Shared Preferences( "mmm" ) . getBoolean ( "pref_disable_low_quality_module_filter" , false ) & & isDeveloper ( ) ;
}
}
public static boolean isUsingMagiskCommand ( ) {
public static boolean isUsingMagiskCommand ( ) {
return InstallerInitializer . peekMagiskVersion ( ) > = Constants . MAGISK_VER_CODE_INSTALL_COMMAND & & get Preferences( "mmm" ) . getBoolean ( "pref_use_magisk_install_command" , false ) & & isDeveloper ( ) ;
return InstallerInitializer . peekMagiskVersion ( ) > = Constants . MAGISK_VER_CODE_INSTALL_COMMAND & & get Shared Preferences( "mmm" ) . getBoolean ( "pref_use_magisk_install_command" , false ) & & isDeveloper ( ) ;
}
}
public static boolean isBackgroundUpdateCheckEnabled ( ) {
public static boolean isBackgroundUpdateCheckEnabled ( ) {
@ -253,13 +254,13 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
return Boolean . parseBoolean ( updateCheckBg ) ;
return Boolean . parseBoolean ( updateCheckBg ) ;
}
}
boolean wrapped = isWrapped ( ) ;
boolean wrapped = isWrapped ( ) ;
boolean updateCheckBgTemp = ! wrapped & & get Preferences( "mmm" ) . getBoolean ( "pref_background_update_check" , true ) ;
boolean updateCheckBgTemp = ! wrapped & & get Shared Preferences( "mmm" ) . getBoolean ( "pref_background_update_check" , true ) ;
updateCheckBg = String . valueOf ( updateCheckBgTemp ) ;
updateCheckBg = String . valueOf ( updateCheckBgTemp ) ;
return Boolean . parseBoolean ( updateCheckBg ) ;
return Boolean . parseBoolean ( updateCheckBg ) ;
}
}
public static boolean isAndroidacyTestMode ( ) {
public static boolean isAndroidacyTestMode ( ) {
return isDeveloper ( ) & & get Preferences( "mmm" ) . getBoolean ( "pref_androidacy_test_mode" , false ) ;
return isDeveloper ( ) & & get Shared Preferences( "mmm" ) . getBoolean ( "pref_androidacy_test_mode" , false ) ;
}
}
public static boolean isFirstBoot ( ) {
public static boolean isFirstBoot ( ) {
@ -267,15 +268,15 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
}
}
public static void setHasGottenRootAccess ( boolean bool ) {
public static void setHasGottenRootAccess ( boolean bool ) {
get Preferences( "mmm" ) . edit ( ) . putBoolean ( "has_root_access" , bool ) . apply ( ) ;
get Shared Preferences( "mmm" ) . edit ( ) . putBoolean ( "has_root_access" , bool ) . apply ( ) ;
}
}
public static boolean isCrashReportingEnabled ( ) {
public static boolean isCrashReportingEnabled ( ) {
return SentryMain . IS_SENTRY_INSTALLED & & get Preferences( "mmm" ) . getBoolean ( "pref_crash_reporting" , BuildConfig . DEFAULT_ENABLE_CRASH_REPORTING ) ;
return SentryMain . IS_SENTRY_INSTALLED & & get Shared Preferences( "mmm" ) . getBoolean ( "pref_crash_reporting" , BuildConfig . DEFAULT_ENABLE_CRASH_REPORTING ) ;
}
}
public static SharedPreferences getBootSharedPreferences ( ) {
public static SharedPreferences getBootSharedPreferences ( ) {
return get Preferences( "mmm_boot" ) ;
return get Shared Preferences( "mmm_boot" ) ;
}
}
public static MainApplication getINSTANCE ( ) {
public static MainApplication getINSTANCE ( ) {
@ -312,7 +313,7 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
@StyleRes int themeResId ;
@StyleRes int themeResId ;
String theme ;
String theme ;
boolean monet = isMonetEnabled ( ) ;
boolean monet = isMonetEnabled ( ) ;
switch ( theme = get Preferences( "mmm" ) . getString ( "pref_theme" , "system" ) ) {
switch ( theme = get Shared Preferences( "mmm" ) . getString ( "pref_theme" , "system" ) ) {
default :
default :
Timber . w ( "Unknown theme id: %s" , theme ) ;
Timber . w ( "Unknown theme id: %s" , theme ) ;
case "system" :
case "system" :
@ -353,7 +354,7 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
@SuppressLint ( "NonConstantResourceId" )
@SuppressLint ( "NonConstantResourceId" )
public boolean isLightTheme ( ) {
public boolean isLightTheme ( ) {
return switch ( get Preferences( "mmm" ) . getString ( "pref_theme" , "system" ) ) {
return switch ( get Shared Preferences( "mmm" ) . getString ( "pref_theme" , "system" ) ) {
case "system" - > this . isSystemLightTheme ( ) ;
case "system" - > this . isSystemLightTheme ( ) ;
case "dark" , "black" - > false ;
case "dark" , "black" - > false ;
default - > true ;
default - > true ;
@ -419,10 +420,10 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
} else {
} else {
tracker . setOptOut ( false ) ;
tracker . setOptOut ( false ) ;
}
}
if ( get Preferences( "matomo" ) . getBoolean ( "install_tracked" , false ) ) {
if ( get Shared Preferences( "matomo" ) . getBoolean ( "install_tracked" , false ) ) {
TrackHelper . track ( ) . download ( ) . with ( MainApplication . getINSTANCE ( ) . getTracker ( ) ) ;
TrackHelper . track ( ) . download ( ) . with ( MainApplication . getINSTANCE ( ) . getTracker ( ) ) ;
Timber . d ( "Sent install event to matomo" ) ;
Timber . d ( "Sent install event to matomo" ) ;
get Preferences( "matomo" ) . edit ( ) . putBoolean ( "install_tracked" , true ) . apply ( ) ;
get Shared Preferences( "matomo" ) . edit ( ) . putBoolean ( "install_tracked" , true ) . apply ( ) ;
} else {
} else {
Timber . d ( "Matomo already has install" ) ;
Timber . d ( "Matomo already has install" ) ;
}
}
@ -434,9 +435,9 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
Iof = Arrays . asList ( osh ) . contains ( oosh ) ;
Iof = Arrays . asList ( osh ) . contains ( oosh ) ;
} catch ( PackageManager . NameNotFoundException ignored ) {
} catch ( PackageManager . NameNotFoundException ignored ) {
}
}
SharedPreferences sharedPreferences = MainApplication . get Preferences( "mmm" ) ;
SharedPreferences sharedPreferences = MainApplication . get Shared Preferences( "mmm" ) ;
// We are only one process so it's ok to do this
// We are only one process so it's ok to do this
SharedPreferences bootPrefs = MainApplication . get Preferences( "mmm_boot" ) ;
SharedPreferences bootPrefs = MainApplication . get Shared Preferences( "mmm_boot" ) ;
long lastBoot = System . currentTimeMillis ( ) - SystemClock . elapsedRealtime ( ) ;
long lastBoot = System . currentTimeMillis ( ) - SystemClock . elapsedRealtime ( ) ;
long lastBootPrefs = bootPrefs . getLong ( "last_boot" , 0 ) ;
long lastBootPrefs = bootPrefs . getLong ( "last_boot" , 0 ) ;
if ( lastBootPrefs = = 0 | | Math . abs ( lastBoot - lastBootPrefs ) > 100 ) {
if ( lastBootPrefs = = 0 | | Math . abs ( lastBoot - lastBootPrefs ) > 100 ) {
@ -474,7 +475,7 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
}
}
private boolean isMatomoAllowed ( ) {
private boolean isMatomoAllowed ( ) {
return get Preferences( "mmm" ) . getBoolean ( "pref_analytics_enabled" , BuildConfig . DEFAULT_ENABLE_ANALYTICS ) ;
return get Shared Preferences( "mmm" ) . getBoolean ( "pref_analytics_enabled" , BuildConfig . DEFAULT_ENABLE_ANALYTICS ) ;
}
}
@SuppressWarnings ( "unused" )
@SuppressWarnings ( "unused" )
@ -592,7 +593,7 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
return existingKey ;
return existingKey ;
}
}
// check if we have a key already
// check if we have a key already
SharedPreferences sharedPreferences = MainApplication . get Preferences( "realm_key" ) ;
SharedPreferences sharedPreferences = MainApplication . get Shared Preferences( "realm_key" ) ;
if ( sharedPreferences . contains ( "iv_and_encrypted_key" ) ) {
if ( sharedPreferences . contains ( "iv_and_encrypted_key" ) ) {
return getExistingKey ( ) ;
return getExistingKey ( ) ;
} else {
} else {
@ -661,7 +662,7 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
buffer . put ( initializationVector ) ;
buffer . put ( initializationVector ) ;
buffer . put ( encryptedKeyForRealm ) ;
buffer . put ( encryptedKeyForRealm ) ;
Timber . d ( "Created all keys successfully." ) ;
Timber . d ( "Created all keys successfully." ) ;
MainApplication . get Preferences( "realm_key" ) . edit ( ) . putString ( "iv_and_encrypted_key" , Base64 . encodeToString ( initializationVectorAndEncryptedKey , Base64 . NO_WRAP ) ) . apply ( ) ;
MainApplication . get Shared Preferences( "realm_key" ) . edit ( ) . putString ( "iv_and_encrypted_key" , Base64 . encodeToString ( initializationVectorAndEncryptedKey , Base64 . NO_WRAP ) ) . apply ( ) ;
Timber . d ( "Saved the encrypted key in shared preferences." ) ;
Timber . d ( "Saved the encrypted key in shared preferences." ) ;
makingNewKey = false ;
makingNewKey = false ;
return realmKey ; // pass to a realm configuration via encryptionKey()
return realmKey ; // pass to a realm configuration via encryptionKey()
@ -686,7 +687,7 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
}
}
Timber . v ( "Keystore opened." ) ;
Timber . v ( "Keystore opened." ) ;
// access the encrypted key that's stored in shared preferences
// access the encrypted key that's stored in shared preferences
byte [ ] initializationVectorAndEncryptedKey = Base64 . decode ( MainApplication . get Preferences( "realm_key" ) . getString ( "iv_and_encrypted_key" , null ) , Base64 . DEFAULT ) ;
byte [ ] initializationVectorAndEncryptedKey = Base64 . decode ( MainApplication . get Shared Preferences( "realm_key" ) . getString ( "iv_and_encrypted_key" , null ) , Base64 . DEFAULT ) ;
Timber . d ( "Retrieved the encrypted key from shared preferences. Key length: %d" , initializationVectorAndEncryptedKey . length ) ;
Timber . d ( "Retrieved the encrypted key from shared preferences. Key length: %d" , initializationVectorAndEncryptedKey . length ) ;
ByteBuffer buffer = ByteBuffer . wrap ( initializationVectorAndEncryptedKey ) ;
ByteBuffer buffer = ByteBuffer . wrap ( initializationVectorAndEncryptedKey ) ;
buffer . order ( ByteOrder . BIG_ENDIAN ) ;
buffer . order ( ByteOrder . BIG_ENDIAN ) ;