android Telephony学习 --- 第八篇 android7.0 来电UI启动流程

incall发起notification后,由systemui根据当前手机状态,来决定是显示来电界面还是headsup小窗口。

在这里插入图片描述

  • package/app/Dialer – InCallPresenter
     接着上篇文章,从onIncomingCall开始查看:
@Override
public void onIncomingCall(Call call) {
    InCallState newState = startOrFinishUi(InCallState.INCOMING);
    for (IncomingCallListener listener : mIncomingCallListeners) {
        listener.onIncomingCall(oldState, mInCallState, call);
    }
}

关注startOrFinishUi方法,若是满足直接显示UI的条件调用showInCall,直接启动UI;否则调用startUi:

private InCallState startOrFinishUi(InCallState newState) {
    if (showCallUi || showAccountPicker || isAutoAnswer) {
        showInCall(false /* showDialpad */, !showAccountPicker /* newOutgoingCall */);
    } else if (startIncomingCallSequence) {
        if (!startUi(newState)) {
            return mInCallState;
        }
    } 
}

调用StatusBarNotifier.updateNotification:

private boolean startUi(InCallState inCallState) {
    if (isCallWaiting || anyOtherSubActive) {
        if (mProximitySensor.isScreenReallyOff() && isActivityStarted()) {
            mInCallActivity.finish();
            return false;
        } else {
            showInCall(false, false);
        }
    } else {
        mStatusBarNotifier.updateNotification(inCallState, mCallList);
    }
    return true;
}
  • package/app/Dialer – StatusBarNotifier
    incall发起通知,后续由notification决定是显示小窗口还是来电界面:
private void buildAndSendNotification(Call originalCall, ContactCacheEntry contactInfo) {
    Notification.Builder publicBuilder = new Notification.Builder(mContext);
    final PendingIntent inCallPendingIntent = createLaunchPendingIntent();

    if (notificationType == NOTIFICATION_INCOMING_CALL
            && (!InCallPresenter.getInstance().isShowingInCallUi() ||
               (pendingAccountSelectionCall != null))) {
        configureFullScreenIntent(builder, inCallPendingIntent, call);
    }

    Notification notification = builder.build();
    mNotificationManager.notify(notificationType, notification);
}

configureFullScreenIntent方法:

private void configureFullScreenIntent(Notification.Builder builder, PendingIntent intent,
        Call call) {
    // Ok, we actually want to launch the incoming call
    // UI at this point (in addition to simply posting a notification
    // to the status bar).  Setting fullScreenIntent will cause
    // the InCallScreen to be launched immediately *unless* the
    // current foreground activity is marked as "immersive".
    builder.setFullScreenIntent(intent, true);
}

携带intent来启动InCallActivity:

private PendingIntent createLaunchPendingIntent() {

    final Intent intent = InCallPresenter.getInstance().getInCallIntent(
            false /* showDialpad */, false /* newOutgoingCall */);

    // PendingIntent that can be used to launch the InCallActivity.  The
    // system fires off this intent if the user pulls down the windowshade
    // and clicks the notification's expanded view.  It's also used to
    // launch the InCallActivity immediately when when there's an incoming
    // call (see the "fullScreenIntent" field below).
    PendingIntent inCallPendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0);

    return inCallPendingIntent;
}
  • frameworks/base/core – NotificationManager
public void notifyAsUser(String tag, int id, Notification notification, UserHandle user)
{
    INotificationManager service = getService();
    try {
        service.enqueueNotificationWithTag(pkg, mContext.getOpPackageName(), tag, id,
                copy, idOut, user.getIdentifier());
    } 
}
  • frameworks/base/core – NotificationManagerService
     找到INotificationManager aidl实现enqueueNotificationWithTag方法的地方:
private final IBinder mService = new INotificationManager.Stub() {
    @Override
    public void enqueueNotificationWithTag(String pkg, String opPkg, String tag, int id,
            Notification notification, int[] idOut, int userId) throws RemoteException {
        enqueueNotificationInternal(pkg, opPkg, Binder.getCallingUid(),
                Binder.getCallingPid(), tag, id, notification, idOut, userId);
    }
  • frameworks/base/packages/SystemUI – BaseStatusBar
private final NotificationListenerService mNotificationListener =
        new NotificationListenerService() {
    @Override
    public void onNotificationPosted(final StatusBarNotification sbn,
            final RankingMap rankingMap) {
        if (sbn != null) {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    if (isUpdate) {
                        updateNotification(sbn, rankingMap);
                    } else {
                        addNotification(sbn, rankingMap, null /* oldEntry */);
                    }
                }
            });
  • frameworks/base/packages/SystemUI – PhoneStatusBar
    isHeadsUped决定是显示headsup还是来电界面:
@Override
public void addNotification(StatusBarNotification notification, RankingMap ranking,
        Entry oldEntry) {

    boolean isHeadsUped = shouldPeek(shadeEntry);
    if (isHeadsUped) {
        mHeadsUpManager.showNotification(shadeEntry);
        setNotificationShown(notification);
    }

    if (!isHeadsUped && notification.getNotification().fullScreenIntent != null) {
            try {
                notification.getNotification().fullScreenIntent.send();
                shadeEntry.notifyFullScreenIntentLaunched();
            } 
``
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
android telephony原理解析与开发指南》是杨青平编写的一本关于Android手机通讯系统的原理和开发指南的书籍。本书主要介绍了Android手机通讯系统的工作原理、架构和相关开发技术。 首先,本书对Android手机通讯系统的工作原理进行了深入解析。Android手机通讯系统是由Android操作系统及其上层应用程序组成的,通过多个模块协同工作实现电话通信功能。本书从系统启动过程、应用层协议、信令流程等方面详细介绍了Android手机通讯系统的运行原理。 其次,本书介绍了Android手机通讯系统的架构。Android手机通讯系统的架构主要包括RIL、Telephony Service和Phone App等重要组件。作者详细解释了各个组件的功能和相互之间的关系,帮助读者理解Android手机通讯系统的整体架构。 同时,本书还提供了Android手机通讯系统开发的指南。作者从配置环境、开发工具和开发步骤等方面详细介绍了Android手机通讯系统的开发过程。读者可以学习到如何使用Android SDK进行开发,如何编写Telephony Service和Phone App等应用程序。 《android telephony原理解析与开发指南》是一本系统而实用的Android手机通讯系统开发指南。通过阅读本书,读者可以全面了解Android手机通讯系统的原理和架构,掌握Android手机通讯系统开发的技巧和方法。作为一名Android开发者,这本书将成为您在Android手机通讯系统开发中的实用指南。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值