Snap for 5984067 from 8a460b7b6ce4779d34f8a63c201f4ac56d3a0752 to rvc-release
Change-Id: I8edacadda0eae63b87feb7cbe3138b79717d9e87
diff --git a/src/com/android/providers/contacts/CallLogProvider.java b/src/com/android/providers/contacts/CallLogProvider.java
index 7dcf2c2..ec1d40e 100644
--- a/src/com/android/providers/contacts/CallLogProvider.java
+++ b/src/com/android/providers/contacts/CallLogProvider.java
@@ -747,9 +747,8 @@
mDbHelper.getWritableDatabase().execSQL(
UNHIDE_BY_PHONE_ACCOUNT_QUERY, handleArgs);
} else {
- TelecomManager tm = TelecomManager.from(getContext());
+ TelecomManager tm = getContext().getSystemService(TelecomManager.class);
if (tm != null) {
-
PhoneAccount account = tm.getPhoneAccount(handle);
if (account != null && account.getAddress() != null) {
// We did not find any items for the specific phone account, so run the
diff --git a/src/com/android/providers/contacts/ContactsDatabaseHelper.java b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
index 91a2a91..2e5cdac 100644
--- a/src/com/android/providers/contacts/ContactsDatabaseHelper.java
+++ b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
@@ -3221,8 +3221,7 @@
// ON_BOOT_COMPLETE instead of PRE_BOOT_COMPLETE.
SubscriptionManager sm = SubscriptionManager.from(mContext);
if (sm != null) {
- Log.i(TAG, "count: " + sm.getAllSubscriptionInfoCount());
- for (SubscriptionInfo info : sm.getAllSubscriptionInfoList()) {
+ for (SubscriptionInfo info : sm.getActiveSubscriptionInfoList()) {
String iccId = info.getIccId();
int subId = info.getSubscriptionId();
if (!TextUtils.isEmpty(iccId) &&
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index 5811aad..3b06dd5 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -9720,7 +9720,8 @@
@VisibleForTesting
protected boolean isPhone() {
if (!mIsPhoneInitialized) {
- mIsPhone = new TelephonyManager(getContext()).isVoiceCapable();
+ TelephonyManager tm = getContext().getSystemService(TelephonyManager.class);
+ mIsPhone = tm.isVoiceCapable();
mIsPhoneInitialized = true;
}
return mIsPhone;
diff --git a/src/com/android/providers/contacts/VoicemailPermissions.java b/src/com/android/providers/contacts/VoicemailPermissions.java
index 7e409ea..fc83ebc 100644
--- a/src/com/android/providers/contacts/VoicemailPermissions.java
+++ b/src/com/android/providers/contacts/VoicemailPermissions.java
@@ -18,7 +18,7 @@
import android.content.Context;
import android.os.Binder;
-import android.telecom.DefaultDialerManager;
+import android.telecom.TelecomManager;
import android.telephony.TelephonyManager;
import com.android.providers.contacts.util.ContactsPermissions;
@@ -41,9 +41,15 @@
|| callerHasCarrierPrivileges();
}
+ private boolean isDefaultOrSystemDialer(String callingPackage) {
+ TelecomManager tm = mContext.getSystemService(TelecomManager.class);
+ return (callingPackage.equals(tm.getDefaultDialerPackage())
+ || callingPackage.equals(tm.getSystemDialerPackage()));
+ }
+
/** Determine if the calling process has full read access to all voicemails. */
public boolean callerHasReadAccess(String callingPackage) {
- if (DefaultDialerManager.isDefaultOrSystemDialer(mContext, callingPackage)) {
+ if (isDefaultOrSystemDialer(callingPackage)) {
return true;
}
return callerHasPermission(android.Manifest.permission.READ_VOICEMAIL);
@@ -52,7 +58,7 @@
/** Determine if the calling process has the permission required to update and remove all
* voicemails */
public boolean callerHasWriteAccess(String callingPackage) {
- if (DefaultDialerManager.isDefaultOrSystemDialer(mContext, callingPackage)) {
+ if (isDefaultOrSystemDialer(callingPackage)) {
return true;
}
return callerHasPermission(android.Manifest.permission.WRITE_VOICEMAIL);
diff --git a/tests/src/com/android/providers/contacts/ContactsActor.java b/tests/src/com/android/providers/contacts/ContactsActor.java
index 470f64b..89f296b 100644
--- a/tests/src/com/android/providers/contacts/ContactsActor.java
+++ b/tests/src/com/android/providers/contacts/ContactsActor.java
@@ -16,6 +16,8 @@
package com.android.providers.contacts;
+import static org.mockito.Mockito.when;
+
import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.AccountManagerCallback;
@@ -57,6 +59,7 @@
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.RawContacts;
import android.provider.ContactsContract.StatusUpdates;
+import android.telecom.TelecomManager;
import android.telephony.TelephonyManager;
import android.test.IsolatedContext;
import android.test.mock.MockContentResolver;
@@ -68,6 +71,8 @@
import com.google.android.collect.Sets;
+import org.mockito.Mockito;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -271,6 +276,8 @@
}
}
+ private TelecomManager mMockTelecomManager;
+
/**
* A context wrapper that reports a different user id.
*
@@ -322,6 +329,9 @@
if (Context.TELEPHONY_SERVICE.equals(name)) {
return mMockTelephonyManager;
}
+ if (Context.TELECOM_SERVICE.equals(name)) {
+ return mMockTelecomManager;
+ }
// Use overallContext here; super.getSystemService() somehow won't return
// DevicePolicyManager.
return overallContext.getSystemService(name);
@@ -369,6 +379,9 @@
if (Context.TELEPHONY_SERVICE.equals(name)) {
return mMockTelephonyManager;
}
+ if (Context.TELECOM_SERVICE.equals(name)) {
+ return mMockTelecomManager;
+ }
// Use overallContext here; super.getSystemService() somehow won't return
// DevicePolicyManager.
return overallContext.getSystemService(name);
@@ -403,6 +416,9 @@
mMockAccountManager = new MockAccountManager(mProviderContext);
mockUserManager = new MockUserManager(mProviderContext);
mMockTelephonyManager = new MockTelephonyManager(mProviderContext);
+ mMockTelecomManager = Mockito.mock(TelecomManager.class);
+ when(mMockTelecomManager.getDefaultDialerPackage()).thenReturn("");
+ when(mMockTelecomManager.getSystemDialerPackage()).thenReturn("");
provider = addProvider(providerClass, authority);
}