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
11d716a3
Commit
11d716a3
authored
Apr 22, 2019
by
Viktor De Pasquale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated splash screen with new arch
parent
7cc8c014
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
107 additions
and
113 deletions
+107
-113
App.kt
app/src/main/java/com/topjohnwu/magisk/App.kt
+6
-2
DatabaseModule.kt
app/src/main/java/com/topjohnwu/magisk/di/DatabaseModule.kt
+2
-1
ReposAdapter.java
...ava/com/topjohnwu/magisk/model/adapters/ReposAdapter.java
+2
-3
UpdateRepos.java
...src/main/java/com/topjohnwu/magisk/tasks/UpdateRepos.java
+9
-9
SplashActivity.java
...src/main/java/com/topjohnwu/magisk/ui/SplashActivity.java
+0
-97
SplashActivity.kt
app/src/main/java/com/topjohnwu/magisk/ui/SplashActivity.kt
+87
-0
SettingsFragment.java
...va/com/topjohnwu/magisk/ui/settings/SettingsFragment.java
+1
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/App.kt
View file @
11d716a3
...
...
@@ -19,6 +19,7 @@ import com.topjohnwu.magisk.utils.LocaleManager
import
com.topjohnwu.magisk.utils.RootUtils
import
com.topjohnwu.net.Networking
import
com.topjohnwu.superuser.Shell
import
org.koin.android.ext.android.inject
import
org.koin.android.ext.koin.androidContext
import
org.koin.core.context.startKoin
import
timber.log.Timber
...
...
@@ -29,8 +30,8 @@ open class App : Application(), Application.ActivityLifecycleCallbacks {
// Global resources
val
prefs
:
SharedPreferences
get
()
=
PreferenceManager
.
getDefaultSharedPreferences
(
deContext
)
val
DB
:
MagiskDB
by
lazy
{
MagiskDB
(
deContext
)
}
@
JvmField
va
r
repoDB
:
RepoDatabaseHelper
?
=
null
@
Deprecated
(
"Use dependency injection"
)
va
l
repoDB
:
RepoDatabaseHelper
by
inject
()
@Volatile
private
var
foreground
:
Activity
?
=
null
...
...
@@ -94,11 +95,13 @@ open class App : Application(), Application.ActivityLifecycleCallbacks {
//fixme this should be at least weak reference, me no likey
@SuppressLint
(
"StaticFieldLeak"
)
@Deprecated
(
"Use dependency injection"
)
@JvmStatic
lateinit
var
self
:
App
//fixme this should be at least weak reference, me no likey
@SuppressLint
(
"StaticFieldLeak"
)
@Deprecated
(
"Use dependency injection"
)
@JvmStatic
lateinit
var
deContext
:
Context
...
...
@@ -116,6 +119,7 @@ open class App : Application(), Application.ActivityLifecycleCallbacks {
}
//fixme me no likey
@Deprecated
(
""
)
@JvmStatic
fun
foreground
():
Activity
?
{
return
self
.
foreground
...
...
app/src/main/java/com/topjohnwu/magisk/di/DatabaseModule.kt
View file @
11d716a3
package
com.topjohnwu.magisk.di
import
com.topjohnwu.magisk.App
import
com.topjohnwu.magisk.data.database.RepoDatabaseHelper
import
org.koin.dsl.module
val
databaseModule
=
module
{
single
{
get
<
App
>().
DB
}
single
{
get
<
App
>().
repoDB
}
single
{
RepoDatabaseHelper
(
get
())
}
}
app/src/main/java/com/topjohnwu/magisk/model/adapters/ReposAdapter.java
View file @
11d716a3
...
...
@@ -13,8 +13,6 @@ import android.widget.ImageView;
import
android.widget.SearchView
;
import
android.widget.TextView
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.topjohnwu.magisk.App
;
import
com.topjohnwu.magisk.ClassMap
;
import
com.topjohnwu.magisk.R
;
...
...
@@ -33,6 +31,7 @@ import java.util.Collections;
import
java.util.List
;
import
java.util.Map
;
import
androidx.recyclerview.widget.RecyclerView
;
import
butterknife.BindView
;
import
java9.util.stream.StreamSupport
;
...
...
@@ -51,7 +50,7 @@ public class ReposAdapter
private
SearchView
mSearch
;
public
ReposAdapter
()
{
repoDB
=
App
.
self
.
repoDB
;
repoDB
=
App
.
self
.
getRepoDB
()
;
moduleMap
=
Collections
.
emptyMap
();
fullList
=
Collections
.
emptyList
();
repoPairs
=
new
ArrayList
<>();
...
...
app/src/main/java/com/topjohnwu/magisk/tasks/UpdateRepos.java
View file @
11d716a3
...
...
@@ -34,7 +34,7 @@ import java.util.concurrent.Future;
public
class
UpdateRepos
{
private
static
final
DateFormat
DATE_FORMAT
;
private
App
app
=
App
.
self
;
private
final
App
app
=
App
.
self
;
private
Set
<
String
>
cached
;
private
Queue
<
Pair
<
String
,
Date
>>
moduleQueue
;
...
...
@@ -116,17 +116,17 @@ public class UpdateRepos {
Pair
<
String
,
Date
>
pair
=
moduleQueue
.
poll
();
if
(
pair
==
null
)
return
;
Repo
repo
=
app
.
repoDB
.
getRepo
(
pair
.
first
);
Repo
repo
=
app
.
getRepoDB
()
.
getRepo
(
pair
.
first
);
try
{
if
(
repo
==
null
)
repo
=
new
Repo
(
pair
.
first
);
else
cached
.
remove
(
pair
.
first
);
repo
.
update
(
pair
.
second
);
app
.
repoDB
.
addRepo
(
repo
);
app
.
getRepoDB
()
.
addRepo
(
repo
);
}
catch
(
Repo
.
IllegalRepoException
e
)
{
Logger
.
debug
(
e
.
getMessage
());
app
.
repoDB
.
removeRepo
(
pair
.
first
);
app
.
getRepoDB
()
.
removeRepo
(
pair
.
first
);
}
}
});
...
...
@@ -134,7 +134,7 @@ public class UpdateRepos {
}
private
void
fullReload
()
{
Cursor
c
=
app
.
repoDB
.
getRawCursor
();
Cursor
c
=
app
.
getRepoDB
()
.
getRawCursor
();
runTasks
(()
->
{
while
(
true
)
{
Repo
repo
;
...
...
@@ -145,10 +145,10 @@ public class UpdateRepos {
}
try
{
repo
.
update
();
app
.
repoDB
.
addRepo
(
repo
);
app
.
getRepoDB
()
.
addRepo
(
repo
);
}
catch
(
Repo
.
IllegalRepoException
e
)
{
Logger
.
debug
(
e
.
getMessage
());
app
.
repoDB
.
removeRepo
(
repo
);
app
.
getRepoDB
()
.
removeRepo
(
repo
);
}
}
});
...
...
@@ -157,12 +157,12 @@ public class UpdateRepos {
public
void
exec
(
boolean
force
)
{
Event
.
reset
(
Event
.
REPO_LOAD_DONE
);
App
.
THREAD_POOL
.
execute
(()
->
{
cached
=
Collections
.
synchronizedSet
(
app
.
repoDB
.
getRepoIDSet
());
cached
=
Collections
.
synchronizedSet
(
app
.
getRepoDB
()
.
getRepoIDSet
());
moduleQueue
=
new
ConcurrentLinkedQueue
<>();
if
(
loadPages
())
{
// The leftover cached means they are removed from online repo
app
.
repoDB
.
removeRepo
(
cached
);
app
.
getRepoDB
()
.
removeRepo
(
cached
);
}
else
if
(
force
)
{
fullReload
();
}
...
...
app/src/main/java/com/topjohnwu/magisk/ui/SplashActivity.java
deleted
100644 → 0
View file @
7cc8c014
package
com
.
topjohnwu
.
magisk
.
ui
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
androidx.appcompat.app.AlertDialog
;
import
com.topjohnwu.magisk.BuildConfig
;
import
com.topjohnwu.magisk.ClassMap
;
import
com.topjohnwu.magisk.Config
;
import
com.topjohnwu.magisk.Const
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.data.database.RepoDatabaseHelper
;
import
com.topjohnwu.magisk.tasks.CheckUpdates
;
import
com.topjohnwu.magisk.tasks.UpdateRepos
;
import
com.topjohnwu.magisk.ui.base.BaseActivity
;
import
com.topjohnwu.magisk.utils.LocaleManager
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.view.Notifications
;
import
com.topjohnwu.magisk.view.Shortcuts
;
import
com.topjohnwu.net.Networking
;
import
com.topjohnwu.superuser.Shell
;
public
class
SplashActivity
extends
BaseActivity
{
public
static
boolean
DONE
=
false
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
Shell
.
getShell
(
shell
->
{
if
(
Config
.
magiskVersionCode
>
0
&&
Config
.
magiskVersionCode
<
Const
.
MAGISK_VER
.
MIN_SUPPORT
)
{
new
AlertDialog
.
Builder
(
this
)
.
setTitle
(
R
.
string
.
unsupport_magisk_title
)
.
setMessage
(
R
.
string
.
unsupport_magisk_message
)
.
setNegativeButton
(
R
.
string
.
ok
,
null
)
.
setOnDismissListener
(
dialog
->
finish
())
.
show
();
}
else
{
initAndStart
();
}
});
}
private
void
initAndStart
()
{
String
pkg
=
Config
.
get
(
Config
.
Key
.
SU_MANAGER
);
if
(
pkg
!=
null
&&
getPackageName
().
equals
(
BuildConfig
.
APPLICATION_ID
))
{
Config
.
remove
(
Config
.
Key
.
SU_MANAGER
);
Shell
.
su
(
"pm uninstall "
+
pkg
).
submit
();
}
if
(
TextUtils
.
equals
(
pkg
,
getPackageName
()))
{
try
{
// We are the manager, remove com.topjohnwu.magisk as it could be malware
getPackageManager
().
getApplicationInfo
(
BuildConfig
.
APPLICATION_ID
,
0
);
Shell
.
su
(
"pm uninstall "
+
BuildConfig
.
APPLICATION_ID
).
submit
();
}
catch
(
PackageManager
.
NameNotFoundException
ignored
)
{}
}
// Dynamic detect all locales
LocaleManager
.
loadAvailableLocales
(
R
.
string
.
app_changelog
);
// Set default configs
Config
.
initialize
();
// Create notification channel on Android O
Notifications
.
setup
(
this
);
// Schedule periodic update checks
Utils
.
scheduleUpdateCheck
();
CheckUpdates
.
check
();
// Setup shortcuts
Shortcuts
.
setup
(
this
);
// Create repo database
app
.
repoDB
=
new
RepoDatabaseHelper
(
this
);
// Magisk working as expected
if
(
Shell
.
rootAccess
()
&&
Config
.
magiskVersionCode
>
0
)
{
// Load modules
Utils
.
loadModules
(
false
);
// Load repos
if
(
Networking
.
checkNetworkStatus
(
this
))
new
UpdateRepos
().
exec
();
}
Intent
intent
=
new
Intent
(
this
,
ClassMap
.
get
(
MainActivity
.
class
));
intent
.
putExtra
(
Const
.
Key
.
OPEN_SECTION
,
getIntent
().
getStringExtra
(
Const
.
Key
.
OPEN_SECTION
));
DONE
=
true
;
startActivity
(
intent
);
finish
();
}
}
app/src/main/java/com/topjohnwu/magisk/ui/SplashActivity.kt
0 → 100644
View file @
11d716a3
package
com.topjohnwu.magisk.ui
import
android.content.Intent
import
android.os.Bundle
import
android.text.TextUtils
import
androidx.appcompat.app.AlertDialog
import
androidx.appcompat.app.AppCompatActivity
import
com.topjohnwu.magisk.*
import
com.topjohnwu.magisk.tasks.CheckUpdates
import
com.topjohnwu.magisk.tasks.UpdateRepos
import
com.topjohnwu.magisk.utils.LocaleManager
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.view.Notifications
import
com.topjohnwu.magisk.view.Shortcuts
import
com.topjohnwu.net.Networking
import
com.topjohnwu.superuser.Shell
open
class
SplashActivity
:
AppCompatActivity
()
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
Shell
.
getShell
{
if
(
Config
.
magiskVersionCode
>
0
&&
Config
.
magiskVersionCode
<
Const
.
MAGISK_VER
.
MIN_SUPPORT
)
{
AlertDialog
.
Builder
(
this
)
.
setTitle
(
R
.
string
.
unsupport_magisk_title
)
.
setMessage
(
R
.
string
.
unsupport_magisk_message
)
.
setNegativeButton
(
R
.
string
.
ok
,
null
)
.
setOnDismissListener
{
finish
()
}
.
show
()
}
else
{
initAndStart
()
}
}
}
private
fun
initAndStart
()
{
val
pkg
=
Config
.
get
<
String
>(
Config
.
Key
.
SU_MANAGER
)
if
(
pkg
!=
null
&&
packageName
==
BuildConfig
.
APPLICATION_ID
)
{
Config
.
remove
(
Config
.
Key
.
SU_MANAGER
)
Shell
.
su
(
"pm uninstall $pkg"
).
submit
()
}
if
(
TextUtils
.
equals
(
pkg
,
packageName
))
{
runCatching
{
// We are the manager, remove com.topjohnwu.magisk as it could be malware
packageManager
.
getApplicationInfo
(
BuildConfig
.
APPLICATION_ID
,
0
)
Shell
.
su
(
"pm uninstall "
+
BuildConfig
.
APPLICATION_ID
).
submit
()
}
}
// Dynamic detect all locales
LocaleManager
.
loadAvailableLocales
(
R
.
string
.
app_changelog
)
// Set default configs
Config
.
initialize
()
// Create notification channel on Android O
Notifications
.
setup
(
this
)
// Schedule periodic update checks
Utils
.
scheduleUpdateCheck
()
CheckUpdates
.
check
()
// Setup shortcuts
Shortcuts
.
setup
(
this
)
// Magisk working as expected
if
(
Shell
.
rootAccess
()
&&
Config
.
magiskVersionCode
>
0
)
{
// Load modules
Utils
.
loadModules
(
false
)
// Load repos
if
(
Networking
.
checkNetworkStatus
(
this
))
UpdateRepos
().
exec
()
}
val
intent
=
Intent
(
this
,
ClassMap
.
get
<
Any
>(
MainActivity
::
class
.
java
))
intent
.
putExtra
(
Const
.
Key
.
OPEN_SECTION
,
getIntent
().
getStringExtra
(
Const
.
Key
.
OPEN_SECTION
))
DONE
=
true
startActivity
(
intent
)
finish
()
}
companion
object
{
var
DONE
=
false
}
}
app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.java
View file @
11d716a3
...
...
@@ -74,7 +74,7 @@ public class SettingsFragment extends BasePreferenceFragment {
});
findPreference
(
"clear"
).
setOnPreferenceClickListener
(
pref
->
{
app
.
getPrefs
().
edit
().
remove
(
Config
.
Key
.
ETAG_KEY
).
apply
();
app
.
repoDB
.
clearRepo
();
app
.
getRepoDB
()
.
clearRepo
();
Utils
.
toast
(
R
.
string
.
repo_cache_cleared
,
Toast
.
LENGTH_SHORT
);
return
true
;
});
...
...
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