summaryrefslogtreecommitdiffstats
path: root/packages/PrintSpooler
diff options
context:
space:
mode:
authorSvetoslav <svetoslavganov@google.com>2014-09-24 13:19:49 -0700
committerSvetoslav <svetoslavganov@google.com>2014-09-24 13:22:35 -0700
commitd23bfa9d42c477970189a96d4562d627d609e604 (patch)
tree2941501c74ace1dbfaa764822fa30fedabe9da38 /packages/PrintSpooler
parent63c8e126e7f0b1d0c984c08292962d57db925435 (diff)
downloadframeworks_base-d23bfa9d42c477970189a96d4562d627d609e604.zip
frameworks_base-d23bfa9d42c477970189a96d4562d627d609e604.tar.gz
frameworks_base-d23bfa9d42c477970189a96d4562d627d609e604.tar.bz2
Print spooler should not crash if fed non-PDF content.
It is possible that a buggy app breaks the contract and provides content to be printed in format other than PDF. This was leading to a crash in the print spooler. This change fixes the crash and shows a user friendly error message. bug:17642690 Change-Id: I5a4acb06080a152562655da6851467b3e71d8658
Diffstat (limited to 'packages/PrintSpooler')
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java6
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/renderer/PdfManipulationService.java4
2 files changed, 5 insertions, 5 deletions
diff --git a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java
index eb2c920..85b2490 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java
@@ -412,8 +412,6 @@ public final class PageContentRepository {
}
private static final class AsyncRenderer implements ServiceConnection {
- private static final int MALFORMED_PDF_FILE_ERROR = -2;
-
private final Object mLock = new Object();
private final Context mContext;
@@ -486,7 +484,7 @@ public final class PageContentRepository {
return mRenderer.openDocument(source);
} catch (RemoteException re) {
Log.e(LOG_TAG, "Cannot open PDF document");
- return MALFORMED_PDF_FILE_ERROR;
+ return PdfManipulationService.MALFORMED_PDF_FILE_ERROR;
} finally {
// Close the fd as we passed it to another process
// which took ownership.
@@ -497,7 +495,7 @@ public final class PageContentRepository {
@Override
public void onPostExecute(Integer pageCount) {
- if (pageCount == MALFORMED_PDF_FILE_ERROR) {
+ if (pageCount == PdfManipulationService.MALFORMED_PDF_FILE_ERROR) {
mOnMalformedPdfFileListener.onMalformedPdfFile();
mPageCount = PrintDocumentInfo.PAGE_COUNT_UNKNOWN;
} else {
diff --git a/packages/PrintSpooler/src/com/android/printspooler/renderer/PdfManipulationService.java b/packages/PrintSpooler/src/com/android/printspooler/renderer/PdfManipulationService.java
index 62716b2..00e5051 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/renderer/PdfManipulationService.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/renderer/PdfManipulationService.java
@@ -47,6 +47,8 @@ public final class PdfManipulationService extends Service {
public static final String ACTION_GET_EDITOR =
"com.android.printspooler.renderer.ACTION_GET_EDITOR";
+ public static final int MALFORMED_PDF_FILE_ERROR = -2;
+
private static final String LOG_TAG = "PdfManipulationService";
private static final boolean DEBUG = false;
@@ -88,7 +90,7 @@ public final class PdfManipulationService extends Service {
} catch (IOException|IllegalStateException e) {
IoUtils.closeQuietly(source);
Log.e(LOG_TAG, "Cannot open file", e);
- throw new RemoteException(e.toString());
+ return MALFORMED_PDF_FILE_ERROR;
}
}
}