Skip to content

Commit 827849e

Browse files
kufikugelcodex-corp
authored andcommitted
InCallUI: Heads up meets SlimKat....SlimKat meets Google IO [2/4]
Add native heads up support on dialer. We only have show call in background feature. We combine it now with heads up. So it is doing exactly same like on Google IO was shown. Enabled by default. - Notification is expanded by default - Send as requested to force show the heads up no matter what. Change-Id: Idc1ef59e9821293ac69a72767f918c07acaafc83
1 parent d6019a6 commit 827849e

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

src/com/android/incallui/InCallPresenter.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,9 @@ private void startUi(InCallState inCallState) {
819819

820820
// check if the user want to have the call UI in background and set it up
821821
mCallUiInBackground = Settings.System.getInt(mContext.getContentResolver(),
822-
Settings.System.CALL_UI_IN_BACKGROUND, 0) == 1;
822+
Settings.System.CALL_UI_IN_BACKGROUND, 1) == 1;
823+
824+
boolean isHeadsUp = false;
823825

824826
if (mCallUiInBackground) {
825827
// get power service to check later if screen is on
@@ -833,8 +835,15 @@ private void startUi(InCallState inCallState) {
833835
} catch (RemoteException e) {
834836
}
835837
mCallUiInBackground = pm.isScreenOn() && !isKeyguardShowing;
838+
839+
// Check if user want to see notification as heads up.
840+
isHeadsUp = Settings.System.getInt(mContext.getContentResolver(),
841+
Settings.System.CALL_UI_AS_HEADS_UP, 1) == 1;
836842
}
837843

844+
mStatusBarNotifier.updateNotificationAndLaunchIncomingCallUi(
845+
inCallState, mCallList, mCallUiInBackground, isHeadsUp);
846+
838847
boolean nonIntrusiveDisabled = Settings.System.getInt(mContext.getContentResolver(),
839848
Settings.System.NON_INTRUSIVE_INCALL, 1) == 0;
840849

@@ -858,7 +867,7 @@ public void startIncomingCallUi() {
858867
// First cancel the actual notification and then update
859868
mStatusBarNotifier.cancelInCall();
860869
mStatusBarNotifier.updateNotificationAndLaunchIncomingCallUi(
861-
InCallState.INCALL, mCallList, false);
870+
InCallState.INCALL, mCallList, false, false);
862871
}
863872

864873
/**

src/com/android/incallui/StatusBarNotifier.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import android.graphics.Bitmap;
2727
import android.graphics.BitmapFactory;
2828
import android.graphics.drawable.BitmapDrawable;
29+
import android.os.Bundle;
2930
import android.os.Handler;
3031
import android.os.Message;
3132
import android.text.TextUtils;
@@ -96,6 +97,7 @@ private void fire() {
9697
private Bitmap mSavedLargeIcon;
9798
private String mSavedContentTitle;
9899
private boolean mIsCallUiInBackground;
100+
private boolean mIsHeadsUp;
99101

100102
public StatusBarNotifier(Context context, ContactInfoCache contactInfoCache) {
101103
Preconditions.checkNotNull(context);
@@ -162,10 +164,13 @@ public void updateNotification(InCallState state, CallList callList) {
162164
*
163165
* @see #updateInCallNotification(boolean,InCallState,CallList)
164166
*/
165-
public void updateNotificationAndLaunchIncomingCallUi(
166-
InCallState state, CallList callList, boolean isCallUiInBackground) {
167+
public void updateNotificationAndLaunchIncomingCallUi(
168+
InCallState state, CallList callList,
169+
boolean isCallUiInBackground, boolean isHeadsUp) {
167170
// If the user want to have the UI in background set it no matter what
168171
mIsCallUiInBackground = isCallUiInBackground;
172+
// User want to have heads up notification
173+
mIsHeadsUp = isHeadsUp;
169174
// Set allowFullScreenIntent=true to indicate that we *should*
170175
// launch the incoming call UI if necessary.
171176
updateInCallNotification(true, state, callList);
@@ -354,6 +359,16 @@ private void buildAndSendNotification(Call originalCall, ContactCacheEntry conta
354359
if (state == Call.State.INCOMING) {
355360
addAnswerAction(builder);
356361
addDismissAction(builder);
362+
363+
if (mIsCallUiInBackground && mIsHeadsUp) {
364+
Bundle extras = new Bundle();
365+
// Request a heads up notification and set it as expanded.
366+
extras.putInt(Notification.EXTRA_AS_HEADS_UP,
367+
Notification.HEADS_UP_REQUESTED);
368+
extras.putInt(Notification.EXTRA_HEADS_UP_EXPANDED,
369+
Notification.HEADS_UP_EXPANDED);
370+
builder.setExtras(extras);
371+
}
357372
}
358373

359374

0 commit comments

Comments
 (0)