diff options
author | Dianne Hackborn <hackbod@google.com> | 2014-08-20 15:25:13 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2014-08-20 18:03:43 -0700 |
commit | aec68bb89fe614181a20eb97340149406218ce2f (patch) | |
tree | b0e8807d7fb06487897a5813d9d8e3bb453f8175 /tests/ActivityTests | |
parent | cf038760f2af569a47e81d17d5cc86792a550c3e (diff) | |
download | frameworks_base-aec68bb89fe614181a20eb97340149406218ce2f.zip frameworks_base-aec68bb89fe614181a20eb97340149406218ce2f.tar.gz frameworks_base-aec68bb89fe614181a20eb97340149406218ce2f.tar.bz2 |
Fix issue #17038762: Add API to add entries to the recents list
New API Added to ActivityManager for adding an entry. See docs
there.
Repercussions:
- I hit a bug in system UI where if the thumbnail has alpha, it tries
to modify it, but thumbnails are loading immutable so crashes. Fixed
this by loading the bitmaps to be mutable.
- Improved dump output of recents; there was a lot of stuff missing.
Also split the recents dump output from the rest of the activity
output, since it can be really large.
- Added tests to the lovely ActivityTest app.
Bonus: new method on AppTask to control the exclude from recents flag.
Change-Id: I01e543db4d15320ee1701e95872fef73c116526c
Diffstat (limited to 'tests/ActivityTests')
-rw-r--r-- | tests/ActivityTests/res/drawable-hdpi/icon.png | bin | 0 -> 6939 bytes | |||
-rw-r--r-- | tests/ActivityTests/res/drawable-mdpi/icon.png | bin | 0 -> 3744 bytes | |||
-rw-r--r-- | tests/ActivityTests/res/drawable-xhdpi/icon.png | bin | 0 -> 10942 bytes | |||
-rw-r--r-- | tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java | 58 |
4 files changed, 56 insertions, 2 deletions
diff --git a/tests/ActivityTests/res/drawable-hdpi/icon.png b/tests/ActivityTests/res/drawable-hdpi/icon.png Binary files differnew file mode 100644 index 0000000..2eab6f2 --- /dev/null +++ b/tests/ActivityTests/res/drawable-hdpi/icon.png diff --git a/tests/ActivityTests/res/drawable-mdpi/icon.png b/tests/ActivityTests/res/drawable-mdpi/icon.png Binary files differnew file mode 100644 index 0000000..63aec6f --- /dev/null +++ b/tests/ActivityTests/res/drawable-mdpi/icon.png diff --git a/tests/ActivityTests/res/drawable-xhdpi/icon.png b/tests/ActivityTests/res/drawable-xhdpi/icon.png Binary files differnew file mode 100644 index 0000000..8ea9c48 --- /dev/null +++ b/tests/ActivityTests/res/drawable-xhdpi/icon.png diff --git a/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java b/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java index 9002125..7f3aa77 100644 --- a/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java +++ b/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java @@ -28,6 +28,7 @@ import android.content.ComponentName; import android.content.ContentProviderClient; import android.content.Intent; import android.content.ServiceConnection; +import android.graphics.BitmapFactory; import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; @@ -219,7 +220,7 @@ public class ActivityTestMain extends Activity { @Override public boolean onMenuItemClick(MenuItem item) { Intent intent = new Intent(ActivityTestMain.this, UserTarget.class); sendOrderedBroadcastAsUser(intent, new UserHandle(mSecondUser), null, - new BroadcastResultReceiver(), + new BroadcastResultReceiver(), null, Activity.RESULT_OK, null, null); return true; } @@ -291,6 +292,30 @@ public class ActivityTestMain extends Activity { return true; } }); + menu.add("Add App Recent").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override public boolean onMenuItemClick(MenuItem item) { + addAppRecents(1); + return true; + } + }); + menu.add("Add App 10x Recent").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override public boolean onMenuItemClick(MenuItem item) { + addAppRecents(10); + return true; + } + }); + menu.add("Exclude!").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override public boolean onMenuItemClick(MenuItem item) { + setExclude(true); + return true; + } + }); + menu.add("Include!").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override public boolean onMenuItemClick(MenuItem item) { + setExclude(false); + return true; + } + }); return true; } @@ -317,7 +342,36 @@ public class ActivityTestMain extends Activity { mConnections.clear(); } - private View scrollWrap(View view) { + void addAppRecents(int count) { + ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE); + Intent intent = new Intent(Intent.ACTION_MAIN); + intent.addCategory(Intent.CATEGORY_LAUNCHER); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); + intent.setComponent(new ComponentName(this, ActivityTestMain.class)); + for (int i=0; i<count; i++) { + ActivityManager.TaskDescription desc = new ActivityManager.TaskDescription(); + desc.setLabel("Added #" + i); + Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon); + if ((i&1) == 0) { + desc.setIcon(bitmap); + } + int taskId = am.addAppTask(this, intent, desc, bitmap); + Log.i(TAG, "Added new task id #" + taskId); + } + } + + void setExclude(boolean exclude) { + ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE); + List<ActivityManager.AppTask> tasks = am.getAppTasks(); + int taskId = getTaskId(); + for (int i=0; i<tasks.size(); i++) { + ActivityManager.AppTask task = tasks.get(i); + if (task.getTaskInfo().id == taskId) { + task.setExcludeFromRecents(exclude); + } + } + } + private View scrollWrap(View view) { ScrollView scroller = new ScrollView(this); scroller.addView(view, new ScrollView.LayoutParams(ScrollView.LayoutParams.MATCH_PARENT, ScrollView.LayoutParams.MATCH_PARENT)); |