aboutsummaryrefslogtreecommitdiff
path: root/StrictModeTest/src
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@android.com>2010-08-31 12:55:09 -0700
committerBrad Fitzpatrick <bradfitz@android.com>2010-08-31 12:55:09 -0700
commit4ec87d33cb702da6dbb8315825356210cb7217f1 (patch)
tree44086a2dc5cb0a3191c7f1bff8721e752033120f /StrictModeTest/src
parent9714b692342731d3015e7fd57584854449b76ad9 (diff)
downloadexperimental-4ec87d33cb702da6dbb8315825356210cb7217f1.tar.gz
Add a one-way Binder call test button.
Change-Id: Iad3b5638ba930ca0788b9901be9f29a1d9d9b563
Diffstat (limited to 'StrictModeTest/src')
-rw-r--r--StrictModeTest/src/com/android/strictmodetest/IService.aidl3
-rw-r--r--StrictModeTest/src/com/android/strictmodetest/ServiceBase.java7
-rw-r--r--StrictModeTest/src/com/android/strictmodetest/StrictModeActivity.java22
3 files changed, 27 insertions, 5 deletions
diff --git a/StrictModeTest/src/com/android/strictmodetest/IService.aidl b/StrictModeTest/src/com/android/strictmodetest/IService.aidl
index 19bb0cd..c3fd946 100644
--- a/StrictModeTest/src/com/android/strictmodetest/IService.aidl
+++ b/StrictModeTest/src/com/android/strictmodetest/IService.aidl
@@ -19,5 +19,8 @@ package com.android.strictmodetest;
interface IService {
int getThreadPolicy();
boolean doDiskWrite(int dummyValue);
+
+ // Test that one-way calls don't fire.
+ oneway void doDiskOneWay();
}
diff --git a/StrictModeTest/src/com/android/strictmodetest/ServiceBase.java b/StrictModeTest/src/com/android/strictmodetest/ServiceBase.java
index 56b44a3..d4362b9 100644
--- a/StrictModeTest/src/com/android/strictmodetest/ServiceBase.java
+++ b/StrictModeTest/src/com/android/strictmodetest/ServiceBase.java
@@ -55,6 +55,13 @@ public class ServiceBase extends Service {
return BlockGuard.getThreadPolicy().getPolicyMask();
}
+ public void doDiskOneWay() {
+ int policy = BlockGuard.getThreadPolicy().getPolicyMask();
+ Log.d(TAG, "Doing a one-way disk write; policy is: " + policy);
+ // Fake disk usage...
+ BlockGuard.getThreadPolicy().onWriteToDisk();
+ }
+
public boolean doDiskWrite(int afterCalls) {
if (afterCalls > 0) {
return doDiskWrite(afterCalls - 1);
diff --git a/StrictModeTest/src/com/android/strictmodetest/StrictModeActivity.java b/StrictModeTest/src/com/android/strictmodetest/StrictModeActivity.java
index 6c5140e..bc5d4eb 100644
--- a/StrictModeTest/src/com/android/strictmodetest/StrictModeActivity.java
+++ b/StrictModeTest/src/com/android/strictmodetest/StrictModeActivity.java
@@ -212,6 +212,18 @@ public class StrictModeActivity extends Activity {
}
});
+ final Button binderOneWayButton = (Button) findViewById(R.id.binder_oneway_button);
+ binderOneWayButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ try {
+ Log.d(TAG, "doing oneway disk write over Binder.");
+ mRemoteServiceConn.stub.doDiskOneWay();
+ } catch (RemoteException e) {
+ Log.d(TAG, "remote binderButton error: " + e);
+ }
+ }
+ });
+
final Button binderCheckButton = (Button) findViewById(R.id.binder_check_button);
binderCheckButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
@@ -233,18 +245,18 @@ public class StrictModeActivity extends Activity {
Log.d(TAG, "About to do a service dump...");
File file = new File("/sdcard/strictmode-service-dump.txt");
FileOutputStream output = null;
- final int oldPolicy = StrictMode.getThreadBlockingPolicy();
+ final int oldPolicy = StrictMode.getThreadPolicy();
try {
- StrictMode.setThreadBlockingPolicy(0);
+ StrictMode.setThreadPolicy(0);
output = new FileOutputStream(file);
- StrictMode.setThreadBlockingPolicy(oldPolicy);
+ StrictMode.setThreadPolicy(oldPolicy);
boolean dumped = Debug.dumpService("cpuinfo",
output.getFD(), new String[0]);
Log.d(TAG, "Dumped = " + dumped);
} catch (IOException e) {
Log.e(TAG, "Can't dump service", e);
} finally {
- StrictMode.setThreadBlockingPolicy(oldPolicy);
+ StrictMode.setThreadPolicy(oldPolicy);
}
Log.d(TAG, "Did service dump.");
}
@@ -284,7 +296,7 @@ public class StrictModeActivity extends Activity {
if (checkPenaltyDeath.isChecked()) newPolicy |= StrictMode.PENALTY_DEATH;
if (checkPenaltyDropBox.isChecked()) newPolicy |= StrictMode.PENALTY_DROPBOX;
Log.v(TAG, "Changing policy to: " + newPolicy);
- StrictMode.setThreadBlockingPolicy(newPolicy);
+ StrictMode.setThreadPolicy(newPolicy);
}
};
checkNoWrite.setOnClickListener(changePolicy);