Merge "Exercise voicemail permissions in Test Dialer" into mnc-dev
This commit is contained in:
commit
f3ef994289
|
@ -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" />
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue