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
bef59695
Commit
bef59695
authored
Feb 06, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No more static crap :)
parent
c6bf7bb9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
421 additions
and
234 deletions
+421
-234
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-0
AboutActivity.java
app/src/main/java/com/topjohnwu/magisk/AboutActivity.java
+3
-3
InstallFragment.java
app/src/main/java/com/topjohnwu/magisk/InstallFragment.java
+18
-18
LogFragment.java
app/src/main/java/com/topjohnwu/magisk/LogFragment.java
+2
-2
MagiskHideFragment.java
...rc/main/java/com/topjohnwu/magisk/MagiskHideFragment.java
+7
-7
MagiskLogFragment.java
...src/main/java/com/topjohnwu/magisk/MagiskLogFragment.java
+1
-1
MagiskManager.java
app/src/main/java/com/topjohnwu/magisk/MagiskManager.java
+139
-0
MainActivity.java
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
+16
-16
ModulesFragment.java
app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java
+7
-7
ReposFragment.java
app/src/main/java/com/topjohnwu/magisk/ReposFragment.java
+20
-7
SettingsActivity.java
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
+27
-23
SplashActivity.java
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
+10
-8
StatusFragment.java
app/src/main/java/com/topjohnwu/magisk/StatusFragment.java
+30
-30
SuLogFragment.java
app/src/main/java/com/topjohnwu/magisk/SuLogFragment.java
+1
-1
SuperuserFragment.java
...src/main/java/com/topjohnwu/magisk/SuperuserFragment.java
+1
-1
Activity.java
...c/main/java/com/topjohnwu/magisk/components/Activity.java
+12
-0
Fragment.java
...c/main/java/com/topjohnwu/magisk/components/Fragment.java
+11
-0
ModuleHelper.java
...c/main/java/com/topjohnwu/magisk/module/ModuleHelper.java
+17
-41
BootReceiver.java
...ain/java/com/topjohnwu/magisk/receivers/BootReceiver.java
+5
-4
MagiskDlReceiver.java
...java/com/topjohnwu/magisk/receivers/MagiskDlReceiver.java
+2
-2
RequestActivity.java
.../java/com/topjohnwu/magisk/superuser/RequestActivity.java
+3
-4
SuLogDatabaseHelper.java
...a/com/topjohnwu/magisk/superuser/SuLogDatabaseHelper.java
+5
-2
SuReceiver.java
.../main/java/com/topjohnwu/magisk/superuser/SuReceiver.java
+5
-3
SuRequestActivity.java
...ava/com/topjohnwu/magisk/superuser/SuRequestActivity.java
+10
-8
Async.java
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
+62
-40
Logger.java
app/src/main/java/com/topjohnwu/magisk/utils/Logger.java
+4
-4
Utils.java
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
+2
-2
No files found.
app/src/main/AndroidManifest.xml
View file @
bef59695
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
<uses-permission
android:name=
"android.permission.RECEIVE_BOOT_COMPLETED"
/>
<uses-permission
android:name=
"android.permission.RECEIVE_BOOT_COMPLETED"
/>
<application
<application
android:name=
".MagiskManager"
android:allowBackup=
"true"
android:allowBackup=
"true"
android:icon=
"@mipmap/ic_launcher"
android:icon=
"@mipmap/ic_launcher"
android:label=
"@string/app_name"
android:label=
"@string/app_name"
...
...
app/src/main/java/com/topjohnwu/magisk/AboutActivity.java
View file @
bef59695
...
@@ -7,7 +7,6 @@ import android.os.Bundle;
...
@@ -7,7 +7,6 @@ import android.os.Bundle;
import
android.preference.PreferenceManager
;
import
android.preference.PreferenceManager
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.v7.app.ActionBar
;
import
android.support.v7.app.ActionBar
;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.widget.Toolbar
;
import
android.support.v7.widget.Toolbar
;
import
android.text.Html
;
import
android.text.Html
;
import
android.text.Spanned
;
import
android.text.Spanned
;
...
@@ -17,6 +16,7 @@ import android.view.View;
...
@@ -17,6 +16,7 @@ import android.view.View;
import
android.view.WindowManager
;
import
android.view.WindowManager
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
...
@@ -26,7 +26,7 @@ import java.io.InputStream;
...
@@ -26,7 +26,7 @@ import java.io.InputStream;
import
butterknife.BindView
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.ButterKnife
;
public
class
AboutActivity
extends
A
ppCompatA
ctivity
{
public
class
AboutActivity
extends
Activity
{
private
static
final
String
DONATION_URL
=
"http://topjohnwu.github.io/donate"
;
private
static
final
String
DONATION_URL
=
"http://topjohnwu.github.io/donate"
;
private
static
final
String
XDA_THREAD
=
"http://forum.xda-developers.com/showthread.php?t=3432382"
;
private
static
final
String
XDA_THREAD
=
"http://forum.xda-developers.com/showthread.php?t=3432382"
;
...
@@ -46,7 +46,7 @@ public class AboutActivity extends AppCompatActivity {
...
@@ -46,7 +46,7 @@ public class AboutActivity extends AppCompatActivity {
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
String
theme
=
PreferenceManager
.
getDefaultSharedPreferences
(
getApplicationContext
()).
getString
(
"theme"
,
""
);
String
theme
=
PreferenceManager
.
getDefaultSharedPreferences
(
getApplicationContext
()).
getString
(
"theme"
,
""
);
Logger
.
dev
(
"AboutActivity: Theme is "
+
theme
);
Logger
.
dev
(
"AboutActivity: Theme is "
+
theme
);
if
(
Global
.
Configs
.
isDarkTheme
)
{
if
(
getTopApplication
()
.
isDarkTheme
)
{
setTheme
(
R
.
style
.
AppTheme_dh
);
setTheme
(
R
.
style
.
AppTheme_dh
);
}
}
setContentView
(
R
.
layout
.
activity_about
);
setContentView
(
R
.
layout
.
activity_about
);
...
...
app/src/main/java/com/topjohnwu/magisk/InstallFragment.java
View file @
bef59695
...
@@ -6,7 +6,6 @@ import android.net.Uri;
...
@@ -6,7 +6,6 @@ import android.net.Uri;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.CountDownTimer
;
import
android.os.CountDownTimer
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.v4.app.Fragment
;
import
android.support.v7.widget.CardView
;
import
android.support.v7.widget.CardView
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
...
@@ -17,6 +16,7 @@ import android.widget.CheckBox;
...
@@ -17,6 +16,7 @@ import android.widget.CheckBox;
import
android.widget.Spinner
;
import
android.widget.Spinner
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.receivers.MagiskDlReceiver
;
import
com.topjohnwu.magisk.receivers.MagiskDlReceiver
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
...
@@ -54,19 +54,19 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
...
@@ -54,19 +54,19 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
View
v
=
inflater
.
inflate
(
R
.
layout
.
fragment_install
,
container
,
false
);
View
v
=
inflater
.
inflate
(
R
.
layout
.
fragment_install
,
container
,
false
);
unbinder
=
ButterKnife
.
bind
(
this
,
v
);
unbinder
=
ButterKnife
.
bind
(
this
,
v
);
detectButton
.
setOnClickListener
(
v1
->
toAutoDetect
());
detectButton
.
setOnClickListener
(
v1
->
toAutoDetect
());
currentVersionTitle
.
setText
(
getString
(
R
.
string
.
current_magisk_title
,
Global
.
Info
.
magiskVersionString
));
currentVersionTitle
.
setText
(
getString
(
R
.
string
.
current_magisk_title
,
getApplication
()
.
magiskVersionString
));
installTitle
.
setText
(
getString
(
R
.
string
.
install_magisk_title
,
Global
.
Info
.
remoteMagiskVersion
));
installTitle
.
setText
(
getString
(
R
.
string
.
install_magisk_title
,
getApplication
()
.
remoteMagiskVersion
));
flashButton
.
setOnClickListener
(
v1
->
{
flashButton
.
setOnClickListener
(
v1
->
{
String
bootImage
;
String
bootImage
;
if
(
Global
.
Info
.
bootBlock
!=
null
)
{
if
(
getApplication
()
.
bootBlock
!=
null
)
{
if
(
spinner
.
getSelectedItemPosition
()
>
0
)
if
(
spinner
.
getSelectedItemPosition
()
>
0
)
bootImage
=
Global
.
Data
.
blockList
.
get
(
spinner
.
getSelectedItemPosition
()
-
1
);
bootImage
=
getApplication
()
.
blockList
.
get
(
spinner
.
getSelectedItemPosition
()
-
1
);
else
else
bootImage
=
Global
.
Info
.
bootBlock
;
bootImage
=
getApplication
()
.
bootBlock
;
}
else
{
}
else
{
bootImage
=
Global
.
Data
.
blockList
.
get
(
spinner
.
getSelectedItemPosition
());
bootImage
=
getApplication
()
.
blockList
.
get
(
spinner
.
getSelectedItemPosition
());
}
}
String
filename
=
"Magisk-v"
+
Global
.
Info
.
remoteMagiskVersion
+
".zip"
;
String
filename
=
"Magisk-v"
+
getApplication
()
.
remoteMagiskVersion
+
".zip"
;
Utils
.
getAlertDialogBuilder
(
getActivity
())
Utils
.
getAlertDialogBuilder
(
getActivity
())
.
setTitle
(
getString
(
R
.
string
.
repo_install_title
,
getString
(
R
.
string
.
magisk
)))
.
setTitle
(
getString
(
R
.
string
.
repo_install_title
,
getString
(
R
.
string
.
magisk
)))
.
setMessage
(
getString
(
R
.
string
.
repo_install_msg
,
filename
))
.
setMessage
(
getString
(
R
.
string
.
repo_install_msg
,
filename
))
...
@@ -74,15 +74,15 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
...
@@ -74,15 +74,15 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
.
setPositiveButton
(
R
.
string
.
download_install
,
(
dialogInterface
,
i
)
->
Utils
.
dlAndReceive
(
.
setPositiveButton
(
R
.
string
.
download_install
,
(
dialogInterface
,
i
)
->
Utils
.
dlAndReceive
(
getActivity
(),
getActivity
(),
new
MagiskDlReceiver
(
bootImage
,
keepEncChkbox
.
isChecked
(),
keepVerityChkbox
.
isChecked
()),
new
MagiskDlReceiver
(
bootImage
,
keepEncChkbox
.
isChecked
(),
keepVerityChkbox
.
isChecked
()),
Global
.
Info
.
magiskLink
,
getApplication
()
.
magiskLink
,
Utils
.
getLegalFilename
(
filename
)))
Utils
.
getLegalFilename
(
filename
)))
.
setNeutralButton
(
R
.
string
.
check_release_notes
,
(
dialog
,
which
)
->
{
.
setNeutralButton
(
R
.
string
.
check_release_notes
,
(
dialog
,
which
)
->
{
getActivity
().
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
Global
.
Info
.
releaseNoteLink
)));
getActivity
().
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
getApplication
()
.
releaseNoteLink
)));
})
})
.
setNegativeButton
(
R
.
string
.
no_thanks
,
null
)
.
setNegativeButton
(
R
.
string
.
no_thanks
,
null
)
.
show
();
.
show
();
});
});
if
(
Global
.
Info
.
magiskVersion
<
10.3
)
{
if
(
getApplication
()
.
magiskVersion
<
10.3
)
{
uninstallButton
.
setVisibility
(
View
.
GONE
);
uninstallButton
.
setVisibility
(
View
.
GONE
);
}
else
{
}
else
{
uninstallButton
.
setOnClickListener
(
vi
->
{
uninstallButton
.
setOnClickListener
(
vi
->
{
...
@@ -125,7 +125,7 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
...
@@ -125,7 +125,7 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
});
});
}
}
if
(
Global
.
Events
.
blockDetectionDone
.
isTriggered
)
{
if
(
getApplication
()
.
blockDetectionDone
.
isTriggered
)
{
updateUI
();
updateUI
();
}
}
return
v
;
return
v
;
...
@@ -137,9 +137,9 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
...
@@ -137,9 +137,9 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
}
}
private
void
updateUI
()
{
private
void
updateUI
()
{
List
<
String
>
items
=
new
ArrayList
<>(
Global
.
Data
.
blockList
);
List
<
String
>
items
=
new
ArrayList
<>(
getApplication
()
.
blockList
);
if
(
Global
.
Info
.
bootBlock
!=
null
)
if
(
getApplication
()
.
bootBlock
!=
null
)
items
.
add
(
0
,
getString
(
R
.
string
.
auto_detect
,
Global
.
Info
.
bootBlock
));
items
.
add
(
0
,
getString
(
R
.
string
.
auto_detect
,
getApplication
()
.
bootBlock
));
ArrayAdapter
<
String
>
adapter
=
new
ArrayAdapter
<>(
getActivity
(),
ArrayAdapter
<
String
>
adapter
=
new
ArrayAdapter
<>(
getActivity
(),
android
.
R
.
layout
.
simple_spinner_item
,
items
);
android
.
R
.
layout
.
simple_spinner_item
,
items
);
adapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
adapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
...
@@ -148,7 +148,7 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
...
@@ -148,7 +148,7 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
}
}
private
void
toAutoDetect
()
{
private
void
toAutoDetect
()
{
if
(
Global
.
Info
.
bootBlock
!=
null
)
{
if
(
getApplication
()
.
bootBlock
!=
null
)
{
spinner
.
setSelection
(
0
);
spinner
.
setSelection
(
0
);
}
}
}
}
...
@@ -157,12 +157,12 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
...
@@ -157,12 +157,12 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
public
void
onStart
()
{
public
void
onStart
()
{
super
.
onStart
();
super
.
onStart
();
getActivity
().
setTitle
(
R
.
string
.
install
);
getActivity
().
setTitle
(
R
.
string
.
install
);
CallbackHandler
.
register
(
Global
.
Events
.
blockDetectionDone
,
this
);
CallbackHandler
.
register
(
getApplication
()
.
blockDetectionDone
,
this
);
}
}
@Override
@Override
public
void
onStop
()
{
public
void
onStop
()
{
CallbackHandler
.
unRegister
(
Global
.
Events
.
blockDetectionDone
,
this
);
CallbackHandler
.
unRegister
(
getApplication
()
.
blockDetectionDone
,
this
);
super
.
onStop
();
super
.
onStop
();
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/LogFragment.java
View file @
bef59695
...
@@ -3,13 +3,13 @@ package com.topjohnwu.magisk;
...
@@ -3,13 +3,13 @@ package com.topjohnwu.magisk;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.design.widget.TabLayout
;
import
android.support.design.widget.TabLayout
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.view.ViewPager
;
import
android.support.v4.view.ViewPager
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
com.topjohnwu.magisk.adapters.TabFragmentAdapter
;
import
com.topjohnwu.magisk.adapters.TabFragmentAdapter
;
import
com.topjohnwu.magisk.components.Fragment
;
import
butterknife.BindView
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.ButterKnife
;
...
@@ -33,7 +33,7 @@ public class LogFragment extends Fragment {
...
@@ -33,7 +33,7 @@ public class LogFragment extends Fragment {
adapter
.
addTab
(
new
MagiskLogFragment
(),
getString
(
R
.
string
.
magisk
));
adapter
.
addTab
(
new
MagiskLogFragment
(),
getString
(
R
.
string
.
magisk
));
if
(
Global
.
Info
.
isSuClient
)
{
if
(
getApplication
()
.
isSuClient
)
{
adapter
.
addTab
(
new
SuLogFragment
(),
getString
(
R
.
string
.
superuser
));
adapter
.
addTab
(
new
SuLogFragment
(),
getString
(
R
.
string
.
superuser
));
tab
.
setupWithViewPager
(
viewPager
);
tab
.
setupWithViewPager
(
viewPager
);
tab
.
setVisibility
(
View
.
VISIBLE
);
tab
.
setVisibility
(
View
.
VISIBLE
);
...
...
app/src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java
View file @
bef59695
...
@@ -3,7 +3,6 @@ package com.topjohnwu.magisk;
...
@@ -3,7 +3,6 @@ package com.topjohnwu.magisk;
import
android.content.pm.PackageManager
;
import
android.content.pm.PackageManager
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.view.MenuItemCompat
;
import
android.support.v4.view.MenuItemCompat
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.RecyclerView
;
...
@@ -16,6 +15,7 @@ import android.view.ViewGroup;
...
@@ -16,6 +15,7 @@ import android.view.ViewGroup;
import
android.widget.SearchView
;
import
android.widget.SearchView
;
import
com.topjohnwu.magisk.adapters.ApplicationAdapter
;
import
com.topjohnwu.magisk.adapters.ApplicationAdapter
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Logger
;
...
@@ -50,7 +50,7 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
...
@@ -50,7 +50,7 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
PackageManager
packageManager
=
getActivity
().
getPackageManager
();
PackageManager
packageManager
=
getActivity
().
getPackageManager
();
mSwipeRefreshLayout
.
setRefreshing
(
true
);
mSwipeRefreshLayout
.
setRefreshing
(
true
);
mSwipeRefreshLayout
.
setOnRefreshListener
(()
->
new
Async
.
LoadApps
(
packageManager
).
exec
());
mSwipeRefreshLayout
.
setOnRefreshListener
(()
->
new
Async
.
LoadApps
(
getApplication
()
).
exec
());
appAdapter
=
new
ApplicationAdapter
(
packageManager
);
appAdapter
=
new
ApplicationAdapter
(
packageManager
);
recyclerView
.
setAdapter
(
appAdapter
);
recyclerView
.
setAdapter
(
appAdapter
);
...
@@ -85,15 +85,15 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
...
@@ -85,15 +85,15 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
public
void
onStart
()
{
public
void
onStart
()
{
super
.
onStart
();
super
.
onStart
();
getActivity
().
setTitle
(
R
.
string
.
magiskhide
);
getActivity
().
setTitle
(
R
.
string
.
magiskhide
);
CallbackHandler
.
register
(
Global
.
Events
.
packageLoadDone
,
this
);
CallbackHandler
.
register
(
getApplication
()
.
packageLoadDone
,
this
);
if
(
Global
.
Events
.
packageLoadDone
.
isTriggered
)
{
if
(
getApplication
()
.
packageLoadDone
.
isTriggered
)
{
onTrigger
(
Global
.
Events
.
packageLoadDone
);
onTrigger
(
getApplication
()
.
packageLoadDone
);
}
}
}
}
@Override
@Override
public
void
onStop
()
{
public
void
onStop
()
{
CallbackHandler
.
unRegister
(
Global
.
Events
.
packageLoadDone
,
this
);
CallbackHandler
.
unRegister
(
getApplication
()
.
packageLoadDone
,
this
);
super
.
onStop
();
super
.
onStop
();
}
}
...
@@ -106,7 +106,7 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
...
@@ -106,7 +106,7 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
@Override
@Override
public
void
onTrigger
(
CallbackHandler
.
Event
event
)
{
public
void
onTrigger
(
CallbackHandler
.
Event
event
)
{
Logger
.
dev
(
"MagiskHideFragment: UI refresh"
);
Logger
.
dev
(
"MagiskHideFragment: UI refresh"
);
appAdapter
.
setLists
(
Global
.
Data
.
appList
,
Global
.
Data
.
magiskHideList
);
appAdapter
.
setLists
(
getApplication
().
appList
,
getApplication
()
.
magiskHideList
);
mSwipeRefreshLayout
.
setRefreshing
(
false
);
mSwipeRefreshLayout
.
setRefreshing
(
false
);
if
(!
TextUtils
.
isEmpty
(
lastFilter
))
{
if
(!
TextUtils
.
isEmpty
(
lastFilter
))
{
appAdapter
.
filter
(
lastFilter
);
appAdapter
.
filter
(
lastFilter
);
...
...
app/src/main/java/com/topjohnwu/magisk/MagiskLogFragment.java
View file @
bef59695
...
@@ -11,7 +11,6 @@ import android.support.annotation.NonNull;
...
@@ -11,7 +11,6 @@ import android.support.annotation.NonNull;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.design.widget.Snackbar
;
import
android.support.design.widget.Snackbar
;
import
android.support.v4.app.ActivityCompat
;
import
android.support.v4.app.ActivityCompat
;
import
android.support.v4.app.Fragment
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.Menu
;
import
android.view.Menu
;
...
@@ -25,6 +24,7 @@ import android.widget.ScrollView;
...
@@ -25,6 +24,7 @@ import android.widget.ScrollView;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
...
...
app/src/main/java/com/topjohnwu/magisk/
Global
.java
→
app/src/main/java/com/topjohnwu/magisk/
MagiskManager
.java
View file @
bef59695
package
com
.
topjohnwu
.
magisk
;
package
com
.
topjohnwu
.
magisk
;
import
android.
content.Context
;
import
android.
app.Application
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
android.content.pm.ApplicationInfo
;
import
android.content.pm.ApplicationInfo
;
import
android.preference.PreferenceManager
;
import
android.preference.PreferenceManager
;
...
@@ -16,116 +16,122 @@ import com.topjohnwu.magisk.utils.ValueSortedMap;
...
@@ -16,116 +16,122 @@ import com.topjohnwu.magisk.utils.ValueSortedMap;
import
java.io.File
;
import
java.io.File
;
import
java.util.List
;
import
java.util.List
;
public
class
Global
{
public
class
MagiskManager
extends
Application
{
public
static
final
String
MAGISK_DISABLE_FILE
=
"/cache/.disable_magisk"
;
public
static
final
String
MAGISK_DISABLE_FILE
=
"/cache/.disable_magisk"
;
public
static
class
Info
{
// Events
public
static
double
magiskVersion
;
public
final
CallbackHandler
.
Event
blockDetectionDone
=
new
CallbackHandler
.
Event
();
public
static
String
magiskVersionString
=
"(none)"
;
public
final
CallbackHandler
.
Event
packageLoadDone
=
new
CallbackHandler
.
Event
();
public
static
double
remoteMagiskVersion
=
-
1
;
public
final
CallbackHandler
.
Event
reloadMainActivity
=
new
CallbackHandler
.
Event
();
public
static
String
magiskLink
;
public
final
CallbackHandler
.
Event
moduleLoadDone
=
new
CallbackHandler
.
Event
();
public
static
String
releaseNoteLink
;
public
final
CallbackHandler
.
Event
repoLoadDone
=
new
CallbackHandler
.
Event
();
public
static
int
SNCheckResult
=
-
1
;
public
final
CallbackHandler
.
Event
updateCheckDone
=
new
CallbackHandler
.
Event
();
public
static
String
bootBlock
=
null
;
public
final
CallbackHandler
.
Event
safetyNetDone
=
new
CallbackHandler
.
Event
();
public
static
boolean
isSuClient
=
false
;
public
static
String
suVersion
=
null
;
// Info
public
static
boolean
disabled
=
false
;
public
double
magiskVersion
;
}
public
String
magiskVersionString
=
"(none)"
;
public
static
class
Data
{
public
double
remoteMagiskVersion
=
-
1
;
public
static
ValueSortedMap
<
String
,
Repo
>
repoMap
;
public
String
magiskLink
;
public
static
ValueSortedMap
<
String
,
Module
>
moduleMap
;
public
String
releaseNoteLink
;
public
static
List
<
String
>
blockList
;
public
int
SNCheckResult
=
-
1
;
public
static
List
<
ApplicationInfo
>
appList
;
public
String
bootBlock
=
null
;
public
static
List
<
String
>
magiskHideList
;
public
boolean
isSuClient
=
false
;
}
public
String
suVersion
=
null
;
public
static
class
Events
{
public
boolean
disabled
=
false
;
public
static
final
CallbackHandler
.
Event
blockDetectionDone
=
new
CallbackHandler
.
Event
();
public
static
final
CallbackHandler
.
Event
packageLoadDone
=
new
CallbackHandler
.
Event
();
// Data
public
static
final
CallbackHandler
.
Event
reloadMainActivity
=
new
CallbackHandler
.
Event
();
public
ValueSortedMap
<
String
,
Repo
>
repoMap
;
public
static
final
CallbackHandler
.
Event
moduleLoadDone
=
new
CallbackHandler
.
Event
();
public
ValueSortedMap
<
String
,
Module
>
moduleMap
;
public
static
final
CallbackHandler
.
Event
repoLoadDone
=
new
CallbackHandler
.
Event
();
public
List
<
String
>
blockList
;
public
static
final
CallbackHandler
.
Event
updateCheckDone
=
new
CallbackHandler
.
Event
();
public
List
<
ApplicationInfo
>
appList
;
public
static
final
CallbackHandler
.
Event
safetyNetDone
=
new
CallbackHandler
.
Event
();
public
List
<
String
>
magiskHideList
;
public
static
SparseArray
<
CallbackHandler
.
Event
>
uidMap
=
new
SparseArray
<>();
public
SparseArray
<
CallbackHandler
.
Event
>
uidMap
=
new
SparseArray
<>();
}
public
static
class
Configs
{
// Configurations
public
static
boolean
isDarkTheme
;
public
static
boolean
shellLogging
;
public
static
boolean
shellLogging
;
public
static
boolean
devLogging
;
public
static
boolean
devLogging
;
public
static
boolean
magiskHide
;
public
static
boolean
magiskHide
;
public
static
int
suRequestTimeout
;
public
boolean
isDarkTheme
;
public
static
int
suLogTimeout
=
14
;
public
int
suRequestTimeout
;
public
static
int
suAccessState
;
public
int
suLogTimeout
=
14
;
public
static
int
suResponseType
;
public
int
suAccessState
;
public
static
int
suNotificationType
;
public
int
suResponseType
;
public
int
suNotificationType
;
public
SharedPreferences
prefs
;
@Override
public
void
onCreate
()
{
super
.
onCreate
();
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
);
}
}
public
static
void
init
(
Context
context
)
{
public
void
init
()
{
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
isDarkTheme
=
prefs
.
getBoolean
(
"dark_theme"
,
false
);
Configs
.
isDarkTheme
=
prefs
.
getBoolean
(
"dark_theme"
,
false
);
devLogging
=
prefs
.
getBoolean
(
"developer_logging"
,
false
);
Configs
.
devLogging
=
prefs
.
getBoolean
(
"developer_logging"
,
false
);
shellLogging
=
prefs
.
getBoolean
(
"shell_logging"
,
false
);
Configs
.
shellLogging
=
prefs
.
getBoolean
(
"shell_logging"
,
false
);
magiskHide
=
prefs
.
getBoolean
(
"magiskhide"
,
false
);
Configs
.
magiskHide
=
prefs
.
getBoolean
(
"magiskhide"
,
false
);
updateMagiskInfo
();
updateMagiskInfo
();
initSuAccess
();
initSuAccess
();
initSuConfigs
(
context
);
initSuConfigs
();
// Initialize prefs
// Initialize prefs
prefs
.
edit
()
prefs
.
edit
()
.
putBoolean
(
"dark_theme"
,
Configs
.
isDarkTheme
)
.
putBoolean
(
"dark_theme"
,
isDarkTheme
)
.
putBoolean
(
"magiskhide"
,
Configs
.
magiskHide
)
.
putBoolean
(
"magiskhide"
,
magiskHide
)
.
putBoolean
(
"busybox"
,
Utils
.
commandExists
(
"busybox"
))
.
putBoolean
(
"busybox"
,
Utils
.
commandExists
(
"busybox"
))
.
putBoolean
(
"hosts"
,
new
File
(
"/magisk/.core/hosts"
).
exists
())
.
putBoolean
(
"hosts"
,
new
File
(
"/magisk/.core/hosts"
).
exists
())
.
putBoolean
(
"disable"
,
Utils
.
itemExist
(
MAGISK_DISABLE_FILE
))
.
putBoolean
(
"disable"
,
Utils
.
itemExist
(
MAGISK_DISABLE_FILE
))
.
putString
(
"su_request_timeout"
,
String
.
valueOf
(
Configs
.
suRequestTimeout
))
.
putString
(
"su_request_timeout"
,
String
.
valueOf
(
suRequestTimeout
))
.
putString
(
"su_auto_response"
,
String
.
valueOf
(
Configs
.
suResponseType
))
.
putString
(
"su_auto_response"
,
String
.
valueOf
(
suResponseType
))
.
putString
(
"su_notification"
,
String
.
valueOf
(
Configs
.
suNotificationType
))
.
putString
(
"su_notification"
,
String
.
valueOf
(
suNotificationType
))
.
putString
(
"su_access"
,
String
.
valueOf
(
Configs
.
suAccessState
))
.
putString
(
"su_access"
,
String
.
valueOf
(
suAccessState
))
.
apply
();
.
apply
();
}
}
public
static
void
initSuConfigs
(
Context
context
)
{
public
void
initSuConfigs
()
{
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
suRequestTimeout
=
Utils
.
getPrefsInt
(
prefs
,
"su_request_timeout"
,
10
);
Configs
.
suRequestTimeout
=
Utils
.
getPrefsInt
(
prefs
,
"su_request_timeout"
,
10
);
suResponseType
=
Utils
.
getPrefsInt
(
prefs
,
"su_auto_response"
,
0
);
Configs
.
suResponseType
=
Utils
.
getPrefsInt
(
prefs
,
"su_auto_response"
,
0
);
suNotificationType
=
Utils
.
getPrefsInt
(
prefs
,
"su_notification"
,
1
);
Configs
.
suNotificationType
=
Utils
.
getPrefsInt
(
prefs
,
"su_notification"
,
1
);
}
}
public
static
void
initSuAccess
()
{
public
void
initSuAccess
()
{
List
<
String
>
ret
=
Shell
.
sh
(
"su -v"
);
List
<
String
>
ret
=
Shell
.
sh
(
"su -v"
);
if
(
Utils
.
isValidShellResponse
(
ret
))
{
if
(
Utils
.
isValidShellResponse
(
ret
))
{
Info
.
suVersion
=
ret
.
get
(
0
);
suVersion
=
ret
.
get
(
0
);
Info
.
isSuClient
=
Info
.
suVersion
.
toUpperCase
().
contains
(
"MAGISK"
);
isSuClient
=
suVersion
.
toUpperCase
().
contains
(
"MAGISK"
);
}
}
if
(
Info
.
isSuClient
)
{
if
(
isSuClient
)
{
ret
=
Shell
.
sh
(
"getprop persist.sys.root_access"
);
ret
=
Shell
.
sh
(
"getprop persist.sys.root_access"
);
if
(
Utils
.
isValidShellResponse
(
ret
))
if
(
Utils
.
isValidShellResponse
(
ret
))
Configs
.
suAccessState
=
Integer
.
parseInt
(
ret
.
get
(
0
));
suAccessState
=
Integer
.
parseInt
(
ret
.
get
(
0
));
else
{
else
{
Shell
.
su
(
true
,
"setprop persist.sys.root_access 3"
);
Shell
.
su
(
true
,
"setprop persist.sys.root_access 3"
);
Configs
.
suAccessState
=
3
;
suAccessState
=
3
;
}
}
}
}
}
}
public
static
void
updateMagiskInfo
()
{
public
void
updateMagiskInfo
()
{
List
<
String
>
ret
=
Shell
.
sh
(
"getprop magisk.version"
);
List
<
String
>
ret
=
Shell
.
sh
(
"getprop magisk.version"
);
if
(!
Utils
.
isValidShellResponse
(
ret
))
{
if
(!
Utils
.
isValidShellResponse
(
ret
))
{
Info
.
magiskVersion
=
-
1
;
magiskVersion
=
-
1
;
}
else
{
}
else
{
try
{
try
{
Info
.
magiskVersionString
=
ret
.
get
(
0
);
magiskVersionString
=
ret
.
get
(
0
);
Info
.
magiskVersion
=
Double
.
parseDouble
(
ret
.
get
(
0
));
magiskVersion
=
Double
.
parseDouble
(
ret
.
get
(
0
));
}
catch
(
NumberFormatException
e
)
{
}
catch
(
NumberFormatException
e
)
{
// Custom version don't need to receive updates
// Custom version don't need to receive updates
Info
.
magiskVersion
=
Double
.
POSITIVE_INFINITY
;
magiskVersion
=
Double
.
POSITIVE_INFINITY
;
}
}
}
}
ret
=
Shell
.
sh
(
"getprop ro.magisk.disable"
);
ret
=
Shell
.
sh
(
"getprop ro.magisk.disable"
);
try
{
try
{
Info
.
disabled
=
Utils
.
isValidShellResponse
(
ret
)
&&
Integer
.
parseInt
(
ret
.
get
(
0
))
!=
0
;
disabled
=
Utils
.
isValidShellResponse
(
ret
)
&&
Integer
.
parseInt
(
ret
.
get
(
0
))
!=
0
;
}
catch
(
NumberFormatException
e
)
{
}
catch
(
NumberFormatException
e
)
{
Info
.
disabled
=
false
;
disabled
=
false
;
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
View file @
bef59695
...
@@ -15,19 +15,19 @@ import android.support.v4.app.Fragment;
...
@@ -15,19 +15,19 @@ import android.support.v4.app.Fragment;
import
android.support.v4.app.FragmentTransaction
;
import
android.support.v4.app.FragmentTransaction
;
import
android.support.v4.widget.DrawerLayout
;
import
android.support.v4.widget.DrawerLayout
;
import
android.support.v7.app.ActionBarDrawerToggle
;
import
android.support.v7.app.ActionBarDrawerToggle
;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.widget.Toolbar
;
import
android.support.v7.widget.Toolbar
;
import
android.view.Menu
;
import
android.view.Menu
;
import
android.view.MenuItem
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.View
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
butterknife.BindView
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.ButterKnife
;
public
class
MainActivity
extends
A
ppCompatA
ctivity
public
class
MainActivity
extends
Activity
implements
NavigationView
.
OnNavigationItemSelectedListener
,
CallbackHandler
.
EventListener
{
implements
NavigationView
.
OnNavigationItemSelectedListener
,
CallbackHandler
.
EventListener
{
private
final
Handler
mDrawerHandler
=
new
Handler
();
private
final
Handler
mDrawerHandler
=
new
Handler
();
...
@@ -44,7 +44,7 @@ public class MainActivity extends AppCompatActivity
...
@@ -44,7 +44,7 @@ public class MainActivity extends AppCompatActivity
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
getApplicationContext
());
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
getApplicationContext
());
if
(
Global
.
Configs
.
isDarkTheme
)
{
if
(
getTopApplication
()
.
isDarkTheme
)
{
setTheme
(
R
.
style
.
AppTheme_dh
);
setTheme
(
R
.
style
.
AppTheme_dh
);
}
}
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
...
@@ -79,28 +79,28 @@ public class MainActivity extends AppCompatActivity
...
@@ -79,28 +79,28 @@ public class MainActivity extends AppCompatActivity
navigate
(
R
.
id
.
status
);
navigate
(
R
.
id
.
status
);
navigationView
.
setNavigationItemSelectedListener
(
this
);
navigationView
.
setNavigationItemSelectedListener
(
this
);
CallbackHandler
.
register
(
Global
.
Events
.
reloadMainActivity
,
this
);
CallbackHandler
.
register
(
getTopApplication
()
.
reloadMainActivity
,
this
);
}
}
@Override
@Override
protected
void
onResume
()
{
protected
void
onResume
()
{
super
.
onResume
();
super
.
onResume
();
CallbackHandler
.
register
(
Global
.
Events
.
updateCheckDone
,
this
);
CallbackHandler
.
register
(
getTopApplication
()
.
updateCheckDone
,
this
);
if
(
Global
.
Events
.
updateCheckDone
.
isTriggered
)
if
(
getTopApplication
()
.
updateCheckDone
.
isTriggered
)
onTrigger
(
Global
.
Events
.
updateCheckDone
);
onTrigger
(
getTopApplication
()
.
updateCheckDone
);
checkHideSection
();
checkHideSection
();
}
}
@Override
@Override
protected
void
onPause
()
{
protected
void
onPause
()
{
CallbackHandler
.
unRegister
(
Global
.
Events
.
updateCheckDone
,
this
);
CallbackHandler
.
unRegister
(
getTopApplication
()
.
updateCheckDone
,
this
);
super
.
onPause
();
super
.
onPause
();
}
}
@Override
@Override
protected
void
onDestroy
()
{
protected
void
onDestroy
()
{
CallbackHandler
.
unRegister
(
Global
.
Events
.
reloadMainActivity
,
this
);
CallbackHandler
.
unRegister
(
getTopApplication
()
.
reloadMainActivity
,
this
);
super
.
onDestroy
();
super
.
onDestroy
();
}
}
...
@@ -122,11 +122,11 @@ public class MainActivity extends AppCompatActivity
...
@@ -122,11 +122,11 @@ public class MainActivity extends AppCompatActivity
@Override
@Override
public
void
onTrigger
(
CallbackHandler
.
Event
event
)
{
public
void
onTrigger
(
CallbackHandler
.
Event
event
)
{
if
(
event
==
Global
.
Events
.
updateCheckDone
)
{
if
(
event
==
getTopApplication
()
.
updateCheckDone
)
{
Menu
menu
=
navigationView
.
getMenu
();
Menu
menu
=
navigationView
.
getMenu
();
menu
.
findItem
(
R
.
id
.
install
).
setVisible
(
Global
.
Info
.
remoteMagiskVersion
>
0
&&
menu
.
findItem
(
R
.
id
.
install
).
setVisible
(
getTopApplication
()
.
remoteMagiskVersion
>
0
&&
Shell
.
rootAccess
());
Shell
.
rootAccess
());
}
else
if
(
event
==
Global
.
Events
.
reloadMainActivity
)
{
}
else
if
(
event
==
getTopApplication
()
.
reloadMainActivity
)
{
recreate
();
recreate
();
}
}
}
}
...
@@ -135,11 +135,11 @@ public class MainActivity extends AppCompatActivity
...
@@ -135,11 +135,11 @@ public class MainActivity extends AppCompatActivity
Menu
menu
=
navigationView
.
getMenu
();
Menu
menu
=
navigationView
.
getMenu
();
if
(
Shell
.
rootAccess
())
{
if
(
Shell
.
rootAccess
())
{
menu
.
findItem
(
R
.
id
.
magiskhide
).
setVisible
(
menu
.
findItem
(
R
.
id
.
magiskhide
).
setVisible
(
Global
.
Info
.
magiskVersion
>=
8
&&
prefs
.
getBoolean
(
"magiskhide"
,
false
));
getTopApplication
()
.
magiskVersion
>=
8
&&
prefs
.
getBoolean
(
"magiskhide"
,
false
));
menu
.
findItem
(
R
.
id
.
modules
).
setVisible
(
Global
.
Info
.
magiskVersion
>=
4
);
menu
.
findItem
(
R
.
id
.
modules
).
setVisible
(
getTopApplication
()
.
magiskVersion
>=
4
);
menu
.
findItem
(
R
.
id
.
downloads
).
setVisible
(
Global
.
Info
.
magiskVersion
>=
4
);
menu
.
findItem
(
R
.
id
.
downloads
).
setVisible
(
getTopApplication
()
.
magiskVersion
>=
4
);
menu
.
findItem
(
R
.
id
.
log
).
setVisible
(
true
);
menu
.
findItem
(
R
.
id
.
log
).
setVisible
(
true
);
menu
.
findItem
(
R
.
id
.
superuser
).
setVisible
(
Global
.
Info
.
isSuClient
);
menu
.
findItem
(
R
.
id
.
superuser
).
setVisible
(
getTopApplication
()
.
isSuClient
);
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java
View file @
bef59695
...
@@ -5,7 +5,6 @@ import android.content.Intent;
...
@@ -5,7 +5,6 @@ import android.content.Intent;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.RecyclerView
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
...
@@ -15,8 +14,8 @@ import android.widget.TextView;
...
@@ -15,8 +14,8 @@ import android.widget.TextView;
import
com.github.clans.fab.FloatingActionButton
;
import
com.github.clans.fab.FloatingActionButton
;
import
com.topjohnwu.magisk.adapters.ModulesAdapter
;
import
com.topjohnwu.magisk.adapters.ModulesAdapter
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.ModuleHelper
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Logger
;
...
@@ -54,7 +53,7 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi
...
@@ -54,7 +53,7 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi
mSwipeRefreshLayout
.
setOnRefreshListener
(()
->
{
mSwipeRefreshLayout
.
setOnRefreshListener
(()
->
{
recyclerView
.
setVisibility
(
View
.
GONE
);
recyclerView
.
setVisibility
(
View
.
GONE
);
new
Async
.
LoadModules
().
exec
();
new
Async
.
LoadModules
(
getApplication
()
).
exec
();
});
});
recyclerView
.
addOnScrollListener
(
new
RecyclerView
.
OnScrollListener
()
{
recyclerView
.
addOnScrollListener
(
new
RecyclerView
.
OnScrollListener
()
{
...
@@ -69,7 +68,7 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi
...
@@ -69,7 +68,7 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi
}
}
});
});
if
(
Global
.
Events
.
moduleLoadDone
.
isTriggered
)
{
if
(
getApplication
()
.
moduleLoadDone
.
isTriggered
)
{
updateUI
();
updateUI
();
}
}
...
@@ -95,13 +94,13 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi
...
@@ -95,13 +94,13 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi
@Override
@Override
public
void
onStart
()
{
public
void
onStart
()
{
super
.
onStart
();
super
.
onStart
();
CallbackHandler
.
register
(
Global
.
Events
.
moduleLoadDone
,
this
);
CallbackHandler
.
register
(
getApplication
()
.
moduleLoadDone
,
this
);
getActivity
().
setTitle
(
R
.
string
.
modules
);
getActivity
().
setTitle
(
R
.
string
.
modules
);
}
}
@Override
@Override
public
void
onStop
()
{
public
void
onStop
()
{
CallbackHandler
.
unRegister
(
Global
.
Events
.
moduleLoadDone
,
this
);
CallbackHandler
.
unRegister
(
getApplication
()
.
moduleLoadDone
,
this
);
super
.
onStop
();
super
.
onStop
();
}
}
...
@@ -112,7 +111,8 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi
...
@@ -112,7 +111,8 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi
}
}
private
void
updateUI
()
{
private
void
updateUI
()
{
ModuleHelper
.
getModuleList
(
listModules
);
listModules
.
clear
();
listModules
.
addAll
(
getApplication
().
moduleMap
.
values
());
if
(
listModules
.
size
()
==
0
)
{
if
(
listModules
.
size
()
==
0
)
{
emptyRv
.
setVisibility
(
View
.
VISIBLE
);
emptyRv
.
setVisibility
(
View
.
VISIBLE
);
recyclerView
.
setVisibility
(
View
.
GONE
);
recyclerView
.
setVisibility
(
View
.
GONE
);
...
...
app/src/main/java/com/topjohnwu/magisk/ReposFragment.java
View file @
bef59695
...
@@ -2,7 +2,6 @@ package com.topjohnwu.magisk;
...
@@ -2,7 +2,6 @@ package com.topjohnwu.magisk;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.view.MenuItemCompat
;
import
android.support.v4.view.MenuItemCompat
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.RecyclerView
;
...
@@ -16,7 +15,8 @@ import android.widget.TextView;
...
@@ -16,7 +15,8 @@ import android.widget.TextView;
import
com.topjohnwu.magisk.adapters.ReposAdapter
;
import
com.topjohnwu.magisk.adapters.ReposAdapter
;
import
com.topjohnwu.magisk.adapters.SimpleSectionedRecyclerViewAdapter
;
import
com.topjohnwu.magisk.adapters.SimpleSectionedRecyclerViewAdapter
;
import
com.topjohnwu.magisk.module.ModuleHelper
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
...
@@ -68,10 +68,10 @@ public class ReposFragment extends Fragment implements CallbackHandler.EventList
...
@@ -68,10 +68,10 @@ public class ReposFragment extends Fragment implements CallbackHandler.EventList
mSwipeRefreshLayout
.
setOnRefreshListener
(()
->
{
mSwipeRefreshLayout
.
setOnRefreshListener
(()
->
{
recyclerView
.
setVisibility
(
View
.
GONE
);
recyclerView
.
setVisibility
(
View
.
GONE
);
new
Async
.
LoadRepos
(
getA
ctivity
()).
exec
();
new
Async
.
LoadRepos
(
getA
pplication
()).
exec
();
});
});
if
(
Global
.
Events
.
repoLoadDone
.
isTriggered
)
{
if
(
getApplication
()
.
repoLoadDone
.
isTriggered
)
{
reloadRepos
();
reloadRepos
();
updateUI
();
updateUI
();
}
}
...
@@ -109,13 +109,13 @@ public class ReposFragment extends Fragment implements CallbackHandler.EventList
...
@@ -109,13 +109,13 @@ public class ReposFragment extends Fragment implements CallbackHandler.EventList
@Override
@Override
public
void
onStart
()
{
public
void
onStart
()
{
super
.
onStart
();
super
.
onStart
();
CallbackHandler
.
register
(
Global
.
Events
.
repoLoadDone
,
this
);
CallbackHandler
.
register
(
getApplication
()
.
repoLoadDone
,
this
);
getActivity
().
setTitle
(
R
.
string
.
downloads
);
getActivity
().
setTitle
(
R
.
string
.
downloads
);
}
}
@Override
@Override
public
void
onStop
()
{
public
void
onStop
()
{
CallbackHandler
.
unRegister
(
Global
.
Events
.
repoLoadDone
,
this
);
CallbackHandler
.
unRegister
(
getApplication
()
.
repoLoadDone
,
this
);
super
.
onStop
();
super
.
onStop
();
}
}
...
@@ -126,7 +126,20 @@ public class ReposFragment extends Fragment implements CallbackHandler.EventList
...
@@ -126,7 +126,20 @@ public class ReposFragment extends Fragment implements CallbackHandler.EventList
}
}
private
void
reloadRepos
()
{
private
void
reloadRepos
()
{
ModuleHelper
.
getRepoLists
(
mUpdateRepos
,
mInstalledRepos
,
mOthersRepos
);
mUpdateRepos
.
clear
();
mInstalledRepos
.
clear
();
mOthersRepos
.
clear
();
for
(
Repo
repo
:
getApplication
().
repoMap
.
values
())
{
Module
module
=
getApplication
().
moduleMap
.
get
(
repo
.
getId
());
if
(
module
!=
null
)
{
if
(
repo
.
getVersionCode
()
>
module
.
getVersionCode
())
mUpdateRepos
.
add
(
repo
);
else
mInstalledRepos
.
add
(
repo
);
}
else
{
mOthersRepos
.
add
(
repo
);
}
}
fUpdateRepos
.
clear
();
fUpdateRepos
.
clear
();
fInstalledRepos
.
clear
();
fInstalledRepos
.
clear
();
fOthersRepos
.
clear
();
fOthersRepos
.
clear
();
...
...
app/src/main/java/com/topjohnwu/magisk/SettingsActivity.java
View file @
bef59695
...
@@ -9,11 +9,11 @@ import android.preference.PreferenceManager;
...
@@ -9,11 +9,11 @@ import android.preference.PreferenceManager;
import
android.preference.PreferenceScreen
;
import
android.preference.PreferenceScreen
;
import
android.preference.SwitchPreference
;
import
android.preference.SwitchPreference
;
import
android.support.v7.app.ActionBar
;
import
android.support.v7.app.ActionBar
;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.widget.Toolbar
;
import
android.support.v7.widget.Toolbar
;
import
android.view.WindowManager
;
import
android.view.WindowManager
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.module.ModuleHelper
;
import
com.topjohnwu.magisk.module.ModuleHelper
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Logger
;
...
@@ -23,14 +23,14 @@ import com.topjohnwu.magisk.utils.Utils;
...
@@ -23,14 +23,14 @@ import com.topjohnwu.magisk.utils.Utils;
import
butterknife.BindView
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.ButterKnife
;
public
class
SettingsActivity
extends
A
ppCompatA
ctivity
{
public
class
SettingsActivity
extends
Activity
{
@BindView
(
R
.
id
.
toolbar
)
Toolbar
toolbar
;
@BindView
(
R
.
id
.
toolbar
)
Toolbar
toolbar
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
if
(
Global
.
Configs
.
isDarkTheme
)
{
if
(
getTopApplication
()
.
isDarkTheme
)
{
setTheme
(
R
.
style
.
AppTheme_dh
);
setTheme
(
R
.
style
.
AppTheme_dh
);
}
}
...
@@ -77,6 +77,10 @@ public class SettingsActivity extends AppCompatActivity {
...
@@ -77,6 +77,10 @@ public class SettingsActivity extends AppCompatActivity {
private
ListPreference
suAccess
,
autoRes
,
suNotification
,
requestTimeout
;
private
ListPreference
suAccess
,
autoRes
,
suNotification
,
requestTimeout
;
private
MagiskManager
getApplication
()
{
return
(
MagiskManager
)
getActivity
().
getApplication
();
}
@Override
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
...
@@ -99,7 +103,7 @@ public class SettingsActivity extends AppCompatActivity {
...
@@ -99,7 +103,7 @@ public class SettingsActivity extends AppCompatActivity {
setSummary
();
setSummary
();
findPreference
(
"clear"
).
setOnPreferenceClickListener
((
pref
)
->
{
findPreference
(
"clear"
).
setOnPreferenceClickListener
((
pref
)
->
{
ModuleHelper
.
clearRepoCache
(
getA
ctivity
());
ModuleHelper
.
clearRepoCache
(
getA
pplication
());
return
true
;
return
true
;
});
});
...
@@ -107,11 +111,11 @@ public class SettingsActivity extends AppCompatActivity {
...
@@ -107,11 +111,11 @@ public class SettingsActivity extends AppCompatActivity {
prefScreen
.
removePreference
(
magiskCategory
);
prefScreen
.
removePreference
(
magiskCategory
);
prefScreen
.
removePreference
(
suCategory
);
prefScreen
.
removePreference
(
suCategory
);
}
else
{
}
else
{
if
(!
Global
.
Info
.
isSuClient
)
if
(!
getApplication
()
.
isSuClient
)
prefScreen
.
removePreference
(
suCategory
);
prefScreen
.
removePreference
(
suCategory
);
if
(
Global
.
Info
.
magiskVersion
<
11
)
if
(
getApplication
()
.
magiskVersion
<
11
)
prefScreen
.
removePreference
(
magiskCategory
);
prefScreen
.
removePreference
(
magiskCategory
);
if
(
Global
.
Info
.
disabled
)
{
if
(
getApplication
()
.
disabled
)
{
busybox
.
setEnabled
(
false
);
busybox
.
setEnabled
(
false
);
magiskHide
.
setEnabled
(
false
);
magiskHide
.
setEnabled
(
false
);
hosts
.
setEnabled
(
false
);
hosts
.
setEnabled
(
false
);
...
@@ -139,10 +143,10 @@ public class SettingsActivity extends AppCompatActivity {
...
@@ -139,10 +143,10 @@ public class SettingsActivity extends AppCompatActivity {
switch
(
key
)
{
switch
(
key
)
{
case
"dark_theme"
:
case
"dark_theme"
:
enabled
=
prefs
.
getBoolean
(
"dark_theme"
,
false
);
enabled
=
prefs
.
getBoolean
(
"dark_theme"
,
false
);
if
(
Global
.
Configs
.
isDarkTheme
!=
enabled
)
{
if
(
getApplication
()
.
isDarkTheme
!=
enabled
)
{
Global
.
Configs
.
isDarkTheme
=
enabled
;
getApplication
()
.
isDarkTheme
=
enabled
;
getActivity
().
recreate
();
getActivity
().
recreate
();
Global
.
Events
.
reloadMainActivity
.
trigger
();
getApplication
()
.
reloadMainActivity
.
trigger
();
}
}
break
;
break
;
case
"disable"
:
case
"disable"
:
...
@@ -152,9 +156,9 @@ public class SettingsActivity extends AppCompatActivity {
...
@@ -152,9 +156,9 @@ public class SettingsActivity extends AppCompatActivity {
@Override
@Override
protected
Void
doInBackground
(
Void
...
voids
)
{
protected
Void
doInBackground
(
Void
...
voids
)
{
if
(
enable
)
{
if
(
enable
)
{
Utils
.
createFile
(
Global
.
MAGISK_DISABLE_FILE
);
Utils
.
createFile
(
MagiskManager
.
MAGISK_DISABLE_FILE
);
}
else
{
}
else
{
Utils
.
removeItem
(
Global
.
MAGISK_DISABLE_FILE
);
Utils
.
removeItem
(
MagiskManager
.
MAGISK_DISABLE_FILE
);
}
}
return
null
;
return
null
;
}
}
...
@@ -183,7 +187,7 @@ public class SettingsActivity extends AppCompatActivity {
...
@@ -183,7 +187,7 @@ public class SettingsActivity extends AppCompatActivity {
case
"magiskhide"
:
case
"magiskhide"
:
enabled
=
prefs
.
getBoolean
(
"magiskhide"
,
false
);
enabled
=
prefs
.
getBoolean
(
"magiskhide"
,
false
);
if
(
enabled
)
{
if
(
enabled
)
{
if
(!
Global
.
Info
.
isSuClient
)
{
if
(!
getApplication
()
.
isSuClient
)
{
Utils
.
getAlertDialogBuilder
(
getActivity
())
Utils
.
getAlertDialogBuilder
(
getActivity
())
.
setTitle
(
R
.
string
.
no_magisksu_title
)
.
setTitle
(
R
.
string
.
no_magisksu_title
)
.
setMessage
(
R
.
string
.
no_magisksu_msg
)
.
setMessage
(
R
.
string
.
no_magisksu_msg
)
...
@@ -212,23 +216,23 @@ public class SettingsActivity extends AppCompatActivity {
...
@@ -212,23 +216,23 @@ public class SettingsActivity extends AppCompatActivity {
}.
exec
();
}.
exec
();
break
;
break
;
case
"su_access"
:
case
"su_access"
:
Global
.
Configs
.
suAccessState
=
Utils
.
getPrefsInt
(
prefs
,
"su_access"
,
0
);
getApplication
()
.
suAccessState
=
Utils
.
getPrefsInt
(
prefs
,
"su_access"
,
0
);
Shell
.
su
(
"setprop persist.sys.root_access "
+
Global
.
Configs
.
suAccessState
);
Shell
.
su
(
"setprop persist.sys.root_access "
+
getApplication
()
.
suAccessState
);
break
;
break
;
case
"su_request_timeout"
:
case
"su_request_timeout"
:
Global
.
Configs
.
suRequestTimeout
=
Utils
.
getPrefsInt
(
prefs
,
"su_request_timeout"
,
10
);
getApplication
()
.
suRequestTimeout
=
Utils
.
getPrefsInt
(
prefs
,
"su_request_timeout"
,
10
);
break
;
break
;
case
"su_auto_response"
:
case
"su_auto_response"
:
Global
.
Configs
.
suResponseType
=
Utils
.
getPrefsInt
(
prefs
,
"su_auto_response"
,
0
);
getApplication
()
.
suResponseType
=
Utils
.
getPrefsInt
(
prefs
,
"su_auto_response"
,
0
);
break
;
break
;
case
"su_notification"
:
case
"su_notification"
:
Global
.
Configs
.
suNotificationType
=
Utils
.
getPrefsInt
(
prefs
,
"su_notification"
,
1
);
getApplication
()
.
suNotificationType
=
Utils
.
getPrefsInt
(
prefs
,
"su_notification"
,
1
);
break
;
break
;
case
"developer_logging"
:
case
"developer_logging"
:
Global
.
Configs
.
devLogging
=
prefs
.
getBoolean
(
"developer_logging"
,
false
);
getApplication
()
.
devLogging
=
prefs
.
getBoolean
(
"developer_logging"
,
false
);
break
;
break
;
case
"shell_logging"
:
case
"shell_logging"
:
Global
.
Configs
.
shellLogging
=
prefs
.
getBoolean
(
"shell_logging"
,
false
);
getApplication
()
.
shellLogging
=
prefs
.
getBoolean
(
"shell_logging"
,
false
);
break
;
break
;
}
}
setSummary
();
setSummary
();
...
@@ -236,11 +240,11 @@ public class SettingsActivity extends AppCompatActivity {
...
@@ -236,11 +240,11 @@ public class SettingsActivity extends AppCompatActivity {
private
void
setSummary
()
{
private
void
setSummary
()
{
suAccess
.
setSummary
(
getResources
()
suAccess
.
setSummary
(
getResources
()
.
getStringArray
(
R
.
array
.
su_access
)[
Global
.
Configs
.
suAccessState
]);
.
getStringArray
(
R
.
array
.
su_access
)[
getApplication
()
.
suAccessState
]);
autoRes
.
setSummary
(
getResources
()
autoRes
.
setSummary
(
getResources
()
.
getStringArray
(
R
.
array
.
auto_response
)[
Global
.
Configs
.
suResponseType
]);
.
getStringArray
(
R
.
array
.
auto_response
)[
getApplication
()
.
suResponseType
]);
suNotification
.
setSummary
(
getResources
()
suNotification
.
setSummary
(
getResources
()
.
getStringArray
(
R
.
array
.
su_notification
)[
Global
.
Configs
.
suNotificationType
]);
.
getStringArray
(
R
.
array
.
su_notification
)[
getApplication
()
.
suNotificationType
]);
requestTimeout
.
setSummary
(
requestTimeout
.
setSummary
(
getString
(
R
.
string
.
request_timeout_summary
,
prefs
.
getString
(
"su_request_timeout"
,
"10"
)));
getString
(
R
.
string
.
request_timeout_summary
,
prefs
.
getString
(
"su_request_timeout"
,
"10"
)));
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
View file @
bef59695
...
@@ -2,31 +2,33 @@ package com.topjohnwu.magisk;
...
@@ -2,31 +2,33 @@ package com.topjohnwu.magisk;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.v7.app.AppCompatActivity
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
public
class
SplashActivity
extends
A
ppCompatA
ctivity
{
public
class
SplashActivity
extends
Activity
{
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
MagiskManager
magiskManager
=
getTopApplication
();
// Init the info and configs and root shell
// Init the info and configs and root shell
Global
.
init
(
getApplicationContext
()
);
magiskManager
.
init
(
);
// Now fire all async tasks
// Now fire all async tasks
new
Async
.
CheckUpdates
().
exec
();
new
Async
.
CheckUpdates
(
magiskManager
).
exec
();
new
Async
.
GetBootBlocks
().
exec
();
new
Async
.
GetBootBlocks
(
magiskManager
).
exec
();
new
Async
.
LoadModules
()
{
new
Async
.
LoadModules
(
magiskManager
)
{
@Override
@Override
protected
void
onPostExecute
(
Void
v
)
{
protected
void
onPostExecute
(
Void
v
)
{
super
.
onPostExecute
(
v
);
super
.
onPostExecute
(
v
);
new
Async
.
LoadRepos
(
getApplicationContext
()
).
exec
();
new
Async
.
LoadRepos
(
magiskManager
).
exec
();
}
}
}.
exec
();
}.
exec
();
new
Async
.
LoadApps
(
getPackageManager
()
).
exec
();
new
Async
.
LoadApps
(
magiskManager
).
exec
();
// Preparation done, now start main activity
// Preparation done, now start main activity
Intent
intent
=
new
Intent
(
getApplicationContext
(),
MainActivity
.
class
);
Intent
intent
=
new
Intent
(
getApplicationContext
(),
MainActivity
.
class
);
...
...
app/src/main/java/com/topjohnwu/magisk/StatusFragment.java
View file @
bef59695
...
@@ -5,7 +5,6 @@ import android.content.Intent;
...
@@ -5,7 +5,6 @@ import android.content.Intent;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.app.FragmentTransaction
;
import
android.support.v4.app.FragmentTransaction
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
...
@@ -15,6 +14,7 @@ import android.widget.ImageView;
...
@@ -15,6 +14,7 @@ import android.widget.ImageView;
import
android.widget.ProgressBar
;
import
android.widget.ProgressBar
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Logger
;
...
@@ -80,11 +80,11 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
...
@@ -80,11 +80,11 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
safetyNetStatusText
.
setText
(
R
.
string
.
safetyNet_check_text
);
safetyNetStatusText
.
setText
(
R
.
string
.
safetyNet_check_text
);
safetyNetStatusText
.
setTextColor
(
defaultColor
);
safetyNetStatusText
.
setTextColor
(
defaultColor
);
Global
.
Events
.
safetyNetDone
.
isTriggered
=
false
;
getApplication
()
.
safetyNetDone
.
isTriggered
=
false
;
noDialog
=
false
;
noDialog
=
false
;
updateUI
();
updateUI
();
new
Async
.
CheckUpdates
().
exec
();
new
Async
.
CheckUpdates
(
getApplication
()
).
exec
();
});
});
safetyNetContainer
.
setOnClickListener
(
view
->
{
safetyNetContainer
.
setOnClickListener
(
view
->
{
...
@@ -92,10 +92,10 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
...
@@ -92,10 +92,10 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
safetyNetContainer
.
setBackgroundColor
(
trans
);
safetyNetContainer
.
setBackgroundColor
(
trans
);
safetyNetIcon
.
setImageResource
(
0
);
safetyNetIcon
.
setImageResource
(
0
);
safetyNetStatusText
.
setText
(
R
.
string
.
checking_safetyNet_status
);
safetyNetStatusText
.
setText
(
R
.
string
.
checking_safetyNet_status
);
Async
.
checkSafetyNet
(
getA
ctivity
());
Async
.
checkSafetyNet
(
getA
pplication
());
});
});
if
(
Global
.
Info
.
magiskVersion
<
0
&&
Shell
.
rootAccess
()
&&
!
noDialog
)
{
if
(
getApplication
()
.
magiskVersion
<
0
&&
Shell
.
rootAccess
()
&&
!
noDialog
)
{
noDialog
=
true
;
noDialog
=
true
;
Utils
.
getAlertDialogBuilder
(
getActivity
())
Utils
.
getAlertDialogBuilder
(
getActivity
())
.
setTitle
(
R
.
string
.
no_magisk_title
)
.
setTitle
(
R
.
string
.
no_magisk_title
)
...
@@ -104,7 +104,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
...
@@ -104,7 +104,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
.
setPositiveButton
(
R
.
string
.
goto_install
,
(
dialogInterface
,
i
)
->
{
.
setPositiveButton
(
R
.
string
.
goto_install
,
(
dialogInterface
,
i
)
->
{
((
MainActivity
)
getActivity
()).
navigationView
.
setCheckedItem
(
R
.
id
.
install
);
((
MainActivity
)
getActivity
()).
navigationView
.
setCheckedItem
(
R
.
id
.
install
);
FragmentTransaction
transaction
=
getFragmentManager
().
beginTransaction
();
FragmentTransaction
transaction
=
getFragmentManager
().
beginTransaction
();
transaction
.
setCustomAnimations
(
android
.
R
.
anim
ator
.
fade_in
,
android
.
R
.
animator
.
fade_out
);
transaction
.
setCustomAnimations
(
android
.
R
.
anim
.
fade_in
,
android
.
R
.
anim
.
fade_out
);
try
{
try
{
transaction
.
replace
(
R
.
id
.
content_frame
,
new
InstallFragment
(),
"install"
).
commit
();
transaction
.
replace
(
R
.
id
.
content_frame
,
new
InstallFragment
(),
"install"
).
commit
();
}
catch
(
IllegalStateException
ignored
)
{}
}
catch
(
IllegalStateException
ignored
)
{}
...
@@ -120,10 +120,10 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
...
@@ -120,10 +120,10 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
@Override
@Override
public
void
onTrigger
(
CallbackHandler
.
Event
event
)
{
public
void
onTrigger
(
CallbackHandler
.
Event
event
)
{
if
(
event
==
Global
.
Events
.
updateCheckDone
)
{
if
(
event
==
getApplication
()
.
updateCheckDone
)
{
Logger
.
dev
(
"StatusFragment: Update Check UI refresh triggered"
);
Logger
.
dev
(
"StatusFragment: Update Check UI refresh triggered"
);
updateCheckUI
();
updateCheckUI
();
}
else
if
(
event
==
Global
.
Events
.
safetyNetDone
)
{
}
else
if
(
event
==
getApplication
()
.
safetyNetDone
)
{
Logger
.
dev
(
"StatusFragment: SafetyNet UI refresh triggered"
);
Logger
.
dev
(
"StatusFragment: SafetyNet UI refresh triggered"
);
updateSafetyNetUI
();
updateSafetyNetUI
();
}
}
...
@@ -132,12 +132,12 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
...
@@ -132,12 +132,12 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
@Override
@Override
public
void
onStart
()
{
public
void
onStart
()
{
super
.
onStart
();
super
.
onStart
();
CallbackHandler
.
register
(
Global
.
Events
.
updateCheckDone
,
this
);
CallbackHandler
.
register
(
getApplication
()
.
updateCheckDone
,
this
);
CallbackHandler
.
register
(
Global
.
Events
.
safetyNetDone
,
this
);
CallbackHandler
.
register
(
getApplication
()
.
safetyNetDone
,
this
);
if
(
Global
.
Events
.
updateCheckDone
.
isTriggered
)
{
if
(
getApplication
()
.
updateCheckDone
.
isTriggered
)
{
updateCheckUI
();
updateCheckUI
();
}
}
if
(
Global
.
Events
.
safetyNetDone
.
isTriggered
)
{
if
(
getApplication
()
.
safetyNetDone
.
isTriggered
)
{
updateSafetyNetUI
();
updateSafetyNetUI
();
}
}
getActivity
().
setTitle
(
R
.
string
.
status
);
getActivity
().
setTitle
(
R
.
string
.
status
);
...
@@ -145,8 +145,8 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
...
@@ -145,8 +145,8 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
@Override
@Override
public
void
onStop
()
{
public
void
onStop
()
{
CallbackHandler
.
unRegister
(
Global
.
Events
.
updateCheckDone
,
this
);
CallbackHandler
.
unRegister
(
getApplication
()
.
updateCheckDone
,
this
);
CallbackHandler
.
unRegister
(
Global
.
Events
.
safetyNetDone
,
this
);
CallbackHandler
.
unRegister
(
getApplication
()
.
safetyNetDone
,
this
);
super
.
onStop
();
super
.
onStop
();
}
}
...
@@ -159,14 +159,14 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
...
@@ -159,14 +159,14 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
private
void
updateUI
()
{
private
void
updateUI
()
{
int
image
,
color
;
int
image
,
color
;
Global
.
updateMagiskInfo
();
getApplication
()
.
updateMagiskInfo
();
if
(
Global
.
Info
.
magiskVersion
<
0
)
{
if
(
getApplication
()
.
magiskVersion
<
0
)
{
magiskVersionText
.
setText
(
R
.
string
.
magisk_version_error
);
magiskVersionText
.
setText
(
R
.
string
.
magisk_version_error
);
}
else
if
(
Global
.
Info
.
disabled
)
{
}
else
if
(
getApplication
()
.
disabled
)
{
magiskVersionText
.
setText
(
getString
(
R
.
string
.
magisk_version_disable
,
Global
.
Info
.
magiskVersionString
));
magiskVersionText
.
setText
(
getString
(
R
.
string
.
magisk_version_disable
,
getApplication
()
.
magiskVersionString
));
}
else
{
}
else
{
magiskVersionText
.
setText
(
getString
(
R
.
string
.
magisk_version
,
Global
.
Info
.
magiskVersionString
));
magiskVersionText
.
setText
(
getString
(
R
.
string
.
magisk_version
,
getApplication
()
.
magiskVersionString
));
}
}
switch
(
Shell
.
rootStatus
)
{
switch
(
Shell
.
rootStatus
)
{
...
@@ -177,11 +177,11 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
...
@@ -177,11 +177,11 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
rootInfoText
.
setText
(
R
.
string
.
root_info_warning
);
rootInfoText
.
setText
(
R
.
string
.
root_info_warning
);
break
;
break
;
case
1
:
case
1
:
if
(
Global
.
Info
.
suVersion
!=
null
)
{
if
(
getApplication
()
.
suVersion
!=
null
)
{
color
=
colorOK
;
color
=
colorOK
;
image
=
R
.
drawable
.
ic_check_circle
;
image
=
R
.
drawable
.
ic_check_circle
;
rootStatusText
.
setText
(
R
.
string
.
proper_root
);
rootStatusText
.
setText
(
R
.
string
.
proper_root
);
rootInfoText
.
setText
(
Global
.
Info
.
suVersion
);
rootInfoText
.
setText
(
getApplication
()
.
suVersion
);
break
;
break
;
}
}
case
-
1
:
case
-
1
:
...
@@ -200,24 +200,24 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
...
@@ -200,24 +200,24 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
private
void
updateCheckUI
()
{
private
void
updateCheckUI
()
{
int
image
,
color
;
int
image
,
color
;
if
(
Global
.
Info
.
remoteMagiskVersion
<
0
)
{
if
(
getApplication
()
.
remoteMagiskVersion
<
0
)
{
color
=
colorNeutral
;
color
=
colorNeutral
;
image
=
R
.
drawable
.
ic_help
;
image
=
R
.
drawable
.
ic_help
;
magiskUpdateText
.
setText
(
R
.
string
.
cannot_check_updates
);
magiskUpdateText
.
setText
(
R
.
string
.
cannot_check_updates
);
}
else
if
(
Global
.
Info
.
remoteMagiskVersion
>
Global
.
Info
.
magiskVersion
)
{
}
else
if
(
getApplication
().
remoteMagiskVersion
>
getApplication
()
.
magiskVersion
)
{
color
=
colorInfo
;
color
=
colorInfo
;
image
=
R
.
drawable
.
ic_update
;
image
=
R
.
drawable
.
ic_update
;
magiskUpdateText
.
setText
(
getString
(
R
.
string
.
magisk_update_available
,
Global
.
Info
.
remoteMagiskVersion
));
magiskUpdateText
.
setText
(
getString
(
R
.
string
.
magisk_update_available
,
getApplication
()
.
remoteMagiskVersion
));
}
else
{
}
else
{
color
=
colorOK
;
color
=
colorOK
;
image
=
R
.
drawable
.
ic_check_circle
;
image
=
R
.
drawable
.
ic_check_circle
;
magiskUpdateText
.
setText
(
getString
(
R
.
string
.
up_to_date
,
getString
(
R
.
string
.
magisk
)));
magiskUpdateText
.
setText
(
getString
(
R
.
string
.
up_to_date
,
getString
(
R
.
string
.
magisk
)));
}
}
if
(
Global
.
Info
.
magiskVersion
<
0
)
{
if
(
getApplication
()
.
magiskVersion
<
0
)
{
color
=
colorBad
;
color
=
colorBad
;
image
=
R
.
drawable
.
ic_cancel
;
image
=
R
.
drawable
.
ic_cancel
;
}
else
if
(
Global
.
Info
.
disabled
)
{
}
else
if
(
getApplication
()
.
disabled
)
{
color
=
colorNeutral
;
color
=
colorNeutral
;
image
=
R
.
drawable
.
ic_cancel
;
image
=
R
.
drawable
.
ic_cancel
;
}
}
...
@@ -232,7 +232,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
...
@@ -232,7 +232,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
updateMagisk
=
Utils
.
getAlertDialogBuilder
(
getActivity
())
updateMagisk
=
Utils
.
getAlertDialogBuilder
(
getActivity
())
.
setTitle
(
R
.
string
.
magisk_update_title
)
.
setTitle
(
R
.
string
.
magisk_update_title
)
.
setMessage
(
getString
(
R
.
string
.
magisk_update_message
,
Global
.
Info
.
remoteMagiskVersion
))
.
setMessage
(
getString
(
R
.
string
.
magisk_update_message
,
getApplication
()
.
remoteMagiskVersion
))
.
setCancelable
(
true
)
.
setCancelable
(
true
)
.
setPositiveButton
(
R
.
string
.
goto_install
,
(
dialogInterface
,
i
)
->
{
.
setPositiveButton
(
R
.
string
.
goto_install
,
(
dialogInterface
,
i
)
->
{
((
MainActivity
)
getActivity
()).
navigationView
.
setCheckedItem
(
R
.
id
.
install
);
((
MainActivity
)
getActivity
()).
navigationView
.
setCheckedItem
(
R
.
id
.
install
);
...
@@ -243,12 +243,12 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
...
@@ -243,12 +243,12 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
}
catch
(
IllegalStateException
ignored
)
{}
}
catch
(
IllegalStateException
ignored
)
{}
})
})
.
setNeutralButton
(
R
.
string
.
check_release_notes
,
(
dialog
,
which
)
->
{
.
setNeutralButton
(
R
.
string
.
check_release_notes
,
(
dialog
,
which
)
->
{
getActivity
().
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
Global
.
Info
.
releaseNoteLink
)));
getActivity
().
startActivity
(
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
getApplication
()
.
releaseNoteLink
)));
})
})
.
setNegativeButton
(
R
.
string
.
no_thanks
,
null
)
.
setNegativeButton
(
R
.
string
.
no_thanks
,
null
)
.
create
();
.
create
();
if
(
Global
.
Info
.
magiskVersion
<
Global
.
Info
.
remoteMagiskVersion
&&
Shell
.
rootAccess
())
{
if
(
getApplication
().
magiskVersion
<
getApplication
()
.
remoteMagiskVersion
&&
Shell
.
rootAccess
())
{
magiskStatusContainer
.
setOnClickListener
(
view
->
updateMagisk
.
show
());
magiskStatusContainer
.
setOnClickListener
(
view
->
updateMagisk
.
show
());
if
(!
noDialog
)
{
if
(!
noDialog
)
{
noDialog
=
true
;
noDialog
=
true
;
...
@@ -260,7 +260,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
...
@@ -260,7 +260,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
private
void
updateSafetyNetUI
()
{
private
void
updateSafetyNetUI
()
{
int
image
,
color
;
int
image
,
color
;
safetyNetProgress
.
setVisibility
(
View
.
GONE
);
safetyNetProgress
.
setVisibility
(
View
.
GONE
);
switch
(
Global
.
Info
.
SNCheckResult
)
{
switch
(
getApplication
()
.
SNCheckResult
)
{
case
-
3
:
case
-
3
:
color
=
colorNeutral
;
color
=
colorNeutral
;
image
=
R
.
drawable
.
ic_help
;
image
=
R
.
drawable
.
ic_help
;
...
...
app/src/main/java/com/topjohnwu/magisk/SuLogFragment.java
View file @
bef59695
...
@@ -2,7 +2,6 @@ package com.topjohnwu.magisk;
...
@@ -2,7 +2,6 @@ package com.topjohnwu.magisk;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.v4.app.Fragment
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.RecyclerView
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.Menu
;
import
android.view.Menu
;
...
@@ -13,6 +12,7 @@ import android.view.ViewGroup;
...
@@ -13,6 +12,7 @@ import android.view.ViewGroup;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.topjohnwu.magisk.adapters.SuLogAdapter
;
import
com.topjohnwu.magisk.adapters.SuLogAdapter
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.superuser.SuLogDatabaseHelper
;
import
com.topjohnwu.magisk.superuser.SuLogDatabaseHelper
;
import
com.topjohnwu.magisk.superuser.SuLogEntry
;
import
com.topjohnwu.magisk.superuser.SuLogEntry
;
...
...
app/src/main/java/com/topjohnwu/magisk/SuperuserFragment.java
View file @
bef59695
...
@@ -3,7 +3,6 @@ package com.topjohnwu.magisk;
...
@@ -3,7 +3,6 @@ package com.topjohnwu.magisk;
import
android.content.pm.PackageManager
;
import
android.content.pm.PackageManager
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.Nullable
;
import
android.support.v4.app.Fragment
;
import
android.support.v7.widget.RecyclerView
;
import
android.support.v7.widget.RecyclerView
;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
...
@@ -11,6 +10,7 @@ import android.view.ViewGroup;
...
@@ -11,6 +10,7 @@ import android.view.ViewGroup;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.topjohnwu.magisk.adapters.PolicyAdapter
;
import
com.topjohnwu.magisk.adapters.PolicyAdapter
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.superuser.Policy
;
import
com.topjohnwu.magisk.superuser.Policy
;
import
com.topjohnwu.magisk.superuser.SuDatabaseHelper
;
import
com.topjohnwu.magisk.superuser.SuDatabaseHelper
;
...
...
app/src/main/java/com/topjohnwu/magisk/components/Activity.java
0 → 100644
View file @
bef59695
package
com
.
topjohnwu
.
magisk
.
components
;
import
android.support.v7.app.AppCompatActivity
;
import
com.topjohnwu.magisk.MagiskManager
;
public
class
Activity
extends
AppCompatActivity
{
public
MagiskManager
getTopApplication
()
{
return
(
MagiskManager
)
getApplication
();
}
}
app/src/main/java/com/topjohnwu/magisk/components/Fragment.java
0 → 100644
View file @
bef59695
package
com
.
topjohnwu
.
magisk
.
components
;
import
com.topjohnwu.magisk.MagiskManager
;
public
class
Fragment
extends
android
.
support
.
v4
.
app
.
Fragment
{
public
MagiskManager
getApplication
()
{
return
(
MagiskManager
)
getActivity
().
getApplicationContext
();
}
}
app/src/main/java/com/topjohnwu/magisk/module/ModuleHelper.java
View file @
bef59695
...
@@ -6,7 +6,7 @@ import android.widget.Toast;
...
@@ -6,7 +6,7 @@ import android.widget.Toast;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
com.google.gson.reflect.TypeToken
;
import
com.topjohnwu.magisk.
Global
;
import
com.topjohnwu.magisk.
MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Logger
;
...
@@ -22,7 +22,6 @@ import java.text.ParseException;
...
@@ -22,7 +22,6 @@ import java.text.ParseException;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -36,29 +35,29 @@ public class ModuleHelper {
...
@@ -36,29 +35,29 @@ public class ModuleHelper {
private
static
final
String
REPO_KEY
=
"repomap"
;
private
static
final
String
REPO_KEY
=
"repomap"
;
private
static
final
String
FILE_KEY
=
"RepoMap"
;
private
static
final
String
FILE_KEY
=
"RepoMap"
;
public
static
void
createModuleMap
()
{
public
static
void
createModuleMap
(
MagiskManager
magiskManager
)
{
Logger
.
dev
(
"ModuleHelper: Loading modules"
);
Logger
.
dev
(
"ModuleHelper: Loading modules"
);
Global
.
Data
.
moduleMap
=
new
ValueSortedMap
<>();
magiskManager
.
moduleMap
=
new
ValueSortedMap
<>();
for
(
String
path
:
Utils
.
getModList
(
MAGISK_PATH
))
{
for
(
String
path
:
Utils
.
getModList
(
MAGISK_PATH
))
{
Logger
.
dev
(
"ModuleHelper: Adding modules from "
+
path
);
Logger
.
dev
(
"ModuleHelper: Adding modules from "
+
path
);
Module
module
;
Module
module
;
try
{
try
{
module
=
new
Module
(
path
);
module
=
new
Module
(
path
);
Global
.
Data
.
moduleMap
.
put
(
module
.
getId
(),
module
);
magiskManager
.
moduleMap
.
put
(
module
.
getId
(),
module
);
}
catch
(
BaseModule
.
CacheModException
ignored
)
{}
}
catch
(
BaseModule
.
CacheModException
ignored
)
{}
}
}
Logger
.
dev
(
"ModuleHelper: Data load done"
);
Logger
.
dev
(
"ModuleHelper: Data load done"
);
}
}
public
static
void
createRepoMap
(
Context
context
)
{
public
static
void
createRepoMap
(
MagiskManager
magiskManager
)
{
Logger
.
dev
(
"ModuleHelper: Loading repos"
);
Logger
.
dev
(
"ModuleHelper: Loading repos"
);
SharedPreferences
prefs
=
context
.
getSharedPreferences
(
FILE_KEY
,
Context
.
MODE_PRIVATE
)
;
SharedPreferences
prefs
=
magiskManager
.
prefs
;
Global
.
Data
.
repoMap
=
new
ValueSortedMap
<>();
magiskManager
.
repoMap
=
new
ValueSortedMap
<>();
Gson
gson
=
new
Gson
();
Gson
gson
=
new
Gson
();
String
jsonString
;
String
jsonString
;
...
@@ -88,7 +87,7 @@ public class ModuleHelper {
...
@@ -88,7 +87,7 @@ public class ModuleHelper {
// Making a request to main URL for repo info
// Making a request to main URL for repo info
jsonString
=
WebService
.
request
(
jsonString
=
WebService
.
request
(
context
.
getString
(
R
.
string
.
url_main
),
WebService
.
GET
,
null
,
header
,
false
);
magiskManager
.
getString
(
R
.
string
.
url_main
),
WebService
.
GET
,
null
,
header
,
false
);
if
(!
jsonString
.
isEmpty
())
{
if
(!
jsonString
.
isEmpty
())
{
try
{
try
{
...
@@ -115,13 +114,13 @@ public class ModuleHelper {
...
@@ -115,13 +114,13 @@ public class ModuleHelper {
try
{
try
{
if
(
repo
==
null
)
{
if
(
repo
==
null
)
{
Logger
.
dev
(
"ModuleHelper: Create new repo "
+
id
);
Logger
.
dev
(
"ModuleHelper: Create new repo "
+
id
);
repo
=
new
Repo
(
context
,
name
,
updatedDate
);
repo
=
new
Repo
(
magiskManager
,
name
,
updatedDate
);
}
else
{
}
else
{
Logger
.
dev
(
"ModuleHelper: Update cached repo "
+
id
);
Logger
.
dev
(
"ModuleHelper: Update cached repo "
+
id
);
repo
.
update
(
updatedDate
);
repo
.
update
(
updatedDate
);
}
}
if
(
repo
.
getId
()
!=
null
)
{
if
(
repo
.
getId
()
!=
null
)
{
Global
.
Data
.
repoMap
.
put
(
id
,
repo
);
magiskManager
.
repoMap
.
put
(
id
,
repo
);
}
}
}
catch
(
BaseModule
.
CacheModException
ignored
)
{}
}
catch
(
BaseModule
.
CacheModException
ignored
)
{}
}
}
...
@@ -131,50 +130,27 @@ public class ModuleHelper {
...
@@ -131,50 +130,27 @@ public class ModuleHelper {
}
else
{
}
else
{
// Use cached if no internet or no updates
// Use cached if no internet or no updates
Logger
.
dev
(
"ModuleHelper: No updates, use cached"
);
Logger
.
dev
(
"ModuleHelper: No updates, use cached"
);
Global
.
Data
.
repoMap
.
putAll
(
cached
);
magiskManager
.
repoMap
.
putAll
(
cached
);
}
}
prefs
.
edit
()
prefs
.
edit
()
.
putInt
(
VERSION_KEY
,
GSON_DB_VER
)
.
putInt
(
VERSION_KEY
,
GSON_DB_VER
)
.
putString
(
REPO_KEY
,
gson
.
toJson
(
Global
.
Data
.
repoMap
))
.
putString
(
REPO_KEY
,
gson
.
toJson
(
magiskManager
.
repoMap
))
.
putString
(
ETAG_KEY
,
etag
)
.
putString
(
ETAG_KEY
,
etag
)
.
apply
();
.
apply
();
Logger
.
dev
(
"ModuleHelper: Repo load done"
);
Logger
.
dev
(
"ModuleHelper: Repo load done"
);
}
}
public
static
void
getModuleList
(
List
<
Module
>
moduleList
)
{
public
static
void
clearRepoCache
(
MagiskManager
magiskManager
)
{
moduleList
.
clear
();
SharedPreferences
repoMap
=
magiskManager
.
getSharedPreferences
(
FILE_KEY
,
Context
.
MODE_PRIVATE
);
moduleList
.
addAll
(
Global
.
Data
.
moduleMap
.
values
());
}
public
static
void
getRepoLists
(
List
<
Repo
>
update
,
List
<
Repo
>
installed
,
List
<
Repo
>
others
)
{
update
.
clear
();
installed
.
clear
();
others
.
clear
();
for
(
Repo
repo
:
Global
.
Data
.
repoMap
.
values
())
{
Module
module
=
Global
.
Data
.
moduleMap
.
get
(
repo
.
getId
());
if
(
module
!=
null
)
{
if
(
repo
.
getVersionCode
()
>
module
.
getVersionCode
())
{
update
.
add
(
repo
);
}
else
{
installed
.
add
(
repo
);
}
}
else
{
others
.
add
(
repo
);
}
}
}
public
static
void
clearRepoCache
(
Context
context
)
{
SharedPreferences
repoMap
=
context
.
getSharedPreferences
(
FILE_KEY
,
Context
.
MODE_PRIVATE
);
repoMap
.
edit
()
repoMap
.
edit
()
.
remove
(
ETAG_KEY
)
.
remove
(
ETAG_KEY
)
.
remove
(
VERSION_KEY
)
.
remove
(
VERSION_KEY
)
.
apply
();
.
apply
();
Global
.
Events
.
repoLoadDone
.
isTriggered
=
false
;
magiskManager
.
repoLoadDone
.
isTriggered
=
false
;
new
Async
.
LoadRepos
(
context
).
exec
();
new
Async
.
LoadRepos
(
magiskManager
).
exec
();
Toast
.
makeText
(
context
,
R
.
string
.
repo_cache_cleared
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
magiskManager
,
R
.
string
.
repo_cache_cleared
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/receivers/BootReceiver.java
View file @
bef59695
...
@@ -7,7 +7,7 @@ import android.content.SharedPreferences;
...
@@ -7,7 +7,7 @@ import android.content.SharedPreferences;
import
android.preference.PreferenceManager
;
import
android.preference.PreferenceManager
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.
Global
;
import
com.topjohnwu.magisk.
MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
...
@@ -15,10 +15,11 @@ public class BootReceiver extends BroadcastReceiver {
...
@@ -15,10 +15,11 @@ public class BootReceiver extends BroadcastReceiver {
@Override
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
Global
.
initSuAccess
();
MagiskManager
magiskManager
=
(
MagiskManager
)
context
.
getApplicationContext
();
Global
.
updateMagiskInfo
();
magiskManager
.
initSuAccess
();
magiskManager
.
updateMagiskInfo
();
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
if
(
prefs
.
getBoolean
(
"magiskhide"
,
false
)
&&
!
Global
.
Info
.
disabled
&&
Global
.
Info
.
magiskVersion
>
10.3
)
{
if
(
prefs
.
getBoolean
(
"magiskhide"
,
false
)
&&
!
magiskManager
.
disabled
&&
magiskManager
.
magiskVersion
>
10.3
)
{
Toast
.
makeText
(
context
,
R
.
string
.
start_magiskhide
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
context
,
R
.
string
.
start_magiskhide
,
Toast
.
LENGTH_SHORT
).
show
();
new
Async
.
MagiskHide
(
true
).
enable
();
new
Async
.
MagiskHide
(
true
).
enable
();
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/receivers/MagiskDlReceiver.java
View file @
bef59695
...
@@ -2,7 +2,7 @@ package com.topjohnwu.magisk.receivers;
...
@@ -2,7 +2,7 @@ package com.topjohnwu.magisk.receivers;
import
android.net.Uri
;
import
android.net.Uri
;
import
com.topjohnwu.magisk.
Global
;
import
com.topjohnwu.magisk.
MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
...
@@ -56,7 +56,7 @@ public class MagiskDlReceiver extends DownloadReceiver {
...
@@ -56,7 +56,7 @@ public class MagiskDlReceiver extends DownloadReceiver {
@Override
@Override
protected
Void
doInBackground
(
Void
...
params
)
{
protected
Void
doInBackground
(
Void
...
params
)
{
Shell
.
su
(
"setprop magisk.version "
Shell
.
su
(
"setprop magisk.version "
+
String
.
valueOf
(
Global
.
Info
.
remoteMagiskVersion
));
+
String
.
valueOf
(
((
MagiskManager
)
mContext
.
getApplicationContext
())
.
remoteMagiskVersion
));
return
null
;
return
null
;
}
}
}.
exec
();
}.
exec
();
...
...
app/src/main/java/com/topjohnwu/magisk/superuser/RequestActivity.java
View file @
bef59695
...
@@ -2,11 +2,10 @@ package com.topjohnwu.magisk.superuser;
...
@@ -2,11 +2,10 @@ package com.topjohnwu.magisk.superuser;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.v7.app.AppCompatActivity
;
import
com.topjohnwu.magisk.
Global
;
import
com.topjohnwu.magisk.
components.Activity
;
public
class
RequestActivity
extends
A
ppCompatA
ctivity
{
public
class
RequestActivity
extends
Activity
{
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
@@ -18,7 +17,7 @@ public class RequestActivity extends AppCompatActivity {
...
@@ -18,7 +17,7 @@ public class RequestActivity extends AppCompatActivity {
return
;
return
;
}
}
Global
.
initSuConfigs
(
this
);
getTopApplication
().
initSuConfigs
(
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
intent
.
setClass
(
this
,
SuRequestActivity
.
class
);
intent
.
setClass
(
this
,
SuRequestActivity
.
class
);
startActivity
(
intent
);
startActivity
(
intent
);
...
...
app/src/main/java/com/topjohnwu/magisk/superuser/SuLogDatabaseHelper.java
View file @
bef59695
...
@@ -5,7 +5,7 @@ import android.database.Cursor;
...
@@ -5,7 +5,7 @@ import android.database.Cursor;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.database.sqlite.SQLiteOpenHelper
;
import
android.database.sqlite.SQLiteOpenHelper
;
import
com.topjohnwu.magisk.
Global
;
import
com.topjohnwu.magisk.
MagiskManager
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -15,8 +15,11 @@ public class SuLogDatabaseHelper extends SQLiteOpenHelper {
...
@@ -15,8 +15,11 @@ public class SuLogDatabaseHelper extends SQLiteOpenHelper {
private
static
final
int
DATABASE_VER
=
1
;
private
static
final
int
DATABASE_VER
=
1
;
private
static
final
String
TABLE_NAME
=
"logs"
;
private
static
final
String
TABLE_NAME
=
"logs"
;
private
MagiskManager
magiskManager
;
public
SuLogDatabaseHelper
(
Context
context
)
{
public
SuLogDatabaseHelper
(
Context
context
)
{
super
(
context
,
"sulog.db"
,
null
,
DATABASE_VER
);
super
(
context
,
"sulog.db"
,
null
,
DATABASE_VER
);
magiskManager
=
(
MagiskManager
)
context
.
getApplicationContext
();
}
}
@Override
@Override
...
@@ -57,7 +60,7 @@ public class SuLogDatabaseHelper extends SQLiteOpenHelper {
...
@@ -57,7 +60,7 @@ public class SuLogDatabaseHelper extends SQLiteOpenHelper {
SQLiteDatabase
db
=
getWritableDatabase
();
SQLiteDatabase
db
=
getWritableDatabase
();
// Clear outdated logs
// Clear outdated logs
db
.
delete
(
TABLE_NAME
,
"time < ?"
,
new
String
[]
{
String
.
valueOf
(
db
.
delete
(
TABLE_NAME
,
"time < ?"
,
new
String
[]
{
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
-
Global
.
Configs
.
suLogTimeout
*
86400
)
});
System
.
currentTimeMillis
()
/
1000
-
magiskManager
.
suLogTimeout
*
86400
)
});
try
(
Cursor
c
=
db
.
query
(
TABLE_NAME
,
null
,
selection
,
null
,
null
,
null
,
"time DESC"
))
{
try
(
Cursor
c
=
db
.
query
(
TABLE_NAME
,
null
,
selection
,
null
,
null
,
null
,
"time DESC"
))
{
while
(
c
.
moveToNext
())
while
(
c
.
moveToNext
())
ret
.
add
(
new
SuLogEntry
(
c
));
ret
.
add
(
new
SuLogEntry
(
c
));
...
...
app/src/main/java/com/topjohnwu/magisk/superuser/SuReceiver.java
View file @
bef59695
...
@@ -6,7 +6,7 @@ import android.content.Intent;
...
@@ -6,7 +6,7 @@ import android.content.Intent;
import
android.os.Process
;
import
android.os.Process
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.
Global
;
import
com.topjohnwu.magisk.
MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -23,6 +23,8 @@ public class SuReceiver extends BroadcastReceiver {
...
@@ -23,6 +23,8 @@ public class SuReceiver extends BroadcastReceiver {
String
command
,
action
;
String
command
,
action
;
Policy
policy
;
Policy
policy
;
MagiskManager
magiskManager
=
(
MagiskManager
)
context
.
getApplicationContext
();
if
(
intent
==
null
)
return
;
if
(
intent
==
null
)
return
;
fromUid
=
intent
.
getIntExtra
(
"from.uid"
,
-
1
);
fromUid
=
intent
.
getIntExtra
(
"from.uid"
,
-
1
);
...
@@ -40,7 +42,7 @@ public class SuReceiver extends BroadcastReceiver {
...
@@ -40,7 +42,7 @@ public class SuReceiver extends BroadcastReceiver {
return
;
return
;
}
}
Global
.
initSuConfigs
(
context
);
magiskManager
.
initSuConfigs
(
);
SuLogEntry
log
=
new
SuLogEntry
(
policy
);
SuLogEntry
log
=
new
SuLogEntry
(
policy
);
...
@@ -58,7 +60,7 @@ public class SuReceiver extends BroadcastReceiver {
...
@@ -58,7 +60,7 @@ public class SuReceiver extends BroadcastReceiver {
return
;
return
;
}
}
if
(
policy
.
notification
&&
Global
.
Configs
.
suNotificationType
==
TOAST
)
if
(
policy
.
notification
&&
magiskManager
.
suNotificationType
==
TOAST
)
Toast
.
makeText
(
context
,
message
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
context
,
message
,
Toast
.
LENGTH_SHORT
).
show
();
if
(
policy
.
logging
)
{
if
(
policy
.
logging
)
{
...
...
app/src/main/java/com/topjohnwu/magisk/superuser/SuRequestActivity.java
View file @
bef59695
...
@@ -8,7 +8,6 @@ import android.net.LocalSocketAddress;
...
@@ -8,7 +8,6 @@ import android.net.LocalSocketAddress;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.CountDownTimer
;
import
android.os.CountDownTimer
;
import
android.os.FileObserver
;
import
android.os.FileObserver
;
import
android.support.v7.app.AppCompatActivity
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.view.Window
;
import
android.view.Window
;
import
android.widget.ArrayAdapter
;
import
android.widget.ArrayAdapter
;
...
@@ -18,8 +17,9 @@ import android.widget.LinearLayout;
...
@@ -18,8 +17,9 @@ import android.widget.LinearLayout;
import
android.widget.Spinner
;
import
android.widget.Spinner
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.topjohnwu.magisk.
Global
;
import
com.topjohnwu.magisk.
MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
...
@@ -29,7 +29,7 @@ import java.io.IOException;
...
@@ -29,7 +29,7 @@ import java.io.IOException;
import
butterknife.BindView
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.ButterKnife
;
public
class
SuRequestActivity
extends
A
ppCompatA
ctivity
implements
CallbackHandler
.
EventListener
{
public
class
SuRequestActivity
extends
Activity
implements
CallbackHandler
.
EventListener
{
private
static
final
int
[]
timeoutList
=
{
0
,
-
1
,
10
,
20
,
30
,
60
};
private
static
final
int
[]
timeoutList
=
{
0
,
-
1
,
10
,
20
,
30
,
60
};
private
static
final
int
SU_PROTOCOL_PARAM_MAX
=
20
;
private
static
final
int
SU_PROTOCOL_PARAM_MAX
=
20
;
...
@@ -51,6 +51,7 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand
...
@@ -51,6 +51,7 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand
private
String
socketPath
;
private
String
socketPath
;
private
LocalSocket
socket
;
private
LocalSocket
socket
;
private
PackageManager
pm
;
private
PackageManager
pm
;
private
MagiskManager
magiskManager
;
private
int
uid
;
private
int
uid
;
private
Policy
policy
;
private
Policy
policy
;
...
@@ -64,6 +65,7 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand
...
@@ -64,6 +65,7 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand
supportRequestWindowFeature
(
Window
.
FEATURE_NO_TITLE
);
supportRequestWindowFeature
(
Window
.
FEATURE_NO_TITLE
);
pm
=
getPackageManager
();
pm
=
getPackageManager
();
magiskManager
=
getTopApplication
();
Intent
intent
=
getIntent
();
Intent
intent
=
getIntent
();
socketPath
=
intent
.
getStringExtra
(
"socket"
);
socketPath
=
intent
.
getStringExtra
(
"socket"
);
...
@@ -85,7 +87,7 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand
...
@@ -85,7 +87,7 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand
void
showRequest
()
{
void
showRequest
()
{
switch
(
Global
.
Configs
.
suResponseType
)
{
switch
(
magiskManager
.
suResponseType
)
{
case
AUTO_DENY:
case
AUTO_DENY:
handleAction
(
Policy
.
DENY
,
0
);
handleAction
(
Policy
.
DENY
,
0
);
return
;
return
;
...
@@ -108,7 +110,7 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand
...
@@ -108,7 +110,7 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand
adapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
adapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
timeout
.
setAdapter
(
adapter
);
timeout
.
setAdapter
(
adapter
);
timer
=
new
CountDownTimer
(
Global
.
Configs
.
suRequestTimeout
*
1000
,
1000
)
{
timer
=
new
CountDownTimer
(
magiskManager
.
suRequestTimeout
*
1000
,
1000
)
{
@Override
@Override
public
void
onTick
(
long
millisUntilFinished
)
{
public
void
onTick
(
long
millisUntilFinished
)
{
deny_btn
.
setText
(
getString
(
R
.
string
.
deny_with_str
,
"("
+
millisUntilFinished
/
1000
+
")"
));
deny_btn
.
setText
(
getString
(
R
.
string
.
deny_with_str
,
"("
+
millisUntilFinished
/
1000
+
")"
));
...
@@ -145,7 +147,7 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand
...
@@ -145,7 +147,7 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand
Policy
policy
=
(
Policy
)
event
.
getResult
();
Policy
policy
=
(
Policy
)
event
.
getResult
();
String
response
=
"socket:DENY"
;
String
response
=
"socket:DENY"
;
if
(
policy
!=
null
)
{
if
(
policy
!=
null
)
{
Global
.
Events
.
uidMap
.
remove
(
policy
.
uid
);
magiskManager
.
uidMap
.
remove
(
policy
.
uid
);
if
(
policy
.
policy
==
Policy
.
ALLOW
)
if
(
policy
.
policy
==
Policy
.
ALLOW
)
response
=
"socket:ALLOW"
;
response
=
"socket:ALLOW"
;
}
}
...
@@ -224,7 +226,7 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand
...
@@ -224,7 +226,7 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand
return
;
return
;
}
}
boolean
showRequest
=
false
;
boolean
showRequest
=
false
;
event
=
Global
.
Events
.
uidMap
.
get
(
uid
);
event
=
magiskManager
.
uidMap
.
get
(
uid
);
if
(
event
==
null
)
{
if
(
event
==
null
)
{
showRequest
=
true
;
showRequest
=
true
;
event
=
new
CallbackHandler
.
Event
()
{
event
=
new
CallbackHandler
.
Event
()
{
...
@@ -234,7 +236,7 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand
...
@@ -234,7 +236,7 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand
CallbackHandler
.
unRegister
(
this
);
CallbackHandler
.
unRegister
(
this
);
}
}
};
};
Global
.
Events
.
uidMap
.
put
(
uid
,
event
);
magiskManager
.
uidMap
.
put
(
uid
,
event
);
}
}
CallbackHandler
.
register
(
event
,
self
);
CallbackHandler
.
register
(
event
,
self
);
try
{
try
{
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
View file @
bef59695
This diff is collapsed.
Click to expand it.
app/src/main/java/com/topjohnwu/magisk/utils/Logger.java
View file @
bef59695
...
@@ -2,7 +2,7 @@ package com.topjohnwu.magisk.utils;
...
@@ -2,7 +2,7 @@ package com.topjohnwu.magisk.utils;
import
android.util.Log
;
import
android.util.Log
;
import
com.topjohnwu.magisk.
Global
;
import
com.topjohnwu.magisk.
MagiskManager
;
public
class
Logger
{
public
class
Logger
{
...
@@ -17,7 +17,7 @@ public class Logger {
...
@@ -17,7 +17,7 @@ public class Logger {
}
}
public
static
void
dev
(
String
msg
,
Object
...
args
)
{
public
static
void
dev
(
String
msg
,
Object
...
args
)
{
if
(
Global
.
Configs
.
devLogging
)
{
if
(
MagiskManager
.
devLogging
)
{
if
(
args
.
length
==
1
&&
args
[
0
]
instanceof
Throwable
)
{
if
(
args
.
length
==
1
&&
args
[
0
]
instanceof
Throwable
)
{
Log
.
d
(
TAG
,
"DEV: "
+
msg
,
(
Throwable
)
args
[
0
]);
Log
.
d
(
TAG
,
"DEV: "
+
msg
,
(
Throwable
)
args
[
0
]);
}
else
{
}
else
{
...
@@ -27,13 +27,13 @@ public class Logger {
...
@@ -27,13 +27,13 @@ public class Logger {
}
}
public
static
void
dev
(
String
msg
)
{
public
static
void
dev
(
String
msg
)
{
if
(
Global
.
Configs
.
devLogging
)
{
if
(
MagiskManager
.
devLogging
)
{
Log
.
d
(
TAG
,
"DEBUG: "
+
msg
);
Log
.
d
(
TAG
,
"DEBUG: "
+
msg
);
}
}
}
}
public
static
void
shell
(
boolean
root
,
String
msg
)
{
public
static
void
shell
(
boolean
root
,
String
msg
)
{
if
(
Global
.
Configs
.
shellLogging
)
{
if
(
MagiskManager
.
shellLogging
)
{
Log
.
d
(
root
?
"SU"
:
"SH"
,
msg
);
Log
.
d
(
root
?
"SU"
:
"SH"
,
msg
);
}
}
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
View file @
bef59695
...
@@ -13,7 +13,7 @@ import android.support.v4.app.ActivityCompat;
...
@@ -13,7 +13,7 @@ import android.support.v4.app.ActivityCompat;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.
Global
;
import
com.topjohnwu.magisk.
MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
...
@@ -115,7 +115,7 @@ public class Utils {
...
@@ -115,7 +115,7 @@ public class Utils {
}
}
public
static
AlertDialog
.
Builder
getAlertDialogBuilder
(
Context
context
)
{
public
static
AlertDialog
.
Builder
getAlertDialogBuilder
(
Context
context
)
{
if
(
Global
.
Configs
.
isDarkTheme
)
{
if
(
((
MagiskManager
)
context
.
getApplicationContext
())
.
isDarkTheme
)
{
return
new
AlertDialog
.
Builder
(
context
,
R
.
style
.
AlertDialog_dh
);
return
new
AlertDialog
.
Builder
(
context
,
R
.
style
.
AlertDialog_dh
);
}
else
{
}
else
{
return
new
AlertDialog
.
Builder
(
context
);
return
new
AlertDialog
.
Builder
(
context
);
...
...
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