diff --git a/mobile/build.gradle b/mobile/build.gradle
index c9c17518..8b53230e 100644
--- a/mobile/build.gradle
+++ b/mobile/build.gradle
@@ -11,7 +11,7 @@ android {
minSdkVersion 21
targetSdkVersion 28
resConfigs "zh-rCN"
- versionCode 30
+ versionCode 31
versionName "1.3.5"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
diff --git a/mobile/src/main/AndroidManifest.xml b/mobile/src/main/AndroidManifest.xml
index 96d5babb..ac1f33ba 100644
--- a/mobile/src/main/AndroidManifest.xml
+++ b/mobile/src/main/AndroidManifest.xml
@@ -41,6 +41,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
+
+
= 24) {
- deviceContext = createDeviceProtectedStorageContext()
- deviceContext.moveSharedPreferencesFrom(this, PreferenceManager.getDefaultSharedPreferencesName(this))
- } else deviceContext = this
+ deviceStorage = DeviceStorageApp(this)
+ deviceStorage.moveSharedPreferencesFrom(this, PreferenceManager.getDefaultSharedPreferencesName(this))
+ } else deviceStorage = this
+ Fabric.with(deviceStorage, Crashlytics())
ServiceNotification.updateNotificationChannels()
}
@@ -39,9 +42,9 @@ class App : Application() {
ServiceNotification.updateNotificationChannels()
}
- lateinit var deviceContext: Context
+ lateinit var deviceStorage: Application
val handler = Handler()
- val pref: SharedPreferences by lazy { PreferenceManager.getDefaultSharedPreferences(deviceContext) }
+ val pref: SharedPreferences by lazy { PreferenceManager.getDefaultSharedPreferences(deviceStorage) }
val connectivity by lazy { getSystemService()!! }
val wifi by lazy { getSystemService()!! }
diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/util/DeviceStorageApp.kt b/mobile/src/main/java/be/mygod/vpnhotspot/util/DeviceStorageApp.kt
new file mode 100644
index 00000000..3df4e7f8
--- /dev/null
+++ b/mobile/src/main/java/be/mygod/vpnhotspot/util/DeviceStorageApp.kt
@@ -0,0 +1,20 @@
+package be.mygod.vpnhotspot.util
+
+import android.annotation.SuppressLint
+import android.annotation.TargetApi
+import android.app.Application
+import android.content.Context
+
+@SuppressLint("Registered")
+@TargetApi(24)
+class DeviceStorageApp(context: Context) : Application() {
+ init {
+ attachBaseContext(context.createDeviceProtectedStorageContext())
+ }
+
+ /**
+ * Thou shalt not get the REAL underlying application context which would no longer be operating under device
+ * protected storage.
+ */
+ override fun getApplicationContext(): Context = this
+}
diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/util/NoisySu.kt b/mobile/src/main/java/be/mygod/vpnhotspot/util/NoisySu.kt
index f031b8f2..ac56eb80 100644
--- a/mobile/src/main/java/be/mygod/vpnhotspot/util/NoisySu.kt
+++ b/mobile/src/main/java/be/mygod/vpnhotspot/util/NoisySu.kt
@@ -14,7 +14,7 @@ private class SuFailure : RuntimeException()
fun loggerSuStream(command: String): InputStream? {
val process = try {
ProcessBuilder("su", "-c", command)
- .directory(app.deviceContext.cacheDir)
+ .directory(app.deviceStorage.cacheDir)
.redirectErrorStream(true)
.start()
} catch (e: IOException) {