Skip to content

Commit 8c01004

Browse files
committed
Update
1 parent dd59024 commit 8c01004

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

app/src/main/java/com/tool/tree/SplashActivity.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class SplashActivity : AppCompatActivity() {
3838

3939
private var hasRoot = false
4040
private var started = false
41-
private var starting = false
41+
private var forceReset = false
4242

4343
override fun onCreate(savedInstanceState: Bundle?) {
4444
applyAppLanguage()
@@ -48,8 +48,8 @@ class SplashActivity : AppCompatActivity() {
4848
setContentView(binding.root)
4949

5050
// 1. Kiểm tra nếu script đã chạy hoặc đang chạy thì vào thẳng Home
51-
if (ScriptEnvironmen.isInited() && isTaskRoot &&
52-
!intent.getBooleanExtra("force_reset", false)) {
51+
forceReset = intent.getBooleanExtra("force_reset", false)
52+
if (!forceReset && ScriptEnvironmen.isInited() && isTaskRoot) {
5353
gotoHome()
5454
return
5555
}
@@ -152,8 +152,7 @@ class SplashActivity : AppCompatActivity() {
152152

153153
@Synchronized
154154
private fun checkRootAndStart() {
155-
if (starting) return
156-
starting = true
155+
if (started) return
157156
started = true
158157

159158
// Khi đã vượt qua hết các bước xin quyền và bắt đầu check root -> Lưu trạng thái đồng ý
@@ -162,7 +161,6 @@ class SplashActivity : AppCompatActivity() {
162161
lifecycleScope.launch(Dispatchers.IO) {
163162
hasRoot = KeepShellPublic.checkRoot()
164163
withContext(Dispatchers.Main) {
165-
starting = false
166164
startToFinish()
167165
}
168166
}
@@ -172,7 +170,7 @@ class SplashActivity : AppCompatActivity() {
172170
binding.startStateText.text = getString(R.string.pop_started)
173171
val config = KrScriptConfig().init(this)
174172

175-
if (config.beforeStartSh.isNotEmpty()) {
173+
if (config.beforeStartSh.isNotEmpty() || forceReset) {
176174
runBeforeStartSh(config, hasRoot)
177175
} else {
178176
gotoHome()

0 commit comments

Comments
 (0)