summaryrefslogtreecommitdiffstats
path: root/tests/LockTaskTests/src
diff options
context:
space:
mode:
authorCraig Mautner <cmautner@google.com>2015-04-08 15:43:26 -0700
committerCraig Mautner <cmautner@google.com>2015-04-15 14:27:56 -0700
commit2ad0bb46a42476f91b63baa95f0bcf97a337a4fc (patch)
tree038cec3cde560e9d898ef8c3aa0f1d5cff58fa14 /tests/LockTaskTests/src
parent15df08abd8190353e1430f88c2ed6462d72a5b25 (diff)
downloadframeworks_base-2ad0bb46a42476f91b63baa95f0bcf97a337a4fc.zip
frameworks_base-2ad0bb46a42476f91b63baa95f0bcf97a337a4fc.tar.gz
frameworks_base-2ad0bb46a42476f91b63baa95f0bcf97a337a4fc.tar.bz2
Add tests for android:lockTaskMode.
Android app to exercise the new attribute. For bug 19995702. Change-Id: I0794301a6b677ec6367dd3ad99a40b5d3f9f1d7c
Diffstat (limited to 'tests/LockTaskTests/src')
-rw-r--r--tests/LockTaskTests/src/com/google/android/example/locktasktests/LaunchActivity.java67
-rw-r--r--tests/LockTaskTests/src/com/google/android/example/locktasktests/LockAtLaunchActivity.java20
-rw-r--r--tests/LockTaskTests/src/com/google/android/example/locktasktests/LockDefaultActivity.java20
-rw-r--r--tests/LockTaskTests/src/com/google/android/example/locktasktests/LockTaskNeverActivity.java20
-rw-r--r--tests/LockTaskTests/src/com/google/android/example/locktasktests/LockWhitelistedActivity.java20
-rw-r--r--tests/LockTaskTests/src/com/google/android/example/locktasktests/MainActivity.java58
6 files changed, 205 insertions, 0 deletions
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 0000000..1fc53cb
--- /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 0000000..4390c94
--- /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 0000000..7e57ab7
--- /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 0000000..69c2cbc
--- /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 0000000..387baa2
--- /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 0000000..82fac03
--- /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);
+ }
+}