Loading AndroidManifest.xml +3 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,9 @@ coreApp="true" android:sharedUserId="android.uid.system"> <protected-broadcast android:name="android.intent.action.SHOW_MISSED_CALLS_NOTIFICATION" /> <!-- Prevents the activity manager from delaying any activity-start requests by this package, including requests immediately after the user presses "home". --> Loading res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -38,4 +38,8 @@ <!-- Flag indicating if the tty is enabled --> <bool name="tty_enabled">false</bool> <!-- Component name for the notification handler. The presence of this value will disable MissedCallNotifierImpl's presentation of missed call/voice notifications [DO NOT TRANSLATE] --> <string name="notification_component" translatable="false"></string> </resources> src/com/android/server/telecom/Call.java +5 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import com.android.internal.telephony.SmsApplication; import com.android.server.telecom.ContactsAsyncHelper.OnImageLoadCompleteListener; import com.android.internal.util.Preconditions; import java.lang.String; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; Loading Loading @@ -666,6 +667,10 @@ public class Call implements CreateConnectionResponse { return mCallerInfo == null ? null : mCallerInfo.name; } public String getPhoneNumber() { return mCallerInfo == null ? null : mCallerInfo.phoneNumber; } public Bitmap getPhotoIcon() { return mCallerInfo == null ? null : mCallerInfo.cachedPhotoIcon; } Loading src/com/android/server/telecom/ui/MissedCallNotifierImpl.java +52 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.telecom.ui; import android.content.ComponentName; import android.telecom.TelecomManager; import com.android.server.telecom.Call; import com.android.server.telecom.CallState; import com.android.server.telecom.CallerInfoAsyncQueryFactory; Loading Loading @@ -54,6 +56,9 @@ import android.text.BidiFormatter; import android.text.TextDirectionHeuristics; import android.text.TextUtils; import java.lang.Override; import java.lang.String; // TODO: Needed for move to system service: import com.android.internal.R; /** Loading Loading @@ -89,6 +94,8 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements private final Context mContext; private final NotificationManager mNotificationManager; private final ComponentName mNotificationComponent; // Used to track the number of missed calls. private int mMissedCallCount = 0; Loading @@ -96,6 +103,10 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements mContext = context; mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); final String notificationComponent = context.getString(R.string.notification_component); mNotificationComponent = notificationComponent != null ? ComponentName.unflattenFromString(notificationComponent) : null; } /** {@inheritDoc} */ Loading Loading @@ -134,6 +145,37 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements cancelMissedCallNotification(); } /** * Broadcasts missed call notification to custom component if set. * @param number The phone number associated with the notification. null if * no call. * @param count The number of calls associated with the notification. * @return {@code true} if the broadcast was sent. {@code false} otherwise. */ private boolean sendNotificationCustomComponent(Call call, int count) { if (mNotificationComponent != null) { Intent intent = new Intent(); intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND); intent.setComponent(mNotificationComponent); intent.setAction(TelecomManager.ACTION_SHOW_MISSED_CALLS_NOTIFICATION); intent.putExtra(TelecomManager.EXTRA_NOTIFICATION_COUNT, count); intent.putExtra(TelecomManager.EXTRA_NOTIFICATION_PHONE_NUMBER, call != null ? call.getPhoneNumber() : null); intent.putExtra(TelecomManager.EXTRA_CLEAR_MISSED_CALLS_INTENT, createClearMissedCallsPendingIntent()); if (count == 1 && call != null) { intent.putExtra(TelecomManager.EXTRA_CALL_BACK_INTENT, createCallBackPendingIntent(call.getHandle())); } mContext.sendBroadcast(intent); return true; } return false; } /** * Create a system notification for the missed call. * Loading @@ -143,6 +185,10 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements public void showMissedCallNotification(Call call) { mMissedCallCount++; if (sendNotificationCustomComponent(call, mMissedCallCount)) { return; } final int titleResId; final String expandedText; // The text in the notification's line 1 and 2. Loading Loading @@ -218,6 +264,12 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements private void cancelMissedCallNotification() { // Reset the number of missed calls to 0. mMissedCallCount = 0; if (sendNotificationCustomComponent(null, mMissedCallCount)) { return; } long token = Binder.clearCallingIdentity(); try { mNotificationManager.cancelAsUser(null, MISSED_CALL_NOTIFICATION_ID, Loading Loading
AndroidManifest.xml +3 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,9 @@ coreApp="true" android:sharedUserId="android.uid.system"> <protected-broadcast android:name="android.intent.action.SHOW_MISSED_CALLS_NOTIFICATION" /> <!-- Prevents the activity manager from delaying any activity-start requests by this package, including requests immediately after the user presses "home". --> Loading
res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -38,4 +38,8 @@ <!-- Flag indicating if the tty is enabled --> <bool name="tty_enabled">false</bool> <!-- Component name for the notification handler. The presence of this value will disable MissedCallNotifierImpl's presentation of missed call/voice notifications [DO NOT TRANSLATE] --> <string name="notification_component" translatable="false"></string> </resources>
src/com/android/server/telecom/Call.java +5 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import com.android.internal.telephony.SmsApplication; import com.android.server.telecom.ContactsAsyncHelper.OnImageLoadCompleteListener; import com.android.internal.util.Preconditions; import java.lang.String; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; Loading Loading @@ -666,6 +667,10 @@ public class Call implements CreateConnectionResponse { return mCallerInfo == null ? null : mCallerInfo.name; } public String getPhoneNumber() { return mCallerInfo == null ? null : mCallerInfo.phoneNumber; } public Bitmap getPhotoIcon() { return mCallerInfo == null ? null : mCallerInfo.cachedPhotoIcon; } Loading
src/com/android/server/telecom/ui/MissedCallNotifierImpl.java +52 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.telecom.ui; import android.content.ComponentName; import android.telecom.TelecomManager; import com.android.server.telecom.Call; import com.android.server.telecom.CallState; import com.android.server.telecom.CallerInfoAsyncQueryFactory; Loading Loading @@ -54,6 +56,9 @@ import android.text.BidiFormatter; import android.text.TextDirectionHeuristics; import android.text.TextUtils; import java.lang.Override; import java.lang.String; // TODO: Needed for move to system service: import com.android.internal.R; /** Loading Loading @@ -89,6 +94,8 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements private final Context mContext; private final NotificationManager mNotificationManager; private final ComponentName mNotificationComponent; // Used to track the number of missed calls. private int mMissedCallCount = 0; Loading @@ -96,6 +103,10 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements mContext = context; mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); final String notificationComponent = context.getString(R.string.notification_component); mNotificationComponent = notificationComponent != null ? ComponentName.unflattenFromString(notificationComponent) : null; } /** {@inheritDoc} */ Loading Loading @@ -134,6 +145,37 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements cancelMissedCallNotification(); } /** * Broadcasts missed call notification to custom component if set. * @param number The phone number associated with the notification. null if * no call. * @param count The number of calls associated with the notification. * @return {@code true} if the broadcast was sent. {@code false} otherwise. */ private boolean sendNotificationCustomComponent(Call call, int count) { if (mNotificationComponent != null) { Intent intent = new Intent(); intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND); intent.setComponent(mNotificationComponent); intent.setAction(TelecomManager.ACTION_SHOW_MISSED_CALLS_NOTIFICATION); intent.putExtra(TelecomManager.EXTRA_NOTIFICATION_COUNT, count); intent.putExtra(TelecomManager.EXTRA_NOTIFICATION_PHONE_NUMBER, call != null ? call.getPhoneNumber() : null); intent.putExtra(TelecomManager.EXTRA_CLEAR_MISSED_CALLS_INTENT, createClearMissedCallsPendingIntent()); if (count == 1 && call != null) { intent.putExtra(TelecomManager.EXTRA_CALL_BACK_INTENT, createCallBackPendingIntent(call.getHandle())); } mContext.sendBroadcast(intent); return true; } return false; } /** * Create a system notification for the missed call. * Loading @@ -143,6 +185,10 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements public void showMissedCallNotification(Call call) { mMissedCallCount++; if (sendNotificationCustomComponent(call, mMissedCallCount)) { return; } final int titleResId; final String expandedText; // The text in the notification's line 1 and 2. Loading Loading @@ -218,6 +264,12 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements private void cancelMissedCallNotification() { // Reset the number of missed calls to 0. mMissedCallCount = 0; if (sendNotificationCustomComponent(null, mMissedCallCount)) { return; } long token = Binder.clearCallingIdentity(); try { mNotificationManager.cancelAsUser(null, MISSED_CALL_NOTIFICATION_ID, Loading