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
21504f13
Commit
21504f13
authored
Sep 30, 2016
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add settings for shell logging
parent
ff6bae93
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
85 deletions
+24
-85
AutoRootFragment.java
app/src/main/java/com/topjohnwu/magisk/AutoRootFragment.java
+1
-1
MainActivity.java
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
+1
-58
SettingsFragment.java
app/src/main/java/com/topjohnwu/magisk/SettingsFragment.java
+8
-3
SplashActivity.java
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
+3
-0
Logger.java
app/src/main/java/com/topjohnwu/magisk/utils/Logger.java
+3
-23
strings.xml
app/src/main/res/values/strings.xml
+2
-0
uisettings.xml
app/src/main/res/xml/uisettings.xml
+6
-0
No files found.
app/src/main/java/com/topjohnwu/magisk/AutoRootFragment.java
View file @
21504f13
...
...
@@ -84,7 +84,7 @@ public class AutoRootFragment extends ListFragment {
}
private
void
ToggleApp
(
String
appToCheck
,
int
position
,
View
v
)
{
Logger
.
dev
(
"Magisk"
,
"AutoRootFragment: ToggleApp called for "
+
appToCheck
);
Logger
.
dev
(
"Magisk"
,
"AutoRootFragment: ToggleApp called for "
+
appToCheck
);
Set
<
String
>
blackListSet
=
prefs
.
getStringSet
(
"auto_blacklist"
,
null
);
assert
blackListSet
!=
null
;
arrayBlackList
=
new
ArrayList
<>(
blackListSet
);
...
...
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
View file @
21504f13
...
...
@@ -63,53 +63,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
Snackbar
.
make
(
findViewById
(
android
.
R
.
id
.
content
),
R
.
string
.
no_root_access
,
Snackbar
.
LENGTH_LONG
).
show
();
}
this
.
getFragmentManager
().
addOnBackStackChangedListener
(
()
->
{
Fragment
hm
=
getFragmentManager
().
findFragmentByTag
(
"root"
);
if
(
hm
!=
null
)
{
if
(
hm
.
isVisible
())
{
navigationView
.
setCheckedItem
(
R
.
id
.
root
);
}
}
hm
=
getFragmentManager
().
findFragmentByTag
(
"autoroot"
);
if
(
hm
!=
null
)
{
if
(
hm
.
isVisible
())
{
navigationView
.
setCheckedItem
(
R
.
id
.
autoroot
);
}
}
hm
=
getFragmentManager
().
findFragmentByTag
(
"magisk"
);
if
(
hm
!=
null
)
{
if
(
hm
.
isVisible
())
{
navigationView
.
setCheckedItem
(
R
.
id
.
magisk
);
}
}
hm
=
getFragmentManager
().
findFragmentByTag
(
"modules"
);
if
(
hm
!=
null
)
{
if
(
hm
.
isVisible
())
{
navigationView
.
setCheckedItem
(
R
.
id
.
modules
);
}
}
hm
=
getFragmentManager
().
findFragmentByTag
(
"downloads"
);
if
(
hm
!=
null
)
{
if
(
hm
.
isVisible
())
{
navigationView
.
setCheckedItem
(
R
.
id
.
downloads
);
}
}
hm
=
getFragmentManager
().
findFragmentByTag
(
"log"
);
if
(
hm
!=
null
)
{
if
(
hm
.
isVisible
())
{
navigationView
.
setCheckedItem
(
R
.
id
.
log
);
}
}
hm
=
getFragmentManager
().
findFragmentByTag
(
"settings"
);
if
(
hm
!=
null
)
{
if
(
hm
.
isVisible
())
{
navigationView
.
setCheckedItem
(
R
.
id
.
settings
);
}
}
}
);
setSupportActionBar
(
toolbar
);
ActionBarDrawerToggle
toggle
=
new
ActionBarDrawerToggle
(
this
,
drawer
,
toolbar
,
R
.
string
.
navigation_drawer_open
,
R
.
string
.
navigation_drawer_close
)
{
...
...
@@ -146,11 +99,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
mDrawerHandler
.
removeCallbacksAndMessages
(
null
);
navigate
(
mSelectedId
);
}
@Override
...
...
@@ -166,15 +116,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
if
(
drawer
.
isDrawerOpen
(
GravityCompat
.
START
))
{
drawer
.
closeDrawer
(
GravityCompat
.
START
);
}
else
{
int
backStackEntryCount
=
getFragmentManager
().
getBackStackEntryCount
();
Logger
.
dev
(
"Welcomeactivity: Entrycount is "
+
backStackEntryCount
);
if
(
backStackEntryCount
>=
2
)
{
super
.
onBackPressed
();
}
else
{
finish
();
}
finish
();
}
}
@Override
...
...
app/src/main/java/com/topjohnwu/magisk/SettingsFragment.java
View file @
21504f13
...
...
@@ -22,7 +22,6 @@ import com.topjohnwu.magisk.utils.Utils;
import
butterknife.ButterKnife
;
public
class
SettingsFragment
extends
PreferenceFragment
implements
SharedPreferences
.
OnSharedPreferenceChangeListener
{
private
CheckBoxPreference
quickTilePreference
,
busyboxPreference
;
private
ListPreference
themePreference
;
@Override
...
...
@@ -51,8 +50,8 @@ public class SettingsFragment extends PreferenceFragment implements SharedPrefer
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
View
view
=
super
.
onCreateView
(
inflater
,
container
,
savedInstanceState
);
themePreference
=
(
ListPreference
)
findPreference
(
"theme"
);
busyboxPreference
=
(
CheckBoxPreference
)
findPreference
(
"busybox"
);
quickTilePreference
=
(
CheckBoxPreference
)
findPreference
(
"enable_quicktile"
)
;
CheckBoxPreference
busyboxPreference
=
(
CheckBoxPreference
)
findPreference
(
"busybox"
);
CheckBoxPreference
quickTilePreference
=
(
CheckBoxPreference
)
findPreference
(
"enable_quicktile"
)
;
busyboxPreference
.
setChecked
(
Utils
.
commandExists
(
"unzip"
));
PreferenceManager
.
getDefaultSharedPreferences
(
getActivity
()).
registerOnSharedPreferenceChangeListener
(
this
);
CheckBoxPreference
keepRootOffPreference
=
(
CheckBoxPreference
)
findPreference
(
"keep_root_off"
);
...
...
@@ -62,10 +61,12 @@ public class SettingsFragment extends PreferenceFragment implements SharedPrefer
quickTilePreference
.
setEnabled
(
false
);
keepRootOffPreference
.
setEnabled
(
false
);
hideRootNotificationPreference
.
setEnabled
(
false
);
busyboxPreference
.
setEnabled
(
false
);
}
else
{
quickTilePreference
.
setEnabled
(
true
);
keepRootOffPreference
.
setEnabled
(
true
);
hideRootNotificationPreference
.
setEnabled
(
true
);
busyboxPreference
.
setEnabled
(
true
);
}
// calculate margins
...
...
@@ -142,6 +143,10 @@ public class SettingsFragment extends PreferenceFragment implements SharedPrefer
}
else
if
(
key
.
equals
(
"busybox"
))
{
boolean
checked
=
sharedPreferences
.
getBoolean
(
"busybox"
,
false
);
new
Async
.
LinkBusyBox
(
checked
).
executeOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
}
else
if
(
key
.
equals
(
"developer_logging"
))
{
Logger
.
devLog
=
sharedPreferences
.
getBoolean
(
"developer_logging"
,
false
);
}
else
if
(
key
.
equals
(
"shell_logging"
))
{
Logger
.
logShell
=
sharedPreferences
.
getBoolean
(
"shell_logging"
,
false
);
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
View file @
21504f13
...
...
@@ -25,6 +25,9 @@ public class SplashActivity extends AppCompatActivity {
setTheme
(
R
.
style
.
AppTheme_dh
);
}
Logger
.
devLog
=
defaultPrefs
.
getBoolean
(
"developer_logging"
,
false
);
Logger
.
logShell
=
defaultPrefs
.
getBoolean
(
"shell_logging"
,
false
);
// Set up default preferences,make sure we add "extra" blacklist entries.
if
(!
defaultPrefs
.
contains
(
"auto_blacklist"
))
{
Logger
.
dev
(
"SplashActivity: Setting default preferences for application"
);
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Logger.java
View file @
21504f13
package
com
.
topjohnwu
.
magisk
.
utils
;
import
android.app.Application
;
import
android.content.Context
;
import
android.preference.PreferenceManager
;
import
android.util.Log
;
public
class
Logger
{
private
static
final
String
LOG_TAG
=
"Magisk: DEV"
;
p
rivate
static
final
boolean
logShell
=
true
;
p
ublic
static
boolean
logShell
,
devLog
;
public
static
void
dev
(
String
msg
,
Object
...
args
)
{
Context
context
=
null
;
try
{
context
=
getApplicationUsingReflection
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
PreferenceManager
.
getDefaultSharedPreferences
(
context
).
getBoolean
(
"developer_logging"
,
false
))
{
if
(
devLog
)
{
if
(
args
.
length
==
1
&&
args
[
0
]
instanceof
Throwable
)
{
Log
.
d
(
LOG_TAG
,
msg
,
(
Throwable
)
args
[
0
]);
}
else
{
...
...
@@ -28,13 +19,7 @@ public class Logger {
}
public
static
void
dev
(
String
msg
)
{
Context
context
=
null
;
try
{
context
=
getApplicationUsingReflection
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
PreferenceManager
.
getDefaultSharedPreferences
(
context
).
getBoolean
(
"developer_logging"
,
false
))
{
if
(
devLog
)
{
Log
.
d
(
LOG_TAG
,
msg
);
}
}
...
...
@@ -44,9 +29,4 @@ public class Logger {
Log
.
d
(
root
?
"SU"
:
"SH"
,
msg
);
}
}
private
static
Application
getApplicationUsingReflection
()
throws
Exception
{
return
(
Application
)
Class
.
forName
(
"android.app.AppGlobals"
)
.
getMethod
(
"getInitialApplication"
).
invoke
(
null
,
(
Object
[])
null
);
}
}
app/src/main/res/values/strings.xml
View file @
21504f13
...
...
@@ -130,5 +130,7 @@
<string
name=
"settings_development_category"
>
Development
</string>
<string
name=
"settings_developer_logging_title"
>
Enable advanced debug logging
</string>
<string
name=
"settings_developer_logging_summary"
>
Check this to enable more verbose logging.
</string>
<string
name=
"settings_shell_logging_title"
>
Enable shell command debug logging
</string>
<string
name=
"settings_shell_logging_summary"
>
Check this to enable logging all shell commands and output
</string>
</resources>
app/src/main/res/xml/uisettings.xml
View file @
21504f13
...
...
@@ -57,6 +57,12 @@
android:title=
"@string/settings_developer_logging_title"
android:summary=
"@string/settings_developer_logging_summary"
/>
<CheckBoxPreference
android:key=
"shell_logging"
android:defaultValue=
"false"
android:title=
"@string/settings_shell_logging_title"
android:summary=
"@string/settings_shell_logging_summary"
/>
</PreferenceCategory>
</PreferenceScreen>
\ 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