[coastguard skipped] Merge sparse cherrypicks from sparse-13775243-L92100030014435199 into 24Q3-platform-release.
COASTGUARD_SKIP: I2c73f1b5b884a8b1157ccc333c4be446d12547e7
COASTGUARD_SKIP: I7510c167e3f063ac48840bc9ccab66ab26d046ce
Change-Id: I3fd4168ab0d7195fb0dcb0600cb5dca65f7e21ab
diff --git a/src/com/android/phone/EditPhoneNumberPreference.java b/src/com/android/phone/EditPhoneNumberPreference.java
index de9fc2f..505c284 100644
--- a/src/com/android/phone/EditPhoneNumberPreference.java
+++ b/src/com/android/phone/EditPhoneNumberPreference.java
@@ -97,8 +97,6 @@
private boolean mIsUnknownStatus;
- private boolean mContactPickerEnabled = true;
-
/**
* Interface for the dialog closed listener, related to
* DialogPreference.onDialogClosed(), except we also pass in a buttonClicked
@@ -154,13 +152,6 @@
this(context, null);
}
- /**
- * Sets whether the contact picker button should be enabled and visible.
- * @param enabled true to enable the contact picker, false to disable and hide it.
- */
- public void setContactPickerEnabled(boolean enabled) {
- mContactPickerEnabled = enabled;
- }
/*
* Methods called on UI bindings
@@ -234,19 +225,13 @@
//set contact picker
if (mContactPickButton != null) {
- if (mContactPickerEnabled) {
- mContactPickButton.setVisibility(View.VISIBLE);
- mContactPickButton.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- if (mParentActivity != null && mContactListIntent != null) {
- mParentActivity.startActivityForResult(mContactListIntent, mPrefId);
- }
+ mContactPickButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ if (mParentActivity != null) {
+ mParentActivity.startActivityForResult(mContactListIntent, mPrefId);
}
- });
- } else {
- mContactPickButton.setVisibility(View.GONE);
- mContactPickButton.setOnClickListener(null);
- }
+ }
+ });
}
}
diff --git a/src/com/android/phone/settings/VoicemailSettingsActivity.java b/src/com/android/phone/settings/VoicemailSettingsActivity.java
index 08a6674..817ca4c 100644
--- a/src/com/android/phone/settings/VoicemailSettingsActivity.java
+++ b/src/com/android/phone/settings/VoicemailSettingsActivity.java
@@ -20,6 +20,7 @@
import android.content.ContentProvider;
import android.content.DialogInterface;
import android.content.Intent;
+import android.database.Cursor;
import android.os.AsyncResult;
import android.os.Bundle;
import android.os.Handler;
@@ -31,6 +32,7 @@
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
+import android.provider.ContactsContract.CommonDataKinds;
import android.provider.Settings;
import android.telecom.PhoneAccountHandle;
import android.telephony.CarrierConfigManager;
@@ -274,9 +276,6 @@
mSubMenuVoicemailSettings.setParentActivity(this, VOICEMAIL_PREF_ID, this);
mSubMenuVoicemailSettings.setDialogOnClosedListener(this);
mSubMenuVoicemailSettings.setDialogTitle(R.string.voicemail_settings_number_label);
-
- mSubMenuVoicemailSettings.setContactPickerEnabled(false);
-
if (!getBooleanCarrierConfig(
CarrierConfigManager.KEY_EDITABLE_VOICEMAIL_NUMBER_SETTING_BOOL) ||
mDisallowedConfig) {
@@ -368,7 +367,6 @@
mSubMenuVoicemailSettings.setParentActivity(this, VOICEMAIL_PREF_ID, this);
mSubMenuVoicemailSettings.setDialogOnClosedListener(this);
mSubMenuVoicemailSettings.setDialogTitle(R.string.voicemail_settings_number_label);
- mSubMenuVoicemailSettings.setContactPickerEnabled(false);
updateVoiceNumberField();
if (preference.getIntent() != null) {
@@ -530,9 +528,41 @@
}
if (requestCode == VOICEMAIL_PREF_ID) {
- Log.w(LOG_TAG, "onActivityResult: skipping contact picker result since this"
- + " functionality is no longer supported.");
- return;
+ if (resultCode != RESULT_OK) {
+ if (DBG) log("onActivityResult: contact picker result not OK.");
+ return;
+ }
+
+ Cursor cursor = null;
+ try {
+ // check if the URI returned by the user belongs to the user
+ final int currentUser = UserHandle.getUserId(Process.myUid());
+ if (currentUser
+ != ContentProvider.getUserIdFromUri(data.getData(), currentUser)) {
+
+ if (DBG) {
+ log("onActivityResult: Contact data of different user, "
+ + "cannot access");
+ }
+ return;
+ }
+ cursor = getContentResolver().query(data.getData(),
+ new String[] { CommonDataKinds.Phone.NUMBER }, null, null, null);
+ if ((cursor == null) || (!cursor.moveToFirst())) {
+ if (DBG) log("onActivityResult: bad contact data, no results found.");
+ return;
+ }
+ if (mSubMenuVoicemailSettings != null) {
+ mSubMenuVoicemailSettings.onPickActivityResult(cursor.getString(0));
+ } else {
+ Log.w(LOG_TAG, "VoicemailSettingsActivity destroyed while setting contacts.");
+ }
+ return;
+ } finally {
+ if (cursor != null) {
+ cursor.close();
+ }
+ }
}
super.onActivityResult(requestCode, resultCode, data);