mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 09:17:50 +00:00
Minor adjustments
This commit is contained in:
parent
022c217cfe
commit
98deec232b
@ -2,7 +2,6 @@ package com.topjohnwu.magisk.arch
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build.VERSION.SDK_INT
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||||
import androidx.databinding.ViewDataBinding
|
import androidx.databinding.ViewDataBinding
|
||||||
@ -35,11 +34,7 @@ abstract class BaseMainActivity<VM : BaseViewModel, Binding : ViewDataBinding>
|
|||||||
|
|
||||||
if (isRunningAsStub && doPreload) {
|
if (isRunningAsStub && doPreload) {
|
||||||
// Manually apply splash theme for stub
|
// Manually apply splash theme for stub
|
||||||
if (SDK_INT >= 31) {
|
|
||||||
theme.applyStyle(R.style.StubSplashTheme, true)
|
theme.applyStyle(R.style.StubSplashTheme, true)
|
||||||
} else {
|
|
||||||
theme.applyStyle(R.style.SplashTheme, true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
@ -39,7 +39,7 @@ class JobService : BaseJobService() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun schedule(context: Context) {
|
fun schedule(context: Context) {
|
||||||
val svc = context.getSystemService<JobScheduler>() ?: return
|
val scheduler = context.getSystemService<JobScheduler>() ?: return
|
||||||
if (Config.checkUpdate) {
|
if (Config.checkUpdate) {
|
||||||
val cmp = JobService::class.java.cmp(context.packageName)
|
val cmp = JobService::class.java.cmp(context.packageName)
|
||||||
val info = JobInfo.Builder(Const.ID.JOB_SERVICE_ID, cmp)
|
val info = JobInfo.Builder(Const.ID.JOB_SERVICE_ID, cmp)
|
||||||
@ -47,9 +47,9 @@ class JobService : BaseJobService() {
|
|||||||
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
|
.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
|
||||||
.setRequiresDeviceIdle(true)
|
.setRequiresDeviceIdle(true)
|
||||||
.build()
|
.build()
|
||||||
svc.schedule(info)
|
scheduler.schedule(info)
|
||||||
} else {
|
} else {
|
||||||
svc.cancel(Const.ID.JOB_SERVICE_ID)
|
scheduler.cancel(Const.ID.JOB_SERVICE_ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import androidx.collection.SparseArrayCompat
|
|||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.topjohnwu.magisk.R
|
import com.topjohnwu.magisk.R
|
||||||
|
import com.topjohnwu.magisk.core.isRunningAsStub
|
||||||
import com.topjohnwu.magisk.core.utils.currentLocale
|
import com.topjohnwu.magisk.core.utils.currentLocale
|
||||||
import com.topjohnwu.magisk.core.wrap
|
import com.topjohnwu.magisk.core.wrap
|
||||||
import com.topjohnwu.magisk.ktx.reflectField
|
import com.topjohnwu.magisk.ktx.reflectField
|
||||||
@ -46,11 +47,13 @@ abstract class BaseActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
if (isRunningAsStub) {
|
||||||
// Overwrite private members to avoid nasty "false" stack traces being logged
|
// Overwrite private members to avoid nasty "false" stack traces being logged
|
||||||
val delegate = delegate
|
val delegate = delegate
|
||||||
val clz = delegate.javaClass
|
val clz = delegate.javaClass
|
||||||
clz.reflectField("mActivityHandlesUiModeChecked").set(delegate, true)
|
clz.reflectField("mActivityHandlesUiModeChecked").set(delegate, true)
|
||||||
clz.reflectField("mActivityHandlesUiMode").set(delegate, false)
|
clz.reflectField("mActivityHandlesUiMode").set(delegate, false)
|
||||||
|
}
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<!-- For stub APK, we need to manually handle the SplashScreen -->
|
<!-- For stub on API 31+, we cannot rely on the platform SplashScreen -->
|
||||||
|
<!-- Force using SplashScreenBase that was used for older APIs -->
|
||||||
<style name="StubSplashTheme" parent="Theme.SplashScreenBase">
|
<style name="StubSplashTheme" parent="Theme.SplashScreenBase">
|
||||||
<item name="android:enforceStatusBarContrast">false</item>
|
<item name="android:enforceStatusBarContrast">false</item>
|
||||||
<item name="android:enforceNavigationBarContrast">false</item>
|
<item name="android:enforceNavigationBarContrast">false</item>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="SplashTheme" parent="Theme.Splash" />
|
<style name="SplashTheme" parent="Theme.Splash" />
|
||||||
|
<style name="StubSplashTheme" parent="Theme.Splash"/>
|
||||||
|
|
||||||
<style name="Foundation" parent="Theme.Foundation.Light" />
|
<style name="Foundation" parent="Theme.Foundation.Light" />
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user