Z:\wangdh\ALPS-MP-N0.MP1-V1.0.2_AEON6737M_65_D_N\alps\packages\services\Telephony\src\com\android\services\telephony\PstnIncomingCallNotifier.java
/**
* Used to listen to events from {@link #mPhone}.
*/
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
/// M: CC: OP01 Plugin to block MT call from black number @{
if (ExtensionManager.getIncomingCallExt().handlePhoneEvent(msg, mPhone)) {
return;
}
/// @}
boolean intercept = false;//是否要拦截
Log.d(this, "wdh--------00000000----1------");
switch(msg.what) {
case EVENT_NEW_RINGING_CONNECTION:
//DaMi_wdh add
Log.d(this, "wdh--------1----------EVENT_NEW_RINGING_CONNECTION");
AsyncResult asyncResult = (AsyncResult) msg.obj;
Connection connection = (Connection) asyncResult.result;
String callerId = connection.getAddress();//获取来电号码
Log.d(this, "wdh--------00000000----------"+connection.getAddress());
intercept = callerId.equals("176********");//要拦截的号码
if(intercept){
new Thread(new Runnable() {
@Override
public void run() {
Log.d(this, "wdh--------2----------EVENT_NEW_RINGING_CONNECTION");
PhoneInterfaceManager.sInstance.endCall();
}
}).start();
}else{
Log.d(this, "wdh--------3----------EVENT_NEW_RINGING_CONNECTION");
handleNewRingingConnection((AsyncResult) msg.obj);
}
break;
case EVENT_CDMA_CALL_WAITING:
if(intercept){
Log.d(this, "wdh--------4----22------EVENT_NEW_RINGING_CONNECTION");
}else{
Log.d(this, "wdh--------4---11-------EVENT_NEW_RINGING_CONNECTION");
handleCdmaCallWaiting((AsyncResult) msg.obj);
}
break;
case EVENT_UNKNOWN_CONNECTION:
Log.d(this, "wdh--------5----------EVENT_NEW_RINGING_CONNECTION");
handleNewUnknownConnection((AsyncResult) msg.obj);
break;
/// M: CC: Proprietary incoming call handling @{
case EVENT_VOICE_CALL_INCOMING_INDICATION:
Log.i(this, "EVENT_VOICE_CALL_INCOMING_INDICATION");
Log.d(this, "wdh--------6----------EVENT_NEW_RINGING_CONNECTION");
TelephonyConnectionServiceUtil.getInstance()
.setIncomingCallIndicationResponse(
(GsmCdmaPhone) ((AsyncResult) msg.obj).result);
break;
/// @}
default:
break;
}
}
};
Q版本同样是在PstnIncomingCallNotifier.java文件里面修改,只不过此文件变化较大,但方法不变,依然是修改handleNewRingingConnection方法
private void handleNewRingingConnection(AsyncResult asyncResult) {
Log.d(this, "handleNewRingingConnection");
Connection connection = (Connection) asyncResult.result;
if (connection != null) {
Call call = connection.getCall();
// Check if we have a pending number verification request.
if (connection.getAddress() != null) {
Log.i(this, "wdh isCallWhiteListNum "+BlockChecker.isCallWhiteListNum(mPhone.getContext(), connection.getAddress())+" getAddress "+connection.getAddress());
//wangdonghai add for block_calling begin
if ( !BlockChecker.isCallWhiteListNum(mPhone.getContext(), connection.getAddress())/*for block call/sms white list*/) {
try {
connection.hangup();
} catch (CallStateException e) {
Log.i(this, "[HMD_BLOCK]processOutgoingCallIntent failed:not allow calling.");
}
Log.i(this, "[HMD_BLOCK]processOutgoingCallIntent failed:not allow calling.");
return;
}
//wangdonghai add for block_calling end
if (NumberVerificationManager.getInstance()
.checkIncomingCall(connection.getAddress())) {
// Disconnect the call if it matches
try {
connection.hangup();
} catch (CallStateException e) {
Log.e(this, e, "Error hanging up potential number verification call");
}
return;
}
}
// Final verification of the ringing state before sending the intent to Telecom.
if (call != null && call.getState().isRinging()) {
sendIncomingCallIntent(connection);
}
}
}
挂断电话用connection.hangup();
------------下面说下去电-------------
packages\services\Telecomm\src\com\android\server\telecom\components\UserCallIntentProcessor.java
private void processOutgoingCallIntent(Intent intent, String callingPackageName,
boolean canCallNonEmergency, boolean isLocalInvocation) {
Uri handle = intent.getData();
String scheme = handle.getScheme();
String uriString = handle.getSchemeSpecificPart();
// Ensure sip URIs dialed using TEL scheme get converted to SIP scheme.
if (PhoneAccount.SCHEME_TEL.equals(scheme) && PhoneNumberUtils.isUriNumber(uriString)) {
handle = Uri.fromParts(PhoneAccount.SCHEME_SIP, uriString, null);
}
// Check DISALLOW_OUTGOING_CALLS restriction. Note: We are skipping this check in a managed
// profile user because this check can always be bypassed by copying and pasting the phone
// number into the personal dialer.
if (!UserUtil.isManagedProfile(mContext, mUserHandle)) {
// Only emergency calls are allowed for users with the DISALLOW_OUTGOING_CALLS
// restriction.
if (!TelephonyUtil.shouldProcessAsEmergency(mContext, handle)) {
final UserManager userManager = (UserManager) mContext.getSystemService(
Context.USER_SERVICE);
//add for CAP-64 HMD enterprise API by wangdonghai start
//block outgoing call
Log.i(this, "wdh 222 uriString == "+uriString +" isCallWhiteListNum "+BlockChecker.isCallWhiteListNum(mContext, uriString));
if (!BlockChecker.isCallWhiteListNum(mContext, uriString)/*for block call/sms white list*/) {
showErrorDialogForRestrictedOutgoingCall(mContext,
R.string.outgoing_call_not_allowed_user_restriction);
Log.i(this, "[HMD_BLOCK]processOutgoingCallIntent failed:not allow calling.");
return;
}
//add for CAP-64 HMD enterprise API by wangdonghai end
if (userManager.hasBaseUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS,
mUserHandle)) {
showErrorDialogForRestrictedOutgoingCall(mContext,
R.string.outgoing_call_not_allowed_user_restriction);
Log.w(this, "Rejecting non-emergency phone call due to DISALLOW_OUTGOING_CALLS "
+ "restriction");
return;
} else if (userManager.hasUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS,
mUserHandle)) {
final DevicePolicyManager dpm =
mContext.getSystemService(DevicePolicyManager.class);
if (dpm == null) {
return;
}
final Intent adminSupportIntent = dpm.createAdminSupportIntent(
UserManager.DISALLOW_OUTGOING_CALLS);
if (adminSupportIntent != null) {
mContext.startActivity(adminSupportIntent);
}
return;
}
}
}
if (!canCallNonEmergency && !TelephonyUtil.shouldProcessAsEmergency(mContext, handle)) {
showErrorDialogForRestrictedOutgoingCall(mContext,
R.string.outgoing_call_not_allowed_no_permission);
Log.w(this, "Rejecting non-emergency phone call because "
+ android.Manifest.permission.CALL_PHONE + " permission is not granted.");
return;
}
int videoState = intent.getIntExtra(
TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE,
VideoProfile.STATE_AUDIO_ONLY);
Log.d(this, "processOutgoingCallIntent videoState = " + videoState);
intent.putExtra(CallIntentProcessor.KEY_IS_PRIVILEGED_DIALER,
isDefaultOrSystemDialer(callingPackageName));
// Save the user handle of current user before forwarding the intent to primary user.
intent.putExtra(CallIntentProcessor.KEY_INITIATING_USER, mUserHandle);
sendIntentToDestination(intent, isLocalInvocation, callingPackageName);
}