diff --git a/tests/LockTaskTests/Android.mk b/tests/LockTaskTests/Android.mk
new file mode 100644
index 0000000000000..ed5864304b672
--- /dev/null
+++ b/tests/LockTaskTests/Android.mk
@@ -0,0 +1,15 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_PATH := $(PRODUCT_OUT)/system/priv-app
+
+LOCAL_PACKAGE_NAME := LockTaskTests
+LOCAL_CERTIFICATE := platform
+
+LOCAL_SRC_FILES := $(call all-Iaidl-files-under, src) $(call all-java-files-under, src)
+
+include $(BUILD_PACKAGE)
+
+# Use the following include to make our test apk.
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/LockTaskTests/AndroidManifest.xml b/tests/LockTaskTests/AndroidManifest.xml
new file mode 100644
index 0000000000000..f88744e42084f
--- /dev/null
+++ b/tests/LockTaskTests/AndroidManifest.xml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/LockTaskTests/res/drawable-hdpi/ic_launcher.png b/tests/LockTaskTests/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000000000..288b66551d1ef
Binary files /dev/null and b/tests/LockTaskTests/res/drawable-hdpi/ic_launcher.png differ
diff --git a/tests/LockTaskTests/res/drawable-mdpi/ic_launcher.png b/tests/LockTaskTests/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000000000..6ae570b4db4da
Binary files /dev/null and b/tests/LockTaskTests/res/drawable-mdpi/ic_launcher.png differ
diff --git a/tests/LockTaskTests/res/drawable-xhdpi/ic_launcher.png b/tests/LockTaskTests/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000000000..d4fb7cd9d868f
Binary files /dev/null and b/tests/LockTaskTests/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/tests/LockTaskTests/res/drawable-xxhdpi/ic_launcher.png b/tests/LockTaskTests/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000000000..85a6081587e2c
Binary files /dev/null and b/tests/LockTaskTests/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/tests/LockTaskTests/res/layout/activity_launch.xml b/tests/LockTaskTests/res/layout/activity_launch.xml
new file mode 100644
index 0000000000000..b619743a5c7bc
--- /dev/null
+++ b/tests/LockTaskTests/res/layout/activity_launch.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
diff --git a/tests/LockTaskTests/res/layout/activity_main.xml b/tests/LockTaskTests/res/layout/activity_main.xml
new file mode 100644
index 0000000000000..c2e93c4d38819
--- /dev/null
+++ b/tests/LockTaskTests/res/layout/activity_main.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
diff --git a/tests/LockTaskTests/res/values-v11/styles.xml b/tests/LockTaskTests/res/values-v11/styles.xml
new file mode 100644
index 0000000000000..3c02242ad044b
--- /dev/null
+++ b/tests/LockTaskTests/res/values-v11/styles.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
diff --git a/tests/LockTaskTests/res/values-v14/styles.xml b/tests/LockTaskTests/res/values-v14/styles.xml
new file mode 100644
index 0000000000000..a91fd0372b20f
--- /dev/null
+++ b/tests/LockTaskTests/res/values-v14/styles.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
diff --git a/tests/LockTaskTests/res/values-w820dp/dimens.xml b/tests/LockTaskTests/res/values-w820dp/dimens.xml
new file mode 100644
index 0000000000000..f3e70203b90ac
--- /dev/null
+++ b/tests/LockTaskTests/res/values-w820dp/dimens.xml
@@ -0,0 +1,10 @@
+
+
+
+ 64dp
+
+
diff --git a/tests/LockTaskTests/res/values/dimens.xml b/tests/LockTaskTests/res/values/dimens.xml
new file mode 100644
index 0000000000000..55c1e5908c7e0
--- /dev/null
+++ b/tests/LockTaskTests/res/values/dimens.xml
@@ -0,0 +1,7 @@
+
+
+
+ 16dp
+ 16dp
+
+
diff --git a/tests/LockTaskTests/res/values/strings.xml b/tests/LockTaskTests/res/values/strings.xml
new file mode 100644
index 0000000000000..ae7768ed6dfcf
--- /dev/null
+++ b/tests/LockTaskTests/res/values/strings.xml
@@ -0,0 +1,25 @@
+
+
+
+ Lock Task Tests
+ LockDefaultActivity
+ LockTaskNeverActivity
+ LockWhitelistedActivity
+ LockAtLaunchActivity
+ android:lockTaskMode=\n
+ \"lockTaskModeDefault\"\n
+ Pinnable from Overview.
+ android:lockTaskMode=\n
+ \"lockTaskModeNever\"\n
+ Not Lockable or Pinnable.
+ android:lockTaskMode=\n\"lockTaskModeIfWhitelisted\"\n
+ Lockable if whitelisted, Pinnable.\n
+ Use SampleDeviceOwner app to set whitelist.
+ android:lockTaskMode=\n
+ \"lockTaskModeAlways\"\n
+ Launches into lock mode.
+ launch MainActivity (as activity)"
+ Call startLockMode()
+ Call stopLockMode()
+
+
diff --git a/tests/LockTaskTests/res/values/styles.xml b/tests/LockTaskTests/res/values/styles.xml
new file mode 100644
index 0000000000000..6ce89c7ba4394
--- /dev/null
+++ b/tests/LockTaskTests/res/values/styles.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
diff --git a/tests/LockTaskTests/src/com/google/android/example/locktasktests/LaunchActivity.java b/tests/LockTaskTests/src/com/google/android/example/locktasktests/LaunchActivity.java
new file mode 100644
index 0000000000000..1fc53cbaec37a
--- /dev/null
+++ b/tests/LockTaskTests/src/com/google/android/example/locktasktests/LaunchActivity.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2015 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.google.android.example.locktasktests;
+
+import android.app.Activity;
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.EditText;
+
+public class LaunchActivity extends Activity {
+
+ EditText mEditText;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_launch);
+ setBackgroundOnLockTaskMode();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ setBackgroundOnLockTaskMode();
+ }
+
+ public void onTryLock(View view) {
+ startLockTask();
+ setBackgroundOnLockTaskMode();
+ }
+
+ public void onTryUnlock(View view) {
+ stopLockTask();
+ setBackgroundOnLockTaskMode();
+ }
+
+ public void onLaunchMain(View view) {
+ Intent intent = new Intent(this, MainActivity.class);
+ startActivity(intent);
+ }
+
+ private void setBackgroundOnLockTaskMode() {
+ ActivityManager activityManager =
+ (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
+ final int color =
+ activityManager.getLockTaskModeState() != ActivityManager.LOCK_TASK_MODE_NONE ?
+ 0xFFFFC0C0 : 0xFFFFFFFF;
+ findViewById(R.id.root_launch).setBackgroundColor(color);
+ }
+}
diff --git a/tests/LockTaskTests/src/com/google/android/example/locktasktests/LockAtLaunchActivity.java b/tests/LockTaskTests/src/com/google/android/example/locktasktests/LockAtLaunchActivity.java
new file mode 100644
index 0000000000000..4390c945aa775
--- /dev/null
+++ b/tests/LockTaskTests/src/com/google/android/example/locktasktests/LockAtLaunchActivity.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2015 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.google.android.example.locktasktests;
+
+public class LockAtLaunchActivity extends LaunchActivity {
+}
diff --git a/tests/LockTaskTests/src/com/google/android/example/locktasktests/LockDefaultActivity.java b/tests/LockTaskTests/src/com/google/android/example/locktasktests/LockDefaultActivity.java
new file mode 100644
index 0000000000000..7e57ab7500f88
--- /dev/null
+++ b/tests/LockTaskTests/src/com/google/android/example/locktasktests/LockDefaultActivity.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2015 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.google.android.example.locktasktests;
+
+public class LockDefaultActivity extends LaunchActivity {
+}
diff --git a/tests/LockTaskTests/src/com/google/android/example/locktasktests/LockTaskNeverActivity.java b/tests/LockTaskTests/src/com/google/android/example/locktasktests/LockTaskNeverActivity.java
new file mode 100644
index 0000000000000..69c2cbc626d6c
--- /dev/null
+++ b/tests/LockTaskTests/src/com/google/android/example/locktasktests/LockTaskNeverActivity.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2015 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.google.android.example.locktasktests;
+
+public class LockTaskNeverActivity extends LaunchActivity {
+}
diff --git a/tests/LockTaskTests/src/com/google/android/example/locktasktests/LockWhitelistedActivity.java b/tests/LockTaskTests/src/com/google/android/example/locktasktests/LockWhitelistedActivity.java
new file mode 100644
index 0000000000000..387baa2dd3096
--- /dev/null
+++ b/tests/LockTaskTests/src/com/google/android/example/locktasktests/LockWhitelistedActivity.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2015 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.google.android.example.locktasktests;
+
+public class LockWhitelistedActivity extends LaunchActivity {
+}
diff --git a/tests/LockTaskTests/src/com/google/android/example/locktasktests/MainActivity.java b/tests/LockTaskTests/src/com/google/android/example/locktasktests/MainActivity.java
new file mode 100644
index 0000000000000..82fac036ab2af
--- /dev/null
+++ b/tests/LockTaskTests/src/com/google/android/example/locktasktests/MainActivity.java
@@ -0,0 +1,58 @@
+
+package com.google.android.example.locktasktests;
+
+import android.app.Activity;
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+
+public class MainActivity extends Activity {
+
+ private final static String TAG = "LockTaskTests";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ setBackgroundOnLockTaskMode();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ setBackgroundOnLockTaskMode();
+ }
+
+ public void onButtonPressed(View v) {
+ Class activity = null;
+ switch (v.getId()) {
+ case R.id.button_default:
+ activity = LockDefaultActivity.class;
+ break;
+ case R.id.button_never:
+ activity = LockTaskNeverActivity.class;
+ break;
+ case R.id.button_whitelist:
+ activity = LockWhitelistedActivity.class;
+ break;
+ case R.id.button_always:
+ activity = LockAtLaunchActivity.class;
+ break;
+ }
+ Intent intent = new Intent(this, activity);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startActivity(intent);
+ }
+
+ private void setBackgroundOnLockTaskMode() {
+ ActivityManager activityManager =
+ (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
+ final int color =
+ activityManager.getLockTaskModeState() != ActivityManager.LOCK_TASK_MODE_NONE ?
+ 0xFFFFC0C0 : 0xFFFFFFFF;
+ findViewById(R.id.root_launch).setBackgroundColor(color);
+ }
+}