Fix direct boot
This commit is contained in:
@@ -11,7 +11,7 @@ android {
|
|||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
resConfigs "zh-rCN"
|
resConfigs "zh-rCN"
|
||||||
versionCode 30
|
versionCode 31
|
||||||
versionName "1.3.5"
|
versionName "1.3.5"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,9 @@
|
|||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
|
<meta-data android:name="firebase_crashlytics_collection_enabled"
|
||||||
|
android:value="false"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package be.mygod.vpnhotspot
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
@@ -10,10 +9,13 @@ import android.net.wifi.WifiManager
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.preference.PreferenceManager
|
import android.preference.PreferenceManager
|
||||||
import androidx.annotation.StringRes
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.annotation.StringRes
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
|
import be.mygod.vpnhotspot.util.DeviceStorageApp
|
||||||
import be.mygod.vpnhotspot.util.Event0
|
import be.mygod.vpnhotspot.util.Event0
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
|
import io.fabric.sdk.android.Fabric
|
||||||
|
|
||||||
class App : Application() {
|
class App : Application() {
|
||||||
companion object {
|
companion object {
|
||||||
@@ -28,9 +30,10 @@ class App : Application() {
|
|||||||
super.onCreate()
|
super.onCreate()
|
||||||
app = this
|
app = this
|
||||||
if (Build.VERSION.SDK_INT >= 24) {
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
deviceContext = createDeviceProtectedStorageContext()
|
deviceStorage = DeviceStorageApp(this)
|
||||||
deviceContext.moveSharedPreferencesFrom(this, PreferenceManager.getDefaultSharedPreferencesName(this))
|
deviceStorage.moveSharedPreferencesFrom(this, PreferenceManager.getDefaultSharedPreferencesName(this))
|
||||||
} else deviceContext = this
|
} else deviceStorage = this
|
||||||
|
Fabric.with(deviceStorage, Crashlytics())
|
||||||
ServiceNotification.updateNotificationChannels()
|
ServiceNotification.updateNotificationChannels()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,9 +42,9 @@ class App : Application() {
|
|||||||
ServiceNotification.updateNotificationChannels()
|
ServiceNotification.updateNotificationChannels()
|
||||||
}
|
}
|
||||||
|
|
||||||
lateinit var deviceContext: Context
|
lateinit var deviceStorage: Application
|
||||||
val handler = Handler()
|
val handler = Handler()
|
||||||
val pref: SharedPreferences by lazy { PreferenceManager.getDefaultSharedPreferences(deviceContext) }
|
val pref: SharedPreferences by lazy { PreferenceManager.getDefaultSharedPreferences(deviceStorage) }
|
||||||
val connectivity by lazy { getSystemService<ConnectivityManager>()!! }
|
val connectivity by lazy { getSystemService<ConnectivityManager>()!! }
|
||||||
val wifi by lazy { getSystemService<WifiManager>()!! }
|
val wifi by lazy { getSystemService<WifiManager>()!! }
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ private class SuFailure : RuntimeException()
|
|||||||
fun loggerSuStream(command: String): InputStream? {
|
fun loggerSuStream(command: String): InputStream? {
|
||||||
val process = try {
|
val process = try {
|
||||||
ProcessBuilder("su", "-c", command)
|
ProcessBuilder("su", "-c", command)
|
||||||
.directory(app.deviceContext.cacheDir)
|
.directory(app.deviceStorage.cacheDir)
|
||||||
.redirectErrorStream(true)
|
.redirectErrorStream(true)
|
||||||
.start()
|
.start()
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
|
|||||||
Reference in New Issue
Block a user