Skip to content

Commit c35e670

Browse files
author
Winson Chung
committed
Moving removeTask to separate thread.
Bug: 22760556 Change-Id: Iac6eef77e3ba5432ac1cd4aa792e7b2aadc27c01
1 parent 92e0c86 commit c35e670

1 file changed

Lines changed: 21 additions & 23 deletions

File tree

packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
import android.graphics.drawable.ColorDrawable;
4949
import android.graphics.drawable.Drawable;
5050
import android.os.Bundle;
51+
import android.os.Handler;
52+
import android.os.HandlerThread;
5153
import android.os.ParcelFileDescriptor;
5254
import android.os.RemoteException;
5355
import android.os.SystemProperties;
@@ -85,6 +87,15 @@ public class SystemServicesProxy {
8587
final static String TAG = "SystemServicesProxy";
8688

8789
final static BitmapFactory.Options sBitmapOptions;
90+
final static HandlerThread sBgThread;
91+
92+
static {
93+
sBgThread = new HandlerThread("Recents-SystemServicesProxy",
94+
android.os.Process.THREAD_PRIORITY_BACKGROUND);
95+
sBgThread.start();
96+
sBitmapOptions = new BitmapFactory.Options();
97+
sBitmapOptions.inMutable = true;
98+
}
8899

89100
AccessibilityManager mAccm;
90101
ActivityManager mAm;
@@ -98,17 +109,14 @@ public class SystemServicesProxy {
98109
String mRecentsPackage;
99110
ComponentName mAssistComponent;
100111

112+
Handler mBgThreadHandler;
113+
101114
Bitmap mDummyIcon;
102115
int mDummyThumbnailWidth;
103116
int mDummyThumbnailHeight;
104117
Paint mBgProtectionPaint;
105118
Canvas mBgProtectionCanvas;
106119

107-
static {
108-
sBitmapOptions = new BitmapFactory.Options();
109-
sBitmapOptions.inMutable = true;
110-
}
111-
112120
/** Private constructor */
113121
public SystemServicesProxy(Context context) {
114122
mAccm = AccessibilityManager.getInstance(context);
@@ -121,6 +129,7 @@ public SystemServicesProxy(Context context) {
121129
mWm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
122130
mDisplay = mWm.getDefaultDisplay();
123131
mRecentsPackage = context.getPackageName();
132+
mBgThreadHandler = new Handler(sBgThread.getLooper());
124133

125134
// Get the dummy thumbnail width/heights
126135
Resources res = context.getResources();
@@ -383,12 +392,17 @@ public void moveTaskToFront(int taskId, ActivityOptions opts) {
383392
}
384393

385394
/** Removes the task */
386-
public void removeTask(int taskId) {
395+
public void removeTask(final int taskId) {
387396
if (mAm == null) return;
388397
if (Constants.DebugFlags.App.EnableSystemServicesProxy) return;
389398

390399
// Remove the task.
391-
mAm.removeTask(taskId);
400+
mBgThreadHandler.post(new Runnable() {
401+
@Override
402+
public void run() {
403+
mAm.removeTask(taskId);
404+
}
405+
});
392406
}
393407

394408
/**
@@ -656,22 +670,6 @@ public Rect getWindowRect() {
656670
return windowRect;
657671
}
658672

659-
/**
660-
* Takes a screenshot of the current surface.
661-
*/
662-
public Bitmap takeScreenshot() {
663-
DisplayInfo di = new DisplayInfo();
664-
mDisplay.getDisplayInfo(di);
665-
return SurfaceControl.screenshot(di.getNaturalWidth(), di.getNaturalHeight());
666-
}
667-
668-
/**
669-
* Takes a screenshot of the current app.
670-
*/
671-
public Bitmap takeAppScreenshot() {
672-
return takeScreenshot();
673-
}
674-
675673
/** Starts an activity from recents. */
676674
public boolean startActivityFromRecents(Context context, int taskId, String taskName,
677675
ActivityOptions options) {

0 commit comments

Comments
 (0)