Broadcast authorization result
Masquerade will send out a masquerade.substratum.CALLER_AUTHORIZED intent with an
boolean isCallerAuthorized to notify about the authorization attempt.
Change-Id: Ie88350812a9f8e0b3089e55eb28d1f15a01c77ce
diff --git a/app/src/main/java/masquerade/substratum/services/JobService.java b/app/src/main/java/masquerade/substratum/services/JobService.java
index 2ff0f20..94a22d6 100644
--- a/app/src/main/java/masquerade/substratum/services/JobService.java
+++ b/app/src/main/java/masquerade/substratum/services/JobService.java
@@ -127,6 +127,7 @@
new Sound(IOUtils.SYSTEM_THEME_NOTIFICATION_PATH, "/SoundsCache/notifications/", "notification", "notification", RingtoneManager.TYPE_NOTIFICATION),
new Sound(IOUtils.SYSTEM_THEME_RINGTONE_PATH, "/SoundsCache/ringtones/", "ringtone", "ringtone", RingtoneManager.TYPE_RINGTONE)
);
+ private static final String INTENT_CALLER_AUTHORIZED = "masquerade.substratum.CALLER_AUTHORIZED";
private static IOverlayManager mOMS;
private static IPackageManager mPM;
private final List<Runnable> mJobQueue = new ArrayList<>(0);
@@ -172,8 +173,13 @@
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
- // verify identity
- if (!isCallerAuthorized(intent)) {
+ // Verify identity
+ boolean authorized = isCallerAuthorized(intent);
+
+ // Broadcast authorization result
+ informCaller(authorized);
+
+ if (!authorized) {
log("caller not authorized, aborting");
return START_NOT_STICKY;
}
@@ -738,6 +744,12 @@
return false;
}
+ private void informCaller(boolean result) {
+ Intent intent = new Intent(INTENT_CALLER_AUTHORIZED);
+ intent.putExtra("isCallerAuthorized", result);
+ sendBroadcastAsUser(intent, UserHandle.ALL);
+ }
+
private class MainHandler extends Handler {
static final int MSG_JOB_QUEUE_EMPTY = 1;