Android 11 sim卡来电不弹出悬浮通知,默认来电默认全屏

365体育推荐 📅 2025-12-26 09:12:13 ✍️ admin 👁️ 9346 ❤️ 783
Android 11 sim卡来电不弹出悬浮通知,默认来电默认全屏

默认情况下,来电android是以通知窗口的形式显示,只在屏幕的顶部弹出一个悬浮通知,现在改为全屏显示,直接跳转来电界面InCallActivity

\packages\apps\Dialer\java\com\android\incallui\StatusBarNotifier.java

/**

* Helper method for updateInCallNotification() and updateNotification(): Update the phone app's

* status bar notification based on the current telephony state, or cancels the notification if

* the phone is totally idle.

*/

private boolean firstShow = true;//add

@RequiresPermission(Manifest.permission.READ_PHONE_STATE)

private void updateInCallNotification() {

LogUtil.d("StatusBarNotifier.updateInCallNotification", "");

final DialerCall call = getCallToShow(CallList.getInstance());

// don't show Notification, if call has already been rejected

if (call != null && !call.isRejected()) {

// add 当去电或者来电是会一直重复调用这个方法,要做一个判断,防止重复进入InCallActivity

showNotification(call);

if (firstShow) {

context.startActivity(InCallActivity.getIntent(context, false/*showDialpad*/, false/*newOutgoingCall*/, true /* forFullScreen */));

firstShow = false;

}

//add end

} else {

firstShow = true;//add

cancelNotification();

}

}

Android 11 通知是否弹出,有两个因素决定,

一个是通知的优先级(setPriority(NotificationCompat.PRIORITY_MIN)),

另一个是通知渠道(通道)的优先级(NotificationManager.IMPORTANCE_HIGH)

public NotificationChannel(String id, CharSequence name, @Importance int importance) {

this.mId = getTrimmedString(id);

this.mName = name != null ? getTrimmedString(name.toString()) : null;

this.mImportance = importance;

}

\packages\apps\Dialer\java\com\android\dialer\notification\NotificationChannelManager.java

这是通话app 为通知渠道的管理和创建

private static void createIncomingCallChannel(@NonNull Context context) {

NotificationChannel channel =

new NotificationChannel(

NotificationChannelId.INCOMING_CALL,

context.getText(R.string.notification_channel_incoming_call),

NotificationManager.IMPORTANCE_MAX);

......

}

实际修改 :来电通知弹出悬浮

/** Sets up the main Ui for the notification */

@RequiresPermission(Manifest.permission.READ_PHONE_STATE)

private void buildAndSendNotification(CallList callList, DialerCall originalCall, ContactCacheEntry contactInfo) {

...........

switch (notificationType) {

case NOTIFICATION_INCOMING_CALL:

if (BuildCompat.isAtLeastO()) {

builder.setChannelId(NotificationChannelId.ONGOING_CALL);// add old -> NotificationChannelId.INCOMING_CALL

}

......

}

break;

case NOTIFICATION_INCOMING_CALL_QUIET:

if (BuildCompat.isAtLeastO()) {

builder.setChannelId(NotificationChannelId.ONGOING_CALL);

}

break;

............

}

按钮接听方式

修改位置

packages\apps\Dialer\java\com\android\incallui\answer\impl\answermethod\AnswerMethodFactory.java

@NonNull

public static AnswerMethod createAnswerMethod(@NonNull Activity activity) {

if (needTwoButton(activity)) {

return new TwoButtonMethod();

} else {

//return new FlingUpDownMethod();

return new TwoButtonMethod();//add

}

}

参考1

参考2

mtk dialer 电话接听、拒绝上下滑不灵敏

原因:当前设备屏幕不适配dialer界面,原生滑动距离过长,判定误触条件问题。

packages\apps\Dialer\java\com\android\incallui\answer\impl\answermethod\FlingUpDownTouchHandler.java

// Dp touch needs to move downward to be considered fully rejected

/// M: ALPS06488355, Lower threshold to improve reject experience. @{

/// private static final int REJECT_THRESHOLD_DP = 150;

private static final int REJECT_THRESHOLD_DP = 50;

/// @}

/// M: ALPS06488355, Lower initial judgment condition to improve answer/reject experience. @{

/// if (startProgress <= .15) {

if (startProgress <= .15) {

/// @}

private void endMotionEvent(MotionEvent event, float pointerY, boolean forceCancel) {

trackingPointer = -1;

if ((tracking && touchSlopExceeded)

|| Math.abs(pointerY - initialTouchY) > touchSlop

|| event.getActionMasked() == MotionEvent.ACTION_CANCEL

|| forceCancel) {

float vel = 0f;

float vectorVel = 0f;

if (velocityTracker != null) {

velocityTracker.computeCurrentVelocity(1000);

vel = velocityTracker.getYVelocity();

vectorVel =

Math.copySign(

(float) Math.hypot(velocityTracker.getXVelocity(), velocityTracker.getYVelocity()),

vel);

}

//add text start

boolean falseTouch = false;//isFalseTouch();

//add text end

boolean forceRecenter =

falseTouch

|| !touchSlopExceeded

|| forceCancel

|| event.getActionMasked() == MotionEvent.ACTION_CANCEL;

@FlingTarget

int target = forceRecenter ? FlingTarget.CENTER : getFlingTarget(pointerY, vectorVel);

fling(vel, target, falseTouch);

onTrackingStopped();

} else {

onTrackingStopped();

setCurrentProgress(0);

onMoveEnded();

}

//是否为误触

private boolean isFalseTouch() {

if (falsingManager != null && falsingManager.isEnabled()) {

if (falsingManager.isFalseTouch()) {

if (touchUsesFalsing) {

LogUtil.i("FlingUpDownTouchHandler.isFalseTouch", "rejecting false touch");

return true;

} else {

LogUtil.i(

"FlingUpDownTouchHandler.isFalseTouch",

"Suspected false touch, but not using false touch rejection for this gesture");

return false;

}

} else {

return false;

}

}

return !touchAboveFalsingThreshold;

}

其实通知和SystemUI 相关,也可以在它哪里拦截!!!

SystemIU关于悬浮通知

modified: packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/HeadsUpViewBinder.java

modified: packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/NotificationInterruptStateProviderImpl.java

modified: packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java

//HeadsUpManager.java

@Override

protected void onAlertEntryAdded(AlertEntry alertEntry) {

NotificationEntry entry = alertEntry.mEntry;

if(entry.getSbn().getPackageName().equals("com.xx.xxx")){

return;

}

entry.setHeadsUp(true);

setEntryPinned((HeadsUpEntry) alertEntry, shouldHeadsUpBecomePinned(entry));

for (OnHeadsUpChangedListener listener : mListeners) {

listener.onHeadsUpStateChanged(entry, true);

}

}

参考3

在Frameworks层拦截Home键

https://blog.csdn.net/abc6368765/article/details/132164705

/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java

/** {@inheritDoc} */

@Override

public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) {

......

// First we always handle the home key here, so applications

// can never break it, although if keyguard is on, we do let

// it handle it, because that gives us the correct 5 second

// timeout.

if (keyCode == KeyEvent.KEYCODE_HOME) {

// If we have released the home key, and didn't do anything else

// while it was pressed, then it is time to go home!

if (!down) {

//添加的判断当前前台运行APP代码

if (!isBackgroundActivity(mContext, PKG_NAME_xxxxx)) {

Log.d(TAG, "xxxx app is foreground");

if (!getTopActivity(mContext).equals(ACTIVITY_NAME_xxxx)) {

Log.d(TAG, "xxxxx app is foreground activity");

return -1;

}

return -1;

}

cancelPreloadRecentApps();

mHomePressed = false;

if (mHomeConsumed) {

mHomeConsumed = false;

return -1;

}

......

相关推荐

qq空间名字怎么改
365bet怎么注册

qq空间名字怎么改

📅 10-29 👁️ 8191
微信怎么绑定社保卡,详细步骤教程
365bet体育在线主页

微信怎么绑定社保卡,详细步骤教程

📅 08-30 👁️ 6529