Fixed emergency alert not showing up issue
After receiving a out-of-bound geo-targeting
emergency alert, the device is not able to display
any kind of emergency alert anymore.
Fixed by properly handling out-of-bound alert so
state machine can properly return back to idle
state.
Bug: 142670652
Bug: 139501531
Test: Manual
Change-Id: I7deed086608c9385600270c6feab1f8fae184ad1
diff --git a/src/com/android/cellbroadcastservice/CellBroadcastHandler.java b/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
index 008663c..fa6978f 100644
--- a/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
+++ b/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
@@ -423,6 +423,8 @@
logd("Device location is outside the broadcast area "
+ CbGeoUtils.encodeGeometriesToString(broadcastArea));
}
+
+ sendMessage(EVENT_BROADCAST_NOT_REQUIRED);
}
/**
diff --git a/src/com/android/cellbroadcastservice/WakeLockStateMachine.java b/src/com/android/cellbroadcastservice/WakeLockStateMachine.java
index edb392e..789534d 100644
--- a/src/com/android/cellbroadcastservice/WakeLockStateMachine.java
+++ b/src/com/android/cellbroadcastservice/WakeLockStateMachine.java
@@ -51,6 +51,9 @@
/** Release wakelock after a short timeout when returning to idle state. */
static final int EVENT_RELEASE_WAKE_LOCK = 3;
+ /** Broadcast not required due to geo-fencing check */
+ static final int EVENT_BROADCAST_NOT_REQUIRED = 4;
+
@UnsupportedAppUsage
protected Context mContext;
@@ -148,13 +151,14 @@
@Override
public void exit() {
mWakeLock.acquire();
- if (DBG) log("acquired wakelock, leaving Idle state");
+ if (DBG) log("Idle: acquired wakelock, leaving Idle state");
}
@Override
public boolean processMessage(Message msg) {
switch (msg.what) {
case EVENT_NEW_SMS_MESSAGE:
+ log("Idle: new cell broadcast message");
// transition to waiting state if we sent a broadcast
if (handleSmsMessage(msg)) {
transitionTo(mWaitingState);
@@ -162,9 +166,12 @@
return HANDLED;
case EVENT_RELEASE_WAKE_LOCK:
+ log("Idle: release wakelock");
releaseWakeLock();
return HANDLED;
-
+ case EVENT_BROADCAST_NOT_REQUIRED:
+ log("Idle: broadcast not required");
+ return HANDLED;
default:
return NOT_HANDLED;
}
@@ -180,19 +187,25 @@
public boolean processMessage(Message msg) {
switch (msg.what) {
case EVENT_NEW_SMS_MESSAGE:
- log("deferring message until return to idle");
+ log("Waiting: deferring message until return to idle");
deferMessage(msg);
return HANDLED;
case EVENT_BROADCAST_COMPLETE:
- log("broadcast complete, returning to idle");
+ log("Waiting: broadcast complete, returning to idle");
transitionTo(mIdleState);
return HANDLED;
case EVENT_RELEASE_WAKE_LOCK:
+ log("Waiting: release wakelock");
releaseWakeLock();
return HANDLED;
-
+ case EVENT_BROADCAST_NOT_REQUIRED:
+ log("Waiting: broadcast not required");
+ if (mReceiverCount.get() == 0) {
+ transitionTo(mIdleState);
+ }
+ return HANDLED;
default:
return NOT_HANDLED;
}