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
51b22d1a
Commit
51b22d1a
authored
Feb 06, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make callback events non-static
parent
bef59695
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
116 additions
and
138 deletions
+116
-138
InstallFragment.java
app/src/main/java/com/topjohnwu/magisk/InstallFragment.java
+5
-5
MagiskHideFragment.java
...rc/main/java/com/topjohnwu/magisk/MagiskHideFragment.java
+8
-8
MagiskManager.java
app/src/main/java/com/topjohnwu/magisk/MagiskManager.java
+10
-9
MainActivity.java
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
+11
-11
ModulesFragment.java
app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java
+5
-5
ReposFragment.java
app/src/main/java/com/topjohnwu/magisk/ReposFragment.java
+5
-5
StatusFragment.java
app/src/main/java/com/topjohnwu/magisk/StatusFragment.java
+12
-13
SuRequestActivity.java
...ava/com/topjohnwu/magisk/superuser/SuRequestActivity.java
+13
-15
CallbackEvent.java
...c/main/java/com/topjohnwu/magisk/utils/CallbackEvent.java
+47
-0
CallbackHandler.java
...main/java/com/topjohnwu/magisk/utils/CallbackHandler.java
+0
-67
No files found.
app/src/main/java/com/topjohnwu/magisk/InstallFragment.java
View file @
51b22d1a
...
@@ -18,7 +18,7 @@ import android.widget.TextView;
...
@@ -18,7 +18,7 @@ import android.widget.TextView;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.receivers.MagiskDlReceiver
;
import
com.topjohnwu.magisk.receivers.MagiskDlReceiver
;
import
com.topjohnwu.magisk.utils.Callback
Handler
;
import
com.topjohnwu.magisk.utils.Callback
Event
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
...
@@ -33,7 +33,7 @@ import butterknife.BindView;
...
@@ -33,7 +33,7 @@ import butterknife.BindView;
import
butterknife.ButterKnife
;
import
butterknife.ButterKnife
;
import
butterknife.Unbinder
;
import
butterknife.Unbinder
;
public
class
InstallFragment
extends
Fragment
implements
Callback
Handler
.
EventListener
{
public
class
InstallFragment
extends
Fragment
implements
Callback
Event
.
Listener
<
Void
>
{
private
static
final
String
UNINSTALLER
=
"magisk_uninstaller.sh"
;
private
static
final
String
UNINSTALLER
=
"magisk_uninstaller.sh"
;
...
@@ -132,7 +132,7 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
...
@@ -132,7 +132,7 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
}
}
@Override
@Override
public
void
onTrigger
(
Callback
Handler
.
Event
event
)
{
public
void
onTrigger
(
Callback
Event
<
Void
>
event
)
{
updateUI
();
updateUI
();
}
}
...
@@ -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
(
getApplication
().
blockDetectionDone
,
this
);
getApplication
().
blockDetectionDone
.
register
(
this
);
}
}
@Override
@Override
public
void
onStop
()
{
public
void
onStop
()
{
CallbackHandler
.
unRegister
(
getApplication
().
blockDetectionDone
,
this
);
getApplication
().
blockDetectionDone
.
unRegister
(
this
);
super
.
onStop
();
super
.
onStop
();
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java
View file @
51b22d1a
...
@@ -17,14 +17,14 @@ import android.widget.SearchView;
...
@@ -17,14 +17,14 @@ 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.components.Fragment
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Callback
Handler
;
import
com.topjohnwu.magisk.utils.Callback
Event
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Logger
;
import
butterknife.BindView
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.ButterKnife
;
import
butterknife.Unbinder
;
import
butterknife.Unbinder
;
public
class
MagiskHideFragment
extends
Fragment
implements
Callback
Handler
.
EventListener
{
public
class
MagiskHideFragment
extends
Fragment
implements
Callback
Event
.
Listener
<
Void
>
{
private
Unbinder
unbinder
;
private
Unbinder
unbinder
;
@BindView
(
R
.
id
.
swipeRefreshLayout
)
SwipeRefreshLayout
mSwipeRefreshLayout
;
@BindView
(
R
.
id
.
swipeRefreshLayout
)
SwipeRefreshLayout
mSwipeRefreshLayout
;
...
@@ -71,6 +71,9 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
...
@@ -71,6 +71,9 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
}
}
};
};
if
(
getApplication
().
packageLoadDone
.
isTriggered
)
onTrigger
(
getApplication
().
packageLoadDone
);
return
view
;
return
view
;
}
}
...
@@ -85,15 +88,12 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
...
@@ -85,15 +88,12 @@ 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
(
getApplication
().
packageLoadDone
,
this
);
getApplication
().
packageLoadDone
.
register
(
this
);
if
(
getApplication
().
packageLoadDone
.
isTriggered
)
{
onTrigger
(
getApplication
().
packageLoadDone
);
}
}
}
@Override
@Override
public
void
onStop
()
{
public
void
onStop
()
{
CallbackHandler
.
unRegister
(
getApplication
().
packageLoadDone
,
this
);
getApplication
().
packageLoadDone
.
unRegister
(
this
);
super
.
onStop
();
super
.
onStop
();
}
}
...
@@ -104,7 +104,7 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
...
@@ -104,7 +104,7 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
}
}
@Override
@Override
public
void
onTrigger
(
Callback
Handler
.
Event
event
)
{
public
void
onTrigger
(
Callback
Event
<
Void
>
event
)
{
Logger
.
dev
(
"MagiskHideFragment: UI refresh"
);
Logger
.
dev
(
"MagiskHideFragment: UI refresh"
);
appAdapter
.
setLists
(
getApplication
().
appList
,
getApplication
().
magiskHideList
);
appAdapter
.
setLists
(
getApplication
().
appList
,
getApplication
().
magiskHideList
);
mSwipeRefreshLayout
.
setRefreshing
(
false
);
mSwipeRefreshLayout
.
setRefreshing
(
false
);
...
...
app/src/main/java/com/topjohnwu/magisk/MagiskManager.java
View file @
51b22d1a
...
@@ -8,7 +8,8 @@ import android.util.SparseArray;
...
@@ -8,7 +8,8 @@ import android.util.SparseArray;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.module.Repo
;
import
com.topjohnwu.magisk.utils.CallbackHandler
;
import
com.topjohnwu.magisk.superuser.Policy
;
import
com.topjohnwu.magisk.utils.CallbackEvent
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.ValueSortedMap
;
import
com.topjohnwu.magisk.utils.ValueSortedMap
;
...
@@ -21,13 +22,14 @@ public class MagiskManager extends Application {
...
@@ -21,13 +22,14 @@ 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"
;
// Events
// Events
public
final
CallbackHandler
.
Event
blockDetectionDone
=
new
CallbackHandler
.
Event
();
public
final
CallbackEvent
<
Void
>
blockDetectionDone
=
new
CallbackEvent
<>();
public
final
CallbackHandler
.
Event
packageLoadDone
=
new
CallbackHandler
.
Event
();
public
final
CallbackEvent
<
Void
>
packageLoadDone
=
new
CallbackEvent
<>();
public
final
CallbackHandler
.
Event
reloadMainActivity
=
new
CallbackHandler
.
Event
();
public
final
CallbackEvent
<
Void
>
reloadMainActivity
=
new
CallbackEvent
<>();
public
final
CallbackHandler
.
Event
moduleLoadDone
=
new
CallbackHandler
.
Event
();
public
final
CallbackEvent
<
Void
>
moduleLoadDone
=
new
CallbackEvent
<>();
public
final
CallbackHandler
.
Event
repoLoadDone
=
new
CallbackHandler
.
Event
();
public
final
CallbackEvent
<
Void
>
repoLoadDone
=
new
CallbackEvent
<>();
public
final
CallbackHandler
.
Event
updateCheckDone
=
new
CallbackHandler
.
Event
();
public
final
CallbackEvent
<
Void
>
updateCheckDone
=
new
CallbackEvent
<>();
public
final
CallbackHandler
.
Event
safetyNetDone
=
new
CallbackHandler
.
Event
();
public
final
CallbackEvent
<
Void
>
safetyNetDone
=
new
CallbackEvent
<>();
public
SparseArray
<
CallbackEvent
<
Policy
>>
uidMap
=
new
SparseArray
<>();
// Info
// Info
public
double
magiskVersion
;
public
double
magiskVersion
;
...
@@ -47,7 +49,6 @@ public class MagiskManager extends Application {
...
@@ -47,7 +49,6 @@ public class MagiskManager extends Application {
public
List
<
String
>
blockList
;
public
List
<
String
>
blockList
;
public
List
<
ApplicationInfo
>
appList
;
public
List
<
ApplicationInfo
>
appList
;
public
List
<
String
>
magiskHideList
;
public
List
<
String
>
magiskHideList
;
public
SparseArray
<
CallbackHandler
.
Event
>
uidMap
=
new
SparseArray
<>();
// Configurations
// Configurations
public
static
boolean
shellLogging
;
public
static
boolean
shellLogging
;
...
...
app/src/main/java/com/topjohnwu/magisk/MainActivity.java
View file @
51b22d1a
...
@@ -21,14 +21,14 @@ import android.view.MenuItem;
...
@@ -21,14 +21,14 @@ import android.view.MenuItem;
import
android.view.View
;
import
android.view.View
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.components.Activity
;
import
com.topjohnwu.magisk.utils.Callback
Handler
;
import
com.topjohnwu.magisk.utils.Callback
Event
;
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
Activity
public
class
MainActivity
extends
Activity
implements
NavigationView
.
OnNavigationItemSelectedListener
,
Callback
Handler
.
EventListener
{
implements
NavigationView
.
OnNavigationItemSelectedListener
,
Callback
Event
.
Listener
<
Void
>
{
private
final
Handler
mDrawerHandler
=
new
Handler
();
private
final
Handler
mDrawerHandler
=
new
Handler
();
private
SharedPreferences
prefs
;
private
SharedPreferences
prefs
;
...
@@ -79,28 +79,28 @@ public class MainActivity extends Activity
...
@@ -79,28 +79,28 @@ public class MainActivity extends Activity
navigate
(
R
.
id
.
status
);
navigate
(
R
.
id
.
status
);
navigationView
.
setNavigationItemSelectedListener
(
this
);
navigationView
.
setNavigationItemSelectedListener
(
this
);
CallbackHandler
.
register
(
getTopApplication
().
reloadMainActivity
,
this
);
getTopApplication
().
reloadMainActivity
.
register
(
this
);
}
}
@Override
@Override
protected
void
onResume
()
{
protected
void
onResume
()
{
super
.
onResume
();
super
.
onResume
();
CallbackHandler
.
register
(
getTopApplication
().
updateCheckDone
,
this
);
getTopApplication
().
updateCheckDone
.
register
(
this
);
if
(
getTopApplication
().
updateCheckDone
.
isTriggered
)
//
if (getTopApplication().updateCheckDone.isTriggered)
onTrigger
(
getTopApplication
().
updateCheckDone
);
//
onTrigger(getTopApplication().updateCheckDone);
checkHideSection
();
checkHideSection
();
}
}
@Override
@Override
protected
void
onPause
()
{
protected
void
onPause
()
{
CallbackHandler
.
unRegister
(
getTopApplication
().
updateCheckDone
,
this
);
getTopApplication
().
updateCheckDone
.
unRegister
(
this
);
super
.
onPause
();
super
.
onPause
();
}
}
@Override
@Override
protected
void
onDestroy
()
{
protected
void
onDestroy
()
{
CallbackHandler
.
unRegister
(
getTopApplication
().
reloadMainActivity
,
this
);
getTopApplication
().
reloadMainActivity
.
unRegister
(
this
);
super
.
onDestroy
();
super
.
onDestroy
();
}
}
...
@@ -121,11 +121,11 @@ public class MainActivity extends Activity
...
@@ -121,11 +121,11 @@ public class MainActivity extends Activity
}
}
@Override
@Override
public
void
onTrigger
(
Callback
Handler
.
Event
event
)
{
public
void
onTrigger
(
Callback
Event
<
Void
>
event
)
{
if
(
event
==
getTopApplication
().
updateCheckDone
)
{
if
(
event
==
getTopApplication
().
updateCheckDone
)
{
Menu
menu
=
navigationView
.
getMenu
();
Menu
menu
=
navigationView
.
getMenu
();
menu
.
findItem
(
R
.
id
.
install
).
setVisible
(
getTopApplication
().
remoteMagiskVersion
>
0
&&
menu
.
findItem
(
R
.
id
.
install
).
setVisible
(
Shell
.
rootAccess
());
getTopApplication
().
remoteMagiskVersion
>
0
&&
Shell
.
rootAccess
());
}
else
if
(
event
==
getTopApplication
().
reloadMainActivity
)
{
}
else
if
(
event
==
getTopApplication
().
reloadMainActivity
)
{
recreate
();
recreate
();
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java
View file @
51b22d1a
...
@@ -17,7 +17,7 @@ import com.topjohnwu.magisk.adapters.ModulesAdapter;
...
@@ -17,7 +17,7 @@ import com.topjohnwu.magisk.adapters.ModulesAdapter;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Callback
Handler
;
import
com.topjohnwu.magisk.utils.Callback
Event
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Logger
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -27,7 +27,7 @@ import butterknife.BindView;
...
@@ -27,7 +27,7 @@ import butterknife.BindView;
import
butterknife.ButterKnife
;
import
butterknife.ButterKnife
;
import
butterknife.Unbinder
;
import
butterknife.Unbinder
;
public
class
ModulesFragment
extends
Fragment
implements
Callback
Handler
.
EventListener
{
public
class
ModulesFragment
extends
Fragment
implements
Callback
Event
.
Listener
<
Void
>
{
private
static
final
int
FETCH_ZIP_CODE
=
2
;
private
static
final
int
FETCH_ZIP_CODE
=
2
;
...
@@ -76,7 +76,7 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi
...
@@ -76,7 +76,7 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi
}
}
@Override
@Override
public
void
onTrigger
(
Callback
Handler
.
Event
event
)
{
public
void
onTrigger
(
Callback
Event
<
Void
>
event
)
{
Logger
.
dev
(
"ModulesFragment: UI refresh triggered"
);
Logger
.
dev
(
"ModulesFragment: UI refresh triggered"
);
updateUI
();
updateUI
();
}
}
...
@@ -94,13 +94,13 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi
...
@@ -94,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
(
getApplication
().
moduleLoadDone
,
this
);
getApplication
().
moduleLoadDone
.
register
(
this
);
getActivity
().
setTitle
(
R
.
string
.
modules
);
getActivity
().
setTitle
(
R
.
string
.
modules
);
}
}
@Override
@Override
public
void
onStop
()
{
public
void
onStop
()
{
CallbackHandler
.
unRegister
(
getApplication
().
moduleLoadDone
,
this
);
getApplication
().
moduleLoadDone
.
unRegister
(
this
);
super
.
onStop
();
super
.
onStop
();
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/ReposFragment.java
View file @
51b22d1a
...
@@ -19,7 +19,7 @@ import com.topjohnwu.magisk.components.Fragment;
...
@@ -19,7 +19,7 @@ import com.topjohnwu.magisk.components.Fragment;
import
com.topjohnwu.magisk.module.Module
;
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.Callback
Handler
;
import
com.topjohnwu.magisk.utils.Callback
Event
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Logger
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -29,7 +29,7 @@ import butterknife.BindView;
...
@@ -29,7 +29,7 @@ import butterknife.BindView;
import
butterknife.ButterKnife
;
import
butterknife.ButterKnife
;
import
butterknife.Unbinder
;
import
butterknife.Unbinder
;
public
class
ReposFragment
extends
Fragment
implements
Callback
Handler
.
EventListener
{
public
class
ReposFragment
extends
Fragment
implements
Callback
Event
.
Listener
<
Void
>
{
private
Unbinder
unbinder
;
private
Unbinder
unbinder
;
@BindView
(
R
.
id
.
recyclerView
)
RecyclerView
recyclerView
;
@BindView
(
R
.
id
.
recyclerView
)
RecyclerView
recyclerView
;
...
@@ -93,7 +93,7 @@ public class ReposFragment extends Fragment implements CallbackHandler.EventList
...
@@ -93,7 +93,7 @@ public class ReposFragment extends Fragment implements CallbackHandler.EventList
}
}
@Override
@Override
public
void
onTrigger
(
Callback
Handler
.
Event
event
)
{
public
void
onTrigger
(
Callback
Event
<
Void
>
event
)
{
Logger
.
dev
(
"ReposFragment: UI refresh triggered"
);
Logger
.
dev
(
"ReposFragment: UI refresh triggered"
);
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
(
getApplication
().
repoLoadDone
,
this
);
getApplication
().
repoLoadDone
.
register
(
this
);
getActivity
().
setTitle
(
R
.
string
.
downloads
);
getActivity
().
setTitle
(
R
.
string
.
downloads
);
}
}
@Override
@Override
public
void
onStop
()
{
public
void
onStop
()
{
CallbackHandler
.
unRegister
(
getApplication
().
repoLoadDone
,
this
);
getApplication
().
repoLoadDone
.
unRegister
(
this
);
super
.
onStop
();
super
.
onStop
();
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/StatusFragment.java
View file @
51b22d1a
...
@@ -16,7 +16,7 @@ import android.widget.TextView;
...
@@ -16,7 +16,7 @@ import android.widget.TextView;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.components.Fragment
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Callback
Handler
;
import
com.topjohnwu.magisk.utils.Callback
Event
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Shell
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
...
@@ -26,7 +26,7 @@ import butterknife.BindView;
...
@@ -26,7 +26,7 @@ import butterknife.BindView;
import
butterknife.ButterKnife
;
import
butterknife.ButterKnife
;
import
butterknife.Unbinder
;
import
butterknife.Unbinder
;
public
class
StatusFragment
extends
Fragment
implements
Callback
Handler
.
EventListener
{
public
class
StatusFragment
extends
Fragment
implements
Callback
Event
.
Listener
<
Void
>
{
private
static
boolean
noDialog
=
false
;
private
static
boolean
noDialog
=
false
;
...
@@ -115,11 +115,16 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
...
@@ -115,11 +115,16 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
updateUI
();
updateUI
();
if
(
getApplication
().
updateCheckDone
.
isTriggered
)
updateCheckUI
();
if
(
getApplication
().
safetyNetDone
.
isTriggered
)
updateSafetyNetUI
();
return
v
;
return
v
;
}
}
@Override
@Override
public
void
onTrigger
(
Callback
Handler
.
Event
event
)
{
public
void
onTrigger
(
Callback
Event
<
Void
>
event
)
{
if
(
event
==
getApplication
().
updateCheckDone
)
{
if
(
event
==
getApplication
().
updateCheckDone
)
{
Logger
.
dev
(
"StatusFragment: Update Check UI refresh triggered"
);
Logger
.
dev
(
"StatusFragment: Update Check UI refresh triggered"
);
updateCheckUI
();
updateCheckUI
();
...
@@ -132,21 +137,15 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
...
@@ -132,21 +137,15 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
@Override
@Override
public
void
onStart
()
{
public
void
onStart
()
{
super
.
onStart
();
super
.
onStart
();
CallbackHandler
.
register
(
getApplication
().
updateCheckDone
,
this
);
getApplication
().
updateCheckDone
.
register
(
this
);
CallbackHandler
.
register
(
getApplication
().
safetyNetDone
,
this
);
getApplication
().
safetyNetDone
.
register
(
this
);
if
(
getApplication
().
updateCheckDone
.
isTriggered
)
{
updateCheckUI
();
}
if
(
getApplication
().
safetyNetDone
.
isTriggered
)
{
updateSafetyNetUI
();
}
getActivity
().
setTitle
(
R
.
string
.
status
);
getActivity
().
setTitle
(
R
.
string
.
status
);
}
}
@Override
@Override
public
void
onStop
()
{
public
void
onStop
()
{
CallbackHandler
.
unRegister
(
getApplication
().
updateCheckDone
,
this
);
getApplication
().
updateCheckDone
.
unRegister
(
this
);
CallbackHandler
.
unRegister
(
getApplication
().
safetyNetDone
,
this
);
getApplication
().
safetyNetDone
.
unRegister
(
this
);
super
.
onStop
();
super
.
onStop
();
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/superuser/SuRequestActivity.java
View file @
51b22d1a
...
@@ -21,7 +21,7 @@ import com.topjohnwu.magisk.MagiskManager;
...
@@ -21,7 +21,7 @@ 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.components.Activity
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Callback
Handler
;
import
com.topjohnwu.magisk.utils.Callback
Event
;
import
java.io.DataInputStream
;
import
java.io.DataInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -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
Activity
implements
Callback
Handler
.
EventListener
{
public
class
SuRequestActivity
extends
Activity
implements
Callback
Event
.
Listener
<
Policy
>
{
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
;
...
@@ -56,8 +56,8 @@ public class SuRequestActivity extends Activity implements CallbackHandler.Event
...
@@ -56,8 +56,8 @@ public class SuRequestActivity extends Activity implements CallbackHandler.Event
private
int
uid
;
private
int
uid
;
private
Policy
policy
;
private
Policy
policy
;
private
CountDownTimer
timer
;
private
CountDownTimer
timer
;
private
Callback
Handler
.
EventListener
self
;
private
Callback
Event
.
Listener
<
Policy
>
self
;
private
Callback
Handler
.
Event
event
=
null
;
private
Callback
Event
<
Policy
>
event
=
null
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
@@ -143,14 +143,11 @@ public class SuRequestActivity extends Activity implements CallbackHandler.Event
...
@@ -143,14 +143,11 @@ public class SuRequestActivity extends Activity implements CallbackHandler.Event
}
}
@Override
@Override
public
void
onTrigger
(
Callback
Handler
.
Event
event
)
{
public
void
onTrigger
(
Callback
Event
<
Policy
>
event
)
{
Policy
policy
=
(
Policy
)
event
.
getResult
();
Policy
policy
=
event
.
getResult
();
String
response
=
"socket:DENY"
;
String
response
=
"socket:DENY"
;
if
(
policy
!=
null
)
{
if
(
policy
!=
null
&&
policy
.
policy
==
Policy
.
ALLOW
)
magiskManager
.
uidMap
.
remove
(
policy
.
uid
);
response
=
"socket:ALLOW"
;
if
(
policy
.
policy
==
Policy
.
ALLOW
)
response
=
"socket:ALLOW"
;
}
try
{
try
{
socket
.
getOutputStream
().
write
((
response
).
getBytes
());
socket
.
getOutputStream
().
write
((
response
).
getBytes
());
}
catch
(
Exception
ignored
)
{}
}
catch
(
Exception
ignored
)
{}
...
@@ -229,16 +226,17 @@ public class SuRequestActivity extends Activity implements CallbackHandler.Event
...
@@ -229,16 +226,17 @@ public class SuRequestActivity extends Activity implements CallbackHandler.Event
event
=
magiskManager
.
uidMap
.
get
(
uid
);
event
=
magiskManager
.
uidMap
.
get
(
uid
);
if
(
event
==
null
)
{
if
(
event
==
null
)
{
showRequest
=
true
;
showRequest
=
true
;
event
=
new
Callback
Handler
.
Event
()
{
event
=
new
Callback
Event
<
Policy
>
()
{
@Override
@Override
public
void
trigger
(
Object
result
)
{
public
void
trigger
(
Policy
result
)
{
super
.
trigger
(
result
);
super
.
trigger
(
result
);
CallbackHandler
.
unRegister
(
this
);
unRegister
();
magiskManager
.
uidMap
.
remove
(
uid
);
}
}
};
};
magiskManager
.
uidMap
.
put
(
uid
,
event
);
magiskManager
.
uidMap
.
put
(
uid
,
event
);
}
}
CallbackHandler
.
register
(
event
,
self
);
event
.
register
(
self
);
try
{
try
{
if
(
showRequest
)
{
if
(
showRequest
)
{
policy
=
new
Policy
(
uid
,
pm
);
policy
=
new
Policy
(
uid
,
pm
);
...
...
app/src/main/java/com/topjohnwu/magisk/utils/CallbackEvent.java
0 → 100644
View file @
51b22d1a
package
com
.
topjohnwu
.
magisk
.
utils
;
import
java.util.HashSet
;
import
java.util.Set
;
public
class
CallbackEvent
<
Result
>
{
public
boolean
isTriggered
=
false
;
private
Result
result
;
private
Set
<
Listener
<
Result
>>
listeners
;
public
void
register
(
Listener
<
Result
>
l
)
{
if
(
listeners
==
null
)
listeners
=
new
HashSet
<>();
listeners
.
add
(
l
);
}
public
void
unRegister
()
{
listeners
=
null
;
}
public
void
unRegister
(
Listener
<
Result
>
l
)
{
if
(
listeners
!=
null
)
listeners
.
remove
(
l
);
}
public
void
trigger
()
{
trigger
(
null
);
}
public
void
trigger
(
Result
r
)
{
result
=
r
;
isTriggered
=
true
;
if
(
listeners
!=
null
)
{
for
(
Listener
<
Result
>
listener
:
listeners
)
listener
.
onTrigger
(
this
);
}
}
public
Result
getResult
()
{
return
result
;
}
public
interface
Listener
<
R
>
{
void
onTrigger
(
CallbackEvent
<
R
>
event
);
}
}
app/src/main/java/com/topjohnwu/magisk/utils/CallbackHandler.java
deleted
100644 → 0
View file @
bef59695
package
com
.
topjohnwu
.
magisk
.
utils
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
public
class
CallbackHandler
{
private
static
Map
<
Event
,
Set
<
EventListener
>>
listeners
=
new
HashMap
<>();
public
static
void
register
(
Event
event
,
EventListener
listener
)
{
Set
<
EventListener
>
list
=
listeners
.
get
(
event
);
if
(
list
==
null
)
{
list
=
new
HashSet
<>();
listeners
.
put
(
event
,
list
);
}
list
.
add
(
listener
);
}
public
static
void
unRegister
(
Event
event
)
{
Set
<
EventListener
>
list
=
listeners
.
remove
(
event
);
if
(
list
!=
null
)
{
list
.
clear
();
}
}
public
static
void
unRegister
(
Event
event
,
EventListener
listener
)
{
Set
<
EventListener
>
list
=
listeners
.
get
(
event
);
if
(
list
!=
null
)
{
list
.
remove
(
listener
);
}
}
private
static
void
triggerCallback
(
Event
event
)
{
Set
<
EventListener
>
list
=
listeners
.
get
(
event
);
if
(
list
!=
null
)
{
for
(
EventListener
listener
:
list
)
{
listener
.
onTrigger
(
event
);
}
}
}
public
static
class
Event
{
public
boolean
isTriggered
=
false
;
private
Object
result
;
public
void
trigger
()
{
trigger
(
null
);
}
public
void
trigger
(
Object
result
)
{
this
.
result
=
result
;
isTriggered
=
true
;
triggerCallback
(
this
);
}
public
Object
getResult
()
{
return
result
;
}
}
public
interface
EventListener
{
void
onTrigger
(
Event
event
);
}
}
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