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
6263d684
Commit
6263d684
authored
Jul 20, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate to JobIntentService to prevent boot notification
parent
07140d33
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
42 additions
and
68 deletions
+42
-68
AndroidManifest.xml
app/src/full/AndroidManifest.xml
+4
-1
BootReceiver.java
...ull/java/com/topjohnwu/magisk/receivers/BootReceiver.java
+4
-7
OnBootIntentService.java
...va/com/topjohnwu/magisk/services/OnBootIntentService.java
+0
-44
OnBootService.java
...ull/java/com/topjohnwu/magisk/services/OnBootService.java
+33
-0
Logger.java
app/src/full/java/com/topjohnwu/magisk/utils/Logger.java
+0
-2
RootUtils.java
app/src/full/java/com/topjohnwu/magisk/utils/RootUtils.java
+0
-12
Const.java
app/src/main/java/com/topjohnwu/magisk/utils/Const.java
+1
-2
No files found.
app/src/full/AndroidManifest.xml
View file @
6263d684
...
...
@@ -66,7 +66,10 @@
</intent-filter>
</receiver>
<service
android:name=
".services.OnBootIntentService"
/>
<service
android:name=
".services.OnBootService"
android:exported=
"true"
android:permission=
"android.permission.BIND_JOB_SERVICE"
/>
<service
android:name=
".services.UpdateCheckService"
android:exported=
"true"
...
...
app/src/full/java/com/topjohnwu/magisk/receivers/BootReceiver.java
View file @
6263d684
...
...
@@ -3,19 +3,16 @@ package com.topjohnwu.magisk.receivers;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.
os.Build
;
import
android.
text.TextUtils
;
import
com.topjohnwu.magisk.services.OnBoot
Intent
Service
;
import
com.topjohnwu.magisk.services.OnBootService
;
public
class
BootReceiver
extends
BroadcastReceiver
{
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
context
.
startForegroundService
(
new
Intent
(
context
,
OnBootIntentService
.
class
));
}
else
{
context
.
startService
(
new
Intent
(
context
,
OnBootIntentService
.
class
));
}
if
(
TextUtils
.
equals
(
intent
.
getAction
(),
Intent
.
ACTION_BOOT_COMPLETED
))
OnBootService
.
enqueueWork
(
context
);
}
}
app/src/full/java/com/topjohnwu/magisk/services/OnBootIntentService.java
deleted
100644 → 0
View file @
07140d33
package
com
.
topjohnwu
.
magisk
.
services
;
import
android.app.IntentService
;
import
android.content.Intent
;
import
android.os.Build
;
import
android.support.v4.app.NotificationCompat
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.R
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.RootUtils
;
public
class
OnBootIntentService
extends
IntentService
{
public
OnBootIntentService
()
{
super
(
"OnBootIntentService"
);
}
@Override
public
void
onCreate
()
{
super
.
onCreate
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
startForeground
(
Const
.
ID
.
ONBOOT_NOTIFICATION_ID
,
new
NotificationCompat
.
Builder
(
this
,
Const
.
ID
.
NOTIFICATION_CHANNEL
)
.
setSmallIcon
(
R
.
drawable
.
ic_magisk_outline
)
.
setContentTitle
(
"Startup Operations"
)
.
setContentText
(
"Running startup operations..."
)
.
build
());
}
}
@Override
protected
void
onHandleIntent
(
Intent
intent
)
{
/* Pixel 2 (XL) devices will need to patch dtbo.img.
* However, that is not possible if Magisk is installed by
* patching boot image with Magisk Manager and fastboot flash
* the boot image, since at that time we do not have root.
* Check for dtbo status every boot time, and prompt user
* to reboot if dtbo wasn't patched and patched by Magisk Manager.
* */
MagiskManager
.
get
().
loadMagiskInfo
();
RootUtils
.
patchDTBO
();
}
}
app/src/full/java/com/topjohnwu/magisk/services/OnBootService.java
0 → 100644
View file @
6263d684
package
com
.
topjohnwu
.
magisk
.
services
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.support.annotation.NonNull
;
import
android.support.v4.app.JobIntentService
;
import
com.topjohnwu.magisk.utils.Const
;
import
com.topjohnwu.magisk.utils.ShowUI
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.ShellUtils
;
public
class
OnBootService
extends
JobIntentService
{
public
static
void
enqueueWork
(
Context
context
)
{
enqueueWork
(
context
,
OnBootService
.
class
,
Const
.
ID
.
ONBOOT_SERVICE_ID
,
new
Intent
());
}
@Override
protected
void
onHandleWork
(
@NonNull
Intent
intent
)
{
/* Devices with DTBO might want to patch dtbo.img.
* However, that is not possible if Magisk is installed by
* patching boot image with Magisk Manager and flashed via
* fastboot, since at that time we do not have root.
* Check for dtbo status every boot time, and prompt user
* to reboot if dtbo wasn't patched and patched by Magisk Manager.
* */
Shell
shell
=
Shell
.
newInstance
();
if
(
shell
.
getStatus
()
>=
Shell
.
ROOT_SHELL
&&
Boolean
.
parseBoolean
(
ShellUtils
.
fastCmd
(
shell
,
"mm_patch_dtbo"
)))
ShowUI
.
dtboPatchedNotification
();
}
}
app/src/full/java/com/topjohnwu/magisk/utils/Logger.java
View file @
6263d684
...
...
@@ -4,8 +4,6 @@ import android.util.Log;
import
com.topjohnwu.magisk.BuildConfig
;
import
java.util.Locale
;
public
class
Logger
{
public
static
void
debug
(
String
line
)
{
...
...
app/src/full/java/com/topjohnwu/magisk/utils/RootUtils.java
View file @
6263d684
package
com
.
topjohnwu
.
magisk
.
utils
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.ShellUtils
;
import
com.topjohnwu.superuser.io.SuFile
;
public
class
RootUtils
{
...
...
@@ -25,14 +23,4 @@ public class RootUtils {
public
static
void
uninstallPkg
(
String
pkg
)
{
Shell
.
Sync
.
su
(
"db_clean "
+
Const
.
USER_ID
,
"pm uninstall "
+
pkg
);
}
public
static
void
patchDTBO
()
{
if
(
Shell
.
rootAccess
())
{
MagiskManager
mm
=
MagiskManager
.
get
();
if
(
mm
.
magiskVersionCode
>=
Const
.
MAGISK_VER
.
DTBO_SUPPORT
)
{
if
(
Boolean
.
parseBoolean
(
ShellUtils
.
fastCmd
(
"mm_patch_dtbo"
)))
ShowUI
.
dtboPatchedNotification
();
}
}
}
}
app/src/main/java/com/topjohnwu/magisk/utils/Const.java
View file @
6263d684
...
...
@@ -59,7 +59,6 @@ public class Const {
public
static
final
int
FBE_AWARE
=
1410
;
public
static
final
int
RESETPROP_PERSIST
=
1436
;
public
static
final
int
MANAGER_HIDE
=
1440
;
public
static
final
int
DTBO_SUPPORT
=
1446
;
public
static
final
int
HIDDEN_PATH
=
1460
;
public
static
final
int
REMOVE_LEGACY_LINK
=
1630
;
public
static
final
int
SEPOL_REFACTOR
=
1640
;
...
...
@@ -70,11 +69,11 @@ public class Const {
public
static
final
int
UPDATE_SERVICE_ID
=
1
;
public
static
final
int
FETCH_ZIP
=
2
;
public
static
final
int
SELECT_BOOT
=
3
;
public
static
final
int
ONBOOT_SERVICE_ID
=
6
;
// notifications
public
static
final
int
MAGISK_UPDATE_NOTIFICATION_ID
=
4
;
public
static
final
int
APK_UPDATE_NOTIFICATION_ID
=
5
;
public
static
final
int
ONBOOT_NOTIFICATION_ID
=
6
;
public
static
final
int
DTBO_NOTIFICATION_ID
=
7
;
public
static
final
String
NOTIFICATION_CHANNEL
=
"magisk_notification"
;
}
...
...
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