From 99a82437ed8e0537d9a355a124d2bb30aea46ad8 Mon Sep 17 00:00:00 2001 From: Svet Ganov Date: Fri, 24 Oct 2014 16:27:38 -0700 Subject: [PATCH] Printing from two apps at the same time not working. When printing from two apps at the same time the second print UI is getting stuck. There were a couple of issues here: AdapterView was not notifying for item selection if the data changes after scheduling a dalayed selection notification and the notification execution. The code assumed that a layout pass will occur and posponed the notification after the layout pass but it is not guaranteed that such a layout pass will occur. Now we delay only if a layout pass is being scheduled. Also when binding to the PDF rendering service the print spooler was using the same intent and as a result two print activites were getting the same renderer instance while they should get separate ones. Now we use different data in the intent to ensure we get separate renderer instances. Change-Id: I6aa7c7b041957804b4273549dd837a6d70064efc --- core/java/android/widget/AdapterView.java | 3 ++- .../com/android/printspooler/model/PageContentRepository.java | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/java/android/widget/AdapterView.java b/core/java/android/widget/AdapterView.java index 5fa6e60c0dbc9..5e2394ca834e9 100644 --- a/core/java/android/widget/AdapterView.java +++ b/core/java/android/widget/AdapterView.java @@ -861,7 +861,8 @@ public abstract class AdapterView extends ViewGroup { public void run() { mPendingSelectionNotifier = null; - if (mDataChanged) { + if (mDataChanged && getViewRootImpl() != null + && getViewRootImpl().isLayoutRequested()) { // Data has changed between when this SelectionNotifier was // posted and now. Postpone the notification until the next // layout is complete and we run checkSelectionChanged(). diff --git a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java index 85b2490c68fb1..c73da539cebf2 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java +++ b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java @@ -24,6 +24,7 @@ import android.content.ServiceConnection; import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.drawable.BitmapDrawable; +import android.net.Uri; import android.os.AsyncTask; import android.os.IBinder; import android.os.ParcelFileDescriptor; @@ -467,6 +468,7 @@ public final class PageContentRepository { protected void onPreExecute() { Intent intent = new Intent(PdfManipulationService.ACTION_GET_RENDERER); intent.setClass(mContext, PdfManipulationService.class); + intent.setData(Uri.fromParts("fake-scheme", String.valueOf(hashCode()), null)); mContext.bindService(intent, AsyncRenderer.this, Context.BIND_AUTO_CREATE); }