Skip to content

Commit c6ed651

Browse files
committed
Improve IPC broadcast performance
The broadcast was initially sent in serialized (ordered) mode, which could cause delays when Android is very busy (such as at early boot). The broadcast was changed to use normal broadcast mode. Additionally, FLAG_RECEIVER_FOREGROUND was added to the intent flags, to make sure the receiver gets a foreground priority boost.
1 parent 88ada1f commit c6ed651

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

librootjava/src/main/java/eu/chainfire/librootjava/Reflection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ static void sendBroadcast(Intent intent) {
194194
Method mBroadcastIntent = getBroadcastIntent(oActivityManager.getClass());
195195
if (mBroadcastIntent.getParameterTypes().length == 13) {
196196
// API 24+
197-
mBroadcastIntent.invoke(oActivityManager, null, intent, null, null, 0, null, null, null, -1, null, true, false, 0);
197+
mBroadcastIntent.invoke(oActivityManager, null, intent, null, null, 0, null, null, null, -1, null, false, false, 0);
198198
return;
199199
}
200200
if (mBroadcastIntent.getParameterTypes().length == 12) {
201201
// API 21+
202-
mBroadcastIntent.invoke(oActivityManager, null, intent, null, null, 0, null, null, null, -1, true, false, 0);
202+
mBroadcastIntent.invoke(oActivityManager, null, intent, null, null, 0, null, null, null, -1, false, false, 0);
203203
return;
204204
}
205205
} catch (Exception e) {

librootjava/src/main/java/eu/chainfire/librootjava/RootIPC.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ public void broadcastIPC() {
149149
Intent intent = new Intent();
150150
intent.setPackage(packageName);
151151
intent.setAction(RootIPCReceiver.BROADCAST_ACTION);
152+
intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
152153

153154
Bundle bundle = new Bundle();
154155
bundle.putBinder(RootIPCReceiver.BROADCAST_BINDER, binder);

0 commit comments

Comments
 (0)