Skip to content

Commit 46fc488

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 ce52242 commit 46fc488

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

src/com/android/incallui/InCallPresenter.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import android.os.ServiceManager;
3333
import android.view.IWindowManager;
3434
import android.content.ActivityNotFoundException;
35+
import android.os.PowerManager;
36+
import android.provider.Settings;
3537

3638
import com.android.services.telephony.common.Call;
3739
import com.android.services.telephony.common.Call.Capabilities;
@@ -805,7 +807,9 @@ private void startUi(InCallState inCallState) {
805807

806808
// check if the user want to have the call UI in background and set it up
807809
mCallUiInBackground = Settings.System.getInt(mContext.getContentResolver(),
808-
Settings.System.CALL_UI_IN_BACKGROUND, 0) == 1;
810+
Settings.System.CALL_UI_IN_BACKGROUND, 1) == 1;
811+
812+
boolean isHeadsUp = false;
809813

810814
if (mCallUiInBackground) {
811815
// get power service to check later if screen is on
@@ -819,9 +823,14 @@ private void startUi(InCallState inCallState) {
819823
} catch (RemoteException e) {
820824
}
821825
mCallUiInBackground = pm.isScreenOn() && !isKeyguardShowing;
826+
827+
// Check if user want to see notification as heads up.
828+
isHeadsUp = Settings.System.getInt(mContext.getContentResolver(),
829+
Settings.System.CALL_UI_AS_HEADS_UP, 1) == 1;
822830
}
823831

824-
mStatusBarNotifier.updateNotificationAndLaunchIncomingCallUi(inCallState, mCallList, mCallUiInBackground);
832+
mStatusBarNotifier.updateNotificationAndLaunchIncomingCallUi(
833+
inCallState, mCallList, mCallUiInBackground, isHeadsUp);
825834
}
826835

827836
/**
@@ -833,7 +842,7 @@ public void startIncomingCallUi() {
833842
// First cancel the actual notification and then update
834843
mStatusBarNotifier.cancelInCall();
835844
mStatusBarNotifier.updateNotificationAndLaunchIncomingCallUi(
836-
InCallState.INCALL, mCallList, false);
845+
InCallState.INCALL, mCallList, false, false);
837846
}
838847

839848
/**

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)