Merge "Fixed emergency alert not showing up issue"
diff --git a/src/com/android/cellbroadcastservice/CellBroadcastHandler.java b/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
index 8ca6d1b..4713507 100644
--- a/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
+++ b/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
@@ -424,6 +424,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 99b935c..7de49f0 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;
}