am f6f47a21: am bd2c23b4: am 6d984fe7: Merge "Mark emergency accounts with the correct capability for wear." into cw-e-dev
* commit 'f6f47a212fe4b4102016224712a33c7216cdf92d':
Mark emergency accounts with the correct capability for wear.
diff --git a/res/values/config.xml b/res/values/config.xml
index 139fb71..fa730d4 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -209,4 +209,7 @@
<!-- Component for custom voicemail notification handling. [DO NOT TRANSLATE] -->
<string name="config_customVoicemailComponent">@null</string>
+
+ <!-- Flag indicating whether to allow pstn phone accounts [DO NOT TRANSLATE] -->
+ <bool name="config_pstn_phone_accounts_enabled">true</bool>
</resources>
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index 4f8a20f..d452a7a 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -18,6 +18,7 @@
import android.content.ComponentName;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -173,6 +174,12 @@
}
mIsMergeCallSupported = isCarrierMergeCallSupported();
+ if (isEmergency && mContext.getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_WATCH)) {
+ // For Wear, we mark the emergency phone account as emergency calls only.
+ capabilities |= PhoneAccount.CAPABILITY_EMERGENCY_CALLS_ONLY;
+ }
+
if (icon == null) {
// TODO: Switch to using Icon.createWithResource() once that supports tinting.
Resources res = mContext.getResources();
@@ -204,6 +211,7 @@
// Register with Telecom and put into the account entry.
mTelecomManager.registerPhoneAccount(account);
+
return account;
}
@@ -442,11 +450,18 @@
// will cause the existing entry to be replaced.
Phone[] phones = PhoneFactory.getPhones();
Log.d(this, "Found %d phones. Attempting to register.", phones.length);
- for (Phone phone : phones) {
- long subscriptionId = phone.getSubId();
- Log.d(this, "Phone with subscription id %d", subscriptionId);
- if (subscriptionId >= 0) {
- mAccounts.add(new AccountEntry(phone, false /* emergency */, false /* isDummy */));
+
+ final boolean phoneAccountsEnabled = mContext.getResources().getBoolean(
+ R.bool.config_pstn_phone_accounts_enabled);
+
+ if (phoneAccountsEnabled) {
+ for (Phone phone : phones) {
+ int subscriptionId = phone.getSubId();
+ Log.d(this, "Phone with subscription id %d", subscriptionId);
+ if (subscriptionId >= 0) {
+ mAccounts.add(new AccountEntry(phone, false /* emergency */,
+ false /* isDummy */));
+ }
}
}