summaryrefslogtreecommitdiffstats
path: root/tests/ActivityTests
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2011-04-08 18:14:09 -0700
committerDianne Hackborn <hackbod@google.com>2011-04-08 18:16:21 -0700
commitf26fd99a7c2f554b0297760bb66336473c7db61f (patch)
tree292bc65e6d068857bda10f2f45727a7c88601b64 /tests/ActivityTests
parentbdf7b013f81b0b56a18cc9dd2fb987b56d595650 (diff)
downloadframeworks_base-f26fd99a7c2f554b0297760bb66336473c7db61f.zip
frameworks_base-f26fd99a7c2f554b0297760bb66336473c7db61f.tar.gz
frameworks_base-f26fd99a7c2f554b0297760bb66336473c7db61f.tar.bz2
Rework thumbnails in activity manager.
We now only keep a thumbnail for the task, not for each activity. However if you use FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, we will make a new secondary thumbnail for that series of activities. There is a new API for the app to get these secondary thumbnails. Also set a default thumbnail size for non-xlarge screens so we have thumbnails on phones. (We need some smarter code in the platform for computing the actual thumbnail dimensions of the current device). And add a test app to show recent tasks + thumbnails. Change-Id: Ic36759f6635522118a2cb7f156662229a610c492
Diffstat (limited to 'tests/ActivityTests')
-rw-r--r--tests/ActivityTests/Android.mk11
-rw-r--r--tests/ActivityTests/AndroidManifest.xml29
-rw-r--r--tests/ActivityTests/res/values/strings.xml19
-rw-r--r--tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java99
4 files changed, 158 insertions, 0 deletions
diff --git a/tests/ActivityTests/Android.mk b/tests/ActivityTests/Android.mk
new file mode 100644
index 0000000..f3c6b5a
--- /dev/null
+++ b/tests/ActivityTests/Android.mk
@@ -0,0 +1,11 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_PACKAGE_NAME := ActivityTest
+
+LOCAL_MODULE_TAGS := tests
+LOCAL_CERTIFICATE := platform
+
+include $(BUILD_PACKAGE)
diff --git a/tests/ActivityTests/AndroidManifest.xml b/tests/ActivityTests/AndroidManifest.xml
new file mode 100644
index 0000000..6fa27ed
--- /dev/null
+++ b/tests/ActivityTests/AndroidManifest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 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.google.android.test.activity">
+ <uses-permission android:name="android.permission.GET_TASKS" />
+ <uses-permission android:name="android.permission.READ_FRAME_BUFFER" />
+ <application android:label="ActivityTest">
+ <activity android:name="ActivityTestMain">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/tests/ActivityTests/res/values/strings.xml b/tests/ActivityTests/res/values/strings.xml
new file mode 100644
index 0000000..71705cb
--- /dev/null
+++ b/tests/ActivityTests/res/values/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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>
+ <string name="act_title">DpiTest: Unknown Screen</string>
+</resources>
diff --git a/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java b/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java
new file mode 100644
index 0000000..8c5c35a
--- /dev/null
+++ b/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2011 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.test.activity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import android.app.Activity;
+import android.app.ActivityManager;
+import android.app.ActivityThread;
+import android.app.Application;
+import android.os.Bundle;
+import android.graphics.BitmapFactory;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.widget.ScrollView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.CompatibilityInfo;
+import android.util.DisplayMetrics;
+import android.util.Log;
+
+public class ActivityTestMain extends Activity {
+ private void addThumbnail(LinearLayout container, Bitmap bm) {
+ ImageView iv = new ImageView(this);
+ if (bm != null) {
+ iv.setImageBitmap(bm);
+ }
+ iv.setBackgroundResource(android.R.drawable.gallery_thumb);
+ int w = getResources().getDimensionPixelSize(android.R.dimen.thumbnail_width);
+ int h = getResources().getDimensionPixelSize(android.R.dimen.thumbnail_height);
+ container.addView(iv, new LinearLayout.LayoutParams(w, h));
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ ActivityManager am = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
+
+ LinearLayout top = new LinearLayout(this);
+ top.setOrientation(LinearLayout.VERTICAL);
+
+ List<ActivityManager.RecentTaskInfo> recents = am.getRecentTasks(10,
+ ActivityManager.RECENT_WITH_EXCLUDED);
+ if (recents != null) {
+ for (int i=0; i<recents.size(); i++) {
+ ActivityManager.RecentTaskInfo r = recents.get(i);
+ ActivityManager.TaskThumbnails tt = r != null
+ ? am.getTaskThumbnails(r.persistentId) : null;
+ TextView tv = new TextView(this);
+ tv.setText(r.baseIntent.getComponent().flattenToShortString());
+ top.addView(tv, new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.WRAP_CONTENT,
+ LinearLayout.LayoutParams.WRAP_CONTENT));
+ LinearLayout item = new LinearLayout(this);
+ item.setOrientation(LinearLayout.HORIZONTAL);
+ addThumbnail(item, tt != null ? tt.mainThumbnail : null);
+ for (int j=0; j<tt.numSubThumbbails; j++) {
+ addThumbnail(item, tt.getSubThumbnail(j));
+ }
+ top.addView(item, new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.WRAP_CONTENT,
+ LinearLayout.LayoutParams.WRAP_CONTENT));
+ }
+ }
+
+ setContentView(scrollWrap(top));
+ }
+
+ private View scrollWrap(View view) {
+ ScrollView scroller = new ScrollView(this);
+ scroller.addView(view, new ScrollView.LayoutParams(ScrollView.LayoutParams.MATCH_PARENT,
+ ScrollView.LayoutParams.MATCH_PARENT));
+ return scroller;
+ }
+}