Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip print job if print feature is not defined #2573

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
From 48ba1532a69d4f867a996d464ee89addfba930ed Mon Sep 17 00:00:00 2001
From: Xu Bing <[email protected]>
Date: Mon, 19 Aug 2024 14:35:57 +0800
Subject: [PATCH] Skip print job if print feature is not defined

System doesn't enabel the feature "android.software.print",
so we skip the print job.

Test: run monkey test, no crash happen

Tracked-On: OAM-123126
Signed-off-by: Xu Bing <[email protected]>
---
src/com/android/bips/ImagePrintActivity.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/com/android/bips/ImagePrintActivity.java b/src/com/android/bips/ImagePrintActivity.java
index 75e4d2f..5ff35a8 100644
--- a/src/com/android/bips/ImagePrintActivity.java
+++ b/src/com/android/bips/ImagePrintActivity.java
@@ -19,6 +19,7 @@ package com.android.bips;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
@@ -145,7 +146,8 @@ public class ImagePrintActivity extends Activity {
boolean isPortrait = values[0];
if (DEBUG) Log.d(TAG, "startPrint(portrait=" + isPortrait + ")");
PrintManager printManager = (PrintManager) getSystemService(Context.PRINT_SERVICE);
- if (printManager == null) {
+ boolean isSupportPrinting = getPackageManager().hasSystemFeature("android.software.print");
+ if (printManager == null || !isSupportPrinting) {
finish();
return;
}
--
2.34.1