Loading src/java/com/android/internal/telephony/CellBroadcastHandler.java +20 −2 Original line number Diff line number Diff line Loading @@ -30,15 +30,21 @@ import android.provider.Settings; import android.provider.Telephony; import android.telephony.SmsCbMessage; import android.telephony.SubscriptionManager; import android.util.LocalLog; import com.android.internal.telephony.metrics.TelephonyMetrics; import java.io.FileDescriptor; import java.io.PrintWriter; /** * Dispatch new Cell Broadcasts to receivers. Acquires a private wakelock until the broadcast * completes and our result receiver is called. */ public class CellBroadcastHandler extends WakeLockStateMachine { private final LocalLog mLocalLog = new LocalLog(100); private CellBroadcastHandler(Context context, Phone phone) { this("CellBroadcastHandler", context, phone); } Loading Loading @@ -90,9 +96,12 @@ public class CellBroadcastHandler extends WakeLockStateMachine { message.getMessagePriority(), message.isCmasMessage(), message.isEtwsMessage(), message.getServiceCategory()); String msg; Intent intent; if (message.isEmergencyMessage()) { log("Dispatching emergency SMS CB, SmsCbMessage is: " + message); msg = "Dispatching emergency SMS CB, SmsCbMessage is: " + message; log(msg); mLocalLog.log(msg); intent = new Intent(Telephony.Sms.Intents.SMS_EMERGENCY_CB_RECEIVED_ACTION); // Explicitly send the intent to the default cell broadcast receiver. intent.setPackage(mContext.getResources().getString( Loading @@ -100,7 +109,9 @@ public class CellBroadcastHandler extends WakeLockStateMachine { receiverPermission = Manifest.permission.RECEIVE_EMERGENCY_BROADCAST; appOp = AppOpsManager.OP_RECEIVE_EMERGECY_SMS; } else { log("Dispatching SMS CB, SmsCbMessage is: " + message); msg = "Dispatching SMS CB, SmsCbMessage is: " + message; log(msg); mLocalLog.log(msg); intent = new Intent(Telephony.Sms.Intents.SMS_CB_RECEIVED_ACTION); // Send implicit intent since there are various 3rd party carrier apps listen to // this intent. Loading Loading @@ -129,4 +140,11 @@ public class CellBroadcastHandler extends WakeLockStateMachine { mContext.sendOrderedBroadcastAsUser(intent, UserHandle.ALL, receiverPermission, appOp, mReceiver, getHandler(), Activity.RESULT_OK, null, null); } @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("CellBroadcastHandler:"); mLocalLog.dump(fd, pw, args); pw.flush(); } } src/java/com/android/internal/telephony/IccSmsInterfaceManager.java +56 −22 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.service.carrier.CarrierMessagingService; import android.telephony.Rlog; import android.telephony.SmsManager; import android.telephony.SmsMessage; import android.util.LocalLog; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; Loading @@ -50,6 +51,8 @@ import com.android.internal.telephony.uicc.IccFileHandler; import com.android.internal.telephony.uicc.IccUtils; import com.android.internal.util.HexDump; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; Loading Loading @@ -86,6 +89,8 @@ public class IccSmsInterfaceManager { final private UserManager mUserManager; protected SmsDispatchersController mDispatchersController; private final LocalLog mCellBroadcastLocalLog = new LocalLog(100); protected Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { Loading Loading @@ -788,7 +793,7 @@ public class IccSmsInterfaceManager { } else if (ranType == SmsManager.CELL_BROADCAST_RAN_TYPE_CDMA) { return enableCdmaBroadcastRange(startMessageId, endMessageId); } else { throw new IllegalArgumentException("Not a supportted RAN Type"); throw new IllegalArgumentException("Not a supported RAN Type"); } } Loading @@ -798,7 +803,7 @@ public class IccSmsInterfaceManager { } else if (ranType == SmsManager.CELL_BROADCAST_RAN_TYPE_CDMA) { return disableCdmaBroadcastRange(startMessageId, endMessageId); } else { throw new IllegalArgumentException("Not a supportted RAN Type"); throw new IllegalArgumentException("Not a supported RAN Type"); } } Loading @@ -811,15 +816,21 @@ public class IccSmsInterfaceManager { String client = mContext.getPackageManager().getNameForUid( Binder.getCallingUid()); String msg; if (!mCellBroadcastRangeManager.enableRange(startMessageId, endMessageId, client)) { log("Failed to add GSM cell broadcast subscription for MID range " + startMessageId + " to " + endMessageId + " from client " + client); msg = "Failed to add GSM cell broadcast channels range " + startMessageId + " to " + endMessageId; log(msg); mCellBroadcastLocalLog.log(msg); return false; } if (DBG) log("Added GSM cell broadcast subscription for MID range " + startMessageId + " to " + endMessageId + " from client " + client); if (DBG) { msg = "Added GSM cell broadcast channels range " + startMessageId + " to " + endMessageId; log(msg); mCellBroadcastLocalLog.log(msg); } setCellBroadcastActivation(!mCellBroadcastRangeManager.isEmpty()); Loading @@ -835,15 +846,21 @@ public class IccSmsInterfaceManager { String client = mContext.getPackageManager().getNameForUid( Binder.getCallingUid()); String msg; if (!mCellBroadcastRangeManager.disableRange(startMessageId, endMessageId, client)) { log("Failed to remove GSM cell broadcast subscription for MID range " + startMessageId + " to " + endMessageId + " from client " + client); msg = "Failed to remove GSM cell broadcast channels range " + startMessageId + " to " + endMessageId; log(msg); mCellBroadcastLocalLog.log(msg); return false; } if (DBG) log("Removed GSM cell broadcast subscription for MID range " + startMessageId + " to " + endMessageId + " from client " + client); if (DBG) { msg = "Removed GSM cell broadcast channels range " + startMessageId + " to " + endMessageId; log(msg); mCellBroadcastLocalLog.log(msg); } setCellBroadcastActivation(!mCellBroadcastRangeManager.isEmpty()); Loading @@ -859,15 +876,20 @@ public class IccSmsInterfaceManager { String client = mContext.getPackageManager().getNameForUid( Binder.getCallingUid()); String msg; if (!mCdmaBroadcastRangeManager.enableRange(startMessageId, endMessageId, client)) { log("Failed to add cdma broadcast subscription for MID range " + startMessageId + " to " + endMessageId + " from client " + client); msg = "Failed to add cdma broadcast channels range " + startMessageId + " to " + endMessageId; log(msg); mCellBroadcastLocalLog.log(msg); return false; } if (DBG) log("Added cdma broadcast subscription for MID range " + startMessageId + " to " + endMessageId + " from client " + client); if (DBG) { msg = "Added cdma broadcast channels range " + startMessageId + " to " + endMessageId; log(msg); mCellBroadcastLocalLog.log(msg); } setCdmaBroadcastActivation(!mCdmaBroadcastRangeManager.isEmpty()); Loading @@ -883,15 +905,20 @@ public class IccSmsInterfaceManager { String client = mContext.getPackageManager().getNameForUid( Binder.getCallingUid()); String msg; if (!mCdmaBroadcastRangeManager.disableRange(startMessageId, endMessageId, client)) { log("Failed to remove cdma broadcast subscription for MID range " + startMessageId + " to " + endMessageId + " from client " + client); msg = "Failed to remove cdma broadcast channels range " + startMessageId + " to " + endMessageId; log(msg); mCellBroadcastLocalLog.log(msg); return false; } if (DBG) log("Removed cdma broadcast subscription for MID range " + startMessageId + " to " + endMessageId + " from client " + client); if (DBG) { msg = "Removed cdma broadcast channels range " + startMessageId + " to " + endMessageId; log(msg); mCellBroadcastLocalLog.log(msg); } setCdmaBroadcastActivation(!mCdmaBroadcastRangeManager.isEmpty()); Loading Loading @@ -1335,4 +1362,11 @@ public class IccSmsInterfaceManager { return result != null ? result : destAddr; } public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("CellBroadcast log:"); mCellBroadcastLocalLog.dump(fd, pw, args); pw.println("SMS dispatcher controller log:"); mDispatchersController.dump(fd, pw, args); pw.flush(); } } src/java/com/android/internal/telephony/InboundSmsHandler.java +48 −2 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ import android.telephony.SmsMessage; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.LocalLog; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; Loading @@ -69,6 +70,8 @@ import com.android.internal.util.State; import com.android.internal.util.StateMachine; import java.io.ByteArrayOutputStream; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.List; Loading Loading @@ -157,6 +160,9 @@ public abstract class InboundSmsHandler extends StateMachine { /** New SMS received as an AsyncResult. */ public static final int EVENT_INJECT_SMS = 8; /** Update the sms tracker */ public static final int EVENT_UPDATE_TRACKER = 9; /** Wakelock release delay when returning to idle state. */ private static final int WAKELOCK_TIMEOUT = 3000; Loading Loading @@ -205,6 +211,8 @@ public abstract class InboundSmsHandler extends StateMachine { private UserManager mUserManager; private LocalLog mLocalLog = new LocalLog(64); IDeviceIdleController mDeviceIdleController; // Delete permanently from raw table Loading Loading @@ -449,6 +457,7 @@ public abstract class InboundSmsHandler extends StateMachine { // if any broadcasts were sent, transition to waiting state InboundSmsTracker inboundSmsTracker = (InboundSmsTracker) msg.obj; if (processMessagePart(inboundSmsTracker)) { sendMessage(obtainMessage(EVENT_UPDATE_TRACKER, msg.obj)); transitionTo(mWaitingState); } else { // if event is sent from SmsBroadcastUndelivered.broadcastSms(), and Loading @@ -474,10 +483,17 @@ public abstract class InboundSmsHandler extends StateMachine { } return HANDLED; case EVENT_UPDATE_TRACKER: logd("process tracker message in DeliveringState " + msg.arg1); return HANDLED; // we shouldn't get this message type in this state, log error and halt. case EVENT_BROADCAST_COMPLETE: case EVENT_START_ACCEPTING_SMS: default: String errorMsg = "Unhandled msg in delivering state, msg.what = " + msg.what; loge(errorMsg); mLocalLog.log(errorMsg); // let DefaultState handle these unexpected message types return NOT_HANDLED; } Loading @@ -493,6 +509,8 @@ public abstract class InboundSmsHandler extends StateMachine { */ private class WaitingState extends State { private InboundSmsTracker mLastDeliveredSmsTracker; @Override public void enter() { if (DBG) log("entering Waiting state"); Loading @@ -512,10 +530,20 @@ public abstract class InboundSmsHandler extends StateMachine { switch (msg.what) { case EVENT_BROADCAST_SMS: // defer until the current broadcast completes if (mLastDeliveredSmsTracker != null) { String str = "Defer sms broadcast due to undelivered sms, " + " messageCount = " + mLastDeliveredSmsTracker.getMessageCount() + " destPort = " + mLastDeliveredSmsTracker.getDestPort() + " timestamp = " + mLastDeliveredSmsTracker.getTimestamp() + " currentTimestamp = " + System.currentTimeMillis(); logd(str); mLocalLog.log(str); } deferMessage(msg); return HANDLED; case EVENT_BROADCAST_COMPLETE: mLastDeliveredSmsTracker = null; // return to idle after handling all deferred messages sendMessage(EVENT_RETURN_TO_IDLE); transitionTo(mDeliveringState); Loading @@ -525,6 +553,13 @@ public abstract class InboundSmsHandler extends StateMachine { // not ready to return to idle; ignore return HANDLED; case EVENT_UPDATE_TRACKER: for (int i = 1; i < 10; i++) { deferMessage(obtainMessage(EVENT_UPDATE_TRACKER, i, i, msg.obj)); } mLastDeliveredSmsTracker = (InboundSmsTracker) msg.obj; return HANDLED; default: // parent state handles the other message types return NOT_HANDLED; Loading Loading @@ -853,8 +888,10 @@ public abstract class InboundSmsHandler extends StateMachine { // Do not process null pdu(s). Check for that and return false in that case. List<byte[]> pduList = Arrays.asList(pdus); if (pduList.size() == 0 || pduList.contains(null)) { loge("processMessagePart: returning false due to " + (pduList.size() == 0 ? "pduList.size() == 0" : "pduList.contains(null)")); String errorMsg = "processMessagePart: returning false due to " + (pduList.size() == 0 ? "pduList.size() == 0" : "pduList.contains(null)"); loge(errorMsg); mLocalLog.log(errorMsg); return false; } Loading Loading @@ -1547,6 +1584,15 @@ public abstract class InboundSmsHandler extends StateMachine { } } @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { super.dump(fd, pw, args); if (mCellBroadcastHandler != null) { mCellBroadcastHandler.dump(fd, pw, args); } mLocalLog.dump(fd, pw, args); } // Some providers send formfeeds in their messages. Convert those formfeeds to newlines. private static String replaceFormFeeds(String s) { return s == null ? "" : s.replace('\f', '\n'); Loading src/java/com/android/internal/telephony/SmsDispatchersController.java +7 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,8 @@ import com.android.internal.telephony.cdma.CdmaSMSDispatcher; import com.android.internal.telephony.gsm.GsmInboundSmsHandler; import com.android.internal.telephony.gsm.GsmSMSDispatcher; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; Loading Loading @@ -627,4 +629,9 @@ public class SmsDispatchersController extends Handler { public interface SmsInjectionCallback { void onSmsInjectedResult(int result); } public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { mGsmInboundSmsHandler.dump(fd, pw, args); mCdmaInboundSmsHandler.dump(fd, pw, args); } } src/java/com/android/internal/telephony/UiccSmsController.java +21 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,10 @@ import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import com.android.internal.util.IndentingPrintWriter; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.List; /** Loading Loading @@ -413,6 +417,23 @@ public class UiccSmsController extends ISms.Stub { return getPhone(subId).getAppSmsManager().createAppSpecificSmsToken(callingPkg, intent); } @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { IndentingPrintWriter indentingPW = new IndentingPrintWriter(pw, " " /* singleIndent */); for (Phone phone : PhoneFactory.getPhones()) { int subId = phone.getSubId(); indentingPW.println(String.format("SmsManager for subId = %d:", subId)); indentingPW.increaseIndent(); if (getIccSmsInterfaceManager(subId) != null) { getIccSmsInterfaceManager(subId).dump(fd, indentingPW, args); } indentingPW.decreaseIndent(); } indentingPW.flush(); } private void sendErrorInPendingIntent(@Nullable PendingIntent intent, int errorCode) { if (intent != null) { try { Loading Loading
src/java/com/android/internal/telephony/CellBroadcastHandler.java +20 −2 Original line number Diff line number Diff line Loading @@ -30,15 +30,21 @@ import android.provider.Settings; import android.provider.Telephony; import android.telephony.SmsCbMessage; import android.telephony.SubscriptionManager; import android.util.LocalLog; import com.android.internal.telephony.metrics.TelephonyMetrics; import java.io.FileDescriptor; import java.io.PrintWriter; /** * Dispatch new Cell Broadcasts to receivers. Acquires a private wakelock until the broadcast * completes and our result receiver is called. */ public class CellBroadcastHandler extends WakeLockStateMachine { private final LocalLog mLocalLog = new LocalLog(100); private CellBroadcastHandler(Context context, Phone phone) { this("CellBroadcastHandler", context, phone); } Loading Loading @@ -90,9 +96,12 @@ public class CellBroadcastHandler extends WakeLockStateMachine { message.getMessagePriority(), message.isCmasMessage(), message.isEtwsMessage(), message.getServiceCategory()); String msg; Intent intent; if (message.isEmergencyMessage()) { log("Dispatching emergency SMS CB, SmsCbMessage is: " + message); msg = "Dispatching emergency SMS CB, SmsCbMessage is: " + message; log(msg); mLocalLog.log(msg); intent = new Intent(Telephony.Sms.Intents.SMS_EMERGENCY_CB_RECEIVED_ACTION); // Explicitly send the intent to the default cell broadcast receiver. intent.setPackage(mContext.getResources().getString( Loading @@ -100,7 +109,9 @@ public class CellBroadcastHandler extends WakeLockStateMachine { receiverPermission = Manifest.permission.RECEIVE_EMERGENCY_BROADCAST; appOp = AppOpsManager.OP_RECEIVE_EMERGECY_SMS; } else { log("Dispatching SMS CB, SmsCbMessage is: " + message); msg = "Dispatching SMS CB, SmsCbMessage is: " + message; log(msg); mLocalLog.log(msg); intent = new Intent(Telephony.Sms.Intents.SMS_CB_RECEIVED_ACTION); // Send implicit intent since there are various 3rd party carrier apps listen to // this intent. Loading Loading @@ -129,4 +140,11 @@ public class CellBroadcastHandler extends WakeLockStateMachine { mContext.sendOrderedBroadcastAsUser(intent, UserHandle.ALL, receiverPermission, appOp, mReceiver, getHandler(), Activity.RESULT_OK, null, null); } @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("CellBroadcastHandler:"); mLocalLog.dump(fd, pw, args); pw.flush(); } }
src/java/com/android/internal/telephony/IccSmsInterfaceManager.java +56 −22 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.service.carrier.CarrierMessagingService; import android.telephony.Rlog; import android.telephony.SmsManager; import android.telephony.SmsMessage; import android.util.LocalLog; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; Loading @@ -50,6 +51,8 @@ import com.android.internal.telephony.uicc.IccFileHandler; import com.android.internal.telephony.uicc.IccUtils; import com.android.internal.util.HexDump; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; Loading Loading @@ -86,6 +89,8 @@ public class IccSmsInterfaceManager { final private UserManager mUserManager; protected SmsDispatchersController mDispatchersController; private final LocalLog mCellBroadcastLocalLog = new LocalLog(100); protected Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { Loading Loading @@ -788,7 +793,7 @@ public class IccSmsInterfaceManager { } else if (ranType == SmsManager.CELL_BROADCAST_RAN_TYPE_CDMA) { return enableCdmaBroadcastRange(startMessageId, endMessageId); } else { throw new IllegalArgumentException("Not a supportted RAN Type"); throw new IllegalArgumentException("Not a supported RAN Type"); } } Loading @@ -798,7 +803,7 @@ public class IccSmsInterfaceManager { } else if (ranType == SmsManager.CELL_BROADCAST_RAN_TYPE_CDMA) { return disableCdmaBroadcastRange(startMessageId, endMessageId); } else { throw new IllegalArgumentException("Not a supportted RAN Type"); throw new IllegalArgumentException("Not a supported RAN Type"); } } Loading @@ -811,15 +816,21 @@ public class IccSmsInterfaceManager { String client = mContext.getPackageManager().getNameForUid( Binder.getCallingUid()); String msg; if (!mCellBroadcastRangeManager.enableRange(startMessageId, endMessageId, client)) { log("Failed to add GSM cell broadcast subscription for MID range " + startMessageId + " to " + endMessageId + " from client " + client); msg = "Failed to add GSM cell broadcast channels range " + startMessageId + " to " + endMessageId; log(msg); mCellBroadcastLocalLog.log(msg); return false; } if (DBG) log("Added GSM cell broadcast subscription for MID range " + startMessageId + " to " + endMessageId + " from client " + client); if (DBG) { msg = "Added GSM cell broadcast channels range " + startMessageId + " to " + endMessageId; log(msg); mCellBroadcastLocalLog.log(msg); } setCellBroadcastActivation(!mCellBroadcastRangeManager.isEmpty()); Loading @@ -835,15 +846,21 @@ public class IccSmsInterfaceManager { String client = mContext.getPackageManager().getNameForUid( Binder.getCallingUid()); String msg; if (!mCellBroadcastRangeManager.disableRange(startMessageId, endMessageId, client)) { log("Failed to remove GSM cell broadcast subscription for MID range " + startMessageId + " to " + endMessageId + " from client " + client); msg = "Failed to remove GSM cell broadcast channels range " + startMessageId + " to " + endMessageId; log(msg); mCellBroadcastLocalLog.log(msg); return false; } if (DBG) log("Removed GSM cell broadcast subscription for MID range " + startMessageId + " to " + endMessageId + " from client " + client); if (DBG) { msg = "Removed GSM cell broadcast channels range " + startMessageId + " to " + endMessageId; log(msg); mCellBroadcastLocalLog.log(msg); } setCellBroadcastActivation(!mCellBroadcastRangeManager.isEmpty()); Loading @@ -859,15 +876,20 @@ public class IccSmsInterfaceManager { String client = mContext.getPackageManager().getNameForUid( Binder.getCallingUid()); String msg; if (!mCdmaBroadcastRangeManager.enableRange(startMessageId, endMessageId, client)) { log("Failed to add cdma broadcast subscription for MID range " + startMessageId + " to " + endMessageId + " from client " + client); msg = "Failed to add cdma broadcast channels range " + startMessageId + " to " + endMessageId; log(msg); mCellBroadcastLocalLog.log(msg); return false; } if (DBG) log("Added cdma broadcast subscription for MID range " + startMessageId + " to " + endMessageId + " from client " + client); if (DBG) { msg = "Added cdma broadcast channels range " + startMessageId + " to " + endMessageId; log(msg); mCellBroadcastLocalLog.log(msg); } setCdmaBroadcastActivation(!mCdmaBroadcastRangeManager.isEmpty()); Loading @@ -883,15 +905,20 @@ public class IccSmsInterfaceManager { String client = mContext.getPackageManager().getNameForUid( Binder.getCallingUid()); String msg; if (!mCdmaBroadcastRangeManager.disableRange(startMessageId, endMessageId, client)) { log("Failed to remove cdma broadcast subscription for MID range " + startMessageId + " to " + endMessageId + " from client " + client); msg = "Failed to remove cdma broadcast channels range " + startMessageId + " to " + endMessageId; log(msg); mCellBroadcastLocalLog.log(msg); return false; } if (DBG) log("Removed cdma broadcast subscription for MID range " + startMessageId + " to " + endMessageId + " from client " + client); if (DBG) { msg = "Removed cdma broadcast channels range " + startMessageId + " to " + endMessageId; log(msg); mCellBroadcastLocalLog.log(msg); } setCdmaBroadcastActivation(!mCdmaBroadcastRangeManager.isEmpty()); Loading Loading @@ -1335,4 +1362,11 @@ public class IccSmsInterfaceManager { return result != null ? result : destAddr; } public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("CellBroadcast log:"); mCellBroadcastLocalLog.dump(fd, pw, args); pw.println("SMS dispatcher controller log:"); mDispatchersController.dump(fd, pw, args); pw.flush(); } }
src/java/com/android/internal/telephony/InboundSmsHandler.java +48 −2 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ import android.telephony.SmsMessage; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.LocalLog; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; Loading @@ -69,6 +70,8 @@ import com.android.internal.util.State; import com.android.internal.util.StateMachine; import java.io.ByteArrayOutputStream; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.List; Loading Loading @@ -157,6 +160,9 @@ public abstract class InboundSmsHandler extends StateMachine { /** New SMS received as an AsyncResult. */ public static final int EVENT_INJECT_SMS = 8; /** Update the sms tracker */ public static final int EVENT_UPDATE_TRACKER = 9; /** Wakelock release delay when returning to idle state. */ private static final int WAKELOCK_TIMEOUT = 3000; Loading Loading @@ -205,6 +211,8 @@ public abstract class InboundSmsHandler extends StateMachine { private UserManager mUserManager; private LocalLog mLocalLog = new LocalLog(64); IDeviceIdleController mDeviceIdleController; // Delete permanently from raw table Loading Loading @@ -449,6 +457,7 @@ public abstract class InboundSmsHandler extends StateMachine { // if any broadcasts were sent, transition to waiting state InboundSmsTracker inboundSmsTracker = (InboundSmsTracker) msg.obj; if (processMessagePart(inboundSmsTracker)) { sendMessage(obtainMessage(EVENT_UPDATE_TRACKER, msg.obj)); transitionTo(mWaitingState); } else { // if event is sent from SmsBroadcastUndelivered.broadcastSms(), and Loading @@ -474,10 +483,17 @@ public abstract class InboundSmsHandler extends StateMachine { } return HANDLED; case EVENT_UPDATE_TRACKER: logd("process tracker message in DeliveringState " + msg.arg1); return HANDLED; // we shouldn't get this message type in this state, log error and halt. case EVENT_BROADCAST_COMPLETE: case EVENT_START_ACCEPTING_SMS: default: String errorMsg = "Unhandled msg in delivering state, msg.what = " + msg.what; loge(errorMsg); mLocalLog.log(errorMsg); // let DefaultState handle these unexpected message types return NOT_HANDLED; } Loading @@ -493,6 +509,8 @@ public abstract class InboundSmsHandler extends StateMachine { */ private class WaitingState extends State { private InboundSmsTracker mLastDeliveredSmsTracker; @Override public void enter() { if (DBG) log("entering Waiting state"); Loading @@ -512,10 +530,20 @@ public abstract class InboundSmsHandler extends StateMachine { switch (msg.what) { case EVENT_BROADCAST_SMS: // defer until the current broadcast completes if (mLastDeliveredSmsTracker != null) { String str = "Defer sms broadcast due to undelivered sms, " + " messageCount = " + mLastDeliveredSmsTracker.getMessageCount() + " destPort = " + mLastDeliveredSmsTracker.getDestPort() + " timestamp = " + mLastDeliveredSmsTracker.getTimestamp() + " currentTimestamp = " + System.currentTimeMillis(); logd(str); mLocalLog.log(str); } deferMessage(msg); return HANDLED; case EVENT_BROADCAST_COMPLETE: mLastDeliveredSmsTracker = null; // return to idle after handling all deferred messages sendMessage(EVENT_RETURN_TO_IDLE); transitionTo(mDeliveringState); Loading @@ -525,6 +553,13 @@ public abstract class InboundSmsHandler extends StateMachine { // not ready to return to idle; ignore return HANDLED; case EVENT_UPDATE_TRACKER: for (int i = 1; i < 10; i++) { deferMessage(obtainMessage(EVENT_UPDATE_TRACKER, i, i, msg.obj)); } mLastDeliveredSmsTracker = (InboundSmsTracker) msg.obj; return HANDLED; default: // parent state handles the other message types return NOT_HANDLED; Loading Loading @@ -853,8 +888,10 @@ public abstract class InboundSmsHandler extends StateMachine { // Do not process null pdu(s). Check for that and return false in that case. List<byte[]> pduList = Arrays.asList(pdus); if (pduList.size() == 0 || pduList.contains(null)) { loge("processMessagePart: returning false due to " + (pduList.size() == 0 ? "pduList.size() == 0" : "pduList.contains(null)")); String errorMsg = "processMessagePart: returning false due to " + (pduList.size() == 0 ? "pduList.size() == 0" : "pduList.contains(null)"); loge(errorMsg); mLocalLog.log(errorMsg); return false; } Loading Loading @@ -1547,6 +1584,15 @@ public abstract class InboundSmsHandler extends StateMachine { } } @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { super.dump(fd, pw, args); if (mCellBroadcastHandler != null) { mCellBroadcastHandler.dump(fd, pw, args); } mLocalLog.dump(fd, pw, args); } // Some providers send formfeeds in their messages. Convert those formfeeds to newlines. private static String replaceFormFeeds(String s) { return s == null ? "" : s.replace('\f', '\n'); Loading
src/java/com/android/internal/telephony/SmsDispatchersController.java +7 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,8 @@ import com.android.internal.telephony.cdma.CdmaSMSDispatcher; import com.android.internal.telephony.gsm.GsmInboundSmsHandler; import com.android.internal.telephony.gsm.GsmSMSDispatcher; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; Loading Loading @@ -627,4 +629,9 @@ public class SmsDispatchersController extends Handler { public interface SmsInjectionCallback { void onSmsInjectedResult(int result); } public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { mGsmInboundSmsHandler.dump(fd, pw, args); mCdmaInboundSmsHandler.dump(fd, pw, args); } }
src/java/com/android/internal/telephony/UiccSmsController.java +21 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,10 @@ import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import com.android.internal.util.IndentingPrintWriter; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.List; /** Loading Loading @@ -413,6 +417,23 @@ public class UiccSmsController extends ISms.Stub { return getPhone(subId).getAppSmsManager().createAppSpecificSmsToken(callingPkg, intent); } @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { IndentingPrintWriter indentingPW = new IndentingPrintWriter(pw, " " /* singleIndent */); for (Phone phone : PhoneFactory.getPhones()) { int subId = phone.getSubId(); indentingPW.println(String.format("SmsManager for subId = %d:", subId)); indentingPW.increaseIndent(); if (getIccSmsInterfaceManager(subId) != null) { getIccSmsInterfaceManager(subId).dump(fd, indentingPW, args); } indentingPW.decreaseIndent(); } indentingPW.flush(); } private void sendErrorInPendingIntent(@Nullable PendingIntent intent, int errorCode) { if (intent != null) { try { Loading