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
aababe1a
Commit
aababe1a
authored
Nov 08, 2016
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Officially drop Cache Modules
parent
436b0624
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
56 deletions
+53
-56
ModulesAdapter.java
...in/java/com/topjohnwu/magisk/adapters/ModulesAdapter.java
+13
-15
ReposAdapter.java
...main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java
+1
-5
BaseModule.java
...src/main/java/com/topjohnwu/magisk/module/BaseModule.java
+15
-11
Module.java
app/src/main/java/com/topjohnwu/magisk/module/Module.java
+1
-1
Repo.java
app/src/main/java/com/topjohnwu/magisk/module/Repo.java
+5
-3
ModuleHelper.java
...rc/main/java/com/topjohnwu/magisk/utils/ModuleHelper.java
+18
-21
No files found.
app/src/main/java/com/topjohnwu/magisk/adapters/ModulesAdapter.java
View file @
aababe1a
...
...
@@ -15,6 +15,7 @@ import android.widget.TextView;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Shell
;
import
java.util.List
;
...
...
@@ -43,11 +44,7 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
@Override
public
void
onBindViewHolder
(
final
ViewHolder
holder
,
int
position
)
{
final
Module
module
=
mList
.
get
(
position
);
if
(
module
.
isCache
())
{
holder
.
title
.
setText
(
"[Cache] "
+
module
.
getName
());
}
else
{
holder
.
title
.
setText
(
module
.
getName
());
}
holder
.
title
.
setText
(
module
.
getName
());
String
author
=
module
.
getAuthor
();
String
versionName
=
module
.
getVersion
();
String
description
=
module
.
getDescription
();
...
...
@@ -62,9 +59,10 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
}
holder
.
checkBox
.
setChecked
(
module
.
isEnabled
());
holder
.
checkBox
.
setOnCheckedChangeListener
((
compoundButton
,
isChecked
)
->
{
if
(
isChecked
)
{
new
AsyncTask
<
Void
,
Void
,
Void
>()
{
holder
.
checkBox
.
setOnClickListener
((
v
)
->
{
CheckBox
checkBox
=
(
CheckBox
)
v
;
if
(
checkBox
.
isChecked
())
{
new
Async
.
RootTask
<
Void
,
Void
,
Void
>()
{
@Override
protected
Void
doInBackground
(
Void
...
voids
)
{
module
.
removeDisableFile
();
...
...
@@ -75,9 +73,9 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
protected
void
onPostExecute
(
Void
v
)
{
Snackbar
.
make
(
mView
,
R
.
string
.
disable_file_removed
,
Snackbar
.
LENGTH_SHORT
).
show
();
}
}.
exec
uteOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
}.
exec
(
);
}
else
{
new
AsyncTask
<
Void
,
Void
,
Void
>()
{
new
Async
.
Root
Task
<
Void
,
Void
,
Void
>()
{
@Override
protected
Void
doInBackground
(
Void
...
voids
)
{
module
.
createDisableFile
();
...
...
@@ -88,13 +86,13 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
protected
void
onPostExecute
(
Void
v
)
{
Snackbar
.
make
(
mView
,
R
.
string
.
disable_file_created
,
Snackbar
.
LENGTH_SHORT
).
show
();
}
}.
exec
uteOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
}.
exec
(
);
}
});
holder
.
delete
.
setOnClickListener
(
v
->
{
if
(
module
.
willBeRemoved
())
{
new
AsyncTask
<
Void
,
Void
,
Void
>()
{
new
Async
.
Root
Task
<
Void
,
Void
,
Void
>()
{
@Override
protected
Void
doInBackground
(
Void
...
voids
)
{
module
.
deleteRemoveFile
();
...
...
@@ -106,9 +104,9 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
Snackbar
.
make
(
mView
,
R
.
string
.
remove_file_deleted
,
Snackbar
.
LENGTH_SHORT
).
show
();
updateDeleteButton
(
holder
,
module
);
}
}.
exec
uteOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
}.
exec
(
);
}
else
{
new
AsyncTask
<
Void
,
Void
,
Void
>()
{
new
Async
.
Root
Task
<
Void
,
Void
,
Void
>()
{
@Override
protected
Void
doInBackground
(
Void
...
voids
)
{
module
.
createRemoveFile
();
...
...
@@ -120,7 +118,7 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
Snackbar
.
make
(
mView
,
R
.
string
.
remove_file_created
,
Snackbar
.
LENGTH_SHORT
).
show
();
updateDeleteButton
(
holder
,
module
);
}
}.
exec
uteOnExecutor
(
AsyncTask
.
SERIAL_EXECUTOR
);
}.
exec
(
);
}
});
...
...
app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java
View file @
aababe1a
...
...
@@ -76,11 +76,7 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
}
else
{
repo
=
mUpdateRepos
.
get
(
position
);
}
if
(
repo
.
isCache
())
{
holder
.
title
.
setText
(
"[Cache] "
+
repo
.
getName
());
}
else
{
holder
.
title
.
setText
(
repo
.
getName
());
}
holder
.
title
.
setText
(
repo
.
getName
());
String
author
=
repo
.
getAuthor
();
String
versionName
=
repo
.
getVersion
();
String
description
=
repo
.
getDescription
();
...
...
app/src/main/java/com/topjohnwu/magisk/module/BaseModule.java
View file @
aababe1a
package
com
.
topjohnwu
.
magisk
.
module
;
import
com.topjohnwu.magisk.utils.Logger
;
import
java.util.List
;
public
abstract
class
BaseModule
{
...
...
@@ -9,9 +11,9 @@ public abstract class BaseModule {
protected
boolean
mIsCacheModule
=
false
;
protected
int
mVersionCode
=
0
;
protected
void
parseProps
(
List
<
String
>
props
)
{
parseProps
(
props
.
toArray
(
new
String
[
props
.
size
()]));
}
protected
void
parseProps
(
List
<
String
>
props
)
throws
CacheModException
{
parseProps
(
props
.
toArray
(
new
String
[
props
.
size
()]));
}
protected
void
parseProps
(
String
[]
props
)
{
protected
void
parseProps
(
String
[]
props
)
throws
CacheModException
{
for
(
String
line
:
props
)
{
String
[]
prop
=
line
.
split
(
"="
,
2
);
if
(
prop
.
length
!=
2
)
{
...
...
@@ -34,7 +36,9 @@ public abstract class BaseModule {
this
.
mVersion
=
prop
[
1
];
break
;
case
"versionCode"
:
this
.
mVersionCode
=
Integer
.
parseInt
(
prop
[
1
]);
try
{
this
.
mVersionCode
=
Integer
.
parseInt
(
prop
[
1
]);
}
catch
(
NumberFormatException
ignored
)
{}
break
;
case
"author"
:
this
.
mAuthor
=
prop
[
1
];
...
...
@@ -55,6 +59,8 @@ public abstract class BaseModule {
break
;
}
}
if
(
mIsCacheModule
)
throw
new
CacheModException
(
mId
);
}
public
String
getName
()
{
...
...
@@ -75,14 +81,6 @@ public abstract class BaseModule {
return
mDescription
;
}
public
boolean
isCache
()
{
return
mIsCacheModule
;
}
public
void
setCache
()
{
mIsCacheModule
=
true
;
}
public
int
getVersionCode
()
{
return
mVersionCode
;
}
...
...
@@ -94,4 +92,10 @@ public abstract class BaseModule {
public
String
getSupportUrl
()
{
return
mSupportUrl
;
}
public
static
class
CacheModException
extends
Exception
{
public
CacheModException
(
String
id
)
{
Logger
.
dev
(
"Cache mods are no longer supported! id: "
+
id
);
}
}
}
app/src/main/java/com/topjohnwu/magisk/module/Module.java
View file @
aababe1a
...
...
@@ -8,7 +8,7 @@ public class Module extends BaseModule {
private
String
mRemoveFile
,
mDisableFile
,
mUpdateFile
;
private
boolean
mEnable
,
mRemove
,
mUpdated
;
public
Module
(
String
path
)
{
public
Module
(
String
path
)
throws
CacheModException
{
parseProps
(
Utils
.
readFile
(
path
+
"/module.prop"
));
...
...
app/src/main/java/com/topjohnwu/magisk/module/Repo.java
View file @
aababe1a
...
...
@@ -12,7 +12,7 @@ public class Repo extends BaseModule {
protected
String
repoName
,
mLogUrl
,
mManifestUrl
,
mZipUrl
;
protected
Date
mLastUpdate
;
public
Repo
(
Context
context
,
String
name
,
Date
lastUpdate
)
{
public
Repo
(
Context
context
,
String
name
,
Date
lastUpdate
)
throws
CacheModException
{
repoName
=
name
;
mLastUpdate
=
lastUpdate
;
mLogUrl
=
context
.
getString
(
R
.
string
.
file_url
,
repoName
,
"changelog.txt"
);
...
...
@@ -21,16 +21,18 @@ public class Repo extends BaseModule {
update
();
}
public
void
update
()
{
public
void
update
()
throws
CacheModException
{
Logger
.
dev
(
"Repo: Re-fetch prop "
+
mId
);
String
props
=
WebRequest
.
makeWebServiceCall
(
mManifestUrl
,
WebRequest
.
GET
,
true
);
String
lines
[]
=
props
.
split
(
"\\n"
);
parseProps
(
lines
);
}
public
void
update
(
Date
lastUpdate
)
{
public
void
update
(
Date
lastUpdate
)
throws
CacheModException
{
Logger
.
dev
(
"Repo: Old: "
+
mLastUpdate
);
Logger
.
dev
(
"Repo: New: "
+
lastUpdate
);
if
(
mIsCacheModule
)
throw
new
CacheModException
(
mId
);
if
(
lastUpdate
.
after
(
mLastUpdate
))
{
mLastUpdate
=
lastUpdate
;
update
();
...
...
app/src/main/java/com/topjohnwu/magisk/utils/ModuleHelper.java
View file @
aababe1a
...
...
@@ -6,6 +6,7 @@ import android.content.SharedPreferences;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.module.BaseModule
;
import
com.topjohnwu.magisk.module.Module
;
import
com.topjohnwu.magisk.module.Repo
;
...
...
@@ -23,7 +24,6 @@ import java.util.TreeMap;
public
class
ModuleHelper
{
public
static
final
String
MAGISK_PATH
=
"/magisk"
;
public
static
final
String
MAGISK_CACHE_PATH
=
"/cache/magisk"
;
private
static
final
String
file_key
=
"RepoMap"
;
private
static
final
String
key
=
"repomap"
;
...
...
@@ -38,16 +38,11 @@ public class ModuleHelper {
for
(
String
path
:
Utils
.
getModList
(
MAGISK_PATH
))
{
Logger
.
dev
(
"ModuleHelper: Adding modules from "
+
path
);
Module
module
=
new
Module
(
path
);
moduleMap
.
put
(
module
.
getId
(),
module
);
}
for
(
String
path
:
Utils
.
getModList
(
MAGISK_CACHE_PATH
))
{
Logger
.
dev
(
"ModuleHelper: Adding cache modules from "
+
path
);
Module
cacheMod
=
new
Module
(
path
);
// Force set to cache
cacheMod
.
setCache
();
moduleMap
.
put
(
cacheMod
.
getId
(),
cacheMod
);
Module
module
;
try
{
module
=
new
Module
(
path
);
moduleMap
.
put
(
module
.
getId
(),
module
);
}
catch
(
BaseModule
.
CacheModException
ignored
)
{}
}
Logger
.
dev
(
"ModuleHelper: Module load done"
);
...
...
@@ -90,16 +85,18 @@ public class ModuleHelper {
continue
;
}
Repo
repo
=
cached
.
get
(
id
);
if
(
repo
==
null
)
{
Logger
.
dev
(
"ModuleHelper: Create new repo "
+
id
);
repo
=
new
Repo
(
context
,
name
,
updatedDate
);
}
else
{
Logger
.
dev
(
"ModuleHelper: Cached repo "
+
id
);
repo
.
update
(
updatedDate
);
}
if
(
repo
.
getId
()
!=
null
)
{
repoMap
.
put
(
id
,
repo
);
}
try
{
if
(
repo
==
null
)
{
Logger
.
dev
(
"ModuleHelper: Create new repo "
+
id
);
repo
=
new
Repo
(
context
,
name
,
updatedDate
);
}
else
{
Logger
.
dev
(
"ModuleHelper: Cached repo "
+
id
);
repo
.
update
(
updatedDate
);
}
if
(
repo
.
getId
()
!=
null
)
{
repoMap
.
put
(
id
,
repo
);
}
}
catch
(
BaseModule
.
CacheModException
ignored
)
{}
}
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
...
...
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