summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/AppLaunch/Android.mk17
-rw-r--r--tests/AppLaunch/AndroidManifest.xml13
-rw-r--r--tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java230
-rw-r--r--tests/MemoryUsage/Android.mk3
-rw-r--r--tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java53
-rw-r--r--tests/RenderScriptTests/ImageProcessing/AndroidManifest.xml2
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.rs (renamed from tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.fs)0
-rw-r--r--tests/StatusBar/res/layout/notification_builder_test.xml1047
-rw-r--r--tests/StatusBar/res/values/styles.xml17
-rw-r--r--tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java85
-rw-r--r--tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java2
11 files changed, 965 insertions, 504 deletions
diff --git a/tests/AppLaunch/Android.mk b/tests/AppLaunch/Android.mk
new file mode 100644
index 0000000..c0560fd
--- /dev/null
+++ b/tests/AppLaunch/Android.mk
@@ -0,0 +1,17 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+# Only compile source java files in this apk.
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := AppLaunch
+
+LOCAL_CERTIFICATE := platform
+LOCAL_JAVA_LIBRARIES := android.test.runner
+
+include $(BUILD_PACKAGE)
+
+# Use the following include to make our test apk.
+include $(call all-makefiles-under,$(LOCAL_PATH)) \ No newline at end of file
diff --git a/tests/AppLaunch/AndroidManifest.xml b/tests/AppLaunch/AndroidManifest.xml
new file mode 100644
index 0000000..ac6760b
--- /dev/null
+++ b/tests/AppLaunch/AndroidManifest.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.tests.applaunch"
+ android:sharedUserId="android.uid.system" >
+ <instrumentation android:label="Measure app start up time"
+ android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="com.android.tests.applaunch" />
+
+ <application android:label="App Launch Test">
+ <uses-library android:name="android.test.runner" />
+ </application>
+</manifest> \ No newline at end of file
diff --git a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
new file mode 100644
index 0000000..e2cb65d
--- /dev/null
+++ b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java
@@ -0,0 +1,230 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.tests.applaunch;
+
+import android.app.ActivityManager;
+import android.app.ActivityManager.ProcessErrorStateInfo;
+import android.app.ActivityManagerNative;
+import android.app.IActivityManager;
+import android.app.IActivityManager.WaitResult;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.pm.ResolveInfo;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.os.UserHandle;
+import android.test.InstrumentationTestCase;
+import android.test.InstrumentationTestRunner;
+import android.util.Log;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * This test is intended to measure the time it takes for the apps to start.
+ * Names of the applications are passed in command line, and the
+ * test starts each application, and reports the start up time in milliseconds.
+ * The instrumentation expects the following key to be passed on the command line:
+ * apps - A list of applications to start and their corresponding result keys
+ * in the following format:
+ * -e apps <app name>^<result key>|<app name>^<result key>
+ */
+public class AppLaunch extends InstrumentationTestCase {
+
+ private static final int JOIN_TIMEOUT = 10000;
+ private static final String TAG = "AppLaunch";
+ private static final String KEY_APPS = "apps";
+
+ private Map<String, Intent> mNameToIntent;
+ private Map<String, String> mNameToProcess;
+ private Map<String, String> mNameToResultKey;
+
+ private IActivityManager mAm;
+
+ public void testMeasureStartUpTime() throws RemoteException {
+ InstrumentationTestRunner instrumentation =
+ (InstrumentationTestRunner)getInstrumentation();
+ Bundle args = instrumentation.getBundle();
+ mAm = ActivityManagerNative.getDefault();
+
+ createMappings();
+ parseArgs(args);
+
+ Bundle results = new Bundle();
+ for (String app : mNameToResultKey.keySet()) {
+ try {
+ startApp(app, results);
+ sleep(750);
+ closeApp(app);
+ sleep(2000);
+ } catch (NameNotFoundException e) {
+ Log.i(TAG, "Application " + app + " not found");
+ }
+
+ }
+ instrumentation.sendStatus(0, results);
+ }
+
+ private void parseArgs(Bundle args) {
+ mNameToResultKey = new LinkedHashMap<String, String>();
+ String appList = args.getString(KEY_APPS);
+
+ if (appList == null)
+ return;
+
+ String appNames[] = appList.split("\\|");
+ for (String pair : appNames) {
+ String[] parts = pair.split("\\^");
+ if (parts.length != 2) {
+ Log.e(TAG, "The apps key is incorectly formatted");
+ fail();
+ }
+
+ mNameToResultKey.put(parts[0], parts[1]);
+ }
+ }
+
+ private void createMappings() {
+ mNameToIntent = new LinkedHashMap<String, Intent>();
+ mNameToProcess = new LinkedHashMap<String, String>();
+
+ PackageManager pm = getInstrumentation().getContext()
+ .getPackageManager();
+ Intent intentToResolve = new Intent(Intent.ACTION_MAIN);
+ intentToResolve.addCategory(Intent.CATEGORY_LAUNCHER);
+ List<ResolveInfo> ris = pm.queryIntentActivities(intentToResolve, 0);
+ if (ris == null || ris.isEmpty()) {
+ Log.i(TAG, "Could not find any apps");
+ } else {
+ for (ResolveInfo ri : ris) {
+ Intent startIntent = new Intent(intentToResolve);
+ startIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+ startIntent.setClassName(ri.activityInfo.packageName,
+ ri.activityInfo.name);
+ mNameToIntent.put(ri.loadLabel(pm).toString(), startIntent);
+ mNameToProcess.put(ri.loadLabel(pm).toString(),
+ ri.activityInfo.processName);
+ }
+ }
+ }
+
+ private void startApp(String appName, Bundle results)
+ throws NameNotFoundException, RemoteException {
+ Log.i(TAG, "Starting " + appName);
+
+ Intent startIntent = mNameToIntent.get(appName);
+ if (startIntent == null) {
+ Log.w(TAG, "App does not exist: " + appName);
+ return;
+ }
+ AppLaunchRunnable runnable = new AppLaunchRunnable(startIntent);
+ Thread t = new Thread(runnable);
+ t.start();
+ try {
+ t.join(JOIN_TIMEOUT);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ WaitResult result = runnable.getResult();
+ if(t.isAlive() || (result != null && result.result != ActivityManager.START_SUCCESS)) {
+ Log.w(TAG, "Assuming app " + appName + " crashed.");
+ reportError(appName, mNameToProcess.get(appName), results);
+ return;
+ }
+ results.putString(mNameToResultKey.get(appName), String.valueOf(result.thisTime));
+ }
+
+ private void closeApp(String appName) {
+ Intent homeIntent = new Intent(Intent.ACTION_MAIN);
+ homeIntent.addCategory(Intent.CATEGORY_HOME);
+ homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+ getInstrumentation().getContext().startActivity(homeIntent);
+ Intent startIntent = mNameToIntent.get(appName);
+ if (startIntent != null) {
+ String packageName = startIntent.getComponent().getPackageName();
+ try {
+ mAm.forceStopPackage(packageName, UserHandle.USER_CURRENT);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Error closing app", e);
+ }
+ }
+ }
+
+ private void sleep(int time) {
+ try {
+ Thread.sleep(time);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
+
+ private void reportError(String appName, String processName, Bundle results) {
+ ActivityManager am = (ActivityManager) getInstrumentation()
+ .getContext().getSystemService(Context.ACTIVITY_SERVICE);
+ List<ProcessErrorStateInfo> crashes = am.getProcessesInErrorState();
+ if (crashes != null) {
+ for (ProcessErrorStateInfo crash : crashes) {
+ if (!crash.processName.equals(processName))
+ continue;
+
+ Log.w(TAG, appName + " crashed: " + crash.shortMsg);
+ results.putString(mNameToResultKey.get(appName), crash.shortMsg);
+ return;
+ }
+ }
+
+ results.putString(mNameToResultKey.get(appName),
+ "Crashed for unknown reason");
+ Log.w(TAG, appName
+ + " not found in process list, most likely it is crashed");
+ }
+
+ private class AppLaunchRunnable implements Runnable {
+ private Intent mLaunchIntent;
+ private IActivityManager.WaitResult mResult;
+ public AppLaunchRunnable(Intent intent) {
+ mLaunchIntent = intent;
+ }
+
+ public IActivityManager.WaitResult getResult() {
+ return mResult;
+ }
+
+ public void run() {
+ try {
+ String packageName = mLaunchIntent.getComponent().getPackageName();
+ mAm.forceStopPackage(packageName, UserHandle.USER_CURRENT);
+ String mimeType = mLaunchIntent.getType();
+ if (mimeType == null && mLaunchIntent.getData() != null
+ && "content".equals(mLaunchIntent.getData().getScheme())) {
+ mimeType = mAm.getProviderMimeType(mLaunchIntent.getData(),
+ UserHandle.USER_CURRENT);
+ }
+
+ mResult = mAm.startActivityAndWait(null, mLaunchIntent, mimeType,
+ null, null, 0, mLaunchIntent.getFlags(), null, null, null,
+ UserHandle.USER_CURRENT);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Error launching app", e);
+ }
+ }
+ }
+}
diff --git a/tests/MemoryUsage/Android.mk b/tests/MemoryUsage/Android.mk
index e7bfb4f..0ab793b 100644
--- a/tests/MemoryUsage/Android.mk
+++ b/tests/MemoryUsage/Android.mk
@@ -8,7 +8,8 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := MemoryUsage
-LOCAL_SDK_VERSION := 7
+LOCAL_CERTIFICATE := platform
+LOCAL_JAVA_LIBRARIES := android.test.runner
include $(BUILD_PACKAGE)
diff --git a/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java b/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java
index 5e27ba7..b550957 100644
--- a/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java
+++ b/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java
@@ -18,14 +18,17 @@ package com.android.tests.memoryusage;
import android.app.ActivityManager;
import android.app.ActivityManager.ProcessErrorStateInfo;
import android.app.ActivityManager.RunningAppProcessInfo;
+import android.app.ActivityManagerNative;
+import android.app.IActivityManager;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.os.Debug.MemoryInfo;
+import android.os.RemoteException;
+import android.os.UserHandle;
import android.test.InstrumentationTestCase;
import android.util.Log;
@@ -48,8 +51,9 @@ public class MemoryUsageTest extends InstrumentationTestCase {
private static final int SLEEP_TIME = 1000;
private static final int THRESHOLD = 1024;
- private static final int MAX_ITERATIONS = 10;
- private static final int MIN_ITERATIONS = 4;
+ private static final int MAX_ITERATIONS = 20;
+ private static final int MIN_ITERATIONS = 6;
+ private static final int JOIN_TIMEOUT = 10000;
private static final String TAG = "MemoryUsageInstrumentation";
private static final String KEY_APPS = "apps";
@@ -58,10 +62,13 @@ public class MemoryUsageTest extends InstrumentationTestCase {
private Map<String, String> mNameToProcess;
private Map<String, String> mNameToResultKey;
+ private IActivityManager mAm;
+
public void testMemory() {
MemoryUsageInstrumentation instrumentation =
- (MemoryUsageInstrumentation) getInstrumentation();
+ (MemoryUsageInstrumentation) getInstrumentation();
Bundle args = instrumentation.getBundle();
+ mAm = ActivityManagerNative.getDefault();
createMappings();
parseArgs(args);
@@ -136,7 +143,16 @@ public class MemoryUsageTest extends InstrumentationTestCase {
String process = mNameToProcess.get(appName);
Intent startIntent = mNameToIntent.get(appName);
- getInstrumentation().getContext().startActivity(startIntent);
+
+ AppLaunchRunnable runnable = new AppLaunchRunnable(startIntent);
+ Thread t = new Thread(runnable);
+ t.start();
+ try {
+ t.join(JOIN_TIMEOUT);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+
return process;
}
@@ -234,7 +250,7 @@ public class MemoryUsageTest extends InstrumentationTestCase {
}
int[] pids = {
- proc.pid };
+ proc.pid };
MemoryInfo meminfo = am.getProcessMemoryInfo(pids)[0];
return meminfo.getTotalPss();
@@ -242,4 +258,29 @@ public class MemoryUsageTest extends InstrumentationTestCase {
}
return -1;
}
+
+ private class AppLaunchRunnable implements Runnable {
+ private Intent mLaunchIntent;
+
+ public AppLaunchRunnable(Intent intent) {
+ mLaunchIntent = intent;
+ }
+
+ public void run() {
+ try {
+ String mimeType = mLaunchIntent.getType();
+ if (mimeType == null && mLaunchIntent.getData() != null
+ && "content".equals(mLaunchIntent.getData().getScheme())) {
+ mimeType = mAm.getProviderMimeType(mLaunchIntent.getData(),
+ UserHandle.USER_CURRENT);
+ }
+
+ mAm.startActivityAndWait(null, mLaunchIntent, mimeType,
+ null, null, 0, mLaunchIntent.getFlags(), null, null, null,
+ UserHandle.USER_CURRENT_OR_SELF);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Error launching app", e);
+ }
+ }
+ }
}
diff --git a/tests/RenderScriptTests/ImageProcessing/AndroidManifest.xml b/tests/RenderScriptTests/ImageProcessing/AndroidManifest.xml
index 2232b98..d51fa39 100644
--- a/tests/RenderScriptTests/ImageProcessing/AndroidManifest.xml
+++ b/tests/RenderScriptTests/ImageProcessing/AndroidManifest.xml
@@ -3,7 +3,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.rs.image">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-sdk android:minSdkVersion="11" />
+ <uses-sdk android:minSdkVersion="17" />
<application android:label="Image Processing"
android:hardwareAccelerated="true">
<uses-library android:name="android.test.runner" />
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.fs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.rs
index ac2061b..ac2061b 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.fs
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/mandelbrot.rs
diff --git a/tests/StatusBar/res/layout/notification_builder_test.xml b/tests/StatusBar/res/layout/notification_builder_test.xml
index 94fc089..5987c84 100644
--- a/tests/StatusBar/res/layout/notification_builder_test.xml
+++ b/tests/StatusBar/res/layout/notification_builder_test.xml
@@ -222,307 +222,320 @@
>
<!-- setWhen -->
- <RadioGroup
- android:id="@+id/group_when"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
+ <LinearLayout
+ style="@style/FieldGroup"
+ >
<TextView
style="@style/FieldTitle"
android:text="setWhen"
/>
- <RadioButton
- android:id="@+id/when_midnight"
- style="@style/FieldContents"
- android:text="midnight"
- />
- <RadioButton
- android:id="@+id/when_now"
- style="@style/FieldContents"
- android:text="now"
- />
- <RadioButton
- android:id="@+id/when_now_plus_1h"
- style="@style/FieldContents.Disabled"
- android:text="now + 1h"
- />
- <RadioButton
- android:id="@+id/when_tomorrow"
- style="@style/FieldContents.Disabled"
- android:text="tomorrow"
- />
- </RadioGroup>
+ <RadioGroup
+ android:id="@+id/group_when"
+ style="@style/FieldChoices"
+ >
+ <RadioButton
+ android:id="@+id/when_midnight"
+ style="@style/FieldContents"
+ android:text="midnight"
+ />
+ <RadioButton
+ android:id="@+id/when_now"
+ style="@style/FieldContents"
+ android:text="now"
+ />
+ <RadioButton
+ android:id="@+id/when_now_plus_1h"
+ style="@style/FieldContents.Disabled"
+ android:text="now + 1h"
+ />
+ <RadioButton
+ android:id="@+id/when_tomorrow"
+ style="@style/FieldContents.Disabled"
+ android:text="tomorrow"
+ />
+ </RadioGroup>
+ </LinearLayout>
<!-- icon -->
- <RadioGroup
- android:id="@+id/group_icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
+ <LinearLayout
+ style="@style/FieldGroup"
+ >
<TextView
style="@style/FieldTitle"
android:text="setSmallIcon"
/>
- <RadioButton
- android:id="@+id/icon_im"
- style="@style/FieldContents"
- android:text="IM"
- />
- <RadioButton
- android:id="@+id/icon_alert"
- style="@style/FieldContents"
- android:text="alert"
- />
- <RadioButton
- android:id="@+id/icon_surprise"
- style="@style/FieldContents"
- android:text="surprise"
- />
- <RadioButton
- android:id="@+id/icon_level0"
- style="@style/FieldContents.Disabled"
- android:text="level 0"
- />
- <RadioButton
- android:id="@+id/icon_level50"
- style="@style/FieldContents.Disabled"
- android:text="level 50"
- />
- <RadioButton
- android:id="@+id/icon_level100"
- style="@style/FieldContents.Disabled"
- android:text="level 100"
- />
- <!-- todo setSmallIcon(int icon, int level) -->
- </RadioGroup>
-
+ <RadioGroup
+ android:id="@+id/group_icon"
+ style="@style/FieldChoices"
+ >
+ <RadioButton
+ android:id="@+id/icon_im"
+ style="@style/FieldContents"
+ android:text="IM"
+ />
+ <RadioButton
+ android:id="@+id/icon_alert"
+ style="@style/FieldContents"
+ android:text="alert"
+ />
+ <RadioButton
+ android:id="@+id/icon_surprise"
+ style="@style/FieldContents"
+ android:text="surprise"
+ />
+ <RadioButton
+ android:id="@+id/icon_level0"
+ style="@style/FieldContents.Disabled"
+ android:text="level 0"
+ />
+ <RadioButton
+ android:id="@+id/icon_level50"
+ style="@style/FieldContents.Disabled"
+ android:text="level 50"
+ />
+ <RadioButton
+ android:id="@+id/icon_level100"
+ style="@style/FieldContents.Disabled"
+ android:text="level 100"
+ />
+ <!-- todo setSmallIcon(int icon, int level) -->
+ </RadioGroup>
+ </LinearLayout>
+
<!-- setContentTitle -->
- <RadioGroup
- android:id="@+id/group_title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
+ <LinearLayout
+ style="@style/FieldGroup"
+ >
<TextView
style="@style/FieldTitle"
android:text="setContentTitle"
/>
- <RadioButton
- android:id="@+id/title_short"
- style="@style/FieldContents"
- android:text="none"
- android:tag=""
- />
- <RadioButton
- android:id="@+id/title_short"
- style="@style/FieldContents"
- android:text="short"
- android:tag="Title"
- />
- <RadioButton
- android:id="@+id/title_medium"
- style="@style/FieldContents"
- android:text="medium"
- android:tag="Notification Test"
- />
- <RadioButton
- android:id="@+id/title_long"
- style="@style/FieldContents"
- android:text="long"
- android:tag="This is one heckuva long title for a notification"
- />
- </RadioGroup>
-
+ <RadioGroup
+ android:id="@+id/group_title"
+ style="@style/FieldChoices"
+ >
+ <RadioButton
+ android:id="@+id/title_short"
+ style="@style/FieldContents"
+ android:text="none"
+ android:tag=""
+ />
+ <RadioButton
+ android:id="@+id/title_short"
+ style="@style/FieldContents"
+ android:text="short"
+ android:tag="Title"
+ />
+ <RadioButton
+ android:id="@+id/title_medium"
+ style="@style/FieldContents"
+ android:text="medium"
+ android:tag="Notification Test"
+ />
+ <RadioButton
+ android:id="@+id/title_long"
+ style="@style/FieldContents"
+ android:text="long"
+ android:tag="This is one heckuva long title for a notification"
+ />
+ </RadioGroup>
+ </LinearLayout>
+
<!-- setContentText -->
- <RadioGroup
- android:id="@+id/group_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
+ <LinearLayout
+ style="@style/FieldGroup"
+ >
<TextView
style="@style/FieldTitle"
android:text="setContentText"
/>
- <RadioButton
- android:id="@+id/text_none"
- style="@style/FieldContents"
- android:text="none"
- android:tag=""
- />
- <RadioButton
- android:id="@+id/text_short"
- style="@style/FieldContents"
- android:tag="short"
- android:text="text"
- />
- <RadioButton
- android:id="@+id/text_medium"
- style="@style/FieldContents"
- android:text="medium"
- android:tag="Something happened"
- />
- <RadioButton
- android:id="@+id/text_long"
- style="@style/FieldContents"
- android:text="long"
- android:tag="Oh my goodness. SOMETHING HAPPENED!!!!"
- />
- <RadioButton
- android:id="@+id/text_emoji"
- style="@style/FieldContents"
- android:text="emoji"
- android:tag="_ Cactus _ Cactus _"
- />
- <RadioButton
- android:id="@+id/text_haiku"
- style="@style/FieldContents"
- android:text="haiku"
- android:tag="sholes final approach\nlanding gear punted to flan\nrunway foam glistens"
- />
- </RadioGroup>
+ <RadioGroup
+ android:id="@+id/group_text"
+ style="@style/FieldChoices"
+ >
+ <RadioButton
+ android:id="@+id/text_none"
+ style="@style/FieldContents"
+ android:text="none"
+ android:tag=""
+ />
+ <RadioButton
+ android:id="@+id/text_short"
+ style="@style/FieldContents"
+ android:tag="short"
+ android:text="text"
+ />
+ <RadioButton
+ android:id="@+id/text_medium"
+ style="@style/FieldContents"
+ android:text="medium"
+ android:tag="Something happened"
+ />
+ <RadioButton
+ android:id="@+id/text_long"
+ style="@style/FieldContents"
+ android:text="long"
+ android:tag="Oh my goodness. SOMETHING HAPPENED!!!!"
+ />
+ <RadioButton
+ android:id="@+id/text_emoji"
+ style="@style/FieldContents"
+ android:text="emoji"
+ android:tag="_ Cactus _ Cactus _"
+ />
+ <RadioButton
+ android:id="@+id/text_haiku"
+ style="@style/FieldContents"
+ android:text="haiku"
+ android:tag="sholes final approach\nlanding gear punted to flan\nrunway foam glistens"
+ />
+ </RadioGroup>
+ </LinearLayout>
<!-- setContentInfo -->
- <RadioGroup
- android:id="@+id/group_info"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
+ <LinearLayout
+ style="@style/FieldGroup"
+ >
<TextView
style="@style/FieldTitle"
android:text="setContentInfo"
/>
- <RadioButton
- android:id="@+id/info_none"
- style="@style/FieldContents"
- android:text="none"
- android:tag=""
- />
- <RadioButton
- android:id="@+id/info_number"
- style="@style/FieldContents"
- android:text="snoozed"
- android:tag="snoozed"
- />
- <RadioButton
- android:id="@+id/info_long"
- style="@style/FieldContents"
- android:text="longer"
- android:tag="this content info is way too long"
- />
- </RadioGroup>
+ <RadioGroup
+ android:id="@+id/group_info"
+ style="@style/FieldChoices"
+ >
+ <RadioButton
+ android:id="@+id/info_none"
+ style="@style/FieldContents"
+ android:text="none"
+ android:tag=""
+ />
+ <RadioButton
+ android:id="@+id/info_number"
+ style="@style/FieldContents"
+ android:text="snoozed"
+ android:tag="snoozed"
+ />
+ <RadioButton
+ android:id="@+id/info_long"
+ style="@style/FieldContents"
+ android:text="longer"
+ android:tag="this content info is way too long"
+ />
+ </RadioGroup>
+ </LinearLayout>
<!-- setNumber -->
- <RadioGroup
- android:id="@+id/group_number"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
+ <LinearLayout
+ style="@style/FieldGroup"
+ >
<TextView
style="@style/FieldTitle"
android:text="setNumber"
/>
- <RadioButton
- android:id="@+id/number_0"
- style="@style/FieldContents"
- android:text="0"
- android:tag="0"
- />
- <RadioButton
- android:id="@+id/number_1"
- style="@style/FieldContents"
- android:text="1"
- android:tag="1"
- />
- <RadioButton
- android:id="@+id/number_42"
- style="@style/FieldContents"
- android:text="42"
- android:tag="42"
- />
- <RadioButton
- android:id="@+id/number_334"
- style="@style/FieldContents"
- android:text="334"
- android:tag="334"
- />
- <RadioButton
- android:id="@+id/number_999"
- style="@style/FieldContents"
- android:text="999"
- android:tag="999"
- />
- <RadioButton
- android:id="@+id/number_9876"
- style="@style/FieldContents"
- android:text="9,876"
- android:tag="9876"
- />
- <RadioButton
- android:id="@+id/number_12345"
- style="@style/FieldContents"
- android:text="12,345"
- android:tag="12345"
- />
- </RadioGroup>
-
+ <RadioGroup
+ android:id="@+id/group_number"
+ style="@style/FieldChoices"
+ >
+ <RadioButton
+ android:id="@+id/number_0"
+ style="@style/FieldContents"
+ android:text="0"
+ android:tag="0"
+ />
+ <RadioButton
+ android:id="@+id/number_1"
+ style="@style/FieldContents"
+ android:text="1"
+ android:tag="1"
+ />
+ <RadioButton
+ android:id="@+id/number_42"
+ style="@style/FieldContents"
+ android:text="42"
+ android:tag="42"
+ />
+ <RadioButton
+ android:id="@+id/number_334"
+ style="@style/FieldContents"
+ android:text="334"
+ android:tag="334"
+ />
+ <RadioButton
+ android:id="@+id/number_999"
+ style="@style/FieldContents"
+ android:text="999"
+ android:tag="999"
+ />
+ <RadioButton
+ android:id="@+id/number_9876"
+ style="@style/FieldContents"
+ android:text="9,876"
+ android:tag="9876"
+ />
+ <RadioButton
+ android:id="@+id/number_12345"
+ style="@style/FieldContents"
+ android:text="12,345"
+ android:tag="12345"
+ />
+ </RadioGroup>
+ </LinearLayout>
+
<!-- setContentIntent -->
- <RadioGroup
- android:id="@+id/group_intent"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
+ <LinearLayout
+ style="@style/FieldGroup"
+ >
<TextView
style="@style/FieldTitle"
android:text="setContentIntent"
/>
- <RadioButton
- android:id="@+id/intent_none"
- style="@style/FieldContents"
- android:text="none"
- />
- <RadioButton
- android:id="@+id/intent_alert"
- style="@style/FieldContents"
- android:text="alert"
- />
- </RadioGroup>
-
+ <RadioGroup
+ android:id="@+id/group_intent"
+ style="@style/FieldChoices"
+ >
+ <RadioButton
+ android:id="@+id/intent_none"
+ style="@style/FieldContents"
+ android:text="none"
+ />
+ <RadioButton
+ android:id="@+id/intent_alert"
+ style="@style/FieldContents"
+ android:text="alert"
+ />
+ </RadioGroup>
+ </LinearLayout>
+
<!-- setDeleteIntent -->
- <RadioGroup
- android:id="@+id/group_delete"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
+ <LinearLayout
+ style="@style/FieldGroup"
+ >
<TextView
style="@style/FieldTitle"
android:text="setDeleteIntent"
/>
- <RadioButton
- android:id="@+id/delete_none"
- style="@style/FieldContents"
- android:text="none"
- />
- <RadioButton
- android:id="@+id/delete_alert"
- style="@style/FieldContents"
- android:text="alert"
- />
- </RadioGroup>
-
+ <RadioGroup
+ android:id="@+id/group_delete"
+ style="@style/FieldChoices"
+ >
+ <RadioButton
+ android:id="@+id/delete_none"
+ style="@style/FieldContents"
+ android:text="none"
+ />
+ <RadioButton
+ android:id="@+id/delete_alert"
+ style="@style/FieldContents"
+ android:text="alert"
+ />
+ </RadioGroup>
+ </LinearLayout>
<!-- setFullScreenIntent -->
<RadioGroup
android:id="@+id/group_full_screen"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
+ style="@style/FieldChoices"
android:visibility="gone"
>
<TextView
@@ -543,94 +556,94 @@
<!-- setTicker -->
- <RadioGroup
- android:id="@+id/group_ticker"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
+ <LinearLayout
+ style="@style/FieldGroup"
+ >
<TextView
style="@style/FieldTitle"
android:text="setTicker"
/>
- <RadioButton
- android:id="@+id/ticker_none"
- style="@style/FieldContents"
- android:text="none"
- android:tag=""
- />
- <RadioButton
- android:id="@+id/ticker_short"
- style="@style/FieldContents"
- android:text="short"
- android:tag="tick"
- />
- <RadioButton
- android:id="@+id/ticker_wrap"
- style="@style/FieldContents"
- android:text="wrap"
- android:tag="tick tick tick tock tock tock something fun has happened but i don't know what it is just yet"
- />
- <RadioButton
- android:id="@+id/ticker_haiku"
- style="@style/FieldContents"
- android:text="haiku"
- android:tag="sholes final approach\nlanding gear punted to flan\nrunway foam glistens"
- />
- <RadioButton
- android:id="@+id/ticker_emoji"
- style="@style/FieldContents"
- android:text="emoji"
- android:tag="_ Cactus _ Cactus _"
- />
- <RadioButton
- android:id="@+id/ticker_custom"
- style="@style/FieldContents.Disabled"
- android:text="custom view"
- />
- </RadioGroup>
-
+ <RadioGroup
+ android:id="@+id/group_ticker"
+ style="@style/FieldChoices"
+ >
+ <RadioButton
+ android:id="@+id/ticker_none"
+ style="@style/FieldContents"
+ android:text="none"
+ android:tag=""
+ />
+ <RadioButton
+ android:id="@+id/ticker_short"
+ style="@style/FieldContents"
+ android:text="short"
+ android:tag="tick"
+ />
+ <RadioButton
+ android:id="@+id/ticker_wrap"
+ style="@style/FieldContents"
+ android:text="wrap"
+ android:tag="tick tick tick tock tock tock something fun has happened but i don't know what it is just yet"
+ />
+ <RadioButton
+ android:id="@+id/ticker_haiku"
+ style="@style/FieldContents"
+ android:text="haiku"
+ android:tag="sholes final approach\nlanding gear punted to flan\nrunway foam glistens"
+ />
+ <RadioButton
+ android:id="@+id/ticker_emoji"
+ style="@style/FieldContents"
+ android:text="emoji"
+ android:tag="_ Cactus _ Cactus _"
+ />
+ <RadioButton
+ android:id="@+id/ticker_custom"
+ style="@style/FieldContents.Disabled"
+ android:text="custom view"
+ />
+ </RadioGroup>
+ </LinearLayout>
<!-- setLargeIcon -->
- <RadioGroup
- android:id="@+id/group_large_icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
+ <LinearLayout
+ style="@style/FieldGroup"
+ >
<TextView
style="@style/FieldTitle"
android:text="setLargeIcon"
/>
- <RadioButton
- android:id="@+id/large_icon_none"
- style="@style/FieldContents"
- android:text="none"
- />
- <RadioButton
- android:id="@+id/large_icon_pineapple"
- style="@style/FieldContents"
- android:text="pineapple"
- />
- <RadioButton
- android:id="@+id/large_icon_pineapple2"
- style="@style/FieldContents"
- android:text="pineapple2"
- />
- <RadioButton
- android:id="@+id/large_icon_small"
- style="@style/FieldContents"
- android:text="small"
- />
- </RadioGroup>
-
+ <RadioGroup
+ android:id="@+id/group_large_icon"
+ style="@style/FieldChoices"
+ >
+ <RadioButton
+ android:id="@+id/large_icon_none"
+ style="@style/FieldContents"
+ android:text="none"
+ />
+ <RadioButton
+ android:id="@+id/large_icon_pineapple"
+ style="@style/FieldContents"
+ android:text="pineapple"
+ />
+ <RadioButton
+ android:id="@+id/large_icon_pineapple2"
+ style="@style/FieldContents"
+ android:text="pineapple2"
+ />
+ <RadioButton
+ android:id="@+id/large_icon_small"
+ style="@style/FieldContents"
+ android:text="small"
+ />
+ </RadioGroup>
+ </LinearLayout>
<!-- setSound -->
<RadioGroup
android:id="@+id/group_sound"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
+ style="@style/FieldChoices"
android:visibility="gone"
>
<TextView
@@ -646,190 +659,260 @@
<!-- setVibrate -->
- <RadioGroup
- android:id="@+id/group_vibrate"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
+ <LinearLayout
+ style="@style/FieldGroup"
+ >
<TextView
style="@style/FieldTitle"
android:text="setVibrate"
/>
- <RadioButton
- android:id="@+id/vibrate_none"
- style="@style/FieldContents"
- android:text="none"
- />
- <RadioButton
- android:id="@+id/vibrate_short"
- style="@style/FieldContents"
- android:text="short"
- />
- <RadioButton
- android:id="@+id/vibrate_medium"
- style="@style/FieldContents"
- android:text="long"
- />
- <RadioButton
- android:id="@+id/vibrate_long"
- style="@style/FieldContents"
- android:text="long"
- />
- <RadioButton
- android:id="@+id/vibrate_pattern"
- style="@style/FieldContents"
- android:text="longer"
- />
- </RadioGroup>
-
+ <RadioGroup
+ android:id="@+id/group_vibrate"
+ style="@style/FieldChoices"
+ >
+ <RadioButton
+ android:id="@+id/vibrate_none"
+ style="@style/FieldContents"
+ android:text="none"
+ />
+ <RadioButton
+ android:id="@+id/vibrate_zero"
+ style="@style/FieldContents"
+ android:text="0"
+ />
+ <RadioButton
+ android:id="@+id/vibrate_short"
+ style="@style/FieldContents"
+ android:text="100"
+ />
+ <RadioButton
+ android:id="@+id/vibrate_long"
+ style="@style/FieldContents"
+ android:text="1000"
+ />
+ <RadioButton
+ android:id="@+id/vibrate_pattern"
+ style="@style/FieldContents"
+ android:text="...---..."
+ />
+ </RadioGroup>
+ </LinearLayout>
<!-- setLights -->
- <RadioGroup
- android:id="@+id/group_lights_color"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
+ <LinearLayout
+ style="@style/FieldGroup"
+ >
<TextView
style="@style/FieldTitle"
android:text="setLights (color)"
/>
- <RadioButton
- android:id="@+id/lights_red"
- style="@style/FieldContents"
- android:text="red"
- android:tag="0xff0000"
- />
- <RadioButton
- android:id="@+id/lights_green"
- style="@style/FieldContents"
- android:text="green"
- android:tag="0x00ff00"
- />
- <RadioButton
- android:id="@+id/lights_blue"
- style="@style/FieldContents"
- android:text="blue"
- android:tag="0x0000ff"
- />
- <RadioButton
- android:id="@+id/lights_cyan"
- style="@style/FieldContents"
- android:text="cyan"
- android:tag="0x00ffff"
- />
- <RadioButton
- android:id="@+id/lights_magenta"
- style="@style/FieldContents"
- android:text="magenta"
- android:tag="0xff00ff"
- />
- <RadioButton
- android:id="@+id/lights_yellow"
- style="@style/FieldContents"
- android:text="yellow"
- android:tag="0xffff00"
- />
- <RadioButton
- android:id="@+id/lights_white"
- style="@style/FieldContents"
- android:text="white"
- android:tag="0xffffff"
- />
- </RadioGroup>
+ <RadioGroup
+ android:id="@+id/group_lights_color"
+ style="@style/FieldChoices"
+ >
+ <RadioButton
+ android:id="@+id/lights_red"
+ style="@style/FieldContents"
+ android:text="red"
+ android:tag="0xff0000"
+ />
+ <RadioButton
+ android:id="@+id/lights_green"
+ style="@style/FieldContents"
+ android:text="green"
+ android:tag="0x00ff00"
+ />
+ <RadioButton
+ android:id="@+id/lights_blue"
+ style="@style/FieldContents"
+ android:text="blue"
+ android:tag="0x0000ff"
+ />
+ <RadioButton
+ android:id="@+id/lights_cyan"
+ style="@style/FieldContents"
+ android:text="cyan"
+ android:tag="0x00ffff"
+ />
+ <RadioButton
+ android:id="@+id/lights_magenta"
+ style="@style/FieldContents"
+ android:text="magenta"
+ android:tag="0xff00ff"
+ />
+ <RadioButton
+ android:id="@+id/lights_yellow"
+ style="@style/FieldContents"
+ android:text="yellow"
+ android:tag="0xffff00"
+ />
+ <RadioButton
+ android:id="@+id/lights_white"
+ style="@style/FieldContents"
+ android:text="white"
+ android:tag="0xffffff"
+ />
+ </RadioGroup>
+ </LinearLayout>
+
+ <!-- setPriority -->
+ <LinearLayout
+ style="@style/FieldGroup"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="setPriority"
+ />
+ <RadioGroup
+ android:id="@+id/group_priority"
+ style="@style/FieldChoices"
+ >
+ <RadioButton
+ android:id="@+id/pri_max"
+ style="@style/FieldContents"
+ android:text="MAX"
+ />
+ <RadioButton
+ android:id="@+id/pri_high"
+ style="@style/FieldContents"
+ android:text="HIGH"
+ />
+ <RadioButton
+ android:id="@+id/pri_default"
+ style="@style/FieldContents"
+ android:text="DEFAULT"
+ />
+ <RadioButton
+ android:id="@+id/pri_low"
+ style="@style/FieldContents"
+ android:text="LOW"
+ />
+ <RadioButton
+ android:id="@+id/pri_min"
+ style="@style/FieldContents"
+ android:text="MIN"
+ />
+ </RadioGroup>
+ </LinearLayout>
<!-- setLights -->
- <RadioGroup
- android:id="@+id/group_lights_blink"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
+ <LinearLayout
+ style="@style/FieldGroup"
+ >
<TextView
style="@style/FieldTitle"
android:text="setLights (blink)"
/>
- <RadioButton
- android:id="@+id/lights_off"
- style="@style/FieldContents"
- android:text="off"
- />
- <RadioButton
- android:id="@+id/lights_slow"
- style="@style/FieldContents"
- android:text="slow"
- />
- <RadioButton
- android:id="@+id/lights_fast"
- style="@style/FieldContents"
- android:text="fast"
- />
- <RadioButton
- android:id="@+id/lights_on"
- style="@style/FieldContents"
- android:text="on"
- />
- </RadioGroup>
-
+ <RadioGroup
+ android:id="@+id/group_lights_blink"
+ style="@style/FieldChoices"
+ >
+ <RadioButton
+ android:id="@+id/lights_off"
+ style="@style/FieldContents"
+ android:text="off"
+ />
+ <RadioButton
+ android:id="@+id/lights_slow"
+ style="@style/FieldContents"
+ android:text="slow"
+ />
+ <RadioButton
+ android:id="@+id/lights_fast"
+ style="@style/FieldContents"
+ android:text="fast"
+ />
+ <RadioButton
+ android:id="@+id/lights_on"
+ style="@style/FieldContents"
+ android:text="on"
+ />
+ </RadioGroup>
+ </LinearLayout>
+
<!-- flags -->
<LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:layout_marginTop="12dp"
- >
+ style="@style/FieldGroup"
+ android:layout_marginTop="30dp"
+ >
<TextView
style="@style/FieldTitle"
android:text="flags"
/>
- <CheckBox
- android:id="@+id/flag_ongoing"
- style="@style/FieldContents"
- android:text="setOngoing"
- />
- <CheckBox
- android:id="@+id/flag_once"
- style="@style/FieldContents"
- android:text="setOnlyAlertOnce"
- />
- <CheckBox
- android:id="@+id/flag_auto_cancel"
- style="@style/FieldContents"
- android:text="setAutoCancel"
- />
+ <LinearLayout
+ style="@style/FieldChoices"
+ >
+ <CheckBox
+ android:id="@+id/flag_ongoing"
+ style="@style/FieldContents"
+ android:text="ongoing"
+ />
+ <CheckBox
+ android:id="@+id/flag_once"
+ style="@style/FieldContents"
+ android:text="onlyAlertOnce"
+ />
+ <CheckBox
+ android:id="@+id/flag_auto_cancel"
+ style="@style/FieldContents"
+ android:text="autoCancel"
+ />
+ </LinearLayout>
</LinearLayout>
-
+
<!-- defaults -->
<LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
+ style="@style/FieldGroup"
+ >
<TextView
style="@style/FieldTitle"
android:text="defaults"
/>
- <CheckBox
- android:id="@+id/default_sound"
- style="@style/FieldContents"
- android:text="sound"
- />
- <CheckBox
- android:id="@+id/default_vibrate"
- style="@style/FieldContents"
- android:text="vibrate"
- />
- <CheckBox
- android:id="@+id/default_lights"
- style="@style/FieldContents"
- android:text="lights"
- />
+ <LinearLayout
+ style="@style/FieldChoices"
+ >
+ <CheckBox
+ android:id="@+id/default_sound"
+ style="@style/FieldContents"
+ android:text="sound"
+ />
+ <CheckBox
+ android:id="@+id/default_vibrate"
+ style="@style/FieldContents"
+ android:text="vibrate"
+ />
+ <CheckBox
+ android:id="@+id/default_lights"
+ style="@style/FieldContents"
+ android:text="lights"
+ />
+ </LinearLayout>
</LinearLayout>
-
-
-
+ <!-- delay -->
+ <LinearLayout
+ style="@style/FieldGroup"
+ >
+ <TextView
+ style="@style/FieldTitle"
+ android:text="notify"
+ />
+ <RadioGroup
+ android:id="@+id/group_delay"
+ style="@style/FieldChoices"
+ >
+ <RadioButton
+ android:id="@+id/delay_none"
+ style="@style/FieldContents"
+ android:text="immediately"
+ />
+ <RadioButton
+ android:id="@+id/delay_5"
+ style="@style/FieldContents"
+ android:text="in 5 sec"
+ />
+ </RadioGroup>
+ </LinearLayout>
</LinearLayout>
</LinearLayout>
diff --git a/tests/StatusBar/res/values/styles.xml b/tests/StatusBar/res/values/styles.xml
index 103a25a..f2c9f0d 100644
--- a/tests/StatusBar/res/values/styles.xml
+++ b/tests/StatusBar/res/values/styles.xml
@@ -45,8 +45,10 @@
<style name="FieldTitle">
<item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
- <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_width">120dp</item>
<item name="android:layout_height">wrap_content</item>
+ <item name="android:gravity">right</item>
+ <item name="android:textStyle">bold</item>
</style>
<style name="FieldContents">
@@ -61,5 +63,18 @@
<item name="android:visibility">gone</item>
</style>
+ <style name="FieldGroup">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:orientation">horizontal</item>
+ <item name="android:layout_marginTop">18dp</item>
+ </style>
+
+ <style name="FieldChoices">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:orientation">vertical</item>
+ <item name="android:baselineAlignedChildIndex">0</item>
+ </style>
</resources>
diff --git a/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java b/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java
index 2f0c173..5d0b155 100644
--- a/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java
+++ b/tests/StatusBar/src/com/android/statusbartest/NotificationBuilderTest.java
@@ -30,6 +30,7 @@ import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
+import android.os.Handler;
import android.os.Vibrator;
import android.os.Handler;
import android.text.SpannableStringBuilder;
@@ -49,11 +50,14 @@ public class NotificationBuilderTest extends Activity
private final static String TAG = "NotificationTestList";
NotificationManager mNM;
+ Handler mHandler;
+ int mStartDelay;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
+ mHandler = new Handler();
setContentView(R.layout.notification_builder_test);
if (icicle == null) {
setDefaults();
@@ -100,8 +104,13 @@ public class NotificationBuilderTest extends Activity
setChecked(R.id.large_icon_none);
setChecked(R.id.sound_none);
setChecked(R.id.vibrate_none);
+ setChecked(R.id.pri_default);
setChecked(R.id.lights_red);
setChecked(R.id.lights_off);
+ setChecked(R.id.delay_none);
+// setChecked(R.id.default_vibrate);
+// setChecked(R.id.default_sound);
+// setChecked(R.id.default_lights);
}
private View.OnClickListener mClickListener = new View.OnClickListener() {
@@ -183,9 +192,13 @@ public class NotificationBuilderTest extends Activity
}
};
- private void sendNotification(int id) {
+ private void sendNotification(final int id) {
final Notification n = buildNotification(id);
- mNM.notify(id, n);
+ mHandler.postDelayed(new Runnable() {
+ public void run() {
+ mNM.notify(id, n);
+ }
+ }, mStartDelay);
}
private static CharSequence subst(CharSequence in, char ch, CharSequence sub) {
@@ -323,23 +336,26 @@ public class NotificationBuilderTest extends Activity
// vibrate
switch (getRadioChecked(R.id.group_vibrate)) {
case R.id.vibrate_none:
+ b.setVibrate(null);
break;
- case R.id.vibrate_short:
- b.setVibrate(new long[] { 0, 200 });
+ case R.id.vibrate_zero:
+ b.setVibrate(new long[] { 0 });
break;
- case R.id.vibrate_medium:
- b.setVibrate(new long[] { 0, 500 });
+ case R.id.vibrate_short:
+ b.setVibrate(new long[] { 0, 100 });
break;
case R.id.vibrate_long:
b.setVibrate(new long[] { 0, 1000 });
break;
case R.id.vibrate_pattern:
- b.setVibrate(new long[] { 0, 250, 250, 250, 250, 250, 250, 250 });
+ b.setVibrate(new long[] { 0, 50, 200, 50, 200, 50, 500,
+ 500, 200, 500, 200, 500, 500,
+ 50, 200, 50, 200, 50 });
break;
}
// lights
- final int color = getRadioInt(R.id.group_lights_color, 0xff0000);
+ final int color = getRadioHex(R.id.group_lights_color, 0xff0000);
int onMs;
int offMs;
switch (getRadioChecked(R.id.group_lights_blink)) {
@@ -365,6 +381,35 @@ public class NotificationBuilderTest extends Activity
b.setLights(color, onMs, offMs);
}
+ // priority
+ switch (getRadioChecked(R.id.group_priority)) {
+ case R.id.pri_min:
+ b.setPriority(Notification.PRIORITY_MIN);
+ break;
+ case R.id.pri_low:
+ b.setPriority(Notification.PRIORITY_LOW);
+ break;
+ case R.id.pri_default:
+ b.setPriority(Notification.PRIORITY_DEFAULT);
+ break;
+ case R.id.pri_high:
+ b.setPriority(Notification.PRIORITY_HIGH);
+ break;
+ case R.id.pri_max:
+ b.setPriority(Notification.PRIORITY_MAX);
+ break;
+ }
+
+ // start delay
+ switch (getRadioChecked(R.id.group_delay)) {
+ case R.id.delay_none:
+ mStartDelay = 0;
+ break;
+ case R.id.delay_5:
+ mStartDelay = 5000;
+ break;
+ }
+
// flags
b.setOngoing(getChecked(R.id.flag_ongoing));
b.setOnlyAlertOnce(getChecked(R.id.flag_once));
@@ -383,7 +428,7 @@ public class NotificationBuilderTest extends Activity
}
b.setDefaults(defaults);
- return b.getNotification();
+ return b.build();
}
private void setChecked(int id) {
@@ -396,14 +441,14 @@ public class NotificationBuilderTest extends Activity
return g.getCheckedRadioButtonId();
}
- private CharSequence getRadioTag(int id) {
+ private String getRadioTag(int id) {
final RadioGroup g = (RadioGroup)findViewById(id);
final View v = findViewById(g.getCheckedRadioButtonId());
- return (CharSequence) v.getTag();
+ return (String) v.getTag();
}
private int getRadioInt(int id, int def) {
- CharSequence str = getRadioTag(id);
+ String str = getRadioTag(id);
if (TextUtils.isEmpty(str)) {
return def;
} else {
@@ -415,6 +460,22 @@ public class NotificationBuilderTest extends Activity
}
}
+ private int getRadioHex(int id, int def) {
+ String str = getRadioTag(id);
+ if (TextUtils.isEmpty(str)) {
+ return def;
+ } else {
+ if (str.startsWith("0x")) {
+ str = str.substring(2);
+ }
+ try {
+ return Integer.parseInt(str.toString(), 16);
+ } catch (NumberFormatException ex) {
+ return def;
+ }
+ }
+ }
+
private boolean getChecked(int id) {
final CompoundButton b = (CompoundButton)findViewById(id);
return b.isChecked();
diff --git a/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java b/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java
index 746ac06..596f722 100644
--- a/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java
+++ b/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java
@@ -93,7 +93,7 @@ public class WindowManagerPermissionTests extends TestCase {
}
try {
- mWm.addAppToken(0, null, 0, 0, false, false);
+ mWm.addAppToken(0, 0, null, 0, 0, false, false);
fail("IWindowManager.addAppToken did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {