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
2118beeb
Commit
2118beeb
authored
Sep 28, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Magisk-Modules-Repo now names repo with ID, simplify logic here
parent
5020cd1b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
43 deletions
+22
-43
UpdateRepos.java
...rc/full/java/com/topjohnwu/magisk/asyncs/UpdateRepos.java
+4
-6
Repo.java
app/src/full/java/com/topjohnwu/magisk/container/Repo.java
+8
-19
RepoDatabaseHelper.java
...ava/com/topjohnwu/magisk/database/RepoDatabaseHelper.java
+10
-18
No files found.
app/src/full/java/com/topjohnwu/magisk/asyncs/UpdateRepos.java
View file @
2118beeb
...
@@ -66,17 +66,15 @@ public class UpdateRepos {
...
@@ -66,17 +66,15 @@ public class UpdateRepos {
for
(
int
i
=
0
;
i
<
jsonArray
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
jsonArray
.
length
();
i
++)
{
JSONObject
rawRepo
=
jsonArray
.
getJSONObject
(
i
);
JSONObject
rawRepo
=
jsonArray
.
getJSONObject
(
i
);
String
id
=
rawRepo
.
getString
(
"description"
);
String
id
=
rawRepo
.
getString
(
"name"
);
String
name
=
rawRepo
.
getString
(
"name"
);
Date
date
=
dateFormat
.
parse
(
rawRepo
.
getString
(
"pushed_at"
));
Date
date
=
dateFormat
.
parse
(
rawRepo
.
getString
(
"pushed_at"
));
Set
<
String
>
set
=
Collections
.
synchronizedSet
(
cached
);
threadPool
.
execute
(()
->
{
threadPool
.
execute
(()
->
{
Repo
repo
=
mm
.
repoDB
.
getRepo
(
id
);
Repo
repo
=
mm
.
repoDB
.
getRepo
(
id
);
try
{
try
{
if
(
repo
==
null
)
if
(
repo
==
null
)
repo
=
new
Repo
(
name
);
repo
=
new
Repo
(
id
);
else
else
set
.
remove
(
id
);
cached
.
remove
(
id
);
repo
.
update
(
date
);
repo
.
update
(
date
);
mm
.
repoDB
.
addRepo
(
repo
);
mm
.
repoDB
.
addRepo
(
repo
);
}
catch
(
Repo
.
IllegalRepoException
e
)
{
}
catch
(
Repo
.
IllegalRepoException
e
)
{
...
@@ -141,7 +139,7 @@ public class UpdateRepos {
...
@@ -141,7 +139,7 @@ public class UpdateRepos {
public
void
exec
(
boolean
force
)
{
public
void
exec
(
boolean
force
)
{
Topic
.
reset
(
Topic
.
REPO_LOAD_DONE
);
Topic
.
reset
(
Topic
.
REPO_LOAD_DONE
);
AsyncTask
.
THREAD_POOL_EXECUTOR
.
execute
(()
->
{
AsyncTask
.
THREAD_POOL_EXECUTOR
.
execute
(()
->
{
cached
=
mm
.
repoDB
.
getRepoIDSet
(
);
cached
=
Collections
.
synchronizedSet
(
mm
.
repoDB
.
getRepoIDSet
()
);
threadPool
=
Executors
.
newFixedThreadPool
(
CORE_POOL_SIZE
);
threadPool
=
Executors
.
newFixedThreadPool
(
CORE_POOL_SIZE
);
if
(
loadPage
(
0
))
{
if
(
loadPage
(
0
))
{
...
...
app/src/full/java/com/topjohnwu/magisk/container/Repo.java
View file @
2118beeb
...
@@ -2,7 +2,6 @@ package com.topjohnwu.magisk.container;
...
@@ -2,7 +2,6 @@ package com.topjohnwu.magisk.container;
import
android.content.ContentValues
;
import
android.content.ContentValues
;
import
android.database.Cursor
;
import
android.database.Cursor
;
import
android.text.TextUtils
;
import
com.topjohnwu.magisk.Const
;
import
com.topjohnwu.magisk.Const
;
import
com.topjohnwu.magisk.utils.Download
;
import
com.topjohnwu.magisk.utils.Download
;
...
@@ -15,16 +14,14 @@ import java.util.Date;
...
@@ -15,16 +14,14 @@ import java.util.Date;
public
class
Repo
extends
BaseModule
{
public
class
Repo
extends
BaseModule
{
private
String
repoName
;
private
Date
mLastUpdate
;
private
Date
mLastUpdate
;
public
Repo
(
String
name
)
{
public
Repo
(
String
id
)
{
repoName
=
name
;
setId
(
id
)
;
}
}
public
Repo
(
Cursor
c
)
{
public
Repo
(
Cursor
c
)
{
super
(
c
);
super
(
c
);
repoName
=
c
.
getString
(
c
.
getColumnIndex
(
"repo_name"
));
mLastUpdate
=
new
Date
(
c
.
getLong
(
c
.
getColumnIndex
(
"last_update"
)));
mLastUpdate
=
new
Date
(
c
.
getLong
(
c
.
getColumnIndex
(
"last_update"
)));
}
}
...
@@ -33,17 +30,14 @@ public class Repo extends BaseModule {
...
@@ -33,17 +30,14 @@ public class Repo extends BaseModule {
try
{
try
{
parseProps
(
props
);
parseProps
(
props
);
}
catch
(
NumberFormatException
e
)
{
}
catch
(
NumberFormatException
e
)
{
throw
new
IllegalRepoException
(
"Repo ["
+
repoName
+
"] parse error: "
+
e
.
getMessage
());
throw
new
IllegalRepoException
(
"Repo ["
+
getId
()
+
"] parse error: "
+
e
.
getMessage
());
}
}
if
(
TextUtils
.
isEmpty
(
getId
()))
{
throw
new
IllegalRepoException
(
"Repo ["
+
repoName
+
"] does not contain id"
);
}
if
(
getVersionCode
()
<
0
)
{
if
(
getVersionCode
()
<
0
)
{
throw
new
IllegalRepoException
(
"Repo ["
+
repoName
+
"] does not contain versionCode"
);
throw
new
IllegalRepoException
(
"Repo ["
+
getId
()
+
"] does not contain versionCode"
);
}
}
if
(
getMinMagiskVersion
()
<
Const
.
MIN_MODULE_VER
())
{
if
(
getMinMagiskVersion
()
<
Const
.
MIN_MODULE_VER
())
{
Logger
.
debug
(
"Repo ["
+
repoName
+
"] is outdated"
);
Logger
.
debug
(
"Repo ["
+
getId
()
+
"] is outdated"
);
}
}
}
}
...
@@ -55,25 +49,20 @@ public class Repo extends BaseModule {
...
@@ -55,25 +49,20 @@ public class Repo extends BaseModule {
@Override
@Override
public
ContentValues
getContentValues
()
{
public
ContentValues
getContentValues
()
{
ContentValues
values
=
super
.
getContentValues
();
ContentValues
values
=
super
.
getContentValues
();
values
.
put
(
"repo_name"
,
repoName
);
values
.
put
(
"last_update"
,
mLastUpdate
.
getTime
());
values
.
put
(
"last_update"
,
mLastUpdate
.
getTime
());
return
values
;
return
values
;
}
}
public
String
getRepoName
()
{
return
repoName
;
}
public
String
getZipUrl
()
{
public
String
getZipUrl
()
{
return
String
.
format
(
Const
.
Url
.
ZIP_URL
,
repoName
);
return
String
.
format
(
Const
.
Url
.
ZIP_URL
,
getId
()
);
}
}
public
String
getManifestUrl
()
{
public
String
getManifestUrl
()
{
return
String
.
format
(
Const
.
Url
.
FILE_URL
,
repoName
,
"module.prop"
);
return
String
.
format
(
Const
.
Url
.
FILE_URL
,
getId
()
,
"module.prop"
);
}
}
public
String
getDetailUrl
()
{
public
String
getDetailUrl
()
{
return
String
.
format
(
Const
.
Url
.
FILE_URL
,
repoName
,
"README.md"
);
return
String
.
format
(
Const
.
Url
.
FILE_URL
,
getId
()
,
"README.md"
);
}
}
public
String
getLastUpdateString
()
{
public
String
getLastUpdateString
()
{
...
...
app/src/full/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java
View file @
2118beeb
...
@@ -16,7 +16,7 @@ import java.util.Set;
...
@@ -16,7 +16,7 @@ import java.util.Set;
public
class
RepoDatabaseHelper
extends
SQLiteOpenHelper
{
public
class
RepoDatabaseHelper
extends
SQLiteOpenHelper
{
private
static
final
int
DATABASE_VER
=
3
;
private
static
final
int
DATABASE_VER
=
4
;
private
static
final
String
TABLE_NAME
=
"repos"
;
private
static
final
String
TABLE_NAME
=
"repos"
;
private
SQLiteDatabase
mDb
;
private
SQLiteDatabase
mDb
;
...
@@ -40,21 +40,14 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
...
@@ -40,21 +40,14 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
@Override
@Override
public
void
onUpgrade
(
SQLiteDatabase
db
,
int
oldVersion
,
int
newVersion
)
{
public
void
onUpgrade
(
SQLiteDatabase
db
,
int
oldVersion
,
int
newVersion
)
{
try
{
if
(
oldVersion
!=
newVersion
)
{
if
(
oldVersion
<
3
)
{
// Nuke old DB and create new table
db
.
execSQL
(
"DROP TABLE IF EXISTS "
+
TABLE_NAME
);
db
.
execSQL
(
"DROP TABLE IF EXISTS "
+
TABLE_NAME
);
db
.
execSQL
(
db
.
execSQL
(
"CREATE TABLE IF NOT EXISTS "
+
TABLE_NAME
+
" "
+
"CREATE TABLE IF NOT EXISTS "
+
TABLE_NAME
+
" "
+
"(id TEXT, name TEXT, version TEXT, versionCode INT, minMagisk INT, "
+
"(id TEXT, name TEXT, version TEXT, versionCode INT, minMagisk INT, "
+
"author TEXT, description TEXT, repo_name TEXT, last_update INT, "
+
"author TEXT, description TEXT, last_update INT, PRIMARY KEY(id))"
);
"PRIMARY KEY(id))"
);
mm
.
prefs
.
edit
().
remove
(
Const
.
Key
.
ETAG_KEY
).
apply
();
mm
.
prefs
.
edit
().
remove
(
Const
.
Key
.
ETAG_KEY
).
apply
();
oldVersion
=
3
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
// Reset database
onDowngrade
(
db
,
DATABASE_VER
,
0
);
}
}
}
}
...
@@ -75,8 +68,7 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
...
@@ -75,8 +68,7 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
}
}
public
void
removeRepo
(
Repo
repo
)
{
public
void
removeRepo
(
Repo
repo
)
{
mDb
.
delete
(
TABLE_NAME
,
"repo_name=?"
,
new
String
[]
{
repo
.
getRepoName
()
});
removeRepo
(
repo
.
getId
());
notifyAdapter
();
}
}
public
void
removeRepo
(
Iterable
<
String
>
list
)
{
public
void
removeRepo
(
Iterable
<
String
>
list
)
{
...
...
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