diff options
author | Doris Liu <tianliu@google.com> | 2013-06-18 17:14:26 -0700 |
---|---|---|
committer | Doris Liu <tianliu@google.com> | 2013-06-18 18:37:14 -0700 |
commit | b84b9738c855a525dc1944165983cc3c342ce446 (patch) | |
tree | 159ca7440104e1287df3572dc246009c4d464da8 /src/com/android | |
parent | 4984a6afefe1e9b9514d32c0c4fa874ada57af79 (diff) | |
download | android_packages_apps_Snap-b84b9738c855a525dc1944165983cc3c342ce446.tar.gz android_packages_apps_Snap-b84b9738c855a525dc1944165983cc3c342ce446.tar.bz2 android_packages_apps_Snap-b84b9738c855a525dc1944165983cc3c342ce446.zip |
Set window flags to show secure camera
Change-Id: I9acb47ae5d6c5b9248aeea5cd267e17243f93c74
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/camera/CameraActivity.java | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index baa1e7e19..c5cbb7e8a 100644 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -17,10 +17,12 @@ package com.android.camera; import android.app.Activity; +import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.pm.ActivityInfo; import android.content.res.Configuration; @@ -115,6 +117,14 @@ public class CameraActivity extends Activity mMediaSaveService = null; }}; + // close activity when screen turns off + private BroadcastReceiver mScreenOffReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + finish(); + } + }; + private FilmStripView.Listener mFilmStripListener = new FilmStripView.Listener() { @Override public void onDataPromoted(int dataID) { @@ -194,21 +204,25 @@ public class CameraActivity extends Activity // Check if this is in the secure camera mode. Intent intent = getIntent(); String action = intent.getAction(); - if (INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE.equals(action)) { - mSecureCamera = true; - } else if (ACTION_IMAGE_CAPTURE_SECURE.equals(action)) { + if (INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE.equals(action) + || ACTION_IMAGE_CAPTURE_SECURE.equals(action)) { mSecureCamera = true; } else { mSecureCamera = intent.getBooleanExtra(SECURE_CAMERA_EXTRA, false); } - /*TODO: if (mSecureCamera) { + + if (mSecureCamera) { + // 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); + + // Filter for screen off so that we can finish secure camera activity + // when screen is off. IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF); registerReceiver(mScreenOffReceiver, filter); - if (sScreenOffReceiver == null) { - sScreenOffReceiver = new ScreenOffReceiver(); - getApplicationContext().registerReceiver(sScreenOffReceiver, filter); - } - }*/ + } LayoutInflater inflater = getLayoutInflater(); View rootLayout = inflater.inflate(R.layout.camera, null, false); mRootView = rootLayout.findViewById(R.id.camera_app_root); @@ -289,6 +303,7 @@ public class CameraActivity extends Activity @Override public void onDestroy() { unbindMediaSaveService(); + if (mSecureCamera) unregisterReceiver(mScreenOffReceiver); super.onDestroy(); } |