diff options
author | Yorke Lee <yorkelee@google.com> | 2015-07-28 16:36:01 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-07-28 16:36:01 +0000 |
commit | 320946ebafe24dcecd7d92bf9f7717fdf3ccbff9 (patch) | |
tree | d794eb4318256834da029d104f7c7804aa69c8ca | |
parent | b13f072ae52608122d876920c6f6e8862e9366b8 (diff) | |
parent | 326bc22ade3e340d9f0a421f597e507629bf2c1e (diff) |
Merge "Add ability to add test voicemails from test app"
-rw-r--r-- | tests/AndroidManifest.xml | 2 | ||||
-rw-r--r-- | tests/res/layout/fill_call_log_test.xml | 6 | ||||
-rw-r--r-- | tests/res/values/donottranslate_strings.xml | 1 | ||||
-rw-r--r-- | tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java | 50 |
4 files changed, 56 insertions, 3 deletions
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml index 94aa3aada..73febff64 100644 --- a/tests/AndroidManifest.xml +++ b/tests/AndroidManifest.xml @@ -35,6 +35,8 @@ <uses-permission android:name="android.permission.READ_PROFILE" /> <uses-permission android:name="android.permission.READ_SOCIAL_STREAM" /> + <uses-permission android:name="com.android.voicemail.permission.ADD_VOICEMAIL" /> + <application> <uses-library android:name="android.test.runner" /> <meta-data android:name="com.android.dialer.iconset" android:resource="@xml/iconset" /> diff --git a/tests/res/layout/fill_call_log_test.xml b/tests/res/layout/fill_call_log_test.xml index 2359f2cde..e34125c10 100644 --- a/tests/res/layout/fill_call_log_test.xml +++ b/tests/res/layout/fill_call_log_test.xml @@ -86,6 +86,12 @@ android:layout_height="wrap_content" android:text="@string/call_type_outgoing" android:textSize="9sp" /> + <RadioButton + android:id="@+id/call_type_voicemail" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/call_type_voicemail" + android:textSize="9sp" /> </RadioGroup> <CheckBox android:id="@+id/call_type_video" diff --git a/tests/res/values/donottranslate_strings.xml b/tests/res/values/donottranslate_strings.xml index d4b48a6cd..2f8017cd2 100644 --- a/tests/res/values/donottranslate_strings.xml +++ b/tests/res/values/donottranslate_strings.xml @@ -42,6 +42,7 @@ <string name="call_type_missed">Missed</string> <string name="call_type_outgoing">Outgoing</string> <string name="call_type_video">Video</string> + <string name="call_type_voicemail">Voicemail</string> <string name="call_date">Call date</string> <string name="call_time">Call time</string> <string name="edit">Edit</string> diff --git a/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java b/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java index 2e90c4d33..71571549f 100644 --- a/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java +++ b/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java @@ -23,14 +23,19 @@ import android.app.DialogFragment; import android.app.LoaderManager; import android.app.TimePickerDialog; import android.content.ContentProviderClient; +import android.content.ContentResolver; import android.content.ContentValues; import android.content.CursorLoader; import android.content.Loader; import android.database.Cursor; +import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.RemoteException; import android.provider.CallLog.Calls; +import android.provider.VoicemailContract; +import android.provider.VoicemailContract.Status; +import android.provider.VoicemailContract.Voicemails; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.text.format.DateFormat; @@ -72,6 +77,7 @@ public class FillCallLogTestActivity extends Activity { private RadioButton mCallTypeIncoming; private RadioButton mCallTypeMissed; private RadioButton mCallTypeOutgoing; + private RadioButton mCallTypeVoicemail; private CheckBox mCallTypeVideo; private RadioButton mPresentationAllowed; private RadioButton mPresentationRestricted; @@ -125,6 +131,7 @@ public class FillCallLogTestActivity extends Activity { mCallTypeIncoming = (RadioButton) findViewById(R.id.call_type_incoming); mCallTypeMissed = (RadioButton) findViewById(R.id.call_type_missed); mCallTypeOutgoing = (RadioButton) findViewById(R.id.call_type_outgoing); + mCallTypeVoicemail = (RadioButton) findViewById(R.id.call_type_voicemail); mCallTypeVideo = (CheckBox) findViewById(R.id.call_type_video); mPresentationAllowed = (RadioButton) findViewById(R.id.presentation_allowed); mPresentationPayphone = (RadioButton) findViewById(R.id.presentation_payphone); @@ -375,6 +382,8 @@ public class FillCallLogTestActivity extends Activity { return Calls.INCOMING_TYPE; } else if (mCallTypeOutgoing.isChecked()) { return Calls.OUTGOING_TYPE; + } else if (mCallTypeVoicemail.isChecked()) { + return Calls.VOICEMAIL_TYPE; } else { return Calls.MISSED_TYPE; } @@ -497,9 +506,13 @@ public class FillCallLogTestActivity extends Activity { dataUsage = (long) RNG.nextInt(52428800); } - Calls.addCall(null, this, mPhoneNumber.getText().toString(), getManualPresentation(), - getManualCallType(), features, getManualAccount(), - dateTime.getTimeInMillis(), RNG.nextInt(60 * 60), dataUsage); + if (getManualCallType() == Calls.VOICEMAIL_TYPE) { + addManualVoicemail(dateTime.getTimeInMillis()); + } else { + Calls.addCall(null, this, mPhoneNumber.getText().toString(), getManualPresentation(), + getManualCallType(), features, getManualAccount(), + dateTime.getTimeInMillis(), RNG.nextInt(60 * 60), dataUsage); + } // Subtract offset from the call date/time and store as new date/time int offset = Integer.parseInt(mOffset.getText().toString()); @@ -513,4 +526,35 @@ public class FillCallLogTestActivity extends Activity { setDisplayDate(); setDisplayTime(); } + + private void addManualVoicemail(Long time) { + final ContentValues contentValues = new ContentValues(); + contentValues.put(Voicemails.DATE, time); + contentValues.put(Voicemails.NUMBER, mPhoneNumber.getText().toString()); + contentValues.put(Voicemails.DURATION, 5000); + contentValues.put(Voicemails.SOURCE_PACKAGE, getPackageName()); + contentValues.put(Voicemails.SOURCE_DATA, 500); + contentValues.put(Voicemails.IS_READ, 0); + + getContentResolver().insert(VoicemailContract.Voicemails.buildSourceUri(getPackageName()), + contentValues); + + updateVoicemailStatus(); + } + + private void updateVoicemailStatus() { + ContentResolver contentResolver = getContentResolver(); + Uri statusUri = VoicemailContract.Status.buildSourceUri(getPackageName()); + final PhoneAccountHandle accountHandle = getManualAccount(); + + ContentValues values = new ContentValues(); + values.put(Status.PHONE_ACCOUNT_COMPONENT_NAME, getPackageName()); + values.put(Status.PHONE_ACCOUNT_ID, "ACCOUNT_ID"); + values.put(Status.CONFIGURATION_STATE, VoicemailContract.Status.CONFIGURATION_STATE_OK); + values.put(Status.DATA_CHANNEL_STATE, VoicemailContract.Status.DATA_CHANNEL_STATE_OK); + values.put(Status.NOTIFICATION_CHANNEL_STATE, + VoicemailContract.Status.NOTIFICATION_CHANNEL_STATE_OK); + + contentResolver.insert(statusUri, values); + } } |