一、settings里面勾选“在来电话时发出振动”
1、mms settings勾选振动
class0短信和其他class短信都会振动
2、mms settings关闭振动 ----- 这是唯一class0和class1不同的情况
class0短信振动
其他class短信不振动
二、settings里面关闭“在来电话时发出振动”
1、mms settings勾选振动
class0短信和其他class短信都不振动
2、mms settings关闭振动
class0短信和其他class短信都不振动
仔细查看代码,发现class0的通知和普通短信的通知确实不一样
/packages/apps/Mms/src/com/android/mms/transaction/MessagingNotification.java
class0:
public static boolean notifyClassZeroMessage(Context context, String address)
普通短信:
blockingUpdateNewMessageIndicator方法,最后调用
updateNotification方法
public static void blockingUpdateNewMessageIndicator(Context context, long newMsgThreadId,
boolean isStatusMessage, Uri statusMessageUri) {
/// M: add for notification settings
NotificationProfile notiProf = getNotificationProfileByThreadId(context, newMsgThreadId);
boolean isContinuousComming = false;
long currentTime = System.currentTimeMillis();
if (newMsgThreadId != THREAD_NONE) {
isContinuousComming = currentTime <= sLastNotificationTime + RINGTONE_WAIT_TIME;
Log.d(TAG, "isContinuousComming = " + isContinuousComming + " currentTime " + currentTime + " " + sLastNotificationTime);
}
final boolean isDefaultSmsApp = MmsConfig.isSmsEnabled(context);
if (!isDefaultSmsApp) {
cancelNotification(context, NOTIFICATION_ID);
if (DEBUG || Log.isLoggable(LogTag.APP, Log.VERBOSE))
Log.d(TAG, "blockingUpdateNewMessageIndicator: not the default sms app - skipping "
+ "notification");
return;
}
synchronized (sCurrentlyDisplayedThreadLock) {
Log.d(TAG, "newMsgThreadId = " + newMsgThreadId + "sCurrentlyDisplayedThreadId = " + sCurrentlyDisplayedThreadId);
if (newMsgThreadId > 0 && newMsgThreadId == sCurrentlyDisplayedThreadId) {
if (DEBUG) {
Log.d(TAG, "blockingUpdateNewMessageIndicator: newMsgThreadId == " +
"sCurrentlyDisplayedThreadId so NOT showing notification," +
" but playing soft sound. threadId: " + newMsgThreadId);
}
if (!isContinuousComming) {
playInConversationNotificationSound(context, notiProf);
sLastNotificationTime = currentTime;
}
return;
}
}
SortedSet<NotificationInfo> notificationSet =
new TreeSet<NotificationInfo>(INFO_COMPARATOR);
Set<Long> threads = new HashSet<Long>(4);
int count = 0;
int mmsUnReadCount = addMmsNotificationInfos(context, threads, notificationSet);
int smsUnReadCount = addSmsNotificationInfos(context, threads, notificationSet);
if (!isContinuousComming) {
cancelNotification(context, NOTIFICATION_ID);
}
if (!notificationSet.isEmpty()) {
if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
Log.d(TAG, "blockingUpdateNewMessageIndicator: count=" + count +
", newMsgThreadId=" + newMsgThreadId);
}
updateNotification(context, newMsgThreadId != THREAD_NONE, threads.size(), notificationSet,
newMsgThreadId, notiProf, isContinuousComming, mmsUnReadCount, smsUnReadCount);
sLastNotificationTime = currentTime;
}
// And deals with delivery reports (which use Toasts). It's safe to call in a worker
// thread because the toast will eventually get posted to a handler.
MmsSmsDeliveryInfo delivery = getSmsNewDeliveryInfo(context, statusMessageUri);
if (delivery != null) {
delivery.deliver(context, isStatusMessage);
}
notificationSet.clear();
threads.clear();
}
/// M: the new methods
/// M:Code analyze 004,add for class 0 of sms types,class 0 means the sms will not be save into
/// phone or simCard,but only show on the phone @{
public static boolean notifyClassZeroMessage(Context context, String address) {
Log.d(TAG, "notifyClassZeroMessage");
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
boolean enabled = sp.getBoolean(NotificationPreferenceActivity.NOTIFICATION_ENABLED, true);
Log.d(TAG, "notifyClassZeroMessage, enabled = " + enabled);
if (!enabled) {
return false;
}
NotificationManager nm = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification();
String ringtoneStr = sp.getString(NotificationPreferenceActivity.NOTIFICATION_RINGTONE, null);
ringtoneStr = MessagingNotification.checkRingtone(context, ringtoneStr);
Uri ringtone = TextUtils.isEmpty(ringtoneStr) ? null : Uri.parse(ringtoneStr);
processNotificationSound(context, notification, ringtone);
notification.tickerText = address;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.ledARGB = 0xff00ff00;
notification.ledOnMS = 500;
notification.ledOffMS = 2000;
nm.notify(CLASS_ZERO_NOTIFICATION_ID, notification);
return true;
}
Types of SMS Message
There are four classes of an SMS message. Classes identify the importance of an SMS message and also the location where it must be stored.
-
Class 0
This type of SMS message is displayed on the mobile screen without being saved in the message store or on the SIM card; unless explicitly saved by the mobile user.
-
Class 1
This message is to be stored in the device memory or the SIM card (depending on memory availability).
-
Class 2
This message class carries SIM card data. The SIM card data must be successfully transferred prior to sending acknowledgment to the service center. An error message is sent to the service center if this transmission is not possible.
-
Class 3
This message is forwarded from the receiving entity to an external device. The delivery acknowledgment is sent to the service center regardless of whether or not the message was forwarded to the external device.
Data flow
For an incoming message, the usual route is:
-
The phone receives the SMS. The telephony server notifies the SMS stack.
-
The SMS stack decodes the message and then notifies the SMS watcher that handles messages of the relevant service center. The watcher creates a new messaging entry in the message store's Inbox.
-
Any messaging application that is set as an observer of the message store is notified of the arrival of the new message. The application can then determine whether it should handle the message, and if so, can then read the message and process it appropriately.
For an outgoing message, the route is:
-
A messaging application uses the SMS client MTM APIs to create a message, to set its contents and fields, and to send it
-
The message server passes the send command to the SMS server MTM. This calls the appropriate SMS stack to send the message.
-
The stack calls the telephony server to send the message.