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
7bf83371
Commit
7bf83371
authored
Aug 22, 2016
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add root fragment and refactor
parent
36c57502
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
94 additions
and
106 deletions
+94
-106
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+0
-7
BaseModuleFragment.java
...rc/main/java/com/topjohnwu/magisk/BaseModuleFragment.java
+2
-2
LogFragment.java
app/src/main/java/com/topjohnwu/magisk/LogFragment.java
+3
-3
ModulesFragment.java
app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java
+15
-17
RootFragment.java
app/src/main/java/com/topjohnwu/magisk/RootFragment.java
+28
-27
WelcomeActivity.java
app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java
+30
-5
Module.java
app/src/main/java/com/topjohnwu/magisk/module/Module.java
+2
-2
ModulesAdapter.java
...src/main/java/com/topjohnwu/magisk/rv/ModulesAdapter.java
+6
-1
RootFragment.java
app/src/main/java/com/topjohnwu/magisk/ui/RootFragment.java
+0
-6
Utils.java
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
+5
-26
root_fragment.xml
app/src/main/res/layout/root_fragment.xml
+2
-10
strings.xml
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
7bf83371
...
@@ -12,13 +12,6 @@
...
@@ -12,13 +12,6 @@
android:supportsRtl=
"true"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
android:theme=
"@style/AppTheme"
tools:ignore=
"AllowBackup,GoogleAppIndexingWarning"
>
tools:ignore=
"AllowBackup,GoogleAppIndexingWarning"
>
<!--<activity android:name=".ui.MainActivity">-->
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.MAIN"/>-->
<!--<category android:name="android.intent.category.LAUNCHER"/>-->
<!--</intent-filter>-->
<!--</activity>-->
<activity
<activity
android:name=
".WelcomeActivity"
android:name=
".WelcomeActivity"
android:configChanges=
"orientation|screenSize"
>
android:configChanges=
"orientation|screenSize"
>
...
...
app/src/main/java/com/topjohnwu/magisk/
ui/
BaseModuleFragment.java
→
app/src/main/java/com/topjohnwu/magisk/BaseModuleFragment.java
View file @
7bf83371
package
com
.
topjohnwu
.
magisk
.
ui
;
package
com
.
topjohnwu
.
magisk
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
...
@@ -11,7 +11,7 @@ import android.view.ViewGroup;
...
@@ -11,7 +11,7 @@ import android.view.ViewGroup;
import
android.widget.CheckBox
;
import
android.widget.CheckBox
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.mod
el
.Module
;
import
com.topjohnwu.magisk.mod
ule
.Module
;
import
com.topjohnwu.magisk.rv.ItemClickListener
;
import
com.topjohnwu.magisk.rv.ItemClickListener
;
import
com.topjohnwu.magisk.rv.ModulesAdapter
;
import
com.topjohnwu.magisk.rv.ModulesAdapter
;
...
...
app/src/main/java/com/topjohnwu/magisk/
ui/
LogFragment.java
→
app/src/main/java/com/topjohnwu/magisk/LogFragment.java
View file @
7bf83371
package
com
.
topjohnwu
.
magisk
.
ui
;
package
com
.
topjohnwu
.
magisk
;
import
android.Manifest
;
import
android.Manifest
;
import
android.annotation.SuppressLint
;
import
android.annotation.SuppressLint
;
...
@@ -26,7 +26,7 @@ import android.widget.TextView;
...
@@ -26,7 +26,7 @@ import android.widget.TextView;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.
ui.utils.Utils
;
import
com.topjohnwu.magisk.
WelcomeActivity
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.File
;
...
@@ -234,7 +234,7 @@ public class LogFragment extends Fragment {
...
@@ -234,7 +234,7 @@ public class LogFragment extends Fragment {
protected
String
doInBackground
(
File
...
log
)
{
protected
String
doInBackground
(
File
...
log
)
{
// Ensure initialize is done
// Ensure initialize is done
try
{
try
{
Utils
.
initialize
.
get
();
WelcomeActivity
.
initialize
.
get
();
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/
ui/
ModulesFragment.java
→
app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java
View file @
7bf83371
package
com
.
topjohnwu
.
magisk
.
ui
;
package
com
.
topjohnwu
.
magisk
;
import
android.os.AsyncTask
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.os.Bundle
;
...
@@ -13,9 +13,7 @@ import android.view.View;
...
@@ -13,9 +13,7 @@ import android.view.View;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
android.widget.ProgressBar
;
import
android.widget.ProgressBar
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.model.Module
;
import
com.topjohnwu.magisk.ui.utils.Utils
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileFilter
;
import
java.io.FileFilter
;
...
@@ -31,7 +29,7 @@ public class ModulesFragment extends Fragment {
...
@@ -31,7 +29,7 @@ public class ModulesFragment extends Fragment {
private
static
final
String
MAGISK_PATH
=
"/magisk"
;
private
static
final
String
MAGISK_PATH
=
"/magisk"
;
private
static
final
String
MAGISK_CACHE_PATH
=
"/cache/magisk"
;
private
static
final
String
MAGISK_CACHE_PATH
=
"/cache/magisk"
;
private
static
List
<
Module
>
listModules
NoCache
=
new
ArrayList
<>();
private
static
List
<
Module
>
listModules
=
new
ArrayList
<>();
private
static
List
<
Module
>
listModulesCache
=
new
ArrayList
<>();
private
static
List
<
Module
>
listModulesCache
=
new
ArrayList
<>();
@BindView
(
R
.
id
.
progressBar
)
ProgressBar
progressBar
;
@BindView
(
R
.
id
.
progressBar
)
ProgressBar
progressBar
;
...
@@ -42,8 +40,8 @@ public class ModulesFragment extends Fragment {
...
@@ -42,8 +40,8 @@ public class ModulesFragment extends Fragment {
public
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
public
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
listModules
.
clear
();
listModulesCache
.
clear
();
listModulesCache
.
clear
();
listModulesNoCache
.
clear
();
}
}
@Nullable
@Nullable
...
@@ -60,11 +58,11 @@ public class ModulesFragment extends Fragment {
...
@@ -60,11 +58,11 @@ public class ModulesFragment extends Fragment {
return
view
;
return
view
;
}
}
public
static
class
No
Cache
ModuleFragment
extends
BaseModuleFragment
{
public
static
class
No
rmal
ModuleFragment
extends
BaseModuleFragment
{
@Override
@Override
protected
List
<
Module
>
listModules
()
{
protected
List
<
Module
>
listModules
()
{
return
listModules
NoCache
;
return
listModules
;
}
}
}
}
...
@@ -78,13 +76,13 @@ public class ModulesFragment extends Fragment {
...
@@ -78,13 +76,13 @@ public class ModulesFragment extends Fragment {
}
}
private
class
CheckFolders
extends
AsyncTask
<
Void
,
Integer
,
Boolean
>
{
private
class
CheckFolders
extends
AsyncTask
<
Void
,
Integer
,
Void
>
{
@Override
@Override
protected
Boolean
doInBackground
(
Void
...
voids
)
{
protected
Void
doInBackground
(
Void
...
voids
)
{
// Ensure initialize is done
// Ensure initialize is done
try
{
try
{
Utils
.
initialize
.
get
();
WelcomeActivity
.
initialize
.
get
();
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -109,7 +107,7 @@ public class ModulesFragment extends Fragment {
...
@@ -109,7 +107,7 @@ public class ModulesFragment extends Fragment {
if
(
m
.
isValid
())
{
if
(
m
.
isValid
())
{
try
{
try
{
m
.
parse
();
m
.
parse
();
listModules
NoCache
.
add
(
m
);
listModules
.
add
(
m
);
}
catch
(
Exception
ignored
)
{
}
catch
(
Exception
ignored
)
{
}
}
}
}
...
@@ -129,12 +127,12 @@ public class ModulesFragment extends Fragment {
...
@@ -129,12 +127,12 @@ public class ModulesFragment extends Fragment {
}
}
}
}
return
true
;
return
null
;
}
}
@Override
@Override
protected
void
onPostExecute
(
Boolean
result
)
{
protected
void
onPostExecute
(
Void
v
)
{
super
.
onPostExecute
(
result
);
super
.
onPostExecute
(
v
);
progressBar
.
setVisibility
(
View
.
GONE
);
progressBar
.
setVisibility
(
View
.
GONE
);
}
}
...
@@ -143,7 +141,7 @@ public class ModulesFragment extends Fragment {
...
@@ -143,7 +141,7 @@ public class ModulesFragment extends Fragment {
private
class
TabsAdapter
extends
FragmentPagerAdapter
{
private
class
TabsAdapter
extends
FragmentPagerAdapter
{
String
[]
tabTitles
=
new
String
[]{
String
[]
tabTitles
=
new
String
[]{
"
_no_cache"
,
"_cache
"
"
Modules"
,
"Cache Modules
"
// TODO stringify
// TODO stringify
};
};
...
@@ -164,7 +162,7 @@ public class ModulesFragment extends Fragment {
...
@@ -164,7 +162,7 @@ public class ModulesFragment extends Fragment {
@Override
@Override
public
Fragment
getItem
(
int
position
)
{
public
Fragment
getItem
(
int
position
)
{
if
(
position
==
0
)
{
if
(
position
==
0
)
{
return
new
No
Cache
ModuleFragment
();
return
new
No
rmal
ModuleFragment
();
}
else
{
}
else
{
return
new
CacheModuleFragment
();
return
new
CacheModuleFragment
();
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/
ui/MainActivity
.java
→
app/src/main/java/com/topjohnwu/magisk/
RootFragment
.java
View file @
7bf83371
package
com
.
topjohnwu
.
magisk
.
ui
;
package
com
.
topjohnwu
.
magisk
;
import
android.app.Activity
;
import
android.graphics.Color
;
import
android.graphics.Color
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.v4.app.Fragment
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.CompoundButton
;
import
android.widget.CompoundButton
;
import
android.widget.Switch
;
import
android.widget.Switch
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.Utils
;
import
java.io.File
;
import
java.io.File
;
import
static
com
.
topjohnwu
.
magisk
.
ui
.
utils
.
Utils
.
su
;
public
class
RootFragment
extends
Fragment
{
public
class
MainActivity
extends
Activity
{
private
Switch
rootToggle
,
selinuxToggle
;
private
Switch
rootToggle
,
selinuxToggle
;
private
TextView
magiskVersion
,
rootStatus
,
selinuxStatus
,
safetyNet
,
permissive
;
private
TextView
magiskVersion
,
rootStatus
,
selinuxStatus
,
safetyNet
,
permissive
;
private
String
suPath
;
@Nullable
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
View
view
=
inflater
.
inflate
(
R
.
layout
.
root_fragment
,
container
,
false
);
setContentView
(
R
.
layout
.
activity_main
);
magiskVersion
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
magisk_version
);
magiskVersion
=
(
TextView
)
findViewById
(
R
.
id
.
magisk_version
);
rootToggle
=
(
Switch
)
view
.
findViewById
(
R
.
id
.
root_toggle
);
rootToggle
=
(
Switch
)
findViewById
(
R
.
id
.
root_toggle
);
selinuxToggle
=
(
Switch
)
view
.
findViewById
(
R
.
id
.
selinux_toggle
);
selinuxToggle
=
(
Switch
)
findViewById
(
R
.
id
.
selinux_toggle
);
rootStatus
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
root_status
);
rootStatus
=
(
TextView
)
findViewById
(
R
.
id
.
root_status
);
selinuxStatus
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
selinux_status
);
selinuxStatus
=
(
TextView
)
findViewById
(
R
.
id
.
selinux_status
);
safetyNet
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
safety_net
);
safetyNet
=
(
TextView
)
findViewById
(
R
.
id
.
safety_net
);
permissive
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
permissive
);
permissive
=
(
TextView
)
findViewById
(
R
.
id
.
permissive
);
suPath
=
su
(
"getprop magisk.supath"
);
updateStatus
();
updateStatus
();
rootToggle
.
setOnCheckedChangeListener
(
new
CompoundButton
.
OnCheckedChangeListener
()
{
rootToggle
.
setOnCheckedChangeListener
(
new
CompoundButton
.
OnCheckedChangeListener
()
{
@Override
@Override
public
void
onCheckedChanged
(
CompoundButton
compoundButton
,
boolean
b
)
{
public
void
onCheckedChanged
(
CompoundButton
compoundButton
,
boolean
b
)
{
su
(
b
?
"setprop magisk.root 1"
:
"setprop magisk.root 0"
);
Utils
.
su
(
b
?
"setprop magisk.root 1"
:
"setprop magisk.root 0"
);
updateStatus
();
updateStatus
();
}
}
});
});
...
@@ -46,18 +47,19 @@ public class MainActivity extends Activity {
...
@@ -46,18 +47,19 @@ public class MainActivity extends Activity {
selinuxToggle
.
setOnCheckedChangeListener
(
new
CompoundButton
.
OnCheckedChangeListener
()
{
selinuxToggle
.
setOnCheckedChangeListener
(
new
CompoundButton
.
OnCheckedChangeListener
()
{
@Override
@Override
public
void
onCheckedChanged
(
CompoundButton
compoundButton
,
boolean
b
)
{
public
void
onCheckedChanged
(
CompoundButton
compoundButton
,
boolean
b
)
{
su
(
b
?
"setenforce 1"
:
"setenforce 0"
);
Utils
.
su
(
b
?
"setenforce 1"
:
"setenforce 0"
);
updateStatus
();
updateStatus
();
}
}
});
});
//findViewById(R.id.modules).setOnClickListener(view -> startActivity(new Intent(this, ModulesActivity.class)))
;
return
view
;
}
}
private
void
updateStatus
()
{
private
void
updateStatus
()
{
String
selinux
=
su
(
"getenforce"
);
String
selinux
=
Utils
.
sh
(
"getenforce"
);
String
version
=
Utils
.
sh
(
"getprop magisk.version"
);
magiskVersion
.
setText
(
getString
(
R
.
string
.
magisk_version
,
su
(
"getprop magisk.version"
)
));
magiskVersion
.
setText
(
getString
(
R
.
string
.
magisk_version
,
version
));
selinuxStatus
.
setText
(
selinux
);
selinuxStatus
.
setText
(
selinux
);
if
(
selinux
.
equals
(
"Enforcing"
))
{
if
(
selinux
.
equals
(
"Enforcing"
))
{
...
@@ -82,7 +84,7 @@ public class MainActivity extends Activity {
...
@@ -82,7 +84,7 @@ public class MainActivity extends Activity {
safetyNet
.
setTextColor
(
Color
.
RED
);
safetyNet
.
setTextColor
(
Color
.
RED
);
rootToggle
.
setChecked
(
true
);
rootToggle
.
setChecked
(
true
);
if
(!
new
File
(
suPath
+
"/su"
).
exists
()
)
{
if
(!
Utils
.
rootAccess
)
{
rootStatus
.
setText
(
R
.
string
.
root_system
);
rootStatus
.
setText
(
R
.
string
.
root_system
);
safetyNet
.
setText
(
R
.
string
.
root_system_info
);
safetyNet
.
setText
(
R
.
string
.
root_system_info
);
rootToggle
.
setEnabled
(
false
);
rootToggle
.
setEnabled
(
false
);
...
@@ -96,7 +98,7 @@ public class MainActivity extends Activity {
...
@@ -96,7 +98,7 @@ public class MainActivity extends Activity {
safetyNet
.
setTextColor
(
Color
.
GREEN
);
safetyNet
.
setTextColor
(
Color
.
GREEN
);
rootToggle
.
setChecked
(
false
);
rootToggle
.
setChecked
(
false
);
if
(!
new
File
(
suPath
+
"/su"
).
exists
()
)
{
if
(!
Utils
.
rootAccess
)
{
rootStatus
.
setText
(
R
.
string
.
root_none
);
rootStatus
.
setText
(
R
.
string
.
root_none
);
safetyNet
.
setText
(
R
.
string
.
root_none_info
);
safetyNet
.
setText
(
R
.
string
.
root_none_info
);
rootToggle
.
setEnabled
(
false
);
rootToggle
.
setEnabled
(
false
);
...
@@ -107,5 +109,4 @@ public class MainActivity extends Activity {
...
@@ -107,5 +109,4 @@ public class MainActivity extends Activity {
}
}
}
}
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java
View file @
7bf83371
package
com
.
topjohnwu
.
magisk
;
package
com
.
topjohnwu
.
magisk
;
import
android.os.AsyncTask
;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.support.annotation.IdRes
;
import
android.support.annotation.IdRes
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
android.support.design.widget.NavigationView
;
import
android.support.design.widget.NavigationView
;
import
android.support.design.widget.Snackbar
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.app.FragmentTransaction
;
import
android.support.v4.app.FragmentTransaction
;
import
android.support.v4.view.GravityCompat
;
import
android.support.v4.view.GravityCompat
;
...
@@ -16,10 +18,7 @@ import android.support.v7.widget.Toolbar;
...
@@ -16,10 +18,7 @@ import android.support.v7.widget.Toolbar;
import
android.view.MenuItem
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.View
;
import
com.topjohnwu.magisk.ui.LogFragment
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.ui.ModulesFragment
;
import
com.topjohnwu.magisk.ui.RootFragment
;
import
com.topjohnwu.magisk.ui.utils.Utils
;
import
butterknife.BindView
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.ButterKnife
;
...
@@ -28,6 +27,8 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
...
@@ -28,6 +27,8 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
private
static
final
String
SELECTED_ITEM_ID
=
"SELECTED_ITEM_ID"
;
private
static
final
String
SELECTED_ITEM_ID
=
"SELECTED_ITEM_ID"
;
private
final
Handler
mDrawerHandler
=
new
Handler
();
private
final
Handler
mDrawerHandler
=
new
Handler
();
public
static
Init
initialize
=
new
Init
();
public
static
View
view
;
@BindView
(
R
.
id
.
toolbar
)
Toolbar
toolbar
;
@BindView
(
R
.
id
.
toolbar
)
Toolbar
toolbar
;
@BindView
(
R
.
id
.
drawer_layout
)
DrawerLayout
drawer
;
@BindView
(
R
.
id
.
drawer_layout
)
DrawerLayout
drawer
;
...
@@ -36,16 +37,40 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
...
@@ -36,16 +37,40 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
@IdRes
@IdRes
private
int
mSelectedId
=
R
.
id
.
modules
;
// for now
private
int
mSelectedId
=
R
.
id
.
modules
;
// for now
public
static
class
Init
extends
AsyncTask
<
Void
,
Integer
,
Void
>
{
@Override
protected
Void
doInBackground
(
Void
...
voids
)
{
// Check root access
Utils
.
checkRoot
();
// Permission for java code to read /cache files
if
(
Utils
.
rootAccess
)
{
Utils
.
su
(
"chmod 755 /cache"
,
"chmod 644 /cache/magisk.log"
);
}
return
null
;
}
@Override
protected
void
onPostExecute
(
Void
v
)
{
super
.
onPostExecute
(
v
);
if
(!
Utils
.
rootAccess
)
{
Snackbar
.
make
(
view
,
R
.
string
.
no_root_access
,
Snackbar
.
LENGTH_LONG
).
show
();
}
}
}
@Override
@Override
protected
void
onCreate
(
final
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
final
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_welcome
);
setContentView
(
R
.
layout
.
activity_welcome
);
view
=
findViewById
(
R
.
id
.
toolbar
);
ButterKnife
.
bind
(
this
);
ButterKnife
.
bind
(
this
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
getWindow
().
getDecorView
().
setSystemUiVisibility
(
View
.
SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
);
getWindow
().
getDecorView
().
setSystemUiVisibility
(
View
.
SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
);
}
}
Utils
.
initialize
.
execute
();
initialize
.
execute
();
setSupportActionBar
(
toolbar
);
setSupportActionBar
(
toolbar
);
...
...
app/src/main/java/com/topjohnwu/magisk/mod
el
/Module.java
→
app/src/main/java/com/topjohnwu/magisk/mod
ule
/Module.java
View file @
7bf83371
package
com
.
topjohnwu
.
magisk
.
mod
el
;
package
com
.
topjohnwu
.
magisk
.
mod
ule
;
import
com.topjohnwu.magisk.u
i.u
tils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.File
;
...
...
app/src/main/java/com/topjohnwu/magisk/rv/ModulesAdapter.java
View file @
7bf83371
...
@@ -10,7 +10,8 @@ import android.widget.ImageView;
...
@@ -10,7 +10,8 @@ import android.widget.ImageView;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.model.Module
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.utils.Utils
;
import
java.util.List
;
import
java.util.List
;
...
@@ -92,6 +93,10 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
...
@@ -92,6 +93,10 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
public
ViewHolder
(
View
itemView
)
{
public
ViewHolder
(
View
itemView
)
{
super
(
itemView
);
super
(
itemView
);
ButterKnife
.
bind
(
this
,
itemView
);
ButterKnife
.
bind
(
this
,
itemView
);
if
(!
Utils
.
rootAccess
)
{
checkBox
.
setEnabled
(
false
);
delete
.
setEnabled
(
false
);
}
}
}
}
}
}
}
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/ui/RootFragment.java
deleted
100644 → 0
View file @
36c57502
package
com
.
topjohnwu
.
magisk
.
ui
;
import
android.support.v4.app.Fragment
;
public
class
RootFragment
extends
Fragment
{
}
app/src/main/java/com/topjohnwu/magisk/u
i/u
tils/Utils.java
→
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
View file @
7bf83371
package
com
.
topjohnwu
.
magisk
.
ui
.
utils
;
package
com
.
topjohnwu
.
magisk
.
utils
;
import
android.os.AsyncTask
;
import
java.util.List
;
import
java.util.List
;
import
eu.chainfire.libsuperuser.Shell
;
import
eu.chainfire.libsuperuser.Shell
;
public
class
Utils
{
public
class
Utils
{
public
static
final
String
suPath
=
sh
(
"getprop magisk.supath"
);
public
static
final
String
suPath
=
sh
(
"getprop magisk.supath"
);
public
static
boolean
rootAccess
=
false
;
public
static
boolean
rootAccess
=
false
;
public
static
Init
initialize
=
new
Init
();
public
static
class
Init
extends
AsyncTask
<
Void
,
Integer
,
Void
>
{
@Override
protected
Void
doInBackground
(
Void
...
voids
)
{
// Check root access
rootAccess
=
isRoot
();
// Permission for java code to read /cache files
if
(
rootAccess
)
{
su
(
"chmod 755 /cache"
,
"chmod 644 /cache/magisk.log"
);
}
return
null
;
}
}
public
static
String
sh
(
String
...
commands
)
{
public
static
String
sh
(
String
...
commands
)
{
List
<
String
>
result
=
Shell
.
SH
.
run
(
commands
);
List
<
String
>
result
=
Shell
.
SH
.
run
(
commands
);
...
@@ -48,30 +30,27 @@ public class Utils {
...
@@ -48,30 +30,27 @@ public class Utils {
return
builder
.
toString
();
return
builder
.
toString
();
}
}
public
static
boolean
is
Root
()
{
public
static
void
check
Root
()
{
String
[]
availableTestCommands
=
new
String
[]
{
"echo -BOC-"
,
"id"
};
String
[]
availableTestCommands
=
new
String
[]
{
"echo -BOC-"
,
"id"
};
List
<
String
>
ret
=
Shell
.
run
(
Utils
.
suPath
+
"/su"
,
availableTestCommands
,
null
,
false
);
List
<
String
>
ret
=
Shell
.
run
(
Utils
.
suPath
+
"/su"
,
availableTestCommands
,
null
,
false
);
if
(
ret
==
null
)
if
(
ret
==
null
)
return
false
;
return
;
// Taken from libsuperuser
// Taken from libsuperuser
// this is only one of many ways this can be done
// this is only one of many ways this can be done
boolean
echo_seen
=
false
;
for
(
String
line
:
ret
)
{
for
(
String
line
:
ret
)
{
if
(
line
.
contains
(
"uid="
))
{
if
(
line
.
contains
(
"uid="
))
{
// id command is working, let's see if we are actually root
// id command is working, let's see if we are actually root
r
eturn
line
.
contains
(
"uid=0"
);
r
ootAccess
=
line
.
contains
(
"uid=0"
);
}
else
if
(
line
.
contains
(
"-BOC-"
))
{
}
else
if
(
line
.
contains
(
"-BOC-"
))
{
// if we end up here, at least the su command starts some kind
// if we end up here, at least the su command starts some kind
// of shell, let's hope it has root privileges - no way to know without
// of shell, let's hope it has root privileges - no way to know without
// additional native binaries
// additional native binaries
echo_seen
=
true
;
rootAccess
=
true
;
}
}
}
}
return
echo_seen
;
}
}
}
}
app/src/main/res/layout/
activity_main
.xml
→
app/src/main/res/layout/
root_fragment
.xml
View file @
7bf83371
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:
focusableInTouchMode=
"tru
e"
android:
layout_marginTop=
"?attr/actionBarSiz
e"
tools:context=
".ui.MainActivity
"
>
android:focusableInTouchMode=
"true
"
>
<TextView
<TextView
android:id=
"@+id/magisk_label"
android:id=
"@+id/magisk_label"
...
@@ -120,12 +120,4 @@
...
@@ -120,12 +120,4 @@
android:text=
"@string/selinux_toggle"
android:text=
"@string/selinux_toggle"
android:textSize=
"20sp"
/>
android:textSize=
"20sp"
/>
<Button
android:id=
"@+id/modules"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentBottom=
"true"
android:layout_alignParentStart=
"true"
android:text=
"modules activity"
/>
</RelativeLayout>
</RelativeLayout>
app/src/main/res/values/strings.xml
View file @
7bf83371
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
<string
name=
"log"
>
Log
</string>
<string
name=
"log"
>
Log
</string>
<string
name=
"remove"
>
Remove
</string>
<string
name=
"remove"
>
Remove
</string>
<string
name=
"disable"
>
Disable
</string>
<string
name=
"disable"
>
Disable
</string>
<string
name=
"no_root_access"
>
No root access, functionality limited
</string>
<string
name=
"remove_file_created"
>
Module will be removed at next reboot
</string>
<string
name=
"remove_file_created"
>
Module will be removed at next reboot
</string>
<string
name=
"disable_file_created"
>
Module will be disabled at next reboot
</string>
<string
name=
"disable_file_created"
>
Module will be disabled at next reboot
</string>
<string
name=
"menuSaveToSd"
>
Save to SD
</string>
<string
name=
"menuSaveToSd"
>
Save to SD
</string>
...
...
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