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
75ab1fa5
Commit
75ab1fa5
authored
Oct 28, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Micro optimizations
parent
bf4a46d5
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
99 additions
and
83 deletions
+99
-83
Const.java
app/src/full/java/com/topjohnwu/magisk/Const.java
+1
-4
Data.java
app/src/full/java/com/topjohnwu/magisk/Data.java
+1
-18
MagiskManager.java
app/src/full/java/com/topjohnwu/magisk/MagiskManager.java
+1
-15
MainActivity.java
app/src/full/java/com/topjohnwu/magisk/MainActivity.java
+2
-2
SplashActivity.java
app/src/full/java/com/topjohnwu/magisk/SplashActivity.java
+16
-2
SuRequestActivity.java
...src/full/java/com/topjohnwu/magisk/SuRequestActivity.java
+6
-6
PolicyAdapter.java
...ull/java/com/topjohnwu/magisk/adapters/PolicyAdapter.java
+1
-2
Repo.java
app/src/full/java/com/topjohnwu/magisk/container/Repo.java
+1
-1
RepoDatabaseHelper.java
...ava/com/topjohnwu/magisk/database/RepoDatabaseHelper.java
+2
-3
LogFragment.java
...full/java/com/topjohnwu/magisk/fragments/LogFragment.java
+1
-5
SettingsFragment.java
...java/com/topjohnwu/magisk/fragments/SettingsFragment.java
+46
-23
ShortcutReceiver.java
...java/com/topjohnwu/magisk/receivers/ShortcutReceiver.java
+2
-2
FingerprintHelper.java
...ll/java/com/topjohnwu/magisk/utils/FingerprintHelper.java
+10
-0
Utils.java
app/src/full/java/com/topjohnwu/magisk/utils/Utils.java
+9
-0
No files found.
app/src/full/java/com/topjohnwu/magisk/Const.java
View file @
75ab1fa5
...
...
@@ -34,10 +34,7 @@ public class Const {
// Versions
public
static
final
int
UPDATE_SERVICE_VER
=
1
;
public
static
int
MIN_MODULE_VER
()
{
return
Data
.
magiskVersionCode
>=
MAGISK_VER
.
REMOVE_LEGACY_LINK
?
1500
:
1400
;
}
public
static
final
int
MIN_MODULE_VER
=
1500
;
/* A list of apps that should not be shown as hide-able */
public
static
final
List
<
String
>
HIDE_BLACKLIST
=
Arrays
.
asList
(
...
...
app/src/full/java/com/topjohnwu/magisk/Data.java
View file @
75ab1fa5
...
...
@@ -13,7 +13,6 @@ import com.topjohnwu.magisk.receivers.RebootReceiver;
import
com.topjohnwu.magisk.receivers.ShortcutReceiver
;
import
com.topjohnwu.magisk.services.OnBootService
;
import
com.topjohnwu.magisk.services.UpdateCheckService
;
import
com.topjohnwu.magisk.utils.FingerprintHelper
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.ShellUtils
;
...
...
@@ -62,12 +61,9 @@ public class Data {
public
static
boolean
isDarkTheme
;
public
static
int
suRequestTimeout
;
public
static
int
suLogTimeout
=
14
;
public
static
int
suAccessState
;
public
static
boolean
suFingerprint
;
public
static
int
multiuserMode
;
public
static
int
multiuserState
=
-
1
;
public
static
int
suResponseType
;
public
static
int
suNotificationType
;
public
static
int
suNamespaceMode
;
public
static
int
updateChannel
;
public
static
int
repoOrder
;
...
...
@@ -180,15 +176,6 @@ public class Data {
suRequestTimeout
=
Utils
.
getPrefsInt
(
mm
.
prefs
,
Const
.
Key
.
SU_REQUEST_TIMEOUT
,
Const
.
Value
.
timeoutList
[
2
]);
suResponseType
=
Utils
.
getPrefsInt
(
mm
.
prefs
,
Const
.
Key
.
SU_AUTO_RESPONSE
,
Const
.
Value
.
SU_PROMPT
);
suNotificationType
=
Utils
.
getPrefsInt
(
mm
.
prefs
,
Const
.
Key
.
SU_NOTIFICATION
,
Const
.
Value
.
NOTIFICATION_TOAST
);
suAccessState
=
mm
.
mDB
.
getSettings
(
Const
.
Key
.
ROOT_ACCESS
,
Const
.
Value
.
ROOT_ACCESS_APPS_AND_ADB
);
multiuserMode
=
mm
.
mDB
.
getSettings
(
Const
.
Key
.
SU_MULTIUSER_MODE
,
Const
.
Value
.
MULTIUSER_MODE_OWNER_ONLY
);
suNamespaceMode
=
mm
.
mDB
.
getSettings
(
Const
.
Key
.
SU_MNT_NS
,
Const
.
Value
.
NAMESPACE_MODE_REQUESTER
);
suFingerprint
=
mm
.
mDB
.
getSettings
(
Const
.
Key
.
SU_FINGERPRINT
,
0
)
!=
0
;
if
(
suFingerprint
&&
!
FingerprintHelper
.
canUseFingerprint
())
{
// User revoked the fingerprint
mm
.
mDB
.
setSettings
(
Const
.
Key
.
SU_FINGERPRINT
,
0
);
suFingerprint
=
false
;
}
// config
isDarkTheme
=
mm
.
prefs
.
getBoolean
(
Const
.
Key
.
DARK_THEME
,
false
);
...
...
@@ -202,13 +189,9 @@ public class Data {
.
putBoolean
(
Const
.
Key
.
MAGISKHIDE
,
magiskHide
)
.
putBoolean
(
Const
.
Key
.
HOSTS
,
Const
.
MAGISK_HOST_FILE
.
exists
())
.
putBoolean
(
Const
.
Key
.
COREONLY
,
Const
.
MAGISK_DISABLE_FILE
.
exists
())
.
putBoolean
(
Const
.
Key
.
SU_FINGERPRINT
,
suFingerprint
)
.
putString
(
Const
.
Key
.
SU_REQUEST_TIMEOUT
,
String
.
valueOf
(
suRequestTimeout
))
.
putString
(
Const
.
Key
.
SU_AUTO_RESPONSE
,
String
.
valueOf
(
suResponseType
))
.
putString
(
Const
.
Key
.
SU_NOTIFICATION
,
String
.
valueOf
(
suNotificationType
))
.
putString
(
Const
.
Key
.
ROOT_ACCESS
,
String
.
valueOf
(
suAccessState
))
.
putString
(
Const
.
Key
.
SU_MULTIUSER_MODE
,
String
.
valueOf
(
multiuserMode
))
.
putString
(
Const
.
Key
.
SU_MNT_NS
,
String
.
valueOf
(
suNamespaceMode
))
.
putString
(
Const
.
Key
.
UPDATE_CHANNEL
,
String
.
valueOf
(
updateChannel
))
.
putInt
(
Const
.
Key
.
UPDATE_SERVICE_VER
,
Const
.
UPDATE_SERVICE_VER
)
.
putInt
(
Const
.
Key
.
REPO_ORDER
,
repoOrder
)
...
...
app/src/full/java/com/topjohnwu/magisk/MagiskManager.java
View file @
75ab1fa5
package
com
.
topjohnwu
.
magisk
;
import
android.content.SharedPreferences
;
import
android.content.pm.PackageManager
;
import
android.content.res.Configuration
;
import
android.preference.PreferenceManager
;
import
android.text.TextUtils
;
import
com.topjohnwu.magisk.database.MagiskDB
;
import
com.topjohnwu.magisk.database.RepoDatabaseHelper
;
...
...
@@ -39,19 +37,7 @@ public class MagiskManager extends ContainerApp {
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
);
mDB
=
MagiskDB
.
getInstance
();
String
pkg
=
mDB
.
getStrings
(
Const
.
Key
.
SU_MANAGER
,
null
);
if
(
pkg
!=
null
&&
getPackageName
().
equals
(
Const
.
ORIG_PKG_NAME
))
{
mDB
.
setStrings
(
Const
.
Key
.
SU_MANAGER
,
null
);
Shell
.
su
(
"pm uninstall "
+
pkg
).
exec
();
}
if
(
TextUtils
.
equals
(
pkg
,
getPackageName
()))
{
try
{
// We are the manager, remove com.topjohnwu.magisk as it could be malware
getPackageManager
().
getApplicationInfo
(
Const
.
ORIG_PKG_NAME
,
0
);
RootUtils
.
uninstallPkg
(
Const
.
ORIG_PKG_NAME
);
}
catch
(
PackageManager
.
NameNotFoundException
ignored
)
{}
}
repoDB
=
new
RepoDatabaseHelper
(
this
);
LocaleManager
.
setLocale
(
this
);
Data
.
loadConfig
();
...
...
app/src/full/java/com/topjohnwu/magisk/MainActivity.java
View file @
75ab1fa5
...
...
@@ -18,6 +18,7 @@ import com.topjohnwu.magisk.fragments.SettingsFragment;
import
com.topjohnwu.magisk.fragments.SuperuserFragment
;
import
com.topjohnwu.magisk.utils.Download
;
import
com.topjohnwu.magisk.utils.Topic
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.superuser.Shell
;
import
androidx.annotation.NonNull
;
...
...
@@ -124,8 +125,7 @@ public class MainActivity extends BaseActivity
menu
.
findItem
(
R
.
id
.
downloads
).
setVisible
(
Download
.
checkNetworkStatus
(
this
)
&&
Shell
.
rootAccess
()
&&
Data
.
magiskVersionCode
>=
0
);
menu
.
findItem
(
R
.
id
.
log
).
setVisible
(
Shell
.
rootAccess
());
menu
.
findItem
(
R
.
id
.
superuser
).
setVisible
(
Shell
.
rootAccess
()
&&
!(
Const
.
USER_ID
>
0
&&
Data
.
multiuserMode
==
Const
.
Value
.
MULTIUSER_MODE_OWNER_MANAGED
));
menu
.
findItem
(
R
.
id
.
superuser
).
setVisible
(
Utils
.
showSuperUser
());
}
public
void
navigate
(
String
item
)
{
...
...
app/src/full/java/com/topjohnwu/magisk/SplashActivity.java
View file @
75ab1fa5
...
...
@@ -3,16 +3,18 @@ package com.topjohnwu.magisk;
import
android.app.NotificationChannel
;
import
android.app.NotificationManager
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
com.topjohnwu.magisk.asyncs.CheckUpdates
;
import
com.topjohnwu.magisk.asyncs.UpdateRepos
;
import
com.topjohnwu.magisk.components.BaseActivity
;
import
com.topjohnwu.magisk.database.RepoDatabaseHelper
;
import
com.topjohnwu.magisk.receivers.ShortcutReceiver
;
import
com.topjohnwu.magisk.utils.Download
;
import
com.topjohnwu.magisk.utils.LocaleManager
;
import
com.topjohnwu.magisk.utils.RootUtils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.superuser.Shell
;
...
...
@@ -22,6 +24,19 @@ public class SplashActivity extends BaseActivity {
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
String
pkg
=
mm
.
mDB
.
getStrings
(
Const
.
Key
.
SU_MANAGER
,
null
);
if
(
pkg
!=
null
&&
getPackageName
().
equals
(
Const
.
ORIG_PKG_NAME
))
{
mm
.
mDB
.
setStrings
(
Const
.
Key
.
SU_MANAGER
,
null
);
Shell
.
su
(
"pm uninstall "
+
pkg
).
exec
();
}
if
(
TextUtils
.
equals
(
pkg
,
getPackageName
()))
{
try
{
// We are the manager, remove com.topjohnwu.magisk as it could be malware
getPackageManager
().
getApplicationInfo
(
Const
.
ORIG_PKG_NAME
,
0
);
RootUtils
.
uninstallPkg
(
Const
.
ORIG_PKG_NAME
);
}
catch
(
PackageManager
.
NameNotFoundException
ignored
)
{}
}
// Magisk working as expected
if
(
Shell
.
rootAccess
()
&&
Data
.
magiskVersionCode
>
0
)
{
// Update check service
...
...
@@ -30,7 +45,6 @@ public class SplashActivity extends BaseActivity {
Utils
.
loadModules
();
}
mm
.
repoDB
=
new
RepoDatabaseHelper
(
this
);
Data
.
importPrefs
();
// Dynamic detect all locales
...
...
app/src/full/java/com/topjohnwu/magisk/SuRequestActivity.java
View file @
75ab1fa5
...
...
@@ -181,9 +181,9 @@ public class SuRequestActivity extends BaseActivity {
}
};
boolean
useF
ingerprint
=
Data
.
suFingerprint
&&
FingerprintHelper
.
canUseFingerp
rint
();
boolean
useF
P
=
FingerprintHelper
.
useFingerP
rint
();
if
(
useF
ingerprint
)
{
if
(
useF
P
)
{
try
{
fingerprintHelper
=
new
FingerprintHelper
()
{
@Override
...
...
@@ -209,11 +209,11 @@ public class SuRequestActivity extends BaseActivity {
fingerprintHelper
.
authenticate
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
useF
ingerprint
=
false
;
useF
P
=
false
;
}
}
if
(!
useF
ingerprint
)
{
if
(!
useF
P
)
{
grant_btn
.
setOnClickListener
(
v
->
{
handleAction
(
Policy
.
ALLOW
);
timer
.
cancel
();
...
...
@@ -221,8 +221,8 @@ public class SuRequestActivity extends BaseActivity {
grant_btn
.
requestFocus
();
}
grant_btn
.
setVisibility
(
useF
ingerprint
?
View
.
GONE
:
View
.
VISIBLE
);
fingerprintImg
.
setVisibility
(
useF
ingerprint
?
View
.
VISIBLE
:
View
.
GONE
);
grant_btn
.
setVisibility
(
useF
P
?
View
.
GONE
:
View
.
VISIBLE
);
fingerprintImg
.
setVisibility
(
useF
P
?
View
.
VISIBLE
:
View
.
GONE
);
deny_btn
.
setOnClickListener
(
v
->
{
handleAction
(
Policy
.
DENY
);
...
...
app/src/full/java/com/topjohnwu/magisk/adapters/PolicyAdapter.java
View file @
75ab1fa5
...
...
@@ -10,7 +10,6 @@ import android.widget.Switch;
import
android.widget.TextView
;
import
com.google.android.material.snackbar.Snackbar
;
import
com.topjohnwu.magisk.Data
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.components.CustomAlertDialog
;
import
com.topjohnwu.magisk.components.ExpandableView
;
...
...
@@ -86,7 +85,7 @@ public class PolicyAdapter extends RecyclerView.Adapter<PolicyAdapter.ViewHolder
dbHelper
.
updatePolicy
(
policy
);
}
};
if
(
Data
.
suFingerprint
)
{
if
(
FingerprintHelper
.
useFingerPrint
()
)
{
holder
.
masterSwitch
.
setChecked
(!
isChecked
);
FingerprintHelper
.
showAuthDialog
((
Activity
)
v
.
getContext
(),
()
->
{
holder
.
masterSwitch
.
setChecked
(
isChecked
);
...
...
app/src/full/java/com/topjohnwu/magisk/container/Repo.java
View file @
75ab1fa5
...
...
@@ -36,7 +36,7 @@ public class Repo extends BaseModule {
if
(
getVersionCode
()
<
0
)
{
throw
new
IllegalRepoException
(
"Repo ["
+
getId
()
+
"] does not contain versionCode"
);
}
if
(
getMinMagiskVersion
()
<
Const
.
MIN_MODULE_VER
()
)
{
if
(
getMinMagiskVersion
()
<
Const
.
MIN_MODULE_VER
)
{
Logger
.
debug
(
"Repo ["
+
getId
()
+
"] is outdated"
);
}
}
...
...
app/src/full/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java
View file @
75ab1fa5
...
...
@@ -29,8 +29,7 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
mDb
=
getWritableDatabase
();
// Remove outdated repos
mDb
.
delete
(
TABLE_NAME
,
"minMagisk<?"
,
new
String
[]
{
String
.
valueOf
(
Const
.
MIN_MODULE_VER
())
});
mDb
.
delete
(
TABLE_NAME
,
"minMagisk<?"
,
new
String
[]
{
String
.
valueOf
(
Const
.
MIN_MODULE_VER
)
});
}
@Override
...
...
@@ -107,7 +106,7 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
orderBy
=
"last_update DESC"
;
}
return
mDb
.
query
(
TABLE_NAME
,
null
,
"minMagisk<=? AND minMagisk>=?"
,
new
String
[]
{
String
.
valueOf
(
Data
.
magiskVersionCode
),
String
.
valueOf
(
Const
.
MIN_MODULE_VER
()
)
},
new
String
[]
{
String
.
valueOf
(
Data
.
magiskVersionCode
),
String
.
valueOf
(
Const
.
MIN_MODULE_VER
)
},
null
,
null
,
orderBy
);
}
...
...
app/src/full/java/com/topjohnwu/magisk/fragments/LogFragment.java
View file @
75ab1fa5
...
...
@@ -7,8 +7,6 @@ import android.view.View;
import
android.view.ViewGroup
;
import
com.google.android.material.tabs.TabLayout
;
import
com.topjohnwu.magisk.Const
;
import
com.topjohnwu.magisk.Data
;
import
com.topjohnwu.magisk.MainActivity
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.adapters.TabFragmentAdapter
;
...
...
@@ -33,9 +31,7 @@ public class LogFragment extends BaseFragment {
TabFragmentAdapter
adapter
=
new
TabFragmentAdapter
(
getChildFragmentManager
());
if
(!(
Const
.
USER_ID
>
0
&&
Data
.
multiuserMode
==
Const
.
Value
.
MULTIUSER_MODE_OWNER_MANAGED
))
{
adapter
.
addTab
(
new
SuLogFragment
(),
getString
(
R
.
string
.
superuser
));
}
adapter
.
addTab
(
new
SuLogFragment
(),
getString
(
R
.
string
.
superuser
));
adapter
.
addTab
(
new
MagiskLogFragment
(),
getString
(
R
.
string
.
magisk
));
tab
.
setupWithViewPager
(
viewPager
);
tab
.
setVisibility
(
View
.
VISIBLE
);
...
...
app/src/full/java/com/topjohnwu/magisk/fragments/SettingsFragment.java
View file @
75ab1fa5
...
...
@@ -46,20 +46,36 @@ public class SettingsFragment extends PreferenceFragmentCompat
implements
SharedPreferences
.
OnSharedPreferenceChangeListener
,
Topic
.
Subscriber
,
Topic
.
AutoSubscriber
{
private
PreferenceScreen
prefScreen
;
private
ListPreference
updateChannel
,
suAccess
,
autoRes
,
suNotification
,
requestTimeout
,
multiuserMode
,
namespaceMode
;
private
MagiskManager
mm
;
private
PreferenceCategory
generalCatagory
;
private
ListPreference
updateChannel
,
autoRes
,
suNotification
,
requestTimeout
,
rootConfig
,
multiuserConfig
,
nsConfig
;
private
int
rootState
,
namespaceState
;
private
boolean
showSuperuser
;
private
void
prefsSync
()
{
rootState
=
mm
.
mDB
.
getSettings
(
Const
.
Key
.
ROOT_ACCESS
,
Const
.
Value
.
ROOT_ACCESS_APPS_AND_ADB
);
namespaceState
=
mm
.
mDB
.
getSettings
(
Const
.
Key
.
SU_MNT_NS
,
Const
.
Value
.
NAMESPACE_MODE_REQUESTER
);
showSuperuser
=
Utils
.
showSuperUser
();
mm
.
prefs
.
edit
()
.
putString
(
Const
.
Key
.
ROOT_ACCESS
,
String
.
valueOf
(
rootState
))
.
putString
(
Const
.
Key
.
SU_MNT_NS
,
String
.
valueOf
(
namespaceState
))
.
putString
(
Const
.
Key
.
SU_MULTIUSER_MODE
,
String
.
valueOf
(
Data
.
multiuserState
))
.
putBoolean
(
Const
.
Key
.
SU_FINGERPRINT
,
FingerprintHelper
.
useFingerPrint
())
.
apply
();
}
@Override
public
void
onCreatePreferences
(
Bundle
savedInstanceState
,
String
rootKey
)
{
setPreferencesFromResource
(
R
.
xml
.
app_settings
,
rootKey
);
mm
=
Data
.
MM
();
prefScreen
=
getPreferenceScreen
();
prefsSync
();
setPreferencesFromResource
(
R
.
xml
.
app_settings
,
rootKey
);
generalCatagory
=
(
PreferenceCategory
)
findPreference
(
"general"
);
PreferenceScreen
prefScreen
=
getPreferenceScreen
();
PreferenceCategory
generalCatagory
=
(
PreferenceCategory
)
findPreference
(
"general"
);
PreferenceCategory
magiskCategory
=
(
PreferenceCategory
)
findPreference
(
"magisk"
);
PreferenceCategory
suCategory
=
(
PreferenceCategory
)
findPreference
(
"superuser"
);
Preference
hideManager
=
findPreference
(
"hide"
);
...
...
@@ -72,12 +88,12 @@ public class SettingsFragment extends PreferenceFragmentCompat
});
updateChannel
=
(
ListPreference
)
findPreference
(
Const
.
Key
.
UPDATE_CHANNEL
);
suAccess
=
(
ListPreference
)
findPreference
(
Const
.
Key
.
ROOT_ACCESS
);
rootConfig
=
(
ListPreference
)
findPreference
(
Const
.
Key
.
ROOT_ACCESS
);
autoRes
=
(
ListPreference
)
findPreference
(
Const
.
Key
.
SU_AUTO_RESPONSE
);
requestTimeout
=
(
ListPreference
)
findPreference
(
Const
.
Key
.
SU_REQUEST_TIMEOUT
);
suNotification
=
(
ListPreference
)
findPreference
(
Const
.
Key
.
SU_NOTIFICATION
);
multiuser
Mode
=
(
ListPreference
)
findPreference
(
Const
.
Key
.
SU_MULTIUSER_MODE
);
n
amespaceMode
=
(
ListPreference
)
findPreference
(
Const
.
Key
.
SU_MNT_NS
);
multiuser
Config
=
(
ListPreference
)
findPreference
(
Const
.
Key
.
SU_MULTIUSER_MODE
);
n
sConfig
=
(
ListPreference
)
findPreference
(
Const
.
Key
.
SU_MNT_NS
);
SwitchPreference
reauth
=
(
SwitchPreference
)
findPreference
(
Const
.
Key
.
SU_REAUTH
);
SwitchPreference
fingerprint
=
(
SwitchPreference
)
findPreference
(
Const
.
Key
.
SU_FINGERPRINT
);
...
...
@@ -107,7 +123,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
// Disable dangerous settings in secondary user
if
(
Const
.
USER_ID
>
0
)
{
suCategory
.
removePreference
(
multiuser
Mode
);
suCategory
.
removePreference
(
multiuser
Config
);
}
// Disable re-authentication option on Android O, it will not work
...
...
@@ -163,8 +179,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
generalCatagory
.
removePreference
(
hideManager
);
}
if
(!
Shell
.
rootAccess
()
||
(
Const
.
USER_ID
>
0
&&
Data
.
multiuserMode
==
Const
.
Value
.
MULTIUSER_MODE_OWNER_MANAGED
))
{
if
(!
showSuperuser
)
{
prefScreen
.
removePreference
(
suCategory
);
}
...
...
@@ -213,9 +228,16 @@ public class SettingsFragment extends PreferenceFragmentCompat
mm
.
mDB
.
setSettings
(
key
,
Utils
.
getPrefsInt
(
prefs
,
key
));
break
;
}
Data
.
loadConfig
();
setSummary
();
switch
(
key
)
{
case
Const
.
Key
.
ROOT_ACCESS
:
rootState
=
Utils
.
getPrefsInt
(
prefs
,
key
);
break
;
case
Const
.
Key
.
SU_MULTIUSER_MODE
:
Data
.
multiuserState
=
Utils
.
getPrefsInt
(
prefs
,
key
);
break
;
case
Const
.
Key
.
SU_MNT_NS
:
namespaceState
=
Utils
.
getPrefsInt
(
prefs
,
key
);
break
;
case
Const
.
Key
.
DARK_THEME
:
requireActivity
().
recreate
();
break
;
...
...
@@ -259,6 +281,8 @@ public class SettingsFragment extends PreferenceFragmentCompat
Utils
.
setupUpdateCheck
();
break
;
}
Data
.
loadConfig
();
setSummary
();
}
@Override
...
...
@@ -270,7 +294,6 @@ public class SettingsFragment extends PreferenceFragmentCompat
((
SwitchPreference
)
preference
).
setChecked
(!
checked
);
FingerprintHelper
.
showAuthDialog
(
requireActivity
(),
()
->
{
((
SwitchPreference
)
preference
).
setChecked
(
checked
);
Data
.
suFingerprint
=
checked
;
mm
.
mDB
.
setSettings
(
key
,
checked
?
1
:
0
);
});
break
;
...
...
@@ -281,8 +304,8 @@ public class SettingsFragment extends PreferenceFragmentCompat
private
void
setSummary
()
{
updateChannel
.
setSummary
(
getResources
()
.
getStringArray
(
R
.
array
.
update_channel
)[
Data
.
updateChannel
]);
suAccess
.
setSummary
(
getResources
()
.
getStringArray
(
R
.
array
.
su_access
)[
Data
.
suAccess
State
]);
rootConfig
.
setSummary
(
getResources
()
.
getStringArray
(
R
.
array
.
su_access
)[
root
State
]);
autoRes
.
setSummary
(
getResources
()
.
getStringArray
(
R
.
array
.
auto_response
)[
Data
.
suResponseType
]);
suNotification
.
setSummary
(
getResources
()
...
...
@@ -290,10 +313,10 @@ public class SettingsFragment extends PreferenceFragmentCompat
requestTimeout
.
setSummary
(
getString
(
R
.
string
.
request_timeout_summary
,
mm
.
prefs
.
getString
(
Const
.
Key
.
SU_REQUEST_TIMEOUT
,
"10"
)));
multiuser
Mode
.
setSummary
(
getResources
()
.
getStringArray
(
R
.
array
.
multiuser_summary
)[
Data
.
multiuser
Mod
e
]);
n
amespaceMode
.
setSummary
(
getResources
()
.
getStringArray
(
R
.
array
.
namespace_summary
)[
Data
.
suNamespaceMod
e
]);
multiuser
Config
.
setSummary
(
getResources
()
.
getStringArray
(
R
.
array
.
multiuser_summary
)[
Data
.
multiuser
Stat
e
]);
n
sConfig
.
setSummary
(
getResources
()
.
getStringArray
(
R
.
array
.
namespace_summary
)[
namespaceStat
e
]);
}
@Override
...
...
app/src/full/java/com/topjohnwu/magisk/receivers/ShortcutReceiver.java
View file @
75ab1fa5
...
...
@@ -13,6 +13,7 @@ import com.topjohnwu.magisk.Data;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.SplashActivity
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.superuser.Shell
;
import
java.util.ArrayList
;
...
...
@@ -33,8 +34,7 @@ public class ShortcutReceiver extends BroadcastReceiver {
private
ArrayList
<
ShortcutInfo
>
getShortCuts
(
MagiskManager
mm
)
{
ArrayList
<
ShortcutInfo
>
shortCuts
=
new
ArrayList
<>();
boolean
root
=
Shell
.
rootAccess
();
if
(
root
&&
!(
Const
.
USER_ID
>
0
&&
Data
.
multiuserMode
==
Const
.
Value
.
MULTIUSER_MODE_OWNER_MANAGED
))
{
if
(
Utils
.
showSuperUser
())
{
shortCuts
.
add
(
new
ShortcutInfo
.
Builder
(
mm
,
"superuser"
)
.
setShortLabel
(
mm
.
getString
(
R
.
string
.
superuser
))
.
setIntent
(
new
Intent
(
mm
,
Data
.
classMap
.
get
(
SplashActivity
.
class
))
...
...
app/src/full/java/com/topjohnwu/magisk/utils/FingerprintHelper.java
View file @
75ab1fa5
...
...
@@ -35,6 +35,16 @@ public abstract class FingerprintHelper {
private
Cipher
cipher
;
private
CancellationSignal
cancel
;
public
static
boolean
useFingerPrint
()
{
MagiskManager
mm
=
Data
.
MM
();
boolean
fp
=
mm
.
mDB
.
getSettings
(
Const
.
Key
.
SU_FINGERPRINT
,
0
)
!=
0
;
if
(
fp
&&
!
canUseFingerprint
())
{
mm
.
mDB
.
setSettings
(
Const
.
Key
.
SU_FINGERPRINT
,
0
);
fp
=
false
;
}
return
fp
;
}
public
static
boolean
canUseFingerprint
()
{
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
M
)
return
false
;
...
...
app/src/full/java/com/topjohnwu/magisk/utils/Utils.java
View file @
75ab1fa5
...
...
@@ -22,6 +22,7 @@ import com.topjohnwu.magisk.MagiskManager;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.container.Module
;
import
com.topjohnwu.magisk.container.ValueSortedMap
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.io.SuFile
;
import
java.util.Locale
;
...
...
@@ -140,4 +141,12 @@ public class Utils {
}
catch
(
Exception
ignored
)
{}
return
info
.
loadLabel
(
pm
).
toString
();
}
public
static
boolean
showSuperUser
()
{
if
(
Data
.
multiuserState
<
0
)
Data
.
multiuserState
=
Data
.
MM
().
mDB
.
getSettings
(
Const
.
Key
.
SU_MULTIUSER_MODE
,
Const
.
Value
.
MULTIUSER_MODE_OWNER_ONLY
);
return
Shell
.
rootAccess
()
&&
(
Const
.
USER_ID
==
0
||
Data
.
multiuserState
!=
Const
.
Value
.
MULTIUSER_MODE_OWNER_MANAGED
);
}
}
\ No newline at end of file
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