From 5599c8a37b0f0dd153a3581b9c628f9960c44eef Mon Sep 17 00:00:00 2001 From: Michael W Date: Thu, 9 Apr 2020 13:40:42 +0200 Subject: 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 --- quickReader/res/values/strings.xml | 3 +++ .../org/lineageos/quickreader/ScannerActivity.java | 22 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/quickReader/res/values/strings.xml b/quickReader/res/values/strings.xml index 897483115..8633b7c73 100644 --- a/quickReader/res/values/strings.xml +++ b/quickReader/res/values/strings.xml @@ -47,4 +47,7 @@ Share with\u2026 Copied to clipboard + + + This action can only be performed with the device unlocked diff --git a/quickReader/src/org/lineageos/quickreader/ScannerActivity.java b/quickReader/src/org/lineageos/quickreader/ScannerActivity.java index 7ee6be2c6..e07cd584c 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 +} -- cgit v1.2.3