summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael W <baddaemon87@gmail.com>2020-04-09 13:40:42 +0200
committerBruno Martins <bgcngm@gmail.com>2020-04-15 21:45:11 +0100
commit5599c8a37b0f0dd153a3581b9c628f9960c44eef (patch)
tree7bfbcbbeacfc8a9d2105f24ab86c39dce61f7dd2
parentdd3529757021c4511fedf1485e49233e3f4af2f6 (diff)
downloadandroid_packages_apps_Snap-5599c8a37b0f0dd153a3581b9c628f9960c44eef.zip
android_packages_apps_Snap-5599c8a37b0f0dd153a3581b9c628f9960c44eef.tar.gz
android_packages_apps_Snap-5599c8a37b0f0dd153a3581b9c628f9960c44eef.tar.bz2
Snap: quickreader: Don't allow insecure actions
* In order to not allow any app to start in the background or website to be opened, do not allow click actions on quickreader when the device is locked Fixes: https://gitlab.com/LineageOS/issues/android/-/issues/1747 Change-Id: I75486dfb4468405356172c6da51abfca733ec541
-rw-r--r--quickReader/res/values/strings.xml3
-rw-r--r--quickReader/src/org/lineageos/quickreader/ScannerActivity.java22
2 files changed, 21 insertions, 4 deletions
diff --git a/quickReader/res/values/strings.xml b/quickReader/res/values/strings.xml
index 8974831..8633b7c 100644
--- a/quickReader/res/values/strings.xml
+++ b/quickReader/res/values/strings.xml
@@ -47,4 +47,7 @@
<string name="quick_reader_share_title">Share with\u2026</string>
<!-- QuickReader: toast shown when the scanned text has been copied to the clipboard -->
<string name="quick_reader_copied_message">Copied to clipboard</string>
+
+ <!-- QuickReader: Action is only allowed when performed unlocked -->
+ <string name="quick_reader_only_unlocked">This action can only be performed with the device unlocked</string>
</resources>
diff --git a/quickReader/src/org/lineageos/quickreader/ScannerActivity.java b/quickReader/src/org/lineageos/quickreader/ScannerActivity.java
index 7ee6be2..e07cd58 100644
--- a/quickReader/src/org/lineageos/quickreader/ScannerActivity.java
+++ b/quickReader/src/org/lineageos/quickreader/ScannerActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The LineageOS Project
+ * Copyright (C) 2019-2020 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -74,7 +74,8 @@ public class ScannerActivity extends Activity implements ZXingScannerView.Result
super.onCreate(savedInstance);
Intent intent = getIntent();
- if (intent.getBooleanExtra(SECURE_CAMERA_EXTRA, false)) {
+ final boolean isSecure = intent.getBooleanExtra(SECURE_CAMERA_EXTRA, false);
+ if (isSecure) {
// Change the window flags so that secure camera can show when locked
Window win = getWindow();
WindowManager.LayoutParams params = win.getAttributes();
@@ -90,7 +91,13 @@ public class ScannerActivity extends Activity implements ZXingScannerView.Result
mFlashIcon = (ImageView) findViewById(R.id.action_flash);
ImageView closeIcon = (ImageView) findViewById(R.id.action_close);
- mIdentifyLayout.setOnClickListener(v -> sHelper.run(this));
+ mIdentifyLayout.setOnClickListener(v -> {
+ if (isSecure) {
+ showClickErrorDialog();
+ } else {
+ sHelper.run(this);
+ }
+ });
mFlashIcon.setOnClickListener(v -> toggleFlash());
closeIcon.setOnClickListener(v -> finish());
@@ -208,6 +215,13 @@ public class ScannerActivity extends Activity implements ZXingScannerView.Result
.show();
}
+ private void showClickErrorDialog() {
+ new AlertDialog.Builder(this)
+ .setMessage(R.string.quick_reader_only_unlocked)
+ .setPositiveButton(R.string.quick_reader_action_dismiss, null)
+ .show();
+ }
+
private void postAnalyze(int result) {
if (result == 0 || !sHelper.isValid()) {
return;
@@ -331,4 +345,4 @@ public class ScannerActivity extends Activity implements ZXingScannerView.Result
return null;
}
}
-} \ No newline at end of file
+}