Properly solve the connection problem

This commit is contained in:
topjohnwu
2019-11-07 17:41:59 -05:00
parent 46447f7cfd
commit d952cc2327
8 changed files with 194 additions and 85 deletions

View File

@@ -43,10 +43,15 @@
<!-- Superuser -->
<activity
android:name="a.m"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:directBootAware="true"
android:excludeFromRecents="true"
android:exported="false" />
android:exported="false"
tools:ignore="AppLinkUrlError">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<!-- Receiver -->
<receiver

View File

@@ -1,5 +1,6 @@
package com.topjohnwu.magisk.ui.surequest
import android.content.Intent
import android.content.pm.ActivityInfo
import android.os.Build
import android.os.Bundle
@@ -11,6 +12,7 @@ import com.topjohnwu.magisk.model.entity.MagiskPolicy
import com.topjohnwu.magisk.model.events.DieEvent
import com.topjohnwu.magisk.model.events.ViewEvent
import com.topjohnwu.magisk.utils.SuHandler
import com.topjohnwu.magisk.utils.SuHandler.REQUEST
import org.koin.androidx.viewmodel.ext.android.viewModel
open class SuRequestActivity : BaseActivity<SuRequestViewModel, ActivityRequestBinding>() {
@@ -28,13 +30,28 @@ open class SuRequestActivity : BaseActivity<SuRequestViewModel, ActivityRequestB
lockOrientation()
super.onCreate(savedInstanceState)
if (intent?.action == SuHandler.REQUEST) {
fun showRequest() {
if (!viewModel.handleRequest(intent))
finish()
} else {
SuHandler(this, intent.action, intent.extras)
}
fun runHandler(action: String?) {
SuHandler(this, action, intent.extras)
finish()
}
if (intent.action == Intent.ACTION_VIEW) {
val action = intent.getStringExtra("action")
if (action == REQUEST) {
showRequest()
} else {
runHandler(action)
}
} else if (intent.action == REQUEST) {
showRequest()
} else {
runHandler(intent.action)
}
}
override fun onEventDispatched(event: ViewEvent) {