Implement direct boot awareness for tile service
This commit is contained in:
@@ -39,12 +39,15 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<service android:name=".RepeaterService">
|
<service
|
||||||
|
android:name=".RepeaterService"
|
||||||
|
android:directBootAware="true">
|
||||||
</service>
|
</service>
|
||||||
<service android:name=".TetheringService">
|
<service android:name=".TetheringService">
|
||||||
</service>
|
</service>
|
||||||
<service
|
<service
|
||||||
android:name=".RepeaterTileService"
|
android:name=".RepeaterTileService"
|
||||||
|
android:directBootAware="true"
|
||||||
android:icon="@drawable/ic_quick_settings_tile_off"
|
android:icon="@drawable/ic_quick_settings_tile_off"
|
||||||
android:label="@string/title_repeater"
|
android:label="@string/title_repeater"
|
||||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package be.mygod.vpnhotspot
|
package be.mygod.vpnhotspot
|
||||||
|
|
||||||
|
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.os.Build
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.preference.PreferenceManager
|
import android.preference.PreferenceManager
|
||||||
import android.support.annotation.StringRes
|
import android.support.annotation.StringRes
|
||||||
@@ -12,12 +15,17 @@ class App : Application() {
|
|||||||
companion object {
|
companion object {
|
||||||
const val ACTION_CLEAN_ROUTINGS = "be.mygod.vpnhotspot.CLEAN_ROUTINGS"
|
const val ACTION_CLEAN_ROUTINGS = "be.mygod.vpnhotspot.CLEAN_ROUTINGS"
|
||||||
|
|
||||||
|
@SuppressLint("StaticFieldLeak")
|
||||||
lateinit var app: App
|
lateinit var app: App
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
app = this
|
app = this
|
||||||
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
|
deviceContext = createDeviceProtectedStorageContext()
|
||||||
|
deviceContext.moveSharedPreferencesFrom(this, PreferenceManager.getDefaultSharedPreferencesName(this))
|
||||||
|
} else deviceContext = this
|
||||||
ServiceNotification.updateNotificationChannels()
|
ServiceNotification.updateNotificationChannels()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,8 +34,9 @@ class App : Application() {
|
|||||||
ServiceNotification.updateNotificationChannels()
|
ServiceNotification.updateNotificationChannels()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lateinit var deviceContext: Context
|
||||||
val handler = Handler()
|
val handler = Handler()
|
||||||
val pref: SharedPreferences by lazy { PreferenceManager.getDefaultSharedPreferences(this) }
|
val pref: SharedPreferences by lazy { PreferenceManager.getDefaultSharedPreferences(deviceContext) }
|
||||||
|
|
||||||
fun toast(@StringRes resId: Int) = handler.post { Toast.makeText(this, resId, Toast.LENGTH_SHORT).show() }
|
fun toast(@StringRes resId: Int) = handler.post { Toast.makeText(this, resId, Toast.LENGTH_SHORT).show() }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,9 +43,10 @@ fun loggerSuStream(command: String): InputStream? {
|
|||||||
val process = try {
|
val process = try {
|
||||||
ProcessBuilder("su", "-c", command)
|
ProcessBuilder("su", "-c", command)
|
||||||
.redirectErrorStream(true)
|
.redirectErrorStream(true)
|
||||||
.directory(app.cacheDir)
|
.directory(app.deviceContext.cacheDir)
|
||||||
.start()
|
.start()
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
|
e.printStackTrace()
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user