Loading src/com/android/server/telecom/CallsManager.java +63 −0 Original line number Diff line number Diff line Loading @@ -143,6 +143,9 @@ public class CallsManager extends Call.ListenerBase */ private static final int CALL_FILTER_ALL = 3; private static final String PERMISSION_PROCESS_PHONE_ACCOUNT_REGISTRATION = "android.permission.PROCESS_PHONE_ACCOUNT_REGISTRATION"; private static final int HANDLER_WAIT_TIMEOUT = 10000; private static final int MAXIMUM_LIVE_CALLS = 1; private static final int MAXIMUM_HOLD_CALLS = 1; Loading Loading @@ -260,6 +263,21 @@ public class CallsManager extends Call.ListenerBase private Runnable mStopTone; /** * Listener to PhoneAccountRegistrar events. */ private PhoneAccountRegistrar.Listener mPhoneAccountListener = new PhoneAccountRegistrar.Listener() { public void onPhoneAccountRegistered(PhoneAccountRegistrar registrar, PhoneAccountHandle handle) { broadcastRegisterIntent(handle); } public void onPhoneAccountUnRegistered(PhoneAccountRegistrar registrar, PhoneAccountHandle handle) { broadcastUnregisterIntent(handle); } }; /** * Initializes the required Telecom components. */ Loading Loading @@ -288,6 +306,7 @@ public class CallsManager extends Call.ListenerBase mContactsAsyncHelper = contactsAsyncHelper; mCallerInfoAsyncQueryFactory = callerInfoAsyncQueryFactory; mPhoneAccountRegistrar = phoneAccountRegistrar; mPhoneAccountRegistrar.addListener(mPhoneAccountListener); mMissedCallNotifier = missedCallNotifier; StatusBarNotifier statusBarNotifier = new StatusBarNotifier(context, this); mWiredHeadsetManager = wiredHeadsetManager; Loading Loading @@ -2737,4 +2756,48 @@ public class CallsManager extends Call.ListenerBase service.createConnectionFailed(call); } } private void broadcastUnregisterIntent(PhoneAccountHandle accountHandle) { Intent intent = new Intent(TelecomManager.ACTION_PHONE_ACCOUNT_UNREGISTERED); intent.putExtra( TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle); Log.i(this, "Sending phone-account %s unregistered intent as user", accountHandle); mContext.sendBroadcastAsUser(intent, UserHandle.ALL, PERMISSION_PROCESS_PHONE_ACCOUNT_REGISTRATION); String dialerPackage = mDefaultDialerCache.getDefaultDialerApplication( getCurrentUserHandle().getIdentifier()); if (!TextUtils.isEmpty(dialerPackage)) { Intent directedIntent = new Intent(TelecomManager.ACTION_PHONE_ACCOUNT_UNREGISTERED) .setPackage(dialerPackage); directedIntent.putExtra( TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle); Log.i(this, "Sending phone-account unregistered intent to default dialer"); mContext.sendBroadcastAsUser(directedIntent, UserHandle.ALL, null); } return ; } private void broadcastRegisterIntent(PhoneAccountHandle accountHandle) { Intent intent = new Intent( TelecomManager.ACTION_PHONE_ACCOUNT_REGISTERED); intent.putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle); Log.i(this, "Sending phone-account %s registered intent as user", accountHandle); mContext.sendBroadcastAsUser(intent, UserHandle.ALL, PERMISSION_PROCESS_PHONE_ACCOUNT_REGISTRATION); String dialerPackage = mDefaultDialerCache.getDefaultDialerApplication( getCurrentUserHandle().getIdentifier()); if (!TextUtils.isEmpty(dialerPackage)) { Intent directedIntent = new Intent(TelecomManager.ACTION_PHONE_ACCOUNT_REGISTERED) .setPackage(dialerPackage); directedIntent.putExtra( TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle); Log.i(this, "Sending phone-account registered intent to default dialer"); mContext.sendBroadcastAsUser(directedIntent, UserHandle.ALL, null); } return ; } } src/com/android/server/telecom/PhoneAccountRegistrar.java +24 −2 Original line number Diff line number Diff line Loading @@ -120,6 +120,10 @@ public class PhoneAccountRegistrar { public void onAccountsChanged(PhoneAccountRegistrar registrar) {} public void onDefaultOutgoingChanged(PhoneAccountRegistrar registrar) {} public void onSimCallManagerChanged(PhoneAccountRegistrar registrar) {} public void onPhoneAccountRegistered(PhoneAccountRegistrar registrar, PhoneAccountHandle handle) {} public void onPhoneAccountUnRegistered(PhoneAccountRegistrar registrar, PhoneAccountHandle handle) {} } /** Loading Loading @@ -652,14 +656,17 @@ public class PhoneAccountRegistrar { // !!! IMPORTANT !!! It is important that we do not read the enabled state that the // source app provides or else an third party app could enable itself. boolean isEnabled = false; boolean isNewAccount; PhoneAccount oldAccount = getPhoneAccountUnchecked(account.getAccountHandle()); if (oldAccount != null) { mState.accounts.remove(oldAccount); isEnabled = oldAccount.isEnabled(); Log.i(this, getAccountDiffString(account, oldAccount)); Log.i(this, "Modify account: %s", getAccountDiffString(account, oldAccount)); isNewAccount = false; } else { Log.i(this, "New phone account registered: " + account); isNewAccount = true; } // When registering a self-managed PhoneAccount we enforce the rule that the label that the Loading Loading @@ -695,6 +702,9 @@ public class PhoneAccountRegistrar { write(); fireAccountsChanged(); if (isNewAccount) { fireAccountRegistered(account.getAccountHandle()); } } public void unregisterPhoneAccount(PhoneAccountHandle accountHandle) { Loading @@ -703,6 +713,7 @@ public class PhoneAccountRegistrar { if (mState.accounts.remove(account)) { write(); fireAccountsChanged(); fireAccountUnRegistered(accountHandle); } } } Loading Loading @@ -748,6 +759,18 @@ public class PhoneAccountRegistrar { } } private void fireAccountRegistered(PhoneAccountHandle handle) { for (Listener l : mListeners) { l.onPhoneAccountRegistered(this, handle); } } private void fireAccountUnRegistered(PhoneAccountHandle handle) { for (Listener l : mListeners) { l.onPhoneAccountUnRegistered(this, handle); } } private void fireAccountsChanged() { for (Listener l : mListeners) { l.onAccountsChanged(this); Loading @@ -771,7 +794,6 @@ public class PhoneAccountRegistrar { Log.piiHandle(account2.getAddress())); appendDiff(sb, "cap", account1.getCapabilities(), account2.getCapabilities()); appendDiff(sb, "hl", account1.getHighlightColor(), account2.getHighlightColor()); appendDiff(sb, "icon", account1.getIcon(), account2.getIcon()); appendDiff(sb, "lbl", account1.getLabel(), account2.getLabel()); appendDiff(sb, "desc", account1.getShortDescription(), account2.getShortDescription()); appendDiff(sb, "subAddr", Log.piiHandle(account1.getSubscriptionAddress()), Loading src/com/android/server/telecom/TelecomServiceImpl.java +1 −29 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.EventLog; // TODO: Needed for move to system service: import com.android.internal.R; Loading Loading @@ -78,8 +79,6 @@ public class TelecomServiceImpl { } } private static final String PERMISSION_PROCESS_PHONE_ACCOUNT_REGISTRATION = "android.permission.PROCESS_PHONE_ACCOUNT_REGISTRATION"; private static final int DEFAULT_VIDEO_STATE = -1; private final ITelecomService.Stub mBinderImpl = new ITelecomService.Stub() { Loading Loading @@ -401,19 +400,6 @@ public class TelecomServiceImpl { } enforceUserHandleMatchesCaller(account.getAccountHandle()); mPhoneAccountRegistrar.registerPhoneAccount(account); // Broadcast an intent indicating the phone account which was registered. long token = Binder.clearCallingIdentity(); try { Intent intent = new Intent( TelecomManager.ACTION_PHONE_ACCOUNT_REGISTERED); intent.putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, account.getAccountHandle()); Log.i(this, "Sending phone-account registered intent as user"); mContext.sendBroadcastAsUser(intent, UserHandle.ALL, PERMISSION_PROCESS_PHONE_ACCOUNT_REGISTRATION); } finally { Binder.restoreCallingIdentity(token); } } catch (Exception e) { Log.e(this, e, "registerPhoneAccount %s", account); throw e; Loading @@ -433,20 +419,6 @@ public class TelecomServiceImpl { accountHandle.getComponentName().getPackageName()); enforceUserHandleMatchesCaller(accountHandle); mPhoneAccountRegistrar.unregisterPhoneAccount(accountHandle); // Broadcast an intent indicating the phone account which was unregistered. long token = Binder.clearCallingIdentity(); try { Intent intent = new Intent(TelecomManager.ACTION_PHONE_ACCOUNT_UNREGISTERED); intent.putExtra( TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle); Log.i(this, "Sending phone-account unregistered intent as user"); mContext.sendBroadcastAsUser(intent, UserHandle.ALL, PERMISSION_PROCESS_PHONE_ACCOUNT_REGISTRATION); } finally { Binder.restoreCallingIdentity(token); } } catch (Exception e) { Log.e(this, e, "unregisterPhoneAccount %s", accountHandle); throw e; Loading testapps/AndroidManifest.xml +2 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,8 @@ <intent-filter> <action android:name="android.server.telecom.testapps.ACTION_SEND_UPDATE_REQUEST_FROM_TEST_INCALL_SERVICE"/> <action android:name="android.server.telecom.testapps.ACTION_SEND_UPGRADE_RESPONSE"/> <data android:scheme="int" /> <action android:name="android.telecom.action.PHONE_ACCOUNT_REGISTERED"/> <action android:name="android.telecom.action.PHONE_ACCOUNT_UNREGISTERED"/> </intent-filter> </receiver> Loading testapps/src/com/android/server/telecom/testapps/TestInCallServiceBroadcastReceiver.java +7 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.telecom.testapps; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.telecom.TelecomManager; import android.util.Log; /** Loading Loading @@ -56,6 +57,12 @@ public class TestInCallServiceBroadcastReceiver extends BroadcastReceiver { } else if (ACTION_SEND_UPGRADE_RESPONSE.equals(action)) { final int videoState = Integer.parseInt(intent.getData().getSchemeSpecificPart()); TestCallList.getInstance().sendUpgradeToVideoResponse(videoState); } else if (TelecomManager.ACTION_PHONE_ACCOUNT_REGISTERED.equals(action)) { Log.i(TAG, "onReceive: registered " + intent.getExtras().get( TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE)); } else if (TelecomManager.ACTION_PHONE_ACCOUNT_UNREGISTERED.equals(action)) { Log.i(TAG, "onReceive: unregistered " + intent.getExtras().get( TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE)); } } } Loading
src/com/android/server/telecom/CallsManager.java +63 −0 Original line number Diff line number Diff line Loading @@ -143,6 +143,9 @@ public class CallsManager extends Call.ListenerBase */ private static final int CALL_FILTER_ALL = 3; private static final String PERMISSION_PROCESS_PHONE_ACCOUNT_REGISTRATION = "android.permission.PROCESS_PHONE_ACCOUNT_REGISTRATION"; private static final int HANDLER_WAIT_TIMEOUT = 10000; private static final int MAXIMUM_LIVE_CALLS = 1; private static final int MAXIMUM_HOLD_CALLS = 1; Loading Loading @@ -260,6 +263,21 @@ public class CallsManager extends Call.ListenerBase private Runnable mStopTone; /** * Listener to PhoneAccountRegistrar events. */ private PhoneAccountRegistrar.Listener mPhoneAccountListener = new PhoneAccountRegistrar.Listener() { public void onPhoneAccountRegistered(PhoneAccountRegistrar registrar, PhoneAccountHandle handle) { broadcastRegisterIntent(handle); } public void onPhoneAccountUnRegistered(PhoneAccountRegistrar registrar, PhoneAccountHandle handle) { broadcastUnregisterIntent(handle); } }; /** * Initializes the required Telecom components. */ Loading Loading @@ -288,6 +306,7 @@ public class CallsManager extends Call.ListenerBase mContactsAsyncHelper = contactsAsyncHelper; mCallerInfoAsyncQueryFactory = callerInfoAsyncQueryFactory; mPhoneAccountRegistrar = phoneAccountRegistrar; mPhoneAccountRegistrar.addListener(mPhoneAccountListener); mMissedCallNotifier = missedCallNotifier; StatusBarNotifier statusBarNotifier = new StatusBarNotifier(context, this); mWiredHeadsetManager = wiredHeadsetManager; Loading Loading @@ -2737,4 +2756,48 @@ public class CallsManager extends Call.ListenerBase service.createConnectionFailed(call); } } private void broadcastUnregisterIntent(PhoneAccountHandle accountHandle) { Intent intent = new Intent(TelecomManager.ACTION_PHONE_ACCOUNT_UNREGISTERED); intent.putExtra( TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle); Log.i(this, "Sending phone-account %s unregistered intent as user", accountHandle); mContext.sendBroadcastAsUser(intent, UserHandle.ALL, PERMISSION_PROCESS_PHONE_ACCOUNT_REGISTRATION); String dialerPackage = mDefaultDialerCache.getDefaultDialerApplication( getCurrentUserHandle().getIdentifier()); if (!TextUtils.isEmpty(dialerPackage)) { Intent directedIntent = new Intent(TelecomManager.ACTION_PHONE_ACCOUNT_UNREGISTERED) .setPackage(dialerPackage); directedIntent.putExtra( TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle); Log.i(this, "Sending phone-account unregistered intent to default dialer"); mContext.sendBroadcastAsUser(directedIntent, UserHandle.ALL, null); } return ; } private void broadcastRegisterIntent(PhoneAccountHandle accountHandle) { Intent intent = new Intent( TelecomManager.ACTION_PHONE_ACCOUNT_REGISTERED); intent.putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle); Log.i(this, "Sending phone-account %s registered intent as user", accountHandle); mContext.sendBroadcastAsUser(intent, UserHandle.ALL, PERMISSION_PROCESS_PHONE_ACCOUNT_REGISTRATION); String dialerPackage = mDefaultDialerCache.getDefaultDialerApplication( getCurrentUserHandle().getIdentifier()); if (!TextUtils.isEmpty(dialerPackage)) { Intent directedIntent = new Intent(TelecomManager.ACTION_PHONE_ACCOUNT_REGISTERED) .setPackage(dialerPackage); directedIntent.putExtra( TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle); Log.i(this, "Sending phone-account registered intent to default dialer"); mContext.sendBroadcastAsUser(directedIntent, UserHandle.ALL, null); } return ; } }
src/com/android/server/telecom/PhoneAccountRegistrar.java +24 −2 Original line number Diff line number Diff line Loading @@ -120,6 +120,10 @@ public class PhoneAccountRegistrar { public void onAccountsChanged(PhoneAccountRegistrar registrar) {} public void onDefaultOutgoingChanged(PhoneAccountRegistrar registrar) {} public void onSimCallManagerChanged(PhoneAccountRegistrar registrar) {} public void onPhoneAccountRegistered(PhoneAccountRegistrar registrar, PhoneAccountHandle handle) {} public void onPhoneAccountUnRegistered(PhoneAccountRegistrar registrar, PhoneAccountHandle handle) {} } /** Loading Loading @@ -652,14 +656,17 @@ public class PhoneAccountRegistrar { // !!! IMPORTANT !!! It is important that we do not read the enabled state that the // source app provides or else an third party app could enable itself. boolean isEnabled = false; boolean isNewAccount; PhoneAccount oldAccount = getPhoneAccountUnchecked(account.getAccountHandle()); if (oldAccount != null) { mState.accounts.remove(oldAccount); isEnabled = oldAccount.isEnabled(); Log.i(this, getAccountDiffString(account, oldAccount)); Log.i(this, "Modify account: %s", getAccountDiffString(account, oldAccount)); isNewAccount = false; } else { Log.i(this, "New phone account registered: " + account); isNewAccount = true; } // When registering a self-managed PhoneAccount we enforce the rule that the label that the Loading Loading @@ -695,6 +702,9 @@ public class PhoneAccountRegistrar { write(); fireAccountsChanged(); if (isNewAccount) { fireAccountRegistered(account.getAccountHandle()); } } public void unregisterPhoneAccount(PhoneAccountHandle accountHandle) { Loading @@ -703,6 +713,7 @@ public class PhoneAccountRegistrar { if (mState.accounts.remove(account)) { write(); fireAccountsChanged(); fireAccountUnRegistered(accountHandle); } } } Loading Loading @@ -748,6 +759,18 @@ public class PhoneAccountRegistrar { } } private void fireAccountRegistered(PhoneAccountHandle handle) { for (Listener l : mListeners) { l.onPhoneAccountRegistered(this, handle); } } private void fireAccountUnRegistered(PhoneAccountHandle handle) { for (Listener l : mListeners) { l.onPhoneAccountUnRegistered(this, handle); } } private void fireAccountsChanged() { for (Listener l : mListeners) { l.onAccountsChanged(this); Loading @@ -771,7 +794,6 @@ public class PhoneAccountRegistrar { Log.piiHandle(account2.getAddress())); appendDiff(sb, "cap", account1.getCapabilities(), account2.getCapabilities()); appendDiff(sb, "hl", account1.getHighlightColor(), account2.getHighlightColor()); appendDiff(sb, "icon", account1.getIcon(), account2.getIcon()); appendDiff(sb, "lbl", account1.getLabel(), account2.getLabel()); appendDiff(sb, "desc", account1.getShortDescription(), account2.getShortDescription()); appendDiff(sb, "subAddr", Log.piiHandle(account1.getSubscriptionAddress()), Loading
src/com/android/server/telecom/TelecomServiceImpl.java +1 −29 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.EventLog; // TODO: Needed for move to system service: import com.android.internal.R; Loading Loading @@ -78,8 +79,6 @@ public class TelecomServiceImpl { } } private static final String PERMISSION_PROCESS_PHONE_ACCOUNT_REGISTRATION = "android.permission.PROCESS_PHONE_ACCOUNT_REGISTRATION"; private static final int DEFAULT_VIDEO_STATE = -1; private final ITelecomService.Stub mBinderImpl = new ITelecomService.Stub() { Loading Loading @@ -401,19 +400,6 @@ public class TelecomServiceImpl { } enforceUserHandleMatchesCaller(account.getAccountHandle()); mPhoneAccountRegistrar.registerPhoneAccount(account); // Broadcast an intent indicating the phone account which was registered. long token = Binder.clearCallingIdentity(); try { Intent intent = new Intent( TelecomManager.ACTION_PHONE_ACCOUNT_REGISTERED); intent.putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, account.getAccountHandle()); Log.i(this, "Sending phone-account registered intent as user"); mContext.sendBroadcastAsUser(intent, UserHandle.ALL, PERMISSION_PROCESS_PHONE_ACCOUNT_REGISTRATION); } finally { Binder.restoreCallingIdentity(token); } } catch (Exception e) { Log.e(this, e, "registerPhoneAccount %s", account); throw e; Loading @@ -433,20 +419,6 @@ public class TelecomServiceImpl { accountHandle.getComponentName().getPackageName()); enforceUserHandleMatchesCaller(accountHandle); mPhoneAccountRegistrar.unregisterPhoneAccount(accountHandle); // Broadcast an intent indicating the phone account which was unregistered. long token = Binder.clearCallingIdentity(); try { Intent intent = new Intent(TelecomManager.ACTION_PHONE_ACCOUNT_UNREGISTERED); intent.putExtra( TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle); Log.i(this, "Sending phone-account unregistered intent as user"); mContext.sendBroadcastAsUser(intent, UserHandle.ALL, PERMISSION_PROCESS_PHONE_ACCOUNT_REGISTRATION); } finally { Binder.restoreCallingIdentity(token); } } catch (Exception e) { Log.e(this, e, "unregisterPhoneAccount %s", accountHandle); throw e; Loading
testapps/AndroidManifest.xml +2 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,8 @@ <intent-filter> <action android:name="android.server.telecom.testapps.ACTION_SEND_UPDATE_REQUEST_FROM_TEST_INCALL_SERVICE"/> <action android:name="android.server.telecom.testapps.ACTION_SEND_UPGRADE_RESPONSE"/> <data android:scheme="int" /> <action android:name="android.telecom.action.PHONE_ACCOUNT_REGISTERED"/> <action android:name="android.telecom.action.PHONE_ACCOUNT_UNREGISTERED"/> </intent-filter> </receiver> Loading
testapps/src/com/android/server/telecom/testapps/TestInCallServiceBroadcastReceiver.java +7 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.telecom.testapps; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.telecom.TelecomManager; import android.util.Log; /** Loading Loading @@ -56,6 +57,12 @@ public class TestInCallServiceBroadcastReceiver extends BroadcastReceiver { } else if (ACTION_SEND_UPGRADE_RESPONSE.equals(action)) { final int videoState = Integer.parseInt(intent.getData().getSchemeSpecificPart()); TestCallList.getInstance().sendUpgradeToVideoResponse(videoState); } else if (TelecomManager.ACTION_PHONE_ACCOUNT_REGISTERED.equals(action)) { Log.i(TAG, "onReceive: registered " + intent.getExtras().get( TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE)); } else if (TelecomManager.ACTION_PHONE_ACCOUNT_UNREGISTERED.equals(action)) { Log.i(TAG, "onReceive: unregistered " + intent.getExtras().get( TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE)); } } }