diff options
| -rw-r--r-- | core/java/android/print/PrintManager.java | 208 | ||||
| -rw-r--r-- | core/jni/android/graphics/BitmapFactory.cpp | 3 | ||||
| -rw-r--r-- | packages/PrintSpooler/res/layout/printer_dropdown_item.xml | 3 | ||||
| -rw-r--r-- | packages/PrintSpooler/res/values/themes.xml | 1 | ||||
| -rw-r--r-- | packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java | 4 | ||||
| -rw-r--r-- | packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java | 8 | ||||
| -rw-r--r-- | packages/SystemUI/res/drawable-hdpi/recents_thumbnail_bg_dragging.9.png | bin | 264 -> 0 bytes | |||
| -rw-r--r-- | packages/SystemUI/res/drawable-mdpi/recents_thumbnail_bg_dragging.9.png | bin | 243 -> 0 bytes | |||
| -rw-r--r-- | packages/SystemUI/res/drawable-xhdpi/recents_thumbnail_bg_dragging.9.png | bin | 322 -> 0 bytes | |||
| -rw-r--r-- | packages/SystemUI/res/drawable-xxhdpi/recents_thumbnail_bg_dragging.9.png | bin | 1229 -> 0 bytes | |||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/SystemBars.java | 2 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java | 2 |
12 files changed, 185 insertions, 46 deletions
diff --git a/core/java/android/print/PrintManager.java b/core/java/android/print/PrintManager.java index 0859fdde1744..9c7c1feb474f 100644 --- a/core/java/android/print/PrintManager.java +++ b/core/java/android/print/PrintManager.java @@ -57,6 +57,8 @@ public final class PrintManager { private static final String LOG_TAG = "PrintManager"; + private static final boolean DEBUG = false; + /** @hide */ public static final int APP_ID_ANY = -2; @@ -350,6 +352,16 @@ public final class PrintManager { private Handler mHandler; // Strong reference OK - cleared in finish() + private LayoutSpec mLastLayoutSpec; + + private WriteSpec mLastWriteSpec; + + private boolean mStartReqeusted; + private boolean mStarted; + + private boolean mFinishRequested; + private boolean mFinished; + public PrintDocumentAdapterDelegate(PrintDocumentAdapter documentAdapter, Looper looper) { mDocumentAdapter = documentAdapter; mHandler = new MyHandler(looper); @@ -357,47 +369,102 @@ public final class PrintManager { @Override public void start() { - mHandler.sendEmptyMessage(MyHandler.MSG_START); + synchronized (mLock) { + // Started or finished - nothing to do. + if (mStartReqeusted || mFinishRequested) { + return; + } + + mStartReqeusted = true; + + doPendingWorkLocked(); + } } @Override public void layout(PrintAttributes oldAttributes, PrintAttributes newAttributes, ILayoutResultCallback callback, Bundle metadata, int sequence) { synchronized (mLock) { - if (mLayoutOrWriteCancellation != null) { - mLayoutOrWriteCancellation.cancel(); + // Start not called or finish called - nothing to do. + if (!mStartReqeusted || mFinishRequested) { + return; + } + + // Layout cancels write and overrides layout. + if (mLastWriteSpec != null) { + IoUtils.closeQuietly(mLastWriteSpec.fd); + mLastWriteSpec = null; } + + mLastLayoutSpec = new LayoutSpec(); + mLastLayoutSpec.callback = callback; + mLastLayoutSpec.oldAttributes = oldAttributes; + mLastLayoutSpec.newAttributes = newAttributes; + mLastLayoutSpec.metadata = metadata; + mLastLayoutSpec.sequence = sequence; + + // Cancel the previous cancellable operation.When the + // cancellation completes we will do the pending work. + if (cancelPreviousCancellableOperationLocked()) { + return; + } + + doPendingWorkLocked(); } - SomeArgs args = SomeArgs.obtain(); - args.arg1 = oldAttributes; - args.arg2 = newAttributes; - args.arg3 = callback; - args.arg4 = metadata; - args.argi1 = sequence; - mHandler.removeMessages(MyHandler.MSG_LAYOUT); - mHandler.obtainMessage(MyHandler.MSG_LAYOUT, args).sendToTarget(); } @Override public void write(PageRange[] pages, ParcelFileDescriptor fd, IWriteResultCallback callback, int sequence) { synchronized (mLock) { - if (mLayoutOrWriteCancellation != null) { - mLayoutOrWriteCancellation.cancel(); + // Start not called or finish called - nothing to do. + if (!mStartReqeusted || mFinishRequested) { + return; + } + + // Write cancels previous writes. + if (mLastWriteSpec != null) { + IoUtils.closeQuietly(mLastWriteSpec.fd); + mLastWriteSpec = null; } + + mLastWriteSpec = new WriteSpec(); + mLastWriteSpec.callback = callback; + mLastWriteSpec.pages = pages; + mLastWriteSpec.fd = fd; + mLastWriteSpec.sequence = sequence; + + // Cancel the previous cancellable operation.When the + // cancellation completes we will do the pending work. + if (cancelPreviousCancellableOperationLocked()) { + return; + } + + doPendingWorkLocked(); } - SomeArgs args = SomeArgs.obtain(); - args.arg1 = pages; - args.arg2 = fd; - args.arg3 = callback; - args.argi1 = sequence; - mHandler.removeMessages(MyHandler.MSG_WRITE); - mHandler.obtainMessage(MyHandler.MSG_WRITE, args).sendToTarget(); } @Override public void finish() { - mHandler.sendEmptyMessage(MyHandler.MSG_FINISH); + synchronized (mLock) { + // Start not called or finish called - nothing to do. + if (!mStartReqeusted || mFinishRequested) { + return; + } + + mFinishRequested = true; + + // When the current write or layout complete we + // will do the pending work. + if (mLastLayoutSpec != null || mLastWriteSpec != null) { + if (DEBUG) { + Log.i(LOG_TAG, "Waiting for current operation"); + } + return; + } + + doPendingWorkLocked(); + } } private boolean isFinished() { @@ -407,7 +474,49 @@ public final class PrintManager { private void doFinish() { mDocumentAdapter = null; mHandler = null; - mLayoutOrWriteCancellation = null; + synchronized (mLock) { + mLayoutOrWriteCancellation = null; + } + } + + private boolean cancelPreviousCancellableOperationLocked() { + if (mLayoutOrWriteCancellation != null) { + mLayoutOrWriteCancellation.cancel(); + if (DEBUG) { + Log.i(LOG_TAG, "Cancelling previous operation"); + } + return true; + } + return false; + } + + private void doPendingWorkLocked() { + if (mStartReqeusted && !mStarted) { + mStarted = true; + mHandler.sendEmptyMessage(MyHandler.MSG_START); + } else if (mLastLayoutSpec != null) { + mHandler.sendEmptyMessage(MyHandler.MSG_LAYOUT); + } else if (mLastWriteSpec != null) { + mHandler.sendEmptyMessage(MyHandler.MSG_WRITE); + } else if (mFinishRequested && !mFinished) { + mFinished = true; + mHandler.sendEmptyMessage(MyHandler.MSG_FINISH); + } + } + + private class LayoutSpec { + ILayoutResultCallback callback; + PrintAttributes oldAttributes; + PrintAttributes newAttributes; + Bundle metadata; + int sequence; + } + + private class WriteSpec { + IWriteResultCallback callback; + PageRange[] pages; + ParcelFileDescriptor fd; + int sequence; } private final class MyHandler extends Handler { @@ -431,41 +540,52 @@ public final class PrintManager { } break; case MSG_LAYOUT: { - SomeArgs args = (SomeArgs) message.obj; - PrintAttributes oldAttributes = (PrintAttributes) args.arg1; - PrintAttributes newAttributes = (PrintAttributes) args.arg2; - ILayoutResultCallback callback = (ILayoutResultCallback) args.arg3; - Bundle metadata = (Bundle) args.arg4; - final int sequence = args.argi1; - args.recycle(); - - CancellationSignal cancellation = new CancellationSignal(); + final CancellationSignal cancellation; + final LayoutSpec layoutSpec; + synchronized (mLock) { + layoutSpec = mLastLayoutSpec; + mLastLayoutSpec = null; + cancellation = new CancellationSignal(); mLayoutOrWriteCancellation = cancellation; } - mDocumentAdapter.onLayout(oldAttributes, newAttributes, cancellation, - new MyLayoutResultCallback(callback, sequence), metadata); + if (layoutSpec != null) { + if (DEBUG) { + Log.i(LOG_TAG, "Performing layout"); + } + mDocumentAdapter.onLayout(layoutSpec.oldAttributes, + layoutSpec.newAttributes, cancellation, + new MyLayoutResultCallback(layoutSpec.callback, + layoutSpec.sequence), layoutSpec.metadata); + } } break; case MSG_WRITE: { - SomeArgs args = (SomeArgs) message.obj; - PageRange[] pages = (PageRange[]) args.arg1; - ParcelFileDescriptor fd = (ParcelFileDescriptor) args.arg2; - IWriteResultCallback callback = (IWriteResultCallback) args.arg3; - final int sequence = args.argi1; - args.recycle(); - - CancellationSignal cancellation = new CancellationSignal(); + final CancellationSignal cancellation; + final WriteSpec writeSpec; + synchronized (mLock) { + writeSpec= mLastWriteSpec; + mLastWriteSpec = null; + cancellation = new CancellationSignal(); mLayoutOrWriteCancellation = cancellation; } - mDocumentAdapter.onWrite(pages, fd, cancellation, - new MyWriteResultCallback(callback, fd, sequence)); + if (writeSpec != null) { + if (DEBUG) { + Log.i(LOG_TAG, "Performing write"); + } + mDocumentAdapter.onWrite(writeSpec.pages, writeSpec.fd, + cancellation, new MyWriteResultCallback(writeSpec.callback, + writeSpec.fd, writeSpec.sequence)); + } } break; case MSG_FINISH: { + if (DEBUG) { + Log.i(LOG_TAG, "Performing finish"); + } mDocumentAdapter.onFinish(); doFinish(); } break; @@ -533,6 +653,7 @@ public final class PrintManager { private void clearLocked() { mLayoutOrWriteCancellation = null; mCallback = null; + doPendingWorkLocked(); } } @@ -598,6 +719,7 @@ public final class PrintManager { IoUtils.closeQuietly(mFd); mCallback = null; mFd = null; + doPendingWorkLocked(); } } } diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp index 0d757f75bd58..da6219fcfeb1 100644 --- a/core/jni/android/graphics/BitmapFactory.cpp +++ b/core/jni/android/graphics/BitmapFactory.cpp @@ -514,6 +514,9 @@ static jobject nativeDecodeFileDescriptor(JNIEnv* env, jobject clazz, jobject fi } SkAutoTUnref<SkData> data(SkData::NewFromFD(descriptor)); + if (data.get() == NULL) { + return nullObjectReturn("NewFromFD failed in nativeDecodeFileDescriptor"); + } SkAutoTUnref<SkMemoryStream> stream(new SkMemoryStream(data)); /* Allow purgeable iff we own the FD, i.e., in the puregeable and diff --git a/packages/PrintSpooler/res/layout/printer_dropdown_item.xml b/packages/PrintSpooler/res/layout/printer_dropdown_item.xml index 6439b49acc9d..2749aa668ddb 100644 --- a/packages/PrintSpooler/res/layout/printer_dropdown_item.xml +++ b/packages/PrintSpooler/res/layout/printer_dropdown_item.xml @@ -37,7 +37,8 @@ <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" - android:orientation="vertical"> + android:orientation="vertical" + android:duplicateParentState="true"> <TextView android:id="@+id/title" diff --git a/packages/PrintSpooler/res/values/themes.xml b/packages/PrintSpooler/res/values/themes.xml index bb41527baacc..86f4a3716110 100644 --- a/packages/PrintSpooler/res/values/themes.xml +++ b/packages/PrintSpooler/res/values/themes.xml @@ -22,6 +22,7 @@ <item name="android:windowIsTranslucent">true</item> <item name="android:backgroundDimEnabled">true</item> <item name="android:colorBackgroundCacheHint">@android:color/transparent</item> + <item name="android:windowIsFloating">true</item> </style> <style name="SelectPrinterActivityTheme" parent="@android:style/Theme.Holo.Light"> diff --git a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java index 7f9be6ce702a..0bd8344d5b3d 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java +++ b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java @@ -555,6 +555,7 @@ public class PrintJobConfigActivity extends Activity { // TODO: We need some UI for announcing an error. mControllerState = CONTROLLER_STATE_FAILED; Log.e(LOG_TAG, "Received invalid pages from the app"); + mEditor.cancel(); PrintJobConfigActivity.this.finish(); } } @@ -1152,6 +1153,9 @@ public class PrintJobConfigActivity extends Activity { if (!mFavoritePrinterSelected && mDestinationSpinnerAdapter.getCount() > 2) { mFavoritePrinterSelected = true; mDestinationSpinner.setSelection(0); + // Workaround again the weird spinner behavior to notify for selection + // change on the next layout pass as the current printer is used below. + mCurrentPrinter = (PrinterInfo) mDestinationSpinnerAdapter.getItem(0); } // If there is a next printer to select and we succeed selecting diff --git a/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java b/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java index b8a9417a2faa..20315caae650 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java +++ b/packages/PrintSpooler/src/com/android/printspooler/SelectPrinterFragment.java @@ -435,6 +435,8 @@ public final class SelectPrinterFragment extends ListFragment { R.layout.printer_dropdown_item, parent, false); } + convertView.setEnabled(isEnabled(position)); + CharSequence title = null; CharSequence subtitle = null; Drawable icon = null; @@ -476,6 +478,12 @@ public final class SelectPrinterFragment extends ListFragment { } @Override + public boolean isEnabled(int position) { + PrinterInfo printer = (PrinterInfo) getItem(position); + return printer.getStatus() != PrinterInfo.STATUS_UNAVAILABLE; + } + + @Override public Loader<List<PrinterInfo>> onCreateLoader(int id, Bundle args) { if (id == LOADER_ID_PRINTERS_LOADER) { return new FusedPrintersProvider(getActivity()); diff --git a/packages/SystemUI/res/drawable-hdpi/recents_thumbnail_bg_dragging.9.png b/packages/SystemUI/res/drawable-hdpi/recents_thumbnail_bg_dragging.9.png Binary files differdeleted file mode 100644 index 080f2f25a02e..000000000000 --- a/packages/SystemUI/res/drawable-hdpi/recents_thumbnail_bg_dragging.9.png +++ /dev/null diff --git a/packages/SystemUI/res/drawable-mdpi/recents_thumbnail_bg_dragging.9.png b/packages/SystemUI/res/drawable-mdpi/recents_thumbnail_bg_dragging.9.png Binary files differdeleted file mode 100644 index 60dc3f21d4e5..000000000000 --- a/packages/SystemUI/res/drawable-mdpi/recents_thumbnail_bg_dragging.9.png +++ /dev/null diff --git a/packages/SystemUI/res/drawable-xhdpi/recents_thumbnail_bg_dragging.9.png b/packages/SystemUI/res/drawable-xhdpi/recents_thumbnail_bg_dragging.9.png Binary files differdeleted file mode 100644 index 79d1b3c6b4ff..000000000000 --- a/packages/SystemUI/res/drawable-xhdpi/recents_thumbnail_bg_dragging.9.png +++ /dev/null diff --git a/packages/SystemUI/res/drawable-xxhdpi/recents_thumbnail_bg_dragging.9.png b/packages/SystemUI/res/drawable-xxhdpi/recents_thumbnail_bg_dragging.9.png Binary files differdeleted file mode 100644 index c424ffefc258..000000000000 --- a/packages/SystemUI/res/drawable-xxhdpi/recents_thumbnail_bg_dragging.9.png +++ /dev/null diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SystemBars.java b/packages/SystemUI/src/com/android/systemui/statusbar/SystemBars.java index 16fe1aa15922..8819c60aee07 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/SystemBars.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/SystemBars.java @@ -35,7 +35,7 @@ import java.io.PrintWriter; */ public class SystemBars extends SystemUI implements ServiceMonitor.Callbacks { private static final String TAG = "SystemBars"; - private static final boolean DEBUG = true; + private static final boolean DEBUG = false; private static final int WAIT_FOR_BARS_TO_DIE = 500; // manages the implementation coming from the remote process diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 93a9b9299002..c02a99b58d96 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -113,7 +113,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode { public static final boolean DUMPTRUCK = true; // extra dumpsys info public static final boolean DEBUG_GESTURES = false; - public static final boolean DEBUG_WINDOW_STATE = true; + public static final boolean DEBUG_WINDOW_STATE = false; public static final boolean SETTINGS_DRAG_SHORTCUT = true; |