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
c9f6e2e2
Commit
c9f6e2e2
authored
Sep 19, 2016
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create BaseModule (for future merging with repo)
parent
f0d3a4e4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
109 deletions
+122
-109
BaseModule.java
...src/main/java/com/topjohnwu/magisk/module/BaseModule.java
+103
-0
Module.java
app/src/main/java/com/topjohnwu/magisk/module/Module.java
+18
-109
strings.xml
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/src/main/java/com/topjohnwu/magisk/module/BaseModule.java
0 → 100644
View file @
c9f6e2e2
package
com
.
topjohnwu
.
magisk
.
module
;
import
android.util.Log
;
import
java.util.List
;
public
abstract
class
BaseModule
{
protected
String
mId
,
mName
,
mVersion
,
mDescription
,
mSupportUrl
,
mDonateUrl
,
mAuthor
;
protected
boolean
mIsCacheModule
=
false
;
protected
int
mVersionCode
=
0
;
public
BaseModule
(
List
<
String
>
props
)
{
this
(
props
.
toArray
(
new
String
[
props
.
size
()]));
}
public
BaseModule
(
String
[]
props
)
{
for
(
String
line
:
props
)
{
String
[]
prop
=
line
.
split
(
"="
,
2
);
if
(
prop
.
length
!=
2
)
{
continue
;
}
String
key
=
prop
[
0
].
trim
();
if
(
key
.
charAt
(
0
)
==
'#'
)
{
continue
;
}
switch
(
key
)
{
case
"id"
:
this
.
mId
=
prop
[
1
];
break
;
case
"name"
:
this
.
mName
=
prop
[
1
];
break
;
case
"version"
:
this
.
mVersion
=
prop
[
1
];
break
;
case
"versionCode"
:
this
.
mVersionCode
=
Integer
.
parseInt
(
prop
[
1
]);
break
;
case
"author"
:
this
.
mAuthor
=
prop
[
1
];
break
;
case
"description"
:
this
.
mDescription
=
prop
[
1
];
break
;
case
"support"
:
this
.
mSupportUrl
=
prop
[
1
];
break
;
case
"donate"
:
this
.
mDonateUrl
=
prop
[
1
];
break
;
case
"cacheModule"
:
this
.
mIsCacheModule
=
Boolean
.
parseBoolean
(
prop
[
1
]);
break
;
default
:
Log
.
d
(
"Magisk"
,
"Module: Manifest string not recognized: "
+
prop
[
0
]);
break
;
}
}
}
public
String
getName
()
{
return
mName
;
}
public
String
getVersion
()
{
return
mVersion
;
}
public
String
getAuthor
()
{
return
mAuthor
;
}
public
String
getId
()
{
return
mId
;
}
public
String
getDescription
()
{
return
mDescription
;
}
public
boolean
isCache
()
{
return
mIsCacheModule
;
}
public
void
setCache
()
{
mIsCacheModule
=
true
;
}
public
int
getVersionCode
()
{
return
mVersionCode
;
}
public
String
getmDonateUrl
()
{
return
mDonateUrl
;
}
public
String
getmSupportUrl
()
{
return
mSupportUrl
;
}
}
app/src/main/java/com/topjohnwu/magisk/module/Module.java
View file @
c9f6e2e2
...
@@ -5,75 +5,39 @@ import android.content.SharedPreferences;
...
@@ -5,75 +5,39 @@ import android.content.SharedPreferences;
import
android.preference.PreferenceManager
;
import
android.preference.PreferenceManager
;
import
android.util.Log
;
import
android.util.Log
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
public
class
Module
{
public
class
Module
extends
BaseModule
{
private
String
mRemoveFile
;
private
String
mRemoveFile
;
private
String
mDisableFile
;
private
String
mDisableFile
;
private
String
mName
=
null
;
private
String
mZipUrl
,
mLogUrl
;
private
String
mVersion
=
"(No version provided)"
;
private
boolean
mEnable
,
mRemove
,
mUpdateAvailable
=
false
,
mIsInstalled
;
private
String
mDescription
=
"(No description provided)"
;
private
String
mSupportUrl
,
mDonateUrl
,
mZipUrl
,
mAuthor
,
mLogUrl
;
private
boolean
mEnable
=
false
,
mRemove
=
false
,
mUpdateAvailable
=
false
,
mIsInstalled
,
mIsCacheModule
=
false
;
private
String
mId
;
private
int
mVersionCode
;
public
Module
(
String
path
,
Context
context
)
{
public
Module
(
String
path
,
Context
context
)
{
super
(
Utils
.
readFile
(
path
+
"/module.prop"
));
mRemoveFile
=
path
+
"/remove"
;
mRemoveFile
=
path
+
"/remove"
;
mDisableFile
=
path
+
"/disable"
;
mDisableFile
=
path
+
"/disable"
;
for
(
String
line
:
Utils
.
readFile
(
path
+
"/module.prop"
))
{
String
[]
props
=
line
.
split
(
"="
,
2
);
if
(
props
.
length
!=
2
)
{
continue
;
}
String
key
=
props
[
0
].
trim
();
if
(
mId
==
null
)
{
i
f
(
key
.
charAt
(
0
)
==
'#'
)
{
i
nt
sep
=
path
.
lastIndexOf
(
'/'
);
continue
;
mId
=
path
.
substring
(
sep
+
1
)
;
}
}
switch
(
props
[
0
])
{
if
(
mName
==
null
)
case
"id"
:
mName
=
mId
;
this
.
mId
=
props
[
1
];
break
;
case
"name"
:
this
.
mName
=
props
[
1
];
break
;
case
"version"
:
this
.
mVersion
=
props
[
1
];
break
;
case
"versionCode"
:
this
.
mVersionCode
=
Integer
.
parseInt
(
props
[
1
]);
break
;
case
"author"
:
this
.
mAuthor
=
props
[
1
];
break
;
case
"description"
:
this
.
mDescription
=
props
[
1
];
break
;
case
"support"
:
this
.
mSupportUrl
=
props
[
1
];
break
;
case
"donate"
:
this
.
mDonateUrl
=
props
[
1
];
break
;
case
"cacheModule"
:
this
.
mIsCacheModule
=
Boolean
.
parseBoolean
(
props
[
1
]);
break
;
default
:
Log
.
d
(
"Magisk"
,
"Module: Manifest string not recognized: "
+
props
[
0
]);
break
;
}
if
(
mDescription
==
null
)
mDescription
=
context
.
getString
(
R
.
string
.
no_info_provided
);
}
if
(
mVersion
==
null
)
Log
.
d
(
"Magisk"
,
"Module: Loaded module with ID of "
+
this
.
mId
+
" or "
+
mId
);
mVersion
=
context
.
getString
(
R
.
string
.
no_info_provided
);
Log
.
d
(
"Magisk"
,
"Module: Loaded module with ID of "
+
mId
);
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
SharedPreferences
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
...
@@ -140,52 +104,13 @@ public class Module {
...
@@ -140,52 +104,13 @@ public class Module {
editor
.
apply
();
editor
.
apply
();
}
}
if
(
mName
==
null
)
{
int
sep
=
path
.
lastIndexOf
(
'/'
);
mName
=
path
.
substring
(
sep
+
1
);
mId
=
mName
;
}
mEnable
=
!
Utils
.
fileExist
(
mDisableFile
);
mEnable
=
!
Utils
.
fileExist
(
mDisableFile
);
mRemove
=
Utils
.
fileExist
(
mRemoveFile
);
mRemove
=
Utils
.
fileExist
(
mRemoveFile
);
}
}
// public Module(Repo repo) {
//
// mName = repo.getName();
// mVersion = repo.getmVersion();
// mDescription = repo.getDescription();
// mId = repo.getId();
// mVersionCode = repo.getmVersionCode();
// mUrl = repo.getmZipUrl();
// mEnable = true;
// mRemove = false;
//
// }
public
String
getName
()
{
return
mName
;
}
public
String
getVersion
()
{
return
mVersion
;
}
public
String
getAuthor
()
{
return
mAuthor
;
}
public
String
getId
()
{
return
mId
;
}
public
String
getmLogUrl
()
{
return
mLogUrl
;
}
public
String
getmLogUrl
()
{
return
mLogUrl
;
}
public
String
getDescription
()
{
return
mDescription
;
}
public
void
createDisableFile
()
{
public
void
createDisableFile
()
{
mEnable
=
!
Utils
.
createFile
(
mDisableFile
);
mEnable
=
!
Utils
.
createFile
(
mDisableFile
);
}
}
...
@@ -210,24 +135,8 @@ public class Module {
...
@@ -210,24 +135,8 @@ public class Module {
return
mRemove
;
return
mRemove
;
}
}
public
boolean
isCache
()
{
return
mIsCacheModule
;
}
public
void
setCache
()
{
mIsCacheModule
=
true
;
}
public
String
getmDonateUrl
()
{
return
mDonateUrl
;
}
public
String
getmZipUrl
()
{
return
mZipUrl
;
}
public
String
getmZipUrl
()
{
return
mZipUrl
;
}
public
String
getmSupportUrl
()
{
return
mSupportUrl
;
}
public
boolean
isUpdateAvailable
()
{
return
mUpdateAvailable
;
}
public
boolean
isUpdateAvailable
()
{
return
mUpdateAvailable
;
}
}
}
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
c9f6e2e2
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
<string
name=
"selinux_samsung_info"
>
Samsung need custom kernel for switching SELinux status!
</string>
<string
name=
"selinux_samsung_info"
>
Samsung need custom kernel for switching SELinux status!
</string>
<!--Module Fragment-->
<!--Module Fragment-->
<string
name=
"no_info_provided"
>
(No info provided)
</string>
<string
name=
"cache_modules"
>
Cache modules
</string>
<string
name=
"cache_modules"
>
Cache modules
</string>
<string
name=
"no_modules_found"
>
No modules found
</string>
<string
name=
"no_modules_found"
>
No modules found
</string>
<string
name=
"module_update_available"
>
An update is available!
</string>
<string
name=
"module_update_available"
>
An update is available!
</string>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment