源码位置 packages/apps/InCallUI/src/com/android/incallui/StatusBarNotifier.java
private void updateInCallNotification(final InCallState state, CallList callList) { ... final Call call = getCallToShow(callList); //2018-10-10 cczheng add intercept incoming notification start if (true) { if (call != null) { Log.v("InCallNotification", "phoneNumber = " + call.getNumber()); } return; } //2018-10-10 cczheng add intercept incoming notification end if (call != null) { showNotification(call); } else { cancelNotification(); } ... }其实核心方法就是showNotification(call),发送通知当statusBar收到通知就处理并显示在状态栏。
当你发现这样处理完后,重新mm,然后push替换Dialer.apk重启后,你会坑爹的发现状态栏那个未接来电图标依旧显示,无fa可说,继续跟踪日志揪出罪魁祸首,最终发现另一处奇葩的地方。
源码位置 packages/services/Telecomm/src/com/android/server/telecom/ui/MissedCallNotifierImpl.java
诺,就是这了,看注释就明白了吧 Create a system notification for the missed call
/** * Create a system notification for the missed call. * * @param call The missed call. */ @Override public void showMissedCallNotification(Call call) { ////2018-10-10 cczheng hide missed call notification [S] if (true) { android.util.Log.i("misscall", "showMissedCallNotification......"); return; } ///2018-10-10 cczheng hide missed call notification [E] mMissedCallCount++; final int titleResId; final String expandedText; // The text in the notification's line 1 and 2. .... }ok,这样我们就搞定了来电功能。
三、隐藏短信应用和电话应用在launcher中显示(去除AndroidManifest中的category) <category android:name="android.intent.category.LAUNCHER" /> 四、总结Android源码修改没有大家想象的那么难,毕竟Google工程师都已经给我们标注了详细的注释说明,只是框架和封装的思路难以理解,这就考验我们的耐心了,Log是个好东西,多加日志,多分析,这样很容易上手。