Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
9ab75509
Commit
9ab75509
authored
Jun 02, 2022
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use weak reference to track activity
parent
47e7a0a4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
App.kt
app/src/main/java/com/topjohnwu/magisk/core/App.kt
+6
-5
No files found.
app/src/main/java/com/topjohnwu/magisk/core/App.kt
View file @
9ab75509
package
com.topjohnwu.magisk.core
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.app.Application
import
android.content.Context
...
...
@@ -15,6 +14,7 @@ import com.topjohnwu.superuser.internal.UiThreadHandler
import
com.topjohnwu.superuser.ipc.RootService
import
kotlinx.coroutines.Dispatchers
import
timber.log.Timber
import
java.lang.ref.WeakReference
import
kotlin.system.exitProcess
open
class
App
()
:
Application
()
{
...
...
@@ -81,20 +81,21 @@ open class App() : Application() {
}
}
@SuppressLint
(
"StaticFieldLeak"
)
object
ActivityTracker
:
Application
.
ActivityLifecycleCallbacks
{
val
foreground
:
Activity
?
get
()
=
ref
.
get
()
@Volatile
var
foreground
:
Activity
?
=
null
private
var
ref
=
WeakReference
<
Activity
>(
null
)
override
fun
onActivityResumed
(
activity
:
Activity
)
{
if
(
activity
is
SuRequestActivity
)
return
foreground
=
activity
ref
=
WeakReference
(
activity
)
}
override
fun
onActivityPaused
(
activity
:
Activity
)
{
if
(
activity
is
SuRequestActivity
)
return
foreground
=
null
ref
.
clear
()
}
override
fun
onActivityCreated
(
activity
:
Activity
,
bundle
:
Bundle
?)
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment