diff --git a/api/system-current.txt b/api/system-current.txt
index 325167a10ea23..7cd0ef7c1be6e 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -24,6 +24,7 @@ package android {
field public static final String BACKUP = "android.permission.BACKUP";
field public static final String BIND_ATTENTION_SERVICE = "android.permission.BIND_ATTENTION_SERVICE";
field public static final String BIND_AUGMENTED_AUTOFILL_SERVICE = "android.permission.BIND_AUGMENTED_AUTOFILL_SERVICE";
+ field public static final String BIND_CELL_BROADCAST_SERVICE = "android.permission.BIND_CELL_BROADCAST_SERVICE";
field @Deprecated public static final String BIND_CONNECTION_SERVICE = "android.permission.BIND_CONNECTION_SERVICE";
field public static final String BIND_CONTENT_CAPTURE_SERVICE = "android.permission.BIND_CONTENT_CAPTURE_SERVICE";
field public static final String BIND_CONTENT_SUGGESTIONS_SERVICE = "android.permission.BIND_CONTENT_SUGGESTIONS_SERVICE";
@@ -7294,6 +7295,14 @@ package android.telephony {
method @NonNull public android.telephony.CarrierRestrictionRules.Builder setMultiSimPolicy(int);
}
+ public abstract class CellBroadcastService extends android.app.Service {
+ ctor public CellBroadcastService();
+ method @CallSuper public android.os.IBinder onBind(android.content.Intent);
+ method public abstract void onCdmaCellBroadcastSms(int, byte[]);
+ method public abstract void onGsmCellBroadcastSms(int, byte[]);
+ field public static final String CELL_BROADCAST_SERVICE_INTERFACE = "android.telephony.CellBroadcastService";
+ }
+
public final class DataFailCause {
field public static final int ACCESS_ATTEMPT_ALREADY_IN_PROGRESS = 2219; // 0x8ab
field public static final int ACCESS_BLOCK = 2087; // 0x827
diff --git a/api/test-current.txt b/api/test-current.txt
index 51b569f029d09..18b2482a047bb 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -5,6 +5,7 @@ package android {
field public static final String ACCESS_NOTIFICATIONS = "android.permission.ACCESS_NOTIFICATIONS";
field public static final String ACTIVITY_EMBEDDING = "android.permission.ACTIVITY_EMBEDDING";
field public static final String APPROVE_INCIDENT_REPORTS = "android.permission.APPROVE_INCIDENT_REPORTS";
+ field public static final String BIND_CELL_BROADCAST_SERVICE = "android.permission.BIND_CELL_BROADCAST_SERVICE";
field public static final String BRIGHTNESS_SLIDER_USAGE = "android.permission.BRIGHTNESS_SLIDER_USAGE";
field public static final String CHANGE_APP_IDLE_STATE = "android.permission.CHANGE_APP_IDLE_STATE";
field public static final String CLEAR_APP_USER_DATA = "android.permission.CLEAR_APP_USER_DATA";
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 1d590ea2f8961..18f8d7b04c3f0 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -794,6 +794,18 @@
android:permissionFlags="hardRestricted"
android:protectionLevel="dangerous" />
+
+
+ * To extend this class, you must declare the service in your manifest file to require the + * {@link android.Manifest.permission#BIND_CELL_BROADCAST_SERVICE} permission and include an intent + * filter with the {@link #CELL_BROADCAST_SERVICE_INTERFACE}. + * Implementations of this service should run in the phone process and with its UID. + *
+ * For example: + *
{@code
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * }
+ * @hide
+ */
+@SystemApi
+public abstract class CellBroadcastService extends Service {
+
+ public static final String CELL_BROADCAST_SERVICE_INTERFACE =
+ "android.telephony.CellBroadcastService";
+
+ private final ICellBroadcastService.Stub mStubWrapper;
+
+ public CellBroadcastService() {
+ mStubWrapper = new ICellBroadcastServiceWrapper();
+ }
+
+ /**
+ * Handle a GSM cell broadcast SMS message forwarded from the system.
+ * @param slotIndex the index of the slot which received the message
+ * @param message the SMS PDU
+ */
+ public abstract void onGsmCellBroadcastSms(int slotIndex, byte[] message);
+
+ /**
+ * Handle a CDMA cell broadcast SMS message forwarded from the system.
+ * @param slotIndex the index of the slot which received the message
+ * @param message the SMS PDU
+ */
+ public abstract void onCdmaCellBroadcastSms(int slotIndex, byte[] message);
+
+ /**
+ * If overriding this method, call through to the super method for any unknown actions.
+ * {@inheritDoc}
+ */
+ @Override
+ @CallSuper
+ public IBinder onBind(Intent intent) {
+ return mStubWrapper;
+ }
+
+ /**
+ * A wrapper around ICellBroadcastService that forwards calls to implementations of
+ * {@link CellBroadcastService}.
+ * @hide
+ */
+ public class ICellBroadcastServiceWrapper extends ICellBroadcastService.Stub {
+ /**
+ * Handle a GSM cell broadcast SMS.
+ * @param slotIndex the index of the slot which received the broadcast
+ * @param message the SMS message PDU
+ */
+ @Override
+ public void handleGsmCellBroadcastSms(int slotIndex, byte[] message) {
+ CellBroadcastService.this.onGsmCellBroadcastSms(slotIndex, message);
+ }
+
+ /**
+ * Handle a CDMA cell broadcast SMS.
+ * @param slotIndex the index of the slot which received the broadcast
+ * @param message the SMS message PDU
+ */
+ @Override
+ public void handleCdmaCellBroadcastSms(int slotIndex, byte[] message) {
+ CellBroadcastService.this.onCdmaCellBroadcastSms(slotIndex, message);
+ }
+ }
+}
diff --git a/telephony/java/android/telephony/ICellBroadcastService.aidl b/telephony/java/android/telephony/ICellBroadcastService.aidl
new file mode 100644
index 0000000000000..eff64a2e35baa
--- /dev/null
+++ b/telephony/java/android/telephony/ICellBroadcastService.aidl
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2019, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony;
+
+/**
+ * Service bound to by the system to allow custom handling of cell broadcast messages.
+ * + * @see android.telephony.CellBroadcastService + * @hide + */ +interface ICellBroadcastService { + + /** @see android.telephony.CellBroadcastService#onGsmCellBroadcastSms */ + oneway void handleGsmCellBroadcastSms(int slotId, in byte[] message); + + /** @see android.telephony.CellBroadcastService#onCdmaCellBroadcastSms */ + oneway void handleCdmaCellBroadcastSms(int slotId, in byte[] message); +} diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmSmsCbMessage.java b/telephony/java/com/android/internal/telephony/gsm/GsmSmsCbMessage.java index 6eea118787a7d..c65c45fa015b1 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmSmsCbMessage.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmSmsCbMessage.java @@ -461,7 +461,11 @@ public class GsmSmsCbMessage { } } - static final class GeoFencingTriggerMessage { + /** + * Part of a GSM SMS cell broadcast message which may trigger geo-fencing logic. + * @hide + */ + public static final class GeoFencingTriggerMessage { /** * Indicate the list of active alerts share their warning area coordinates which means the * broadcast area is the union of the broadcast areas of the active alerts in this list. @@ -476,6 +480,11 @@ public class GsmSmsCbMessage { this.cbIdentifiers = cbIdentifiers; } + /** + * Whether the trigger message indicates that the broadcast areas are shared between all + * active alerts. + * @return true if broadcast areas are to be shared + */ boolean shouldShareBroadcastArea() { return type == TYPE_ACTIVE_ALERT_SHARE_WAC; } diff --git a/telephony/java/com/android/internal/telephony/gsm/SmsCbHeader.java b/telephony/java/com/android/internal/telephony/gsm/SmsCbHeader.java index 6bbff4b91ee7e..cbe5211826672 100644 --- a/telephony/java/com/android/internal/telephony/gsm/SmsCbHeader.java +++ b/telephony/java/com/android/internal/telephony/gsm/SmsCbHeader.java @@ -74,22 +74,22 @@ public class SmsCbHeader { /** * Length of SMS-CB header */ - static final int PDU_HEADER_LENGTH = 6; + public static final int PDU_HEADER_LENGTH = 6; /** * GSM pdu format, as defined in 3gpp TS 23.041, section 9.4.1 */ - static final int FORMAT_GSM = 1; + public static final int FORMAT_GSM = 1; /** * UMTS pdu format, as defined in 3gpp TS 23.041, section 9.4.2 */ - static final int FORMAT_UMTS = 2; + public static final int FORMAT_UMTS = 2; /** - * GSM pdu format, as defined in 3gpp TS 23.041, section 9.4.1.3 + * ETWS pdu format, as defined in 3gpp TS 23.041, section 9.4.1.3 */ - static final int FORMAT_ETWS_PRIMARY = 3; + public static final int FORMAT_ETWS_PRIMARY = 3; /** * Message type value as defined in 3gpp TS 25.324, section 11.1. @@ -230,43 +230,43 @@ public class SmsCbHeader { } @UnsupportedAppUsage - int getGeographicalScope() { + public int getGeographicalScope() { return mGeographicalScope; } @UnsupportedAppUsage - int getSerialNumber() { + public int getSerialNumber() { return mSerialNumber; } @UnsupportedAppUsage - int getServiceCategory() { + public int getServiceCategory() { return mMessageIdentifier; } - int getDataCodingScheme() { + public int getDataCodingScheme() { return mDataCodingScheme; } - DataCodingScheme getDataCodingSchemeStructedData() { + public DataCodingScheme getDataCodingSchemeStructedData() { return mDataCodingSchemeStructedData; } @UnsupportedAppUsage - int getPageIndex() { + public int getPageIndex() { return mPageIndex; } @UnsupportedAppUsage - int getNumberOfPages() { + public int getNumberOfPages() { return mNrOfPages; } - SmsCbEtwsInfo getEtwsInfo() { + public SmsCbEtwsInfo getEtwsInfo() { return mEtwsInfo; } - SmsCbCmasInfo getCmasInfo() { + public SmsCbCmasInfo getCmasInfo() { return mCmasInfo; } @@ -274,7 +274,7 @@ public class SmsCbHeader { * Return whether this broadcast is an emergency (PWS) message type. * @return true if this message is emergency type; false otherwise */ - boolean isEmergencyMessage() { + public boolean isEmergencyMessage() { return mMessageIdentifier >= SmsCbConstants.MESSAGE_ID_PWS_FIRST_IDENTIFIER && mMessageIdentifier <= SmsCbConstants.MESSAGE_ID_PWS_LAST_IDENTIFIER; } @@ -292,7 +292,7 @@ public class SmsCbHeader { * Return whether this broadcast is an ETWS primary notification. * @return true if this message is an ETWS primary notification; false otherwise */ - boolean isEtwsPrimaryNotification() { + public boolean isEtwsPrimaryNotification() { return mFormat == FORMAT_ETWS_PRIMARY; } @@ -300,7 +300,7 @@ public class SmsCbHeader { * Return whether this broadcast is in UMTS format. * @return true if this message is in UMTS format; false otherwise */ - boolean isUmtsFormat() { + public boolean isUmtsFormat() { return mFormat == FORMAT_UMTS; }