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
214649ec
Commit
214649ec
authored
Sep 08, 2016
by
d8ahazard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apparently Github is sensitive...
parent
e3866eeb
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
15 deletions
+68
-15
Repo.java
app/src/main/java/com/topjohnwu/magisk/module/Repo.java
+15
-4
RepoHelper.java
...src/main/java/com/topjohnwu/magisk/module/RepoHelper.java
+5
-3
Utils.java
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
+46
-8
strings.xml
app/src/main/res/values/strings.xml
+2
-0
No files found.
app/src/main/java/com/topjohnwu/magisk/module/Repo.java
View file @
214649ec
...
@@ -5,13 +5,14 @@ import android.content.SharedPreferences;
...
@@ -5,13 +5,14 @@ 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.WebRequest
;
import
com.topjohnwu.magisk.utils.WebRequest
;
import
org.json.JSONArray
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Date
;
public
class
Repo
{
public
class
Repo
{
...
@@ -32,6 +33,7 @@ public class Repo {
...
@@ -32,6 +33,7 @@ public class Repo {
private
Context
appContext
;
private
Context
appContext
;
private
boolean
mIsInstalled
,
mCanUpdate
;
private
boolean
mIsInstalled
,
mCanUpdate
;
public
Repo
(
String
manifestString
,
Context
context
)
{
public
Repo
(
String
manifestString
,
Context
context
)
{
appContext
=
context
;
appContext
=
context
;
ParseProps
(
manifestString
);
ParseProps
(
manifestString
);
...
@@ -45,6 +47,7 @@ public class Repo {
...
@@ -45,6 +47,7 @@ public class Repo {
this
.
mName
=
name
;
this
.
mName
=
name
;
this
.
mBaseUrl
=
url
;
this
.
mBaseUrl
=
url
;
this
.
lastUpdate
=
updated
.
toString
();
this
.
lastUpdate
=
updated
.
toString
();
this
.
fetch
();
this
.
fetch
();
}
}
...
@@ -60,10 +63,11 @@ public class Repo {
...
@@ -60,10 +63,11 @@ public class Repo {
}
}
public
void
fetch
()
{
public
void
fetch
()
{
WebRequest
webreq
=
new
WebRequest
();
WebRequest
webreq
=
new
WebRequest
();
// Construct initial url for contents
// Construct initial url for contents
Log
.
d
(
"Magisk"
,
"Repo: Fetch called, Manifest string is: "
+
mBaseUrl
+
"/contents?access_token=
5c9f47a299d48a6a649af3587bc97200bafcac65"
);
Log
.
d
(
"Magisk"
,
"Repo: Fetch called, Manifest string is: "
+
mBaseUrl
+
"/contents?access_token=
"
+
Utils
.
procFile
(
appContext
.
getString
(
R
.
string
.
some_string
),
appContext
)
);
String
repoString
=
webreq
.
makeWebServiceCall
(
mBaseUrl
+
"/contents?access_token=
5c9f47a299d48a6a649af3587bc97200bafcac65"
,
WebRequest
.
GET
);
String
repoString
=
webreq
.
makeWebServiceCall
(
mBaseUrl
+
"/contents?access_token=
"
+
Utils
.
procFile
(
appContext
.
getString
(
R
.
string
.
some_string
),
appContext
)
,
WebRequest
.
GET
);
try
{
try
{
JSONArray
repoArray
=
new
JSONArray
(
repoString
);
JSONArray
repoArray
=
new
JSONArray
(
repoString
);
for
(
int
f
=
0
;
f
<
repoArray
.
length
();
f
++)
{
for
(
int
f
=
0
;
f
<
repoArray
.
length
();
f
++)
{
...
@@ -81,7 +85,7 @@ public class Repo {
...
@@ -81,7 +85,7 @@ public class Repo {
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
Log
.
d
(
"Magisk"
,
"Repo: Inner fetch: "
+
mManifestUrl
+
"?access_token=
5c9f47a299d48a6a649af3587bc97200bafcac65"
);
Log
.
d
(
"Magisk"
,
"Repo: Inner fetch: "
+
mManifestUrl
+
"?access_token=
"
+
Utils
.
procFile
(
appContext
.
getString
(
R
.
string
.
some_string
),
appContext
)
);
WebRequest
propReq
=
new
WebRequest
();
WebRequest
propReq
=
new
WebRequest
();
String
manifestString
=
propReq
.
makeWebServiceCall
(
mManifestUrl
,
WebRequest
.
GET
,
true
);
String
manifestString
=
propReq
.
makeWebServiceCall
(
mManifestUrl
,
WebRequest
.
GET
,
true
);
Log
.
d
(
"Magisk"
,
"Repo: parseprops called from fetch for string "
+
manifestString
);
Log
.
d
(
"Magisk"
,
"Repo: parseprops called from fetch for string "
+
manifestString
);
...
@@ -176,6 +180,13 @@ public class Repo {
...
@@ -176,6 +180,13 @@ public class Repo {
}
}
}
}
public
String
getStringProperty
(
String
mValue
)
{
public
String
getStringProperty
(
String
mValue
)
{
switch
(
mValue
)
{
switch
(
mValue
)
{
case
"author"
:
case
"author"
:
...
...
app/src/main/java/com/topjohnwu/magisk/module/RepoHelper.java
View file @
214649ec
...
@@ -3,11 +3,12 @@ package com.topjohnwu.magisk.module;
...
@@ -3,11 +3,12 @@ package com.topjohnwu.magisk.module;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
android.os.AsyncTask
;
import
android.os.AsyncTask
;
import
android.os.Build
;
import
android.preference.PreferenceManager
;
import
android.preference.PreferenceManager
;
import
android.util.Log
;
import
android.util.Log
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.WebRequest
;
import
com.topjohnwu.magisk.utils.WebRequest
;
import
org.json.JSONArray
;
import
org.json.JSONArray
;
...
@@ -23,7 +24,7 @@ import java.util.Map;
...
@@ -23,7 +24,7 @@ import java.util.Map;
public
class
RepoHelper
{
public
class
RepoHelper
{
private
String
[]
result
;
private
String
[]
result
;
private
static
String
url
=
"https://api.github.com/orgs/Magisk-Modules-Repo/repos?access_token=
5c9f47a299d48a6a649af3587bc97200bafcac65
"
;
private
static
String
url
=
"https://api.github.com/orgs/Magisk-Modules-Repo/repos?access_token="
;
private
static
List
<
Repo
>
repos
=
new
ArrayList
<
Repo
>();
private
static
List
<
Repo
>
repos
=
new
ArrayList
<
Repo
>();
private
static
final
String
TAG_ID
=
"id"
;
private
static
final
String
TAG_ID
=
"id"
;
private
static
final
String
TAG_NAME
=
"name"
;
private
static
final
String
TAG_NAME
=
"name"
;
...
@@ -103,7 +104,8 @@ public class RepoHelper {
...
@@ -103,7 +104,8 @@ public class RepoHelper {
WebRequest
webreq
=
new
WebRequest
();
WebRequest
webreq
=
new
WebRequest
();
// Making a request to url and getting response
// Making a request to url and getting response
String
jsonStr
=
webreq
.
makeWebServiceCall
(
url
,
WebRequest
.
GET
);
String
token
=
activityContext
.
getString
(
R
.
string
.
some_string
);
String
jsonStr
=
webreq
.
makeWebServiceCall
(
url
+
Utils
.
procFile
(
token
,
activityContext
),
WebRequest
.
GET
);
Log
.
d
(
"Magisk"
,
"doInBackground Running, String: "
+
jsonStr
+
" Url: "
+
url
);
Log
.
d
(
"Magisk"
,
"doInBackground Running, String: "
+
jsonStr
+
" Url: "
+
url
);
if
(
jsonStr
!=
null
&&
!
jsonStr
.
isEmpty
())
{
if
(
jsonStr
!=
null
&&
!
jsonStr
.
isEmpty
())
{
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
View file @
214649ec
...
@@ -10,6 +10,7 @@ import android.content.Intent;
...
@@ -10,6 +10,7 @@ import android.content.Intent;
import
android.content.IntentFilter
;
import
android.content.IntentFilter
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
android.content.pm.PackageManager
;
import
android.content.pm.PackageManager
;
import
android.content.res.Resources
;
import
android.database.Cursor
;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.AsyncTask
;
import
android.os.AsyncTask
;
...
@@ -18,6 +19,7 @@ import android.preference.PreferenceManager;
...
@@ -18,6 +19,7 @@ import android.preference.PreferenceManager;
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.v7.app.AlertDialog
;
import
android.support.v7.app.AlertDialog
;
import
android.util.Base64
;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.Toast
;
import
android.widget.Toast
;
...
@@ -36,10 +38,22 @@ import java.io.BufferedReader;
...
@@ -36,10 +38,22 @@ import java.io.BufferedReader;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.io.UnsupportedEncodingException
;
import
java.net.HttpURLConnection
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URL
;
import
java.security.InvalidKeyException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.spec.InvalidKeySpecException
;
import
java.util.List
;
import
java.util.List
;
import
javax.crypto.BadPaddingException
;
import
javax.crypto.Cipher
;
import
javax.crypto.IllegalBlockSizeException
;
import
javax.crypto.NoSuchPaddingException
;
import
javax.crypto.SecretKey
;
import
javax.crypto.SecretKeyFactory
;
import
javax.crypto.spec.DESKeySpec
;
public
class
Utils
{
public
class
Utils
{
public
static
int
magiskVersion
,
remoteMagiskVersion
=
-
1
,
remoteAppVersion
=
-
1
;
public
static
int
magiskVersion
,
remoteMagiskVersion
=
-
1
,
remoteAppVersion
=
-
1
;
...
@@ -371,15 +385,39 @@ public class Utils {
...
@@ -371,15 +385,39 @@ public class Utils {
}
}
}
}
public
static
class
AuthGithub
extends
AsyncTask
<
Void
,
Void
,
Void
>
{
public
static
String
procFile
(
String
value
,
Context
context
)
{
private
static
String
mClientToken
=
"5c9f47a299d48a6a649af3587bc97200bafcac65"
;
public
AuthGithub
(
Context
context
)
{}
@Override
String
cryptoPass
=
context
.
getResources
().
getString
(
R
.
string
.
pass
);
protected
Void
doInBackground
(
Void
...
voids
)
{
try
{
return
null
;
DESKeySpec
keySpec
=
new
DESKeySpec
(
cryptoPass
.
getBytes
(
"UTF8"
));
}
SecretKeyFactory
keyFactory
=
SecretKeyFactory
.
getInstance
(
"DES"
);
SecretKey
key
=
keyFactory
.
generateSecret
(
keySpec
);
byte
[]
encrypedPwdBytes
=
Base64
.
decode
(
value
,
Base64
.
DEFAULT
);
// cipher is not thread safe
Cipher
cipher
=
Cipher
.
getInstance
(
"DES"
);
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
key
);
byte
[]
decrypedValueBytes
=
(
cipher
.
doFinal
(
encrypedPwdBytes
));
String
decrypedValue
=
new
String
(
decrypedValueBytes
);
return
decrypedValue
;
}
catch
(
InvalidKeyException
e
)
{
e
.
printStackTrace
();
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
catch
(
InvalidKeySpecException
e
)
{
e
.
printStackTrace
();
}
catch
(
NoSuchAlgorithmException
e
)
{
e
.
printStackTrace
();
}
catch
(
BadPaddingException
e
)
{
e
.
printStackTrace
();
}
catch
(
NoSuchPaddingException
e
)
{
e
.
printStackTrace
();
}
catch
(
IllegalBlockSizeException
e
)
{
e
.
printStackTrace
();
}
return
value
;
}
}
public
static
class
LoadModules
extends
AsyncTask
<
Void
,
Void
,
Void
>
{
public
static
class
LoadModules
extends
AsyncTask
<
Void
,
Void
,
Void
>
{
...
...
app/src/main/res/values/strings.xml
View file @
214649ec
...
@@ -92,4 +92,6 @@
...
@@ -92,4 +92,6 @@
<string
name=
"phh"
>
phh\'s superuser
</string>
<string
name=
"phh"
>
phh\'s superuser
</string>
<string
name=
"supersu"
>
SuperSU
</string>
<string
name=
"supersu"
>
SuperSU
</string>
<string
name=
"root_system_msg"
>
It seems that you have incompatible root installed\nDo you want to install Magisk compatible root now?
</string>
<string
name=
"root_system_msg"
>
It seems that you have incompatible root installed\nDo you want to install Magisk compatible root now?
</string>
<string
name=
"pass"
>
MagiskRox666
</string>
<string
name=
"some_string"
>
GTYybRBTYf5his9kQ16ZNO7qgkBJ/5MyVe4CGceAOIoXgSnnk8FTd4F1dE9p5Eus
</string>
</resources>
</resources>
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