Merge "Fixing ADD_CALL (3/3)" into lmp-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index ee47f18..c0cdc3e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -585,5 +585,11 @@
</intent-filter>
</provider>
+ <receiver android:name="com.android.services.telephony.AddAccountsReceiver">
+ <intent-filter>
+ <action android:name="android.intent.action.BOOT_COMPLETED" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </receiver>
</application>
</manifest>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 2825a7e..70dcfc2 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -125,7 +125,7 @@
<!-- Label for the "Network settings" screen in the Settings UI -->
<string name="settings_label">Network settings</string>
<!-- Label for connection service setting -->
- <string name="connection_service">Connection service to use</string>
+ <string name="phone_accounts">Phone account settings</string>
<!-- Built-in label for the default connection service setting. -->
<string name="connection_service_default_label">Built-in connection service</string>
<!-- Call settings screen, setting option name -->
diff --git a/res/xml/call_feature_setting.xml b/res/xml/call_feature_setting.xml
index 6c1b570..30811e4 100644
--- a/res/xml/call_feature_setting.xml
+++ b/res/xml/call_feature_setting.xml
@@ -41,11 +41,13 @@
android:title="@string/other_settings"
android:persistent="false" />
- <ListPreference
- android:key="button_connection_service"
- android:title="@string/connection_service"
- android:defaultValue="@string/connection_service_default"
- android:persistent="true" />
+ <Preference
+ android:key="phone_accounts"
+ android:title="@string/phone_accounts" >
+ <intent
+ android:targetClass="com.android.telecomm.PhoneAccountPreferencesActivity"
+ android:targetPackage="com.android.telecomm" />
+ </Preference>
<PreferenceScreen
android:key="button_voicemail_category_key"
diff --git a/sip/src/com/android/services/telephony/sip/SipConnectionService.java b/sip/src/com/android/services/telephony/sip/SipConnectionService.java
index a46180d..a87b398 100644
--- a/sip/src/com/android/services/telephony/sip/SipConnectionService.java
+++ b/sip/src/com/android/services/telephony/sip/SipConnectionService.java
@@ -48,9 +48,7 @@
static PhoneAccount getPhoneAccount(Context context) {
return new PhoneAccount(
new ComponentName(context, SipConnectionService.class),
- null /* id */,
- null /* handle */,
- PhoneAccount.CAPABILITY_CALL_PROVIDER);
+ null /* id */);
}
@Override
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 90f2f35..8e25be9 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -1742,4 +1742,10 @@
}
return adnRecord.getAlphaTag();
}
+
+ @Override
+ public boolean setOperatorBrandOverride(String iccId, String brand) {
+ enforceModifyPermissionOrCarrierPrivilege();
+ return mPhone.setOperatorBrandOverride(iccId, brand);
+ }
}
diff --git a/src/com/android/services/telephony/AddAccountsReceiver.java b/src/com/android/services/telephony/AddAccountsReceiver.java
new file mode 100644
index 0000000..2e635c7
--- /dev/null
+++ b/src/com/android/services/telephony/AddAccountsReceiver.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.services.telephony;
+
+import com.android.phone.R;
+
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.telecomm.PhoneAccount;
+import android.telecomm.PhoneAccountMetadata;
+import android.telecomm.TelecommManager;
+
+public class AddAccountsReceiver extends BroadcastReceiver {
+
+ private static String SCHEME_TEL = "tel";
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.d(this, "onReceive");
+ try {
+ TelecommManager telecommManager = TelecommManager.from(context);
+ telecommManager.clearAccounts(context.getPackageName());
+ PhoneAccountMetadata[] accounts = makeAccounts(context);
+ for (int i = 0; i < accounts.length; i++) {
+ telecommManager.registerPhoneAccount(accounts[i]);
+ }
+ } catch (Exception e) {
+ Log.e(this, e, "onReceive");
+ throw e;
+ }
+ }
+
+ public static PhoneAccountMetadata[] makeAccounts(Context context) {
+ ComponentName componentName = new ComponentName(
+ context.getPackageName(),
+ TelephonyConnectionService.class.getName());
+ return new PhoneAccountMetadata[]{
+ new PhoneAccountMetadata(
+ new PhoneAccount(componentName, "sim_0"),
+ Uri.fromParts(SCHEME_TEL, "650-555-1212", null),
+ PhoneAccountMetadata.CAPABILITY_CALL_PROVIDER,
+ R.drawable.fab_ic_call,
+ "Zero SIM Account",
+ "Short description for SIM card zero",
+ false),
+ new PhoneAccountMetadata(
+ new PhoneAccount(componentName, "sim_1"),
+ Uri.fromParts(SCHEME_TEL, "650-555-1234", null),
+ PhoneAccountMetadata.CAPABILITY_CALL_PROVIDER,
+ R.drawable.fab_ic_call,
+ "One SIM Account",
+ "Short description for SIM card one",
+ false)
+ };
+ }
+}
diff --git a/src/com/android/services/telephony/PstnIncomingCallNotifier.java b/src/com/android/services/telephony/PstnIncomingCallNotifier.java
index e19991a..1ba4a4e 100644
--- a/src/com/android/services/telephony/PstnIncomingCallNotifier.java
+++ b/src/com/android/services/telephony/PstnIncomingCallNotifier.java
@@ -20,7 +20,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.net.Uri;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Message;
@@ -157,7 +156,7 @@
Intent intent = new Intent(TelecommConstants.ACTION_INCOMING_CALL);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(TelecommConstants.EXTRA_PHONE_ACCOUNT,
- TelephonyConnectionService.getPhoneAccount(context));
+ AddAccountsReceiver.makeAccounts(context)[0].getAccount());
Log.d(this, "Sending incoming call intent: %s", intent);
context.startActivityAsUser(intent, UserHandle.CURRENT);
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index f829fd3..bf2e3a0 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -20,6 +20,8 @@
import android.content.Context;
import android.net.Uri;
import android.os.Debug;
+import android.telecomm.PhoneAccountMetadata;
+import android.telecomm.TelecommManager;
import android.telephony.DisconnectCause;
import android.telephony.ServiceState;
import android.text.TextUtils;
@@ -45,14 +47,6 @@
private EmergencyCallHelper mEmergencyCallHelper;
- static PhoneAccount getPhoneAccount(Context context) {
- return new PhoneAccount(
- new ComponentName(context, TelephonyConnectionService.class),
- null /* id */,
- null,
- PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION);
- }
-
@Override
protected void onCreateOutgoingConnection(
final ConnectionRequest request,
@@ -176,7 +170,7 @@
Uri handle = getHandleFromAddress(originalConnection.getAddress());
ConnectionRequest telephonyRequest = new ConnectionRequest(
- getPhoneAccount(this),
+ request.getAccount(),
request.getCallId(),
handle,
originalConnection.getNumberPresentation(),
@@ -236,7 +230,7 @@
}
ConnectionRequest telephonyRequest = new ConnectionRequest(
- getPhoneAccount(this),
+ request.getAccount(),
request.getCallId(),
request.getHandle(),
request.getHandlePresentation(),