OSDN Git Service

Support SMS cell broadcasting for GSM in RIL.java
authorjohnwang <johnwang@google.com>
Thu, 11 Jun 2009 17:05:29 +0000 (10:05 -0700)
committerjohnwang <johnwang@google.com>
Thu, 11 Jun 2009 22:43:29 +0000 (15:43 -0700)
enable gsm related cell broadcast requests in RIL.java and add SmsBraodcastConfigInfo class.

The gsm related cell broadcast requests include

RIL_REQUEST_GET_BROADCAST_CONFIG
RIL_REQUEST_GET_BROADCAST_CONFIG
RIL_REQUEST_BROADCAST_ACTIVATION
RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS

modified:   BaseCommands.java
modified:   CommandsInterface.java
modified:   RIL.java
modified:   RILConstants.java
modified:   cdma/CdmaSMSDispatcher.java
new file:   gsm/SmsBroadcastConfigInfo.java
modified:   test/SimulatedCommands.java

telephony/java/com/android/internal/telephony/BaseCommands.java
telephony/java/com/android/internal/telephony/CommandsInterface.java
telephony/java/com/android/internal/telephony/RIL.java
telephony/java/com/android/internal/telephony/RILConstants.java
telephony/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
telephony/java/com/android/internal/telephony/gsm/SmsBroadcastConfigInfo.java [new file with mode: 0644]
telephony/java/com/android/internal/telephony/test/SimulatedCommands.java

index 0b99911..3edca66 100644 (file)
@@ -81,6 +81,7 @@ public abstract class BaseCommands implements CommandsInterface {
     protected Registrant mIccRefreshRegistrant;
     protected Registrant mRingRegistrant;
     protected Registrant mRestrictedStateRegistrant;
+    protected Registrant mGsmBroadcastSmsRegistrant;
 
     // Network Mode received from PhoneFactory
     protected int mNetworkMode;
@@ -337,6 +338,14 @@ public abstract class BaseCommands implements CommandsInterface {
         mSMSRegistrant.clear();
     }
 
+    public void setOnNewGsmBroadcastSms(Handler h, int what, Object obj) {
+        mGsmBroadcastSmsRegistrant = new Registrant (h, what, obj);
+    }
+
+    public void unSetOnNewGsmBroadcastSms(Handler h) {
+        mGsmBroadcastSmsRegistrant.clear();
+    }
+
     public void setOnSmsOnSim(Handler h, int what, Object obj) {
         mSmsOnSimRegistrant = new Registrant (h, what, obj);
     }
index 75df955..25c512e 100644 (file)
@@ -16,6 +16,8 @@
 
 package com.android.internal.telephony;
 
+import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
+
 import android.os.Message;
 import android.os.Handler;
 
@@ -1200,6 +1202,31 @@ public interface CommandsInterface {
      */
     public void handleCallSetupRequestFromSim(boolean accept, Message response);
 
+    /**
+     * Activate or deactivate cell broadcast SMS for GSM.
+     *
+     * @param activate
+     *            true = activate, false = deactivate
+     * @param result Callback message is empty on completion
+     */
+    public void setGsmBroadcastActivation(boolean activate, Message result);
+
+    /**
+     * Configure cell broadcast SMS for GSM.
+     *
+     * @param response Callback message is empty on completion
+     */
+    public void setGsmBroadcastConfig(SmsBroadcastConfigInfo[] config, Message response);
+
+    /**
+     * Query the current configuration of cell broadcast SMS of GSM.
+     *
+     * @param response
+     *        Callback message contains the configuration from the modem
+     *        on completion
+     */
+    public void getGsmBroadcastConfig(Message response);
+
     //***** new Methods for CDMA support
 
     /**
@@ -1306,14 +1333,14 @@ public interface CommandsInterface {
     public void deactivateDataCall(int cid, Message result);
 
     /**
-     * Activate or deactivate cell broadcast SMS.
+     * Activate or deactivate cell broadcast SMS for CDMA.
      *
      * @param activate
-     *            0 = activate, 1 = deactivate
+     *            true = activate, false = deactivate
      * @param result
      *            Callback message is empty on completion
      */
-    public void activateCdmaBroadcastSms(int activate, Message result);
+    public void setCdmaBroadcastActivation(boolean activate, Message result);
 
     /**
      * Configure cdma cell broadcast SMS.
index 900683b..07fc7c6 100644 (file)
@@ -42,6 +42,7 @@ import com.android.internal.telephony.CallForwardInfo;
 import com.android.internal.telephony.CommandException;
 import com.android.internal.telephony.DataCallState;
 import com.android.internal.telephony.gsm.NetworkInfo;
+import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
 import com.android.internal.telephony.gsm.SuppServiceNotification;
 import com.android.internal.telephony.IccCardApplication;
 import com.android.internal.telephony.IccCardStatus;
@@ -1842,6 +1843,59 @@ public final class RIL extends BaseCommands implements CommandsInterface {
         send(rr);
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    public void getGsmBroadcastConfig(Message response) {
+        RILRequest rr = RILRequest.obtain(RIL_REQUEST_GSM_GET_BROADCAST_CONFIG, response);
+
+        if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
+
+        send(rr);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setGsmBroadcastConfig(SmsBroadcastConfigInfo[] config, Message response) {
+        RILRequest rr = RILRequest.obtain(RIL_REQUEST_GSM_SET_BROADCAST_CONFIG, response);
+
+        int numOfConfig = config.length;
+        rr.mp.writeInt(numOfConfig);
+
+        for(int i = 0; i < numOfConfig; i++) {
+            rr.mp.writeInt(config[i].getFromServiceId());
+            rr.mp.writeInt(config[i].getToServiceId());
+            rr.mp.writeInt(config[i].getFromCodeScheme());
+            rr.mp.writeInt(config[i].getToCodeScheme());
+            rr.mp.writeInt(config[i].isSelected() ? 1 : 0);
+        }
+
+        if (RILJ_LOGD) {
+            riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+                    + " with " + numOfConfig + "configs : ");
+            for (int i = 0; i < numOfConfig; i++) {
+                riljLog(config[i].toString());
+            }
+        }
+
+        send(rr);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setGsmBroadcastActivation(boolean activate, Message response) {
+        RILRequest rr = RILRequest.obtain(RIL_REQUEST_GSM_BROADCAST_ACTIVATION, response);
+
+        rr.mp.writeInt(1);
+        rr.mp.writeInt(activate ? 0 : 1);
+
+        if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
+
+        send(rr);
+    }
+
     //***** Private Methods
 
     private void sendScreenState(boolean on) {
@@ -2095,13 +2149,13 @@ public final class RIL extends BaseCommands implements CommandsInterface {
             case RIL_REQUEST_CDMA_BURST_DTMF: ret =  responseVoid(p); break;
             case RIL_REQUEST_CDMA_SEND_SMS: ret =  responseSMS(p); break;
             case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE: ret =  responseVoid(p); break;
-            case RIL_REQUEST_GET_BROADCAST_CONFIG: ret =  responseBR_SMS_CNF(p); break;
-            case RIL_REQUEST_SET_BROADCAST_CONFIG: ret =  responseVoid(p); break;
-            case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG: ret =  responseCDMA_BR_CNF(p); break;
+            case RIL_REQUEST_GSM_GET_BROADCAST_CONFIG: ret =  responseGmsBroadcastConfig(p); break;
+            case RIL_REQUEST_GSM_SET_BROADCAST_CONFIG: ret =  responseVoid(p); break;
+            case RIL_REQUEST_GSM_BROADCAST_ACTIVATION: ret =  responseVoid(p); break;
+            case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG: ret =  responseCdmaBroadcastConfig(p); break;
             case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG: ret =  responseVoid(p); break;
-            case RIL_REQUEST_BROADCAST_ACTIVATION: ret =  responseVoid(p); break;
-            case RIL_REQUEST_CDMA_VALIDATE_AKEY: ret =  responseVoid(p); break;
             case RIL_REQUEST_CDMA_BROADCAST_ACTIVATION: ret =  responseVoid(p); break;
+            case RIL_REQUEST_CDMA_VALIDATE_AKEY: ret =  responseVoid(p); break;
             case RIL_REQUEST_CDMA_SUBSCRIPTION: ret =  responseStrings(p); break;
             case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: ret =  responseInts(p); break;
             case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: ret =  responseVoid(p); break;
@@ -2449,12 +2503,16 @@ public final class RIL extends BaseCommands implements CommandsInterface {
                 }
 
             case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED:
+                if (RILJ_LOGD) unsljLog(response);
+
                 if (mIccStatusChangedRegistrants != null) {
                     mIccStatusChangedRegistrants.notifyRegistrants();
                 }
                 break;
 
             case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS:
+                if (RILJ_LOGD) unsljLog(response);
+
                 SmsMessage sms = (SmsMessage) ret;
 
                 if (mSMSRegistrant != null) {
@@ -2464,13 +2522,16 @@ public final class RIL extends BaseCommands implements CommandsInterface {
                 break;
 
             case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS:
-                // TODO T: waiting for SMS BC feature
+                if (RILJ_LOGD) unsljLog(response);
+
+                if (mGsmBroadcastSmsRegistrant != null) {
+                    mGsmBroadcastSmsRegistrant
+                        .notifyRegistrant(new AsyncResult(null, ret, null));
+                }
                 break;
 
             case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL:
-                if (Config.LOGD) {
-                    if (RILJ_LOGD) riljLog("[UNSL]< RUIM_SMS_STORAGE_FULL");
-                }
+                if (RILJ_LOGD) unsljLog(response);
 
                 if (mIccSmsFullRegistrant != null) {
                     mIccSmsFullRegistrant.notifyRegistrant();
@@ -2858,26 +2919,39 @@ public final class RIL extends BaseCommands implements CommandsInterface {
        response = new ArrayList<NeighboringCellInfo>(num);
 
        for (int i = 0 ; i < num ; i++) {
-           try {
-               int rssi = p.readInt();
-               int cid = Integer.valueOf(p.readString(), 16);
-               cell = new NeighboringCellInfo(rssi, cid);
-               response.add(cell);
-           } catch ( Exception e) {
-           }
+           int rssi = p.readInt();
+           int cid = Integer.valueOf(p.readString(), 16);
+           cell = new NeighboringCellInfo(rssi, cid);
+           response.add(cell);
        }
 
     return response;
     }
 
-    private Object
-    responseBR_SMS_CNF(Parcel p) {
-        // TODO
-        return null;
+    private Object responseGmsBroadcastConfig(Parcel p) {
+        int num;
+        ArrayList<SmsBroadcastConfigInfo> response;
+        SmsBroadcastConfigInfo info;
+
+        num = p.readInt();
+        response = new ArrayList<SmsBroadcastConfigInfo>(num);
+
+        for (int i = 0; i < num; i++) {
+            int fromId = p.readInt();
+            int toId = p.readInt();
+            int fromScheme = p.readInt();
+            int toScheme = p.readInt();
+            boolean selected = (p.readInt() == 1);
+
+            info = new SmsBroadcastConfigInfo(fromId, toId, fromScheme,
+                    toScheme, selected);
+            response.add(info);
+        }
+        return response;
     }
 
     private Object
-    responseCDMA_BR_CNF(Parcel p) {
+    responseCdmaBroadcastConfig(Parcel p) {
         int numServiceCategories;
         int response[];
 
@@ -3121,11 +3195,11 @@ public final class RIL extends BaseCommands implements CommandsInterface {
             case RIL_REQUEST_CDMA_BURST_DTMF: return "RIL_REQUEST_CDMA_BURST_DTMF";
             case RIL_REQUEST_CDMA_SEND_SMS: return "RIL_REQUEST_CDMA_SEND_SMS";
             case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE: return "RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE";
-            case RIL_REQUEST_GET_BROADCAST_CONFIG: return "RIL_REQUEST_GET_BROADCAST_CONFIG";
-            case RIL_REQUEST_SET_BROADCAST_CONFIG: return "RIL_REQUEST_SET_BROADCAST_CONFIG";
+            case RIL_REQUEST_GSM_GET_BROADCAST_CONFIG: return "RIL_REQUEST_GSM_GET_BROADCAST_CONFIG";
+            case RIL_REQUEST_GSM_SET_BROADCAST_CONFIG: return "RIL_REQUEST_GSM_SET_BROADCAST_CONFIG";
             case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG: return "RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG";
             case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG: return "RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG";
-            case RIL_REQUEST_BROADCAST_ACTIVATION: return "RIL_REQUEST_BROADCAST_ACTIVATION";
+            case RIL_REQUEST_GSM_BROADCAST_ACTIVATION: return "RIL_REQUEST_GSM_BROADCAST_ACTIVATION";
             case RIL_REQUEST_CDMA_VALIDATE_AKEY: return "RIL_REQUEST_CDMA_VALIDATE_AKEY";
             case RIL_REQUEST_CDMA_BROADCAST_ACTIVATION: return "RIL_REQUEST_CDMA_BROADCAST_ACTIVATION";
             case RIL_REQUEST_CDMA_SUBSCRIPTION: return "RIL_REQUEST_CDMA_SUBSCRIPTION";
@@ -3332,11 +3406,11 @@ public final class RIL extends BaseCommands implements CommandsInterface {
         send(rr);
     }
 
-    public void activateCdmaBroadcastSms(int activate, Message response) {
+    public void setCdmaBroadcastActivation(boolean activate, Message response) {
         RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_BROADCAST_ACTIVATION, response);
 
         rr.mp.writeInt(1);
-        rr.mp.writeInt(activate);
+        rr.mp.writeInt(activate ? 0 :1);
 
         if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
 
index b09832b..b2e16c7 100644 (file)
@@ -206,9 +206,9 @@ cat include/telephony/ril.h | \
     int RIL_REQUEST_CDMA_VALIDATE_AKEY = 86;
     int RIL_REQUEST_CDMA_SEND_SMS = 87;
     int RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE = 88;
-    int RIL_REQUEST_GET_BROADCAST_CONFIG = 89;
-    int RIL_REQUEST_SET_BROADCAST_CONFIG = 90;
-    int RIL_REQUEST_BROADCAST_ACTIVATION = 91;
+    int RIL_REQUEST_GSM_GET_BROADCAST_CONFIG = 89;
+    int RIL_REQUEST_GSM_SET_BROADCAST_CONFIG = 90;
+    int RIL_REQUEST_GSM_BROADCAST_ACTIVATION = 91;
     int RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG = 92;
     int RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG = 93;
     int RIL_REQUEST_CDMA_BROADCAST_ACTIVATION = 94;
index f12e7e3..79e1cd6 100644 (file)
@@ -342,7 +342,7 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
 
     /** {@inheritDoc} */
     protected void activateCellBroadcastSms(int activate, Message response) {
-        mCm.activateCdmaBroadcastSms(activate, response);
+        mCm.setCdmaBroadcastActivation((activate == 0), response);
     }
 
     /** {@inheritDoc} */
diff --git a/telephony/java/com/android/internal/telephony/gsm/SmsBroadcastConfigInfo.java b/telephony/java/com/android/internal/telephony/gsm/SmsBroadcastConfigInfo.java
new file mode 100644 (file)
index 0000000..45f50bc
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2009 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 com.android.internal.telephony.gsm;
+
+/**
+ * SmsBroadcastConfigInfo defines one configuration of Cell Broadcast
+ * Message (CBM) to be received by the ME
+ *
+ * fromServiceId - toServiceId defines a range of CBM message identifiers
+ * whose value is 0x0000 - 0xFFFF as defined in TS 23.041 9.4.1.2.2 for GMS
+ * and 9.4.4.2.2 for UMTS. All other values can be treated as empty
+ * CBM message ID.
+ *
+ * fromCodeScheme - toCodeScheme defines a range of CBM data coding schemes
+ * whose value is 0x00 - 0xFF as defined in TS 23.041 9.4.1.2.3 for GMS
+ * and 9.4.4.2.3 for UMTS.
+ * All other values can be treated as empty CBM data coding scheme.
+ *
+ * selected false means message types specified in <fromServiceId, toServiceId>
+ * and <fromCodeScheme, toCodeScheme>are not accepted, while true means accepted.
+ *
+ */
+public class SmsBroadcastConfigInfo {
+    private int fromServiceId;
+    private int toServiceId;
+    private int fromCodeScheme;
+    private int toCodeScheme;
+    private boolean selected;
+
+    /**
+     * Initialize the object from rssi and cid.
+     */
+    public SmsBroadcastConfigInfo(int fromId, int toId, int fromScheme,
+            int toScheme, boolean selected) {
+        setFromServiceId(fromId);
+        setToServiceId(toId);
+        setFromCodeScheme(fromScheme);
+        setToCodeScheme(toScheme);
+        this.setSelected(selected);
+    }
+
+    /**
+     * @param fromServiceId the fromServiceId to set
+     */
+    public void setFromServiceId(int fromServiceId) {
+        this.fromServiceId = fromServiceId;
+    }
+
+    /**
+     * @return the fromServiceId
+     */
+    public int getFromServiceId() {
+        return fromServiceId;
+    }
+
+    /**
+     * @param toServiceId the toServiceId to set
+     */
+    public void setToServiceId(int toServiceId) {
+        this.toServiceId = toServiceId;
+    }
+
+    /**
+     * @return the toServiceId
+     */
+    public int getToServiceId() {
+        return toServiceId;
+    }
+
+    /**
+     * @param fromCodeScheme the fromCodeScheme to set
+     */
+    public void setFromCodeScheme(int fromCodeScheme) {
+        this.fromCodeScheme = fromCodeScheme;
+    }
+
+    /**
+     * @return the fromCodeScheme
+     */
+    public int getFromCodeScheme() {
+        return fromCodeScheme;
+    }
+
+    /**
+     * @param toCodeScheme the toCodeScheme to set
+     */
+    public void setToCodeScheme(int toCodeScheme) {
+        this.toCodeScheme = toCodeScheme;
+    }
+
+    /**
+     * @return the toCodeScheme
+     */
+    public int getToCodeScheme() {
+        return toCodeScheme;
+    }
+
+    /**
+     * @param selected the selected to set
+     */
+    public void setSelected(boolean selected) {
+        this.selected = selected;
+    }
+
+    /**
+     * @return the selected
+     */
+    public boolean isSelected() {
+        return selected;
+    }
+
+    @Override
+    public String toString() {
+        return "SmsBroadcastConfigInfo: Id [" +
+            getFromServiceId() + "," + getToServiceId() + "] Code [" +
+            getFromCodeScheme() + "," + getToCodeScheme() + "] " +
+            (isSelected() ? "ENABLED" : "DISABLED");
+    }
+}
\ No newline at end of file
index ff7004f..22adc19 100644 (file)
@@ -28,6 +28,7 @@ import com.android.internal.telephony.CommandException;
 import com.android.internal.telephony.CommandsInterface;
 import com.android.internal.telephony.DataCallState;
 import com.android.internal.telephony.gsm.CallFailCause;
+import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
 import com.android.internal.telephony.gsm.SuppServiceNotification;
 import com.android.internal.telephony.Phone;
 
@@ -1453,22 +1454,36 @@ public final class SimulatedCommands extends BaseCommands
        Log.w(LOG_TAG, "CDMA not implemented in SimulatedCommands");
     }
 
-    public void activateCdmaBroadcastSms(int activate, Message result) {
-        // TODO Auto-generated method stub
+    public void setCdmaBroadcastActivation(boolean activate, Message response) {
+        unimplemented(response);
 
     }
 
-    public void getCdmaBroadcastConfig(Message result) {
-        // TODO Auto-generated method stub
+    public void getCdmaBroadcastConfig(Message response) {
+        unimplemented(response);
 
     }
 
-    public void setCdmaBroadcastConfig(int[] configValuesArray, Message result) {
-        // TODO Auto-generated method stub
+    public void setCdmaBroadcastConfig(int[] configValuesArray, Message response) {
+        unimplemented(response);
 
     }
 
     public void forceDataDormancy(Message response) {
-        // TODO method stub
+        unimplemented(response);
+    }
+
+
+    public void setGsmBroadcastActivation(boolean activate, Message response) {
+        unimplemented(response);
+    }
+
+
+    public void setGsmBroadcastConfig(SmsBroadcastConfigInfo[] config, Message response) {
+        unimplemented(response);
+    }
+
+    public void getGsmBroadcastConfig(Message response) {
+        unimplemented(response);
     }
 }