Skip to content

Commit

Permalink
Move ACTION_SIP_INCOMING_CALL back to Manifest
Browse files Browse the repository at this point in the history
The ACTION_SIP_INCOMING_CALL intent receiver along with
all of the other SIP intent receivers were moved to
dynamic registration because background check
was not letting them be received. Since
ACTION_SIP_INCOMING_CALL is an explicit intent, this
caused this intent to not be received anymore and
caused SIP incoming calls to not show InCall UI.

This change moves that intent back to the manifest
so that it can be received.

Bug: 64508600
Test: Manual
Change-Id: Ie330f748790fc0470a2b59128258c50e17d4cdf7
  • Loading branch information
Brad Ebinger committed Aug 10, 2017
1 parent 51e2046 commit 2862612
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 28 deletions.
6 changes: 6 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,12 @@
</intent-filter>
</service>

<receiver android:name="com.android.services.telephony.sip.SipIncomingCallReceiver">
<intent-filter>
<action android:name="com.android.phone.SIP_INCOMING_CALL" />
</intent-filter>
</receiver>

<activity android:name="com.android.services.telephony.sip.SipPhoneAccountSettingsActivity"
android:theme="@android:style/Theme.NoDisplay"
android:excludeFromRecents="true">
Expand Down
2 changes: 1 addition & 1 deletion sip/proguard.flags
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-verbose
-keep class com.android.services.telephony.sip.SipConnectionService
-keep class com.android.services.telephony.sip.SipBroadcastReceiver
-keep class com.android.services.telephony.sip.SipIncomingCallReceiver
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ public static SipAccountRegistry getInstance() {
return INSTANCE;
}

void setup(Context context) {
/**
* Sets up the Account registry and performs any upgrade operations before it is used.
*/
public void setup(Context context) {
verifyAndPurgeInvalidPhoneAccounts(context);
startSipProfilesAsync(context, (String) null, false);
}
Expand Down Expand Up @@ -157,7 +160,7 @@ void startSipService(Context context, String sipProfileName, boolean enableProfi
*
* @param sipProfileName Name of the SIP profile.
*/
void removeSipProfile(String sipProfileName) {
public void removeSipProfile(String sipProfileName) {
AccountEntry accountEntry = getAccountEntry(sipProfileName);

if (accountEntry != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,19 @@
import android.telecom.TelecomManager;
import android.util.Log;

import com.android.phone.PhoneGlobals;
import com.android.server.sip.SipService;

/**
* Broadcast receiver that handles SIP-related intents.
* Broadcast receiver that handles explicit incoming call intents
*/
public class SipBroadcastReceiver extends BroadcastReceiver {
private static final String PREFIX = "[SipBroadcastReceiver] ";
public class SipIncomingCallReceiver extends BroadcastReceiver {
private static final String PREFIX = "[SipIncomingCallReceiver] ";
private static final boolean VERBOSE = false; /* STOP SHIP if true */

@Override
public void onReceive(Context context, final Intent intent) {
String action = intent.getAction();

if (!isRunningInSystemUser()) {
if (VERBOSE) log("SipBroadcastReceiver only run in system user, ignore " + action);
if (VERBOSE) log("SipIncomingCallReceiver only run in system user, ignore " + action);
return;
}

Expand All @@ -51,18 +48,8 @@ public void onReceive(Context context, final Intent intent) {
return;
}

SipAccountRegistry sipAccountRegistry = SipAccountRegistry.getInstance();
if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
SipUtil.startSipService();
} else if (action.equals(SipManager.ACTION_SIP_INCOMING_CALL)) {
if (action.equals(SipManager.ACTION_SIP_INCOMING_CALL)) {
takeCall(context, intent);
} else if (action.equals(SipManager.ACTION_SIP_SERVICE_UP) ||
action.equals(SipManager.ACTION_SIP_CALL_OPTION_CHANGED)) {
sipAccountRegistry.setup(context);
} else if (action.equals(SipManager.ACTION_SIP_REMOVE_PHONE)) {
if (VERBOSE) log("SIP_REMOVE_PHONE " +
intent.getStringExtra(SipManager.EXTRA_LOCAL_URI));
sipAccountRegistry.removeSipProfile(intent.getStringExtra(SipManager.EXTRA_LOCAL_URI));
} else {
if (VERBOSE) log("onReceive, action not processed: " + action);
}
Expand All @@ -82,7 +69,7 @@ private void takeCall(Context context, Intent intent) {
extras.putParcelable(SipUtil.EXTRA_INCOMING_CALL_INTENT, intent);
TelecomManager tm = TelecomManager.from(context);
PhoneAccount phoneAccount = tm.getPhoneAccount(accountHandle);
if(phoneAccount != null && phoneAccount.isEnabled()) {
if (phoneAccount != null && phoneAccount.isEnabled()) {
tm.addNewIncomingCall(accountHandle, extras);
} else {
log("takeCall, PhoneAccount is disabled. Not accepting incoming call...");
Expand Down
2 changes: 1 addition & 1 deletion sip/src/com/android/services/telephony/sip/SipUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static boolean isVoipSupported(Context context) {

static PendingIntent createIncomingCallPendingIntent(
Context context, String sipProfileName) {
Intent intent = new Intent(context, SipBroadcastReceiver.class);
Intent intent = new Intent(context, SipIncomingCallReceiver.class);
intent.setAction(SipManager.ACTION_SIP_INCOMING_CALL);
intent.putExtra(EXTRA_PHONE_ACCOUNT, SipUtil.createAccountHandle(context, sipProfileName));
return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Expand Down
34 changes: 29 additions & 5 deletions src/com/android/phone/PhoneGlobals.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
import com.android.phone.common.CallLogAsync;
import com.android.phone.settings.SettingsConstants;
import com.android.phone.vvm.CarrierVvmPackageInstalledReceiver;
import com.android.services.telephony.sip.SipBroadcastReceiver;
import com.android.services.telephony.sip.SipAccountRegistry;
import com.android.services.telephony.sip.SipUtil;

import java.io.FileDescriptor;
Expand Down Expand Up @@ -176,7 +176,7 @@ public enum WakeState {
// Broadcast receiver for various intent broadcasts (see onCreate())
private final BroadcastReceiver mReceiver = new PhoneAppBroadcastReceiver();
// Broadcast receiver for SIP based intents (see onCreate())
private final SipBroadcastReceiver mSipBroadcastReceiver = new SipBroadcastReceiver();
private final SipReceiver mSipReceiver = new SipReceiver();

private final CarrierVvmPackageInstalledReceiver mCarrierVvmPackageInstalledReceiver =
new CarrierVvmPackageInstalledReceiver();
Expand Down Expand Up @@ -247,7 +247,7 @@ public void handleMessage(Message msg) {
case EVENT_RESTART_SIP:
// This should only run if the Phone process crashed and was restarted. We do
// not want this running if the device is still in the FBE encrypted state.
// This is the same procedure that is triggered in the SipBroadcastReceiver
// This is the same procedure that is triggered in the SipIncomingCallReceiver
// upon BOOT_COMPLETED.
UserManager userManager = UserManager.get(sMe);
if (userManager != null && userManager.isUserUnlocked()) {
Expand Down Expand Up @@ -367,11 +367,10 @@ public void onCreate() {
registerReceiver(mReceiver, intentFilter);

IntentFilter sipIntentFilter = new IntentFilter(Intent.ACTION_BOOT_COMPLETED);
sipIntentFilter.addAction(SipManager.ACTION_SIP_INCOMING_CALL);
sipIntentFilter.addAction(SipManager.ACTION_SIP_SERVICE_UP);
sipIntentFilter.addAction(SipManager.ACTION_SIP_CALL_OPTION_CHANGED);
sipIntentFilter.addAction(SipManager.ACTION_SIP_REMOVE_PHONE);
registerReceiver(mSipBroadcastReceiver, sipIntentFilter);
registerReceiver(mSipReceiver, sipIntentFilter);

mCarrierVvmPackageInstalledReceiver.register(this);

Expand Down Expand Up @@ -763,6 +762,31 @@ public void onReceive(Context context, Intent intent) {
}
}

private class SipReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();

SipAccountRegistry sipAccountRegistry = SipAccountRegistry.getInstance();
if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
SipUtil.startSipService();
} else if (action.equals(SipManager.ACTION_SIP_SERVICE_UP)
|| action.equals(SipManager.ACTION_SIP_CALL_OPTION_CHANGED)) {
sipAccountRegistry.setup(context);
} else if (action.equals(SipManager.ACTION_SIP_REMOVE_PHONE)) {
if (DBG) {
Log.d(LOG_TAG, "SIP_REMOVE_PHONE "
+ intent.getStringExtra(SipManager.EXTRA_LOCAL_URI));
}
sipAccountRegistry.removeSipProfile(intent.getStringExtra(
SipManager.EXTRA_LOCAL_URI));
} else {
if (DBG) Log.d(LOG_TAG, "onReceive, action not processed: " + action);
}
}
}

private void handleServiceStateChanged(Intent intent) {
/**
* This used to handle updating EriTextWidgetProvider this routine
Expand Down

0 comments on commit 2862612

Please sign in to comment.