summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael W <baddaemon87@gmail.com>2018-05-25 00:00:26 +0200
committerMichael W <baddaemon87@gmail.com>2018-08-13 13:16:04 +0200
commit516483bf052d3285063e84ab185799e55d725890 (patch)
tree5354dcc05866cfb432a5bd61b84c2c21e993fbfe
parentb2359181b3345b03a2002b1fa571f97c48c38e72 (diff)
downloadandroid_packages_apps_Snap-516483bf052d3285063e84ab185799e55d725890.zip
android_packages_apps_Snap-516483bf052d3285063e84ab185799e55d725890.tar.gz
android_packages_apps_Snap-516483bf052d3285063e84ab185799e55d725890.tar.bz2
Snap: Allow quickreader to work with secure device
* Mimic the behaviour from CameraActivity to allow using the quickreader activity with locked screen * Pass the value if mSecureCamera as SECURE_CAMERA_EXTRA flag to get knowledge if the WindowManager flags have to be modified * Also tested: Scanning an url doesn't allow bypassing the lockscreen, so it's only the reader itself which will work with a locked device Change-Id: Ia9da7b712f5e5aab32a49d272e3d42651dee412d
-rw-r--r--quickReader/src/org/lineageos/quickreader/ScannerActivity.java13
-rw-r--r--src/com/android/camera/CameraActivity.java5
2 files changed, 16 insertions, 2 deletions
diff --git a/quickReader/src/org/lineageos/quickreader/ScannerActivity.java b/quickReader/src/org/lineageos/quickreader/ScannerActivity.java
index fb583a2..7ee6be2 100644
--- a/quickReader/src/org/lineageos/quickreader/ScannerActivity.java
+++ b/quickReader/src/org/lineageos/quickreader/ScannerActivity.java
@@ -27,6 +27,8 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.util.Patterns;
+import android.view.Window;
+import android.view.WindowManager;
import android.webkit.URLUtil;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -54,6 +56,8 @@ public class ScannerActivity extends Activity implements ZXingScannerView.Result
"(.*)"
);
+ public static final String SECURE_CAMERA_EXTRA = "secure_camera";
+
private static ScannerIntentHelper sHelper;
private AnalyzeTask task;
@@ -69,6 +73,15 @@ public class ScannerActivity extends Activity implements ZXingScannerView.Result
protected void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
+ Intent intent = getIntent();
+ if (intent.getBooleanExtra(SECURE_CAMERA_EXTRA, false)) {
+ // Change the window flags so that secure camera can show when locked
+ Window win = getWindow();
+ WindowManager.LayoutParams params = win.getAttributes();
+ params.flags |= WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
+ win.setAttributes(params);
+ }
+
setContentView(R.layout.activity_scanner);
mScanView = (ZXingScannerView) findViewById(R.id.scanner_view);
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 29a5cdb..74e1a7f 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -2144,8 +2144,9 @@ public class CameraActivity extends Activity
@Override
public void onModuleSelected(int moduleIndex) {
if (moduleIndex == ModuleSwitcher.QR_MODULE_INDEX) {
- startActivity(new Intent(this, ScannerActivity.class));
- finish();
+ Intent intent = new Intent(this, ScannerActivity.class);
+ intent.putExtra(SECURE_CAMERA_EXTRA, mSecureCamera);
+ startActivity(intent);
return;
}