Merge "Print spooler should not crash if fed non-PDF content." into lmp-dev
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user