diff options
author | Brian Attwell <brianattwell@google.com> | 2015-02-04 01:37:49 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-02-04 01:37:51 +0000 |
commit | 8a397adffe40af39fe4ca20865cc3748a29376a1 (patch) | |
tree | 174543344e8d00c7e05ac2f914d030c4ce8d698b /src | |
parent | ccd69473fc82052b1630aacda8402af47b9f757f (diff) | |
parent | 8204324a69c4d6b1b95351ab2863b5ddac6fb0a5 (diff) |
Merge "Move CallUtil into Dialer. P1/3"
Diffstat (limited to 'src')
10 files changed, 161 insertions, 24 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index 6c576508c..fb663d729 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -50,9 +50,9 @@ import android.widget.TextView; import android.widget.Toast; import com.android.contacts.common.ContactPhotoManager; -import com.android.contacts.common.CallUtil; import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; import com.android.contacts.common.GeoUtil; +import com.android.contacts.common.CallUtil; import com.android.dialer.calllog.CallDetailHistoryAdapter; import com.android.dialer.calllog.CallTypeHelper; import com.android.dialer.calllog.ContactInfo; @@ -62,6 +62,7 @@ import com.android.dialer.calllog.PhoneNumberDisplayHelper; import com.android.dialer.calllog.PhoneNumberUtilsWrapper; import com.android.dialer.util.AsyncTaskExecutor; import com.android.dialer.util.AsyncTaskExecutors; +import com.android.dialer.util.PrivilegedCallUtil; import com.android.dialer.util.DialerUtils; import com.android.dialer.voicemail.VoicemailPlaybackFragment; import com.android.dialer.voicemail.VoicemailStatusHelper; @@ -364,8 +365,8 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware getSystemService(Context.TELEPHONY_SERVICE); if (tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) { DialerUtils.startActivityWithErrorToast(this, - CallUtil.getCallIntent(Uri.fromParts(PhoneAccount.SCHEME_TEL, mNumber, - null)), R.string.call_not_available); + PrivilegedCallUtil.getCallIntent(Uri.fromParts(PhoneAccount.SCHEME_TEL, + mNumber, null)), R.string.call_not_available); return true; } } diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 21e613fed..01d59c45f 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -59,7 +59,6 @@ import android.widget.ImageButton; import android.widget.PopupMenu; import android.widget.Toast; -import com.android.contacts.common.CallUtil; import com.android.contacts.common.activity.TransactionSafeActivity; import com.android.contacts.common.dialog.ClearFrequentsDialog; import com.android.contacts.common.interactions.ImportExportDialogFragment; @@ -83,6 +82,7 @@ import com.android.dialer.list.SearchFragment; import com.android.dialer.list.SmartDialSearchFragment; import com.android.dialer.list.SpeedDialFragment; import com.android.dialer.settings.DialerSettingsActivity; +import com.android.dialer.util.PrivilegedCallUtil; import com.android.dialer.util.DialerUtils; import com.android.dialer.widget.ActionBarController; import com.android.dialer.widget.SearchEditTextLayout; @@ -1165,8 +1165,8 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O @Override public void onCallNumberDirectly(String phoneNumber, boolean isVideoCall) { Intent intent = isVideoCall ? - CallUtil.getVideoCallIntent(phoneNumber, getCallOrigin()) : - CallUtil.getCallIntent(phoneNumber, getCallOrigin()); + PrivilegedCallUtil.getVideoCallIntent(phoneNumber, getCallOrigin()) : + PrivilegedCallUtil.getCallIntent(phoneNumber, getCallOrigin()); DialerUtils.startActivityWithErrorToast(this, intent); mClearSearchOnPause = true; } diff --git a/src/com/android/dialer/PhoneCallDetailsHelper.java b/src/com/android/dialer/PhoneCallDetailsHelper.java index b4e817174..7855a1d13 100644 --- a/src/com/android/dialer/PhoneCallDetailsHelper.java +++ b/src/com/android/dialer/PhoneCallDetailsHelper.java @@ -28,7 +28,6 @@ import android.text.format.DateUtils; import android.view.View; import android.widget.TextView; -import com.android.contacts.common.CallUtil; import com.android.contacts.common.testing.NeededForTesting; import com.android.contacts.common.util.PhoneNumberHelper; import com.android.dialer.calllog.ContactInfo; diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index bb20a1306..9c50a3b73 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -19,7 +19,6 @@ package com.android.dialer.calllog; import android.content.ContentValues; import android.content.Context; import android.content.Intent; -import android.content.Loader; import android.content.res.Resources; import android.database.Cursor; import android.database.sqlite.SQLiteFullException; @@ -48,7 +47,6 @@ import com.android.common.widget.GroupingListAdapter; import com.android.contacts.common.CallUtil; import com.android.contacts.common.ContactPhotoManager; import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; -import com.android.contacts.common.util.PhoneNumberHelper; import com.android.contacts.common.model.Contact; import com.android.contacts.common.model.ContactLoader; import com.android.contacts.common.util.UriUtils; diff --git a/src/com/android/dialer/calllog/IntentProvider.java b/src/com/android/dialer/calllog/IntentProvider.java index 3084e2424..8e96da717 100644 --- a/src/com/android/dialer/calllog/IntentProvider.java +++ b/src/com/android/dialer/calllog/IntentProvider.java @@ -23,8 +23,8 @@ import android.net.Uri; import android.provider.CallLog.Calls; import android.telecom.PhoneAccountHandle; -import com.android.contacts.common.CallUtil; import com.android.dialer.CallDetailActivity; +import com.android.dialer.util.PrivilegedCallUtil; /** * Used to create an intent to attach to an action in the call log. @@ -46,7 +46,7 @@ public abstract class IntentProvider { return new IntentProvider() { @Override public Intent getIntent(Context context) { - return CallUtil.getCallIntent(number, accountHandle); + return PrivilegedCallUtil.getCallIntent(number, accountHandle); } }; } @@ -60,7 +60,7 @@ public abstract class IntentProvider { return new IntentProvider() { @Override public Intent getIntent(Context context) { - return CallUtil.getVideoCallIntent(number, accountHandle); + return PrivilegedCallUtil.getVideoCallIntent(number, accountHandle); } }; } @@ -69,7 +69,7 @@ public abstract class IntentProvider { return new IntentProvider() { @Override public Intent getIntent(Context context) { - return CallUtil.getVoicemailIntent(); + return PrivilegedCallUtil.getVoicemailIntent(); } }; } diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index 87501fbcb..fbf862fc6 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -68,7 +68,6 @@ import android.widget.PopupMenu; import android.widget.RelativeLayout; import android.widget.TextView; -import com.android.contacts.common.CallUtil; import com.android.contacts.common.ContactsUtils; import com.android.contacts.common.GeoUtil; import com.android.contacts.common.util.PhoneNumberFormatter; @@ -79,6 +78,7 @@ import com.android.dialer.NeededForReflection; import com.android.dialer.R; import com.android.dialer.SpecialCharSequenceMgr; import com.android.dialer.calllog.PhoneAccountUtils; +import com.android.dialer.util.PrivilegedCallUtil; import com.android.dialer.util.DialerUtils; import com.android.phone.common.CallLogAsync; import com.android.phone.common.HapticFeedback; @@ -1006,7 +1006,8 @@ public class DialpadFragment extends Fragment } public void callVoicemail() { - DialerUtils.startActivityWithErrorToast(getActivity(), CallUtil.getVoicemailIntent()); + DialerUtils.startActivityWithErrorToast(getActivity(), PrivilegedCallUtil + .getVoicemailIntent()); hideAndClearDialpad(false); } @@ -1102,7 +1103,7 @@ public class DialpadFragment extends Fragment // Clear the digits just in case. clearDialpad(); } else { - final Intent intent = CallUtil.getCallIntent(number, + final Intent intent = PrivilegedCallUtil.getCallIntent(number, (getActivity() instanceof DialtactsActivity ? ((DialtactsActivity) getActivity()).getCallOrigin() : null)); DialerUtils.startActivityWithErrorToast(getActivity(), intent); @@ -1632,7 +1633,7 @@ public class DialpadFragment extends Fragment } private Intent newFlashIntent() { - final Intent intent = CallUtil.getCallIntent(EMPTY_NUMBER); + final Intent intent = PrivilegedCallUtil.getCallIntent(EMPTY_NUMBER); intent.putExtra(EXTRA_SEND_EMPTY_FLASH, true); return intent; } diff --git a/src/com/android/dialer/interactions/PhoneNumberInteraction.java b/src/com/android/dialer/interactions/PhoneNumberInteraction.java index de217ce7b..78c468bbc 100644 --- a/src/com/android/dialer/interactions/PhoneNumberInteraction.java +++ b/src/com/android/dialer/interactions/PhoneNumberInteraction.java @@ -45,7 +45,6 @@ import android.widget.CheckBox; import android.widget.ListAdapter; import android.widget.TextView; -import com.android.contacts.common.CallUtil; import com.android.contacts.common.Collapser; import com.android.contacts.common.Collapser.Collapsible; import com.android.contacts.common.MoreContactUtils; @@ -53,6 +52,7 @@ import com.android.contacts.common.activity.TransactionSafeActivity; import com.android.contacts.common.util.ContactDisplayUtils; import com.android.dialer.R; import com.android.dialer.contact.ContactUpdateService; +import com.android.dialer.util.PrivilegedCallUtil; import com.android.dialer.util.DialerUtils; import com.google.common.annotations.VisibleForTesting; @@ -322,7 +322,7 @@ public class PhoneNumberInteraction implements OnLoadCompleteListener<Cursor> { Intent.ACTION_SENDTO, Uri.fromParts("sms", phoneNumber, null)); break; default: - intent = CallUtil.getCallIntent(phoneNumber, callOrigin); + intent = PrivilegedCallUtil.getCallIntent(phoneNumber, callOrigin); break; } DialerUtils.startActivityWithErrorToast(context, intent); diff --git a/src/com/android/dialer/list/RegularSearchListAdapter.java b/src/com/android/dialer/list/RegularSearchListAdapter.java index f1f2ae039..9d6694a7f 100644 --- a/src/com/android/dialer/list/RegularSearchListAdapter.java +++ b/src/com/android/dialer/list/RegularSearchListAdapter.java @@ -18,12 +18,10 @@ package com.android.dialer.list; import android.content.Context; import android.database.Cursor; import android.net.Uri; -import android.provider.ContactsContract; import android.text.TextUtils; import com.android.contacts.common.CallUtil; import com.android.contacts.common.list.DirectoryPartition; -import com.android.contacts.common.list.PhoneNumberListAdapter; import com.android.dialer.calllog.ContactInfo; import com.android.dialer.service.CachedNumberLookupService; import com.android.dialer.service.CachedNumberLookupService.CachedContactInfo; diff --git a/src/com/android/dialer/list/SmartDialNumberListAdapter.java b/src/com/android/dialer/list/SmartDialNumberListAdapter.java index 04c0d620d..db9668267 100644 --- a/src/com/android/dialer/list/SmartDialNumberListAdapter.java +++ b/src/com/android/dialer/list/SmartDialNumberListAdapter.java @@ -20,15 +20,12 @@ import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.provider.ContactsContract; -import android.provider.ContactsContract.CommonDataKinds.Callable; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.util.Log; import com.android.contacts.common.CallUtil; import com.android.contacts.common.list.ContactListItemView; -import com.android.contacts.common.list.PhoneNumberListAdapter; -import com.android.contacts.common.list.PhoneNumberListAdapter.PhoneQuery; import com.android.dialer.dialpad.SmartDialCursorLoader; import com.android.dialer.dialpad.SmartDialNameMatcher; import com.android.dialer.dialpad.SmartDialPrefix; diff --git a/src/com/android/dialer/util/PrivilegedCallUtil.java b/src/com/android/dialer/util/PrivilegedCallUtil.java new file mode 100644 index 000000000..88adc725e --- /dev/null +++ b/src/com/android/dialer/util/PrivilegedCallUtil.java @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2012 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.dialer.util; + +import android.content.Intent; +import android.net.Uri; +import android.telecom.PhoneAccount; +import android.telecom.PhoneAccountHandle; +import android.telecom.TelecomManager; +import android.telecom.VideoProfile; + +import com.android.contacts.common.CallUtil; +import com.android.phone.common.PhoneConstants; + +/** + * Utilities related to calls that can only be used by system apps. These + * use {@link Intent#ACTION_CALL_PRIVILEGED}. + */ +public class PrivilegedCallUtil { + + /** + * Return an Intent for making a phone call. Scheme (e.g. tel, sip) will be determined + * automatically. + */ + public static Intent getCallIntent(String number) { + return getCallIntent(number, null, null); + } + + /** + * Return an Intent for making a phone call. A given Uri will be used as is (without any + * sanity check). + */ + public static Intent getCallIntent(Uri uri) { + return getCallIntent(uri, null, null); + } + + /** + * A variant of {@link #getCallIntent(String)} but also accept a call origin. + * For more information about call origin, see comments in Phone package (PhoneApp). + */ + public static Intent getCallIntent(String number, String callOrigin) { + return getCallIntent(CallUtil.getCallUri(number), callOrigin, null); + } + + /** + * A variant of {@link #getCallIntent(String)} but also include {@code Account}. + */ + public static Intent getCallIntent(String number, PhoneAccountHandle accountHandle) { + return getCallIntent(number, null, accountHandle); + } + + /** + * A variant of {@link #getCallIntent(android.net.Uri)} but also include {@code Account}. + */ + public static Intent getCallIntent(Uri uri, PhoneAccountHandle accountHandle) { + return getCallIntent(uri, null, accountHandle); + } + + /** + * A variant of {@link #getCallIntent(String, String)} but also include {@code Account}. + */ + public static Intent getCallIntent( + String number, String callOrigin, PhoneAccountHandle accountHandle) { + return getCallIntent(CallUtil.getCallUri(number), callOrigin, accountHandle); + } + + /** + * A variant of {@link #getCallIntent(android.net.Uri)} but also accept a call + * origin and {@code Account}. + * For more information about call origin, see comments in Phone package (PhoneApp). + */ + public static Intent getCallIntent( + Uri uri, String callOrigin, PhoneAccountHandle accountHandle) { + return getCallIntent(uri, callOrigin, accountHandle, + VideoProfile.VideoState.AUDIO_ONLY); + } + + /** + * A variant of {@link #getCallIntent(String, String)} for starting a video call. + */ + public static Intent getVideoCallIntent(String number, String callOrigin) { + return getCallIntent(CallUtil.getCallUri(number), callOrigin, null, + VideoProfile.VideoState.BIDIRECTIONAL); + } + + /** + * A variant of {@link #getCallIntent(String, String, android.telecom.PhoneAccountHandle)} for + * starting a video call. + */ + public static Intent getVideoCallIntent( + String number, String callOrigin, PhoneAccountHandle accountHandle) { + return getCallIntent(CallUtil.getCallUri(number), callOrigin, accountHandle, + VideoProfile.VideoState.BIDIRECTIONAL); + } + + /** + * A variant of {@link #getCallIntent(String, String, android.telecom.PhoneAccountHandle)} for + * starting a video call. + */ + public static Intent getVideoCallIntent(String number, PhoneAccountHandle accountHandle) { + return getVideoCallIntent(number, null, accountHandle); + } + + /** + * A variant of {@link #getCallIntent(android.net.Uri)} for calling Voicemail. + */ + public static Intent getVoicemailIntent() { + return getCallIntent(Uri.fromParts(PhoneAccount.SCHEME_VOICEMAIL, "", null)); + } + + /** + * A variant of {@link #getCallIntent(android.net.Uri)} but also accept a call + * origin and {@code Account} and {@code VideoCallProfile} state. + * For more information about call origin, see comments in Phone package (PhoneApp). + */ + public static Intent getCallIntent( + Uri uri, String callOrigin, PhoneAccountHandle accountHandle, int videoState) { + final Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED, uri); + intent.putExtra(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, videoState); + if (callOrigin != null) { + intent.putExtra(PhoneConstants.EXTRA_CALL_ORIGIN, callOrigin); + } + if (accountHandle != null) { + intent.putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle); + } + + return intent; + } +} |