summaryrefslogtreecommitdiff
path: root/tests/src
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2015-07-20 16:19:36 -0700
committerYorke Lee <yorkelee@google.com>2015-07-27 18:34:58 -0700
commit326bc22ade3e340d9f0a421f597e507629bf2c1e (patch)
treea4d16cefce64295c1192c8424361c28f70493a54 /tests/src
parent59c4dfdf471ee72d9e7994853daa6344a555a9e8 (diff)
Add ability to add test voicemails from test app
Change-Id: Ic86c8e03ab55e31df7c66602218e1822b8fc23d5
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java50
1 files changed, 47 insertions, 3 deletions
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);
+ }
}