Merge "Exercise voicemail permissions in Test Dialer" into mnc-dev

This commit is contained in:
Yorke Lee 2015-04-27 22:22:40 +00:00 committed by Android (Google) Code Review
commit f3ef994289
4 changed files with 36 additions and 0 deletions

View File

@ -21,10 +21,12 @@
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CONTROL_INCALL_EXPERIENCE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.REGISTER_CALL_PROVIDER" />
<uses-permission android:name="android.permission.REGISTER_CONNECTION_MANAGER" />
<uses-permission android:name="android.permission.REGISTER_SIM_SUBSCRIPTION" />
<uses-permission android:name="android.permission.WRITE_CALL_LOG" />
<application android:label="@string/app_name">
<uses-library android:name="android.test.runner" />

View File

@ -34,4 +34,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/defaultDialerButton" />
<Button
android:id="@+id/test_voicemail_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/testVoicemailButton" />
</LinearLayout>

View File

@ -29,4 +29,8 @@
<!-- String for button in TestDialerActivity that places a test call -->
<string name="placeCallButton">Place call</string>
<!-- String for button in TestDialerActivity that performs voicemail requests to verify
voicemail permissions -->
<string name="testVoicemailButton">Exercise voicemail permissions</string>
</resources>

View File

@ -1,13 +1,16 @@
package com.android.server.telecom.testapps;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.CallLog.Calls;
import android.telecom.PhoneAccount;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.Toast;
import com.android.server.telecom.testapps.R;
@ -31,6 +34,13 @@ public class TestDialerActivity extends Activity {
}
});
findViewById(R.id.test_voicemail_button).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
testVoicemail();
}
});
mNumberView = (EditText) findViewById(R.id.number);
updateEditTextWithNumber();
}
@ -57,4 +67,19 @@ public class TestDialerActivity extends Activity {
Uri.fromParts(PhoneAccount.SCHEME_TEL, mNumberView.getText().toString(), null));
startActivityForResult(intent, 0);
}
private void testVoicemail() {
try {
// Test read
getContentResolver().query(Calls.CONTENT_URI_WITH_VOICEMAIL, null, null, null, null);
// Test write
final ContentValues values = new ContentValues();
values.put(Calls.CACHED_NAME, "hello world");
getContentResolver().update(Calls.CONTENT_URI_WITH_VOICEMAIL, values, "1=0", null);
} catch (SecurityException e) {
Toast.makeText(this, "Permission check failed", Toast.LENGTH_SHORT).show();
return;
}
Toast.makeText(this, "Permission check succeeded", Toast.LENGTH_SHORT).show();
}
}