summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2013-12-05 13:10:46 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2013-12-05 13:10:46 -0800
commitebcb32f58a6220802ca129ea33f47b4b69931a10 (patch)
tree32b57c1d6ba9180ae63979e06d7421e107a9aa6c /tests
parent6e2d0c1d91f644ab50e0c0b7cae4306262a4ca41 (diff)
parentbac61807d3bcfff957b358cb9ad77850bd373689 (diff)
downloadframeworks_base-ebcb32f58a6220802ca129ea33f47b4b69931a10.zip
frameworks_base-ebcb32f58a6220802ca129ea33f47b4b69931a10.tar.gz
frameworks_base-ebcb32f58a6220802ca129ea33f47b4b69931a10.tar.bz2
Merge commit 'bac61807d3bcfff957b358cb9ad77850bd373689' into HEAD
Change-Id: I29374270c8e0c2f2859efaf1d55af9f73da0f8d7
Diffstat (limited to 'tests')
-rw-r--r--tests/RemoteDisplayProvider/Android.mk26
-rw-r--r--tests/RemoteDisplayProvider/AndroidManifest.xml38
-rw-r--r--tests/RemoteDisplayProvider/README16
-rwxr-xr-xtests/RemoteDisplayProvider/res/drawable-hdpi/ic_app.pngbin0 -> 3608 bytes
-rw-r--r--tests/RemoteDisplayProvider/res/drawable-mdpi/ic_app.pngbin0 -> 5198 bytes
-rw-r--r--tests/RemoteDisplayProvider/res/values/strings.xml19
-rw-r--r--tests/RemoteDisplayProvider/src/com/android/media/remotedisplay/test/RemoteDisplayProviderService.java321
-rw-r--r--tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java2
8 files changed, 421 insertions, 1 deletions
diff --git a/tests/RemoteDisplayProvider/Android.mk b/tests/RemoteDisplayProvider/Android.mk
new file mode 100644
index 0000000..2f4b343
--- /dev/null
+++ b/tests/RemoteDisplayProvider/Android.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2013 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.
+
+LOCAL_PATH := $(call my-dir)
+
+# Build the application.
+include $(CLEAR_VARS)
+LOCAL_PACKAGE_NAME := RemoteDisplayProviderTest
+LOCAL_MODULE_TAGS := tests
+LOCAL_SDK_VERSION := current
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_RESOURCE_DIR = $(LOCAL_PATH)/res
+LOCAL_JAVA_LIBRARIES := com.android.media.remotedisplay
+LOCAL_CERTIFICATE := platform
+include $(BUILD_PACKAGE)
diff --git a/tests/RemoteDisplayProvider/AndroidManifest.xml b/tests/RemoteDisplayProvider/AndroidManifest.xml
new file mode 100644
index 0000000..afb7c78
--- /dev/null
+++ b/tests/RemoteDisplayProvider/AndroidManifest.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.media.remotedisplay.test" >
+
+ <uses-sdk android:minSdkVersion="19" />
+ <uses-permission android:name="android.permission.CAPTURE_VIDEO_OUTPUT"/>
+
+ <application android:label="@string/app_name"
+ android:icon="@drawable/ic_app">
+ <uses-library android:name="com.android.media.remotedisplay"
+ android:required="true" />
+
+ <service android:name=".RemoteDisplayProviderService"
+ android:label="@string/app_name"
+ android:exported="true"
+ android:permission="android.permission.BIND_REMOTE_DISPLAY">
+ <intent-filter>
+ <action android:name="com.android.media.remotedisplay.RemoteDisplayProvider"/>
+ </intent-filter>
+ </service>
+
+ </application>
+</manifest>
diff --git a/tests/RemoteDisplayProvider/README b/tests/RemoteDisplayProvider/README
new file mode 100644
index 0000000..8bf0130
--- /dev/null
+++ b/tests/RemoteDisplayProvider/README
@@ -0,0 +1,16 @@
+This directory contains sample code to test system integration with
+remote display providers using the API declared by the
+com.android.media.remotedisplay.jar library.
+
+--- DESCRIPTION ---
+
+The application registers a service that publishes a few different
+remote display routes. Behavior can be controlled by modifying the
+code.
+
+To exercise the provider, use System UI features for connecting to
+wireless displays or launch an activity that uses the MediaRouter,
+such as the PresentationWithMediaRouterActivity in ApiDemos.
+
+This code is mainly intended for development and not meant to be
+used as an example implementation of a robust remote display provider.
diff --git a/tests/RemoteDisplayProvider/res/drawable-hdpi/ic_app.png b/tests/RemoteDisplayProvider/res/drawable-hdpi/ic_app.png
new file mode 100755
index 0000000..66a1984
--- /dev/null
+++ b/tests/RemoteDisplayProvider/res/drawable-hdpi/ic_app.png
Binary files differ
diff --git a/tests/RemoteDisplayProvider/res/drawable-mdpi/ic_app.png b/tests/RemoteDisplayProvider/res/drawable-mdpi/ic_app.png
new file mode 100644
index 0000000..5ae7701
--- /dev/null
+++ b/tests/RemoteDisplayProvider/res/drawable-mdpi/ic_app.png
Binary files differ
diff --git a/tests/RemoteDisplayProvider/res/values/strings.xml b/tests/RemoteDisplayProvider/res/values/strings.xml
new file mode 100644
index 0000000..dd82d2c
--- /dev/null
+++ b/tests/RemoteDisplayProvider/res/values/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="app_name">Remote Display Provider Test</string>
+</resources>
diff --git a/tests/RemoteDisplayProvider/src/com/android/media/remotedisplay/test/RemoteDisplayProviderService.java b/tests/RemoteDisplayProvider/src/com/android/media/remotedisplay/test/RemoteDisplayProviderService.java
new file mode 100644
index 0000000..611d7e4
--- /dev/null
+++ b/tests/RemoteDisplayProvider/src/com/android/media/remotedisplay/test/RemoteDisplayProviderService.java
@@ -0,0 +1,321 @@
+/*
+ * Copyright (C) 2013 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.media.remotedisplay.test;
+
+import com.android.media.remotedisplay.RemoteDisplay;
+import com.android.media.remotedisplay.RemoteDisplayProvider;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.Handler;
+import android.os.IBinder;
+import android.util.Log;
+
+/**
+ * Remote display provider implementation that publishes working routes.
+ */
+public class RemoteDisplayProviderService extends Service {
+ private static final String TAG = "RemoteDisplayProviderTest";
+
+ private Provider mProvider;
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ if (intent.getAction().equals(RemoteDisplayProvider.SERVICE_INTERFACE)) {
+ if (mProvider == null) {
+ mProvider = new Provider();
+ return mProvider.getBinder();
+ }
+ }
+ return null;
+ }
+
+ final class Provider extends RemoteDisplayProvider {
+ private RemoteDisplay mTestDisplay1; // variable volume
+ private RemoteDisplay mTestDisplay2; // fixed volume
+ private RemoteDisplay mTestDisplay3; // not available
+ private RemoteDisplay mTestDisplay4; // in use
+ private RemoteDisplay mTestDisplay5; // available but ignores request to connect
+ private RemoteDisplay mTestDisplay6; // available but never finishes connecting
+ private RemoteDisplay mTestDisplay7; // blinks in and out of existence
+ private RemoteDisplay mTestDisplay8; // available but connecting attempt flakes out
+ private RemoteDisplay mTestDisplay9; // available but connection flakes out
+ private RemoteDisplay mTestDisplay10; // available and reconnects periodically
+
+ private final Handler mHandler;
+ private boolean mBlinking;
+
+ public Provider() {
+ super(RemoteDisplayProviderService.this);
+ mHandler = new Handler(getMainLooper());
+ }
+
+ @Override
+ public void onDiscoveryModeChanged(int mode) {
+ Log.d(TAG, "onDiscoveryModeChanged: mode=" + mode);
+
+ if (mode != DISCOVERY_MODE_NONE) {
+ // When discovery begins, go find all of the routes.
+ if (mTestDisplay1 == null) {
+ mTestDisplay1 = new RemoteDisplay("testDisplay1",
+ "Test Display 1 (variable)");
+ mTestDisplay1.setDescription("Variable volume");
+ mTestDisplay1.setStatus(RemoteDisplay.STATUS_AVAILABLE);
+ mTestDisplay1.setVolume(10);
+ mTestDisplay1.setVolumeHandling(RemoteDisplay.PLAYBACK_VOLUME_VARIABLE);
+ mTestDisplay1.setVolumeMax(15);
+ addDisplay(mTestDisplay1);
+ }
+ if (mTestDisplay2 == null) {
+ mTestDisplay2 = new RemoteDisplay("testDisplay2",
+ "Test Display 2 (fixed)");
+ mTestDisplay2.setDescription("Fixed volume");
+ mTestDisplay2.setStatus(RemoteDisplay.STATUS_AVAILABLE);
+ addDisplay(mTestDisplay2);
+ }
+ if (mTestDisplay3 == null) {
+ mTestDisplay3 = new RemoteDisplay("testDisplay3",
+ "Test Display 3 (unavailable)");
+ mTestDisplay3.setDescription("Always unavailable");
+ mTestDisplay3.setStatus(RemoteDisplay.STATUS_NOT_AVAILABLE);
+ addDisplay(mTestDisplay3);
+ }
+ if (mTestDisplay4 == null) {
+ mTestDisplay4 = new RemoteDisplay("testDisplay4",
+ "Test Display 4 (in-use)");
+ mTestDisplay4.setDescription("Always in-use");
+ mTestDisplay4.setStatus(RemoteDisplay.STATUS_IN_USE);
+ addDisplay(mTestDisplay4);
+ }
+ if (mTestDisplay5 == null) {
+ mTestDisplay5 = new RemoteDisplay("testDisplay5",
+ "Test Display 5 (connect ignored)");
+ mTestDisplay5.setDescription("Ignores connect");
+ mTestDisplay5.setStatus(RemoteDisplay.STATUS_AVAILABLE);
+ addDisplay(mTestDisplay5);
+ }
+ if (mTestDisplay6 == null) {
+ mTestDisplay6 = new RemoteDisplay("testDisplay6",
+ "Test Display 6 (connect hangs)");
+ mTestDisplay6.setDescription("Never finishes connecting");
+ mTestDisplay6.setStatus(RemoteDisplay.STATUS_AVAILABLE);
+ addDisplay(mTestDisplay6);
+ }
+ if (mTestDisplay8 == null) {
+ mTestDisplay8 = new RemoteDisplay("testDisplay8",
+ "Test Display 8 (flaky when connecting)");
+ mTestDisplay8.setDescription("Aborts spontaneously while connecting");
+ mTestDisplay8.setStatus(RemoteDisplay.STATUS_AVAILABLE);
+ addDisplay(mTestDisplay8);
+ }
+ if (mTestDisplay9 == null) {
+ mTestDisplay9 = new RemoteDisplay("testDisplay9",
+ "Test Display 9 (flaky when connected)");
+ mTestDisplay9.setDescription("Aborts spontaneously while connected");
+ mTestDisplay9.setStatus(RemoteDisplay.STATUS_AVAILABLE);
+ addDisplay(mTestDisplay9);
+ }
+ if (mTestDisplay10 == null) {
+ mTestDisplay10 = new RemoteDisplay("testDisplay10",
+ "Test Display 10 (reconnects periodically)");
+ mTestDisplay10.setDescription("Reconnects spontaneously");
+ mTestDisplay10.setStatus(RemoteDisplay.STATUS_AVAILABLE);
+ addDisplay(mTestDisplay10);
+ }
+ } else {
+ // When discovery ends, go hide some of the routes we can't actually use.
+ // This isn't something a normal route provider would do though.
+ // The routes will usually stay published.
+ if (mTestDisplay3 != null) {
+ removeDisplay(mTestDisplay3);
+ mTestDisplay3 = null;
+ }
+ if (mTestDisplay4 != null) {
+ removeDisplay(mTestDisplay4);
+ mTestDisplay4 = null;
+ }
+ }
+
+ // When active discovery is on, pretend there's a route that we can't quite
+ // reach that blinks in and out of existence.
+ if (mode == DISCOVERY_MODE_ACTIVE) {
+ if (!mBlinking) {
+ mBlinking = true;
+ mHandler.post(mBlink);
+ }
+ } else {
+ mBlinking = false;
+ }
+ }
+
+ @Override
+ public void onConnect(final RemoteDisplay display) {
+ Log.d(TAG, "onConnect: display.getId()=" + display.getId());
+
+ if (display == mTestDisplay1 || display == mTestDisplay2) {
+ display.setStatus(RemoteDisplay.STATUS_CONNECTING);
+ updateDisplay(display);
+ mHandler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if ((display == mTestDisplay1 || display == mTestDisplay2)
+ && display.getStatus() == RemoteDisplay.STATUS_CONNECTING) {
+ display.setStatus(RemoteDisplay.STATUS_CONNECTED);
+ updateDisplay(display);
+ }
+ }
+ }, 2000);
+ } else if (display == mTestDisplay6 || display == mTestDisplay7) {
+ // never finishes connecting
+ display.setStatus(RemoteDisplay.STATUS_CONNECTING);
+ updateDisplay(display);
+ } else if (display == mTestDisplay8) {
+ // flakes out while connecting
+ display.setStatus(RemoteDisplay.STATUS_CONNECTING);
+ updateDisplay(display);
+ mHandler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if ((display == mTestDisplay8)
+ && display.getStatus() == RemoteDisplay.STATUS_CONNECTING) {
+ display.setStatus(RemoteDisplay.STATUS_AVAILABLE);
+ updateDisplay(display);
+ }
+ }
+ }, 2000);
+ } else if (display == mTestDisplay9) {
+ // flakes out when connected
+ display.setStatus(RemoteDisplay.STATUS_CONNECTING);
+ updateDisplay(display);
+ mHandler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if ((display == mTestDisplay9)
+ && display.getStatus() == RemoteDisplay.STATUS_CONNECTING) {
+ display.setStatus(RemoteDisplay.STATUS_CONNECTED);
+ updateDisplay(display);
+ }
+ }
+ }, 2000);
+ mHandler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if ((display == mTestDisplay9)
+ && display.getStatus() == RemoteDisplay.STATUS_CONNECTED) {
+ display.setStatus(RemoteDisplay.STATUS_AVAILABLE);
+ updateDisplay(display);
+ }
+ }
+ }, 5000);
+ } else if (display == mTestDisplay10) {
+ display.setStatus(RemoteDisplay.STATUS_CONNECTING);
+ updateDisplay(display);
+ mHandler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if (display == mTestDisplay10) {
+ if (display.getStatus() == RemoteDisplay.STATUS_CONNECTING) {
+ display.setStatus(RemoteDisplay.STATUS_CONNECTED);
+ updateDisplay(display);
+ mHandler.postDelayed(this, 7000);
+ } else if (display.getStatus() == RemoteDisplay.STATUS_CONNECTED) {
+ display.setStatus(RemoteDisplay.STATUS_CONNECTING);
+ updateDisplay(display);
+ mHandler.postDelayed(this, 2000);
+ }
+ }
+ }
+ }, 2000);
+ }
+ }
+
+ @Override
+ public void onDisconnect(RemoteDisplay display) {
+ Log.d(TAG, "onDisconnect: display.getId()=" + display.getId());
+
+ if (display == mTestDisplay1 || display == mTestDisplay2
+ || display == mTestDisplay6 || display == mTestDisplay8
+ || display == mTestDisplay9 || display == mTestDisplay10) {
+ display.setStatus(RemoteDisplay.STATUS_AVAILABLE);
+ updateDisplay(display);
+ }
+ }
+
+ @Override
+ public void onSetVolume(RemoteDisplay display, int volume) {
+ Log.d(TAG, "onSetVolume: display.getId()=" + display.getId()
+ + ", volume=" + volume);
+
+ if (display == mTestDisplay1) {
+ display.setVolume(Math.max(0, Math.min(display.getVolumeMax(), volume)));
+ updateDisplay(display);
+ }
+ }
+
+ @Override
+ public void onAdjustVolume(RemoteDisplay display, int delta) {
+ Log.d(TAG, "onAdjustVolume: display.getId()=" + display.getId()
+ + ", delta=" + delta);
+
+ if (display == mTestDisplay1) {
+ display.setVolume(Math.max(0, Math.min(display.getVolumeMax(),
+ display .getVolume() + delta)));
+ updateDisplay(display);
+ }
+ }
+
+ @Override
+ public void addDisplay(RemoteDisplay display) {
+ Log.d(TAG, "addDisplay: display=" + display);
+ super.addDisplay(display);
+ }
+
+ @Override
+ public void removeDisplay(RemoteDisplay display) {
+ Log.d(TAG, "removeDisplay: display=" + display);
+ super.removeDisplay(display);
+ }
+
+ @Override
+ public void updateDisplay(RemoteDisplay display) {
+ Log.d(TAG, "updateDisplay: display=" + display);
+ super.updateDisplay(display);
+ }
+
+ private final Runnable mBlink = new Runnable() {
+ @Override
+ public void run() {
+ if (mTestDisplay7 == null) {
+ if (mBlinking) {
+ mTestDisplay7 = new RemoteDisplay("testDisplay7",
+ "Test Display 7 (blinky)");
+ mTestDisplay7.setDescription("Comes and goes but can't connect");
+ mTestDisplay7.setStatus(RemoteDisplay.STATUS_AVAILABLE);
+ addDisplay(mTestDisplay7);
+ mHandler.postDelayed(this, 7000);
+ }
+ } else {
+ removeDisplay(mTestDisplay7);
+ mTestDisplay7 = null;
+ if (mBlinking) {
+ mHandler.postDelayed(this, 4000);
+ }
+ }
+ }
+ };
+ }
+}
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 e4c4214..df32ee1 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, 0, false, false, 0);
+ mWm.addAppToken(0, null, 0, 0, 0, false, false, 0, 0);
fail("IWindowManager.addAppToken did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {