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
b4ecd93f
Commit
b4ecd93f
authored
Sep 15, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proper FBE support: place files in DE
parent
0acc23e0
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
11 deletions
+39
-11
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+2
-1
MagiskManager.java
app/src/main/java/com/topjohnwu/magisk/MagiskManager.java
+21
-2
InstallMagisk.java
.../main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
+8
-1
SuDatabaseHelper.java
.../java/com/topjohnwu/magisk/database/SuDatabaseHelper.java
+8
-7
No files found.
app/src/main/AndroidManifest.xml
View file @
b4ecd93f
...
...
@@ -17,7 +17,8 @@
android:label=
"@string/app_name"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
tools:ignore=
"AllowBackup,GoogleAppIndexingWarning"
>
android:directBootAware=
"true"
tools:ignore=
"UnusedAttribute"
>
<activity
android:name=
".MainActivity"
android:configChanges=
"orientation|screenSize"
...
...
app/src/main/java/com/topjohnwu/magisk/MagiskManager.java
View file @
b4ecd93f
...
...
@@ -136,9 +136,17 @@ public class MagiskManager extends Application {
@Override
public
void
onCreate
()
{
super
.
onCreate
();
new
File
(
getApplicationInfo
().
dataDir
).
mkdirs
();
/* Create the app data directory */
prefs
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
);
if
(
getDatabasePath
(
SuDatabaseHelper
.
DB_NAME
).
exists
()
||
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
N
)
{
// Don't migrate yet, wait and check Magisk version
suDB
=
new
SuDatabaseHelper
(
this
);
}
else
{
// Place the suDB in DE memory
suDB
=
new
SuDatabaseHelper
(
createDeviceProtectedStorageContext
());
}
repoDB
=
new
RepoDatabaseHelper
(
this
);
defaultLocale
=
Locale
.
getDefault
();
setLocale
();
...
...
@@ -198,6 +206,17 @@ public class MagiskManager extends Application {
boolean
hasNetwork
=
Utils
.
checkNetworkStatus
(
this
);
getMagiskInfo
();
// Check if we need to migrate suDB
if
(
magiskVersionCode
>=
1410
&&
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
&&
getDatabasePath
(
SuDatabaseHelper
.
DB_NAME
).
exists
())
{
suDB
.
close
();
Context
de
=
createDeviceProtectedStorageContext
();
de
.
moveDatabaseFrom
(
this
,
SuDatabaseHelper
.
DB_NAME
);
suDB
=
new
SuDatabaseHelper
(
de
);
}
new
LoadLocale
(
this
).
exec
();
// Root actions
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
View file @
b4ecd93f
...
...
@@ -75,7 +75,14 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
MagiskManager
mm
=
getMagiskManager
();
if
(
mm
==
null
)
return
false
;
File
install
=
new
File
(
mm
.
getApplicationInfo
().
dataDir
,
"install"
);
File
install
;
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
// Need to be stored in device encrypted storage for FBE
install
=
new
File
(
mm
.
createDeviceProtectedStorageContext
().
getFilesDir
().
getParent
(),
"install"
);
}
else
{
install
=
new
File
(
mm
.
getApplicationInfo
().
dataDir
,
"install"
);
}
getShell
().
sh_raw
(
"rm -rf "
+
install
);
List
<
String
>
abis
=
Arrays
.
asList
(
Build
.
SUPPORTED_ABIS
);
...
...
app/src/main/java/com/topjohnwu/magisk/database/SuDatabaseHelper.java
View file @
b4ecd93f
...
...
@@ -39,18 +39,19 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
public
static
final
int
NAMESPACE_MODE_REQUESTER
=
1
;
public
static
final
int
NAMESPACE_MODE_ISOLATE
=
2
;
public
static
final
String
DB_NAME
=
"su.db"
;
private
static
final
int
DATABASE_VER
=
3
;
private
static
final
String
POLICY_TABLE
=
"policies"
;
private
static
final
String
LOG_TABLE
=
"logs"
;
private
static
final
String
SETTINGS_TABLE
=
"settings"
;
private
MagiskManager
m
agiskManager
;
private
MagiskManager
m
m
;
private
PackageManager
pm
;
private
SQLiteDatabase
mDb
;
public
SuDatabaseHelper
(
Context
context
)
{
super
(
context
,
"su.db"
,
null
,
DATABASE_VER
);
m
agiskManager
=
Utils
.
getMagiskManager
(
context
);
super
(
context
,
DB_NAME
,
null
,
DATABASE_VER
);
m
m
=
Utils
.
getMagiskManager
(
context
);
pm
=
context
.
getPackageManager
();
mDb
=
getWritableDatabase
();
cleanup
();
...
...
@@ -81,10 +82,10 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
"FROM "
+
POLICY_TABLE
+
"_old"
);
db
.
execSQL
(
"DROP TABLE "
+
POLICY_TABLE
+
"_old"
);
File
oldDB
=
m
agiskManager
.
getDatabasePath
(
"sulog.db"
);
File
oldDB
=
m
m
.
getDatabasePath
(
"sulog.db"
);
if
(
oldDB
.
exists
())
{
migrateLegacyLogList
(
oldDB
,
db
);
m
agiskManager
.
deleteDatabase
(
"sulog.db"
);
m
m
.
deleteDatabase
(
"sulog.db"
);
}
++
oldVersion
;
}
...
...
@@ -120,7 +121,7 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
new
String
[]
{
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
)
});
// Clear outdated logs
mDb
.
delete
(
LOG_TABLE
,
"time < ?"
,
new
String
[]
{
String
.
valueOf
(
System
.
currentTimeMillis
()
-
m
agiskManager
.
suLogTimeout
*
86400000
)
});
System
.
currentTimeMillis
()
-
m
m
.
suLogTimeout
*
86400000
)
});
}
public
void
deletePolicy
(
Policy
policy
)
{
...
...
@@ -178,7 +179,7 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
Policy
policy
=
new
Policy
(
c
,
pm
);
// The application changed UID for some reason, check user config
if
(
policy
.
info
.
uid
!=
policy
.
uid
)
{
if
(
m
agiskManager
.
suReauth
)
{
if
(
m
m
.
suReauth
)
{
// Reauth required, remove from DB
deletePolicy
(
policy
);
continue
;
...
...
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