Loading testapps/src/com/android/server/telecom/testapps/SelfManagedCallingActivity.java +21 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,10 @@ package com.android.server.telecom.testapps; import android.app.Activity; import android.app.NotificationChannel; import android.app.NotificationManager; import android.media.AudioAttributes; import android.media.RingtoneManager; import android.net.Uri; import android.os.Bundle; import android.telecom.ConnectionRequest; Loading Loading @@ -100,6 +104,7 @@ public class SelfManagedCallingActivity extends Activity { | WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES; getWindow().addFlags(flags); configureNotificationChannel(); setContentView(R.layout.self_managed_sample_main); mCheckIfPermittedBeforeCalling = (CheckBox) findViewById( R.id.checkIfPermittedBeforeCalling); Loading Loading @@ -196,4 +201,20 @@ public class SelfManagedCallingActivity extends Activity { } tm.addNewIncomingCall(getSelectedPhoneAccountHandle(), extras); } private void configureNotificationChannel() { NotificationChannel channel = new NotificationChannel( SelfManagedConnection.INCOMING_CALL_CHANNEL_ID, "Incoming Calls", NotificationManager.IMPORTANCE_MAX); channel.setShowBadge(false); Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE); channel.setSound(ringtoneUri, new AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE) .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) .build()); channel.enableLights(true); NotificationManager mgr = getSystemService(NotificationManager.class); mgr.createNotificationChannel(channel); } } No newline at end of file testapps/src/com/android/server/telecom/testapps/SelfManagedConnection.java +20 −3 Original line number Diff line number Diff line Loading @@ -22,7 +22,10 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.graphics.drawable.Icon; import android.media.AudioAttributes; import android.media.MediaPlayer; import android.media.RingtoneManager; import android.net.Uri; import android.os.Bundle; import android.telecom.Call; import android.telecom.CallAudioState; Loading @@ -43,7 +46,7 @@ public class SelfManagedConnection extends Connection { public void onConnectionStateChanged(SelfManagedConnection connection) {} public void onConnectionRemoved(SelfManagedConnection connection) {} } public static final String INCOMING_CALL_CHANNEL_ID = "INCOMING_CALL_CHANNEL_ID"; public static final String EXTRA_PHONE_ACCOUNT_HANDLE = "com.android.server.telecom.testapps.extra.PHONE_ACCOUNT_HANDLE"; public static final String CALL_NOTIFICATION = "com.android.server.telecom.testapps.CALL"; Loading @@ -58,6 +61,7 @@ public class SelfManagedConnection extends Connection { private boolean mIsIncomingCallUiShowing; private Listener mListener; private boolean mIsHandover; private Notification.Builder mNotificationBuilder; SelfManagedConnection(SelfManagedCallList callList, Context context, boolean isIncoming) { mCallList = callList; Loading Loading @@ -93,7 +97,8 @@ public class SelfManagedConnection extends Connection { PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 1, intent, 0); // Build the notification as an ongoing high priority item. final Notification.Builder builder = new Notification.Builder(mContext); final Notification.Builder builder = new Notification.Builder(mContext, INCOMING_CALL_CHANNEL_ID); builder.setOngoing(true); builder.setPriority(Notification.PRIORITY_HIGH); Loading Loading @@ -131,9 +136,12 @@ public class SelfManagedConnection extends Connection { PendingIntent.FLAG_UPDATE_CURRENT)) .build()); Notification notification = builder.build(); notification.flags |= Notification.FLAG_INSISTENT; NotificationManager notificationManager = mContext.getSystemService( NotificationManager.class); notificationManager.notify(CALL_NOTIFICATION, mCallId, builder.build()); mNotificationBuilder = builder; notificationManager.notify(CALL_NOTIFICATION, mCallId, notification); } @Override Loading Loading @@ -172,6 +180,15 @@ public class SelfManagedConnection extends Connection { setConnectionDisconnected(DisconnectCause.LOCAL); } @Override public void onSilence() { // Re-post our notification without a ringtone. mNotificationBuilder.setOnlyAlertOnce(true); NotificationManager notificationManager = mContext.getSystemService( NotificationManager.class); notificationManager.notify(CALL_NOTIFICATION, mCallId, mNotificationBuilder.build()); } public void setConnectionActive() { mMediaPlayer.start(); setActive(); Loading Loading
testapps/src/com/android/server/telecom/testapps/SelfManagedCallingActivity.java +21 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,10 @@ package com.android.server.telecom.testapps; import android.app.Activity; import android.app.NotificationChannel; import android.app.NotificationManager; import android.media.AudioAttributes; import android.media.RingtoneManager; import android.net.Uri; import android.os.Bundle; import android.telecom.ConnectionRequest; Loading Loading @@ -100,6 +104,7 @@ public class SelfManagedCallingActivity extends Activity { | WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES; getWindow().addFlags(flags); configureNotificationChannel(); setContentView(R.layout.self_managed_sample_main); mCheckIfPermittedBeforeCalling = (CheckBox) findViewById( R.id.checkIfPermittedBeforeCalling); Loading Loading @@ -196,4 +201,20 @@ public class SelfManagedCallingActivity extends Activity { } tm.addNewIncomingCall(getSelectedPhoneAccountHandle(), extras); } private void configureNotificationChannel() { NotificationChannel channel = new NotificationChannel( SelfManagedConnection.INCOMING_CALL_CHANNEL_ID, "Incoming Calls", NotificationManager.IMPORTANCE_MAX); channel.setShowBadge(false); Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE); channel.setSound(ringtoneUri, new AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE) .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) .build()); channel.enableLights(true); NotificationManager mgr = getSystemService(NotificationManager.class); mgr.createNotificationChannel(channel); } } No newline at end of file
testapps/src/com/android/server/telecom/testapps/SelfManagedConnection.java +20 −3 Original line number Diff line number Diff line Loading @@ -22,7 +22,10 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.graphics.drawable.Icon; import android.media.AudioAttributes; import android.media.MediaPlayer; import android.media.RingtoneManager; import android.net.Uri; import android.os.Bundle; import android.telecom.Call; import android.telecom.CallAudioState; Loading @@ -43,7 +46,7 @@ public class SelfManagedConnection extends Connection { public void onConnectionStateChanged(SelfManagedConnection connection) {} public void onConnectionRemoved(SelfManagedConnection connection) {} } public static final String INCOMING_CALL_CHANNEL_ID = "INCOMING_CALL_CHANNEL_ID"; public static final String EXTRA_PHONE_ACCOUNT_HANDLE = "com.android.server.telecom.testapps.extra.PHONE_ACCOUNT_HANDLE"; public static final String CALL_NOTIFICATION = "com.android.server.telecom.testapps.CALL"; Loading @@ -58,6 +61,7 @@ public class SelfManagedConnection extends Connection { private boolean mIsIncomingCallUiShowing; private Listener mListener; private boolean mIsHandover; private Notification.Builder mNotificationBuilder; SelfManagedConnection(SelfManagedCallList callList, Context context, boolean isIncoming) { mCallList = callList; Loading Loading @@ -93,7 +97,8 @@ public class SelfManagedConnection extends Connection { PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 1, intent, 0); // Build the notification as an ongoing high priority item. final Notification.Builder builder = new Notification.Builder(mContext); final Notification.Builder builder = new Notification.Builder(mContext, INCOMING_CALL_CHANNEL_ID); builder.setOngoing(true); builder.setPriority(Notification.PRIORITY_HIGH); Loading Loading @@ -131,9 +136,12 @@ public class SelfManagedConnection extends Connection { PendingIntent.FLAG_UPDATE_CURRENT)) .build()); Notification notification = builder.build(); notification.flags |= Notification.FLAG_INSISTENT; NotificationManager notificationManager = mContext.getSystemService( NotificationManager.class); notificationManager.notify(CALL_NOTIFICATION, mCallId, builder.build()); mNotificationBuilder = builder; notificationManager.notify(CALL_NOTIFICATION, mCallId, notification); } @Override Loading Loading @@ -172,6 +180,15 @@ public class SelfManagedConnection extends Connection { setConnectionDisconnected(DisconnectCause.LOCAL); } @Override public void onSilence() { // Re-post our notification without a ringtone. mNotificationBuilder.setOnlyAlertOnce(true); NotificationManager notificationManager = mContext.getSystemService( NotificationManager.class); notificationManager.notify(CALL_NOTIFICATION, mCallId, mNotificationBuilder.build()); } public void setConnectionActive() { mMediaPlayer.start(); setActive(); Loading