Flag secure in all activities that extends BaseActionBarActivity

Closes #4152
Fixes #3327
pull/1/head
Jodson Leandro 9 years ago committed by Moxie Marlinspike
parent e808ae0ddc
commit a930ec5404

@ -14,8 +14,11 @@ import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.view.ViewConfiguration; import android.view.ViewConfiguration;
import android.view.WindowManager;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -30,6 +33,12 @@ public abstract class BaseActionBarActivity extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
} }
@Override
protected void onResume() {
super.onResume();
initializeScreenshotSecurity();
}
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
return (keyCode == KeyEvent.KEYCODE_MENU && BaseActivity.isMenuWorkaroundRequired()) || super.onKeyDown(keyCode, event); return (keyCode == KeyEvent.KEYCODE_MENU && BaseActivity.isMenuWorkaroundRequired()) || super.onKeyDown(keyCode, event);
@ -44,6 +53,16 @@ public abstract class BaseActionBarActivity extends AppCompatActivity {
return super.onKeyUp(keyCode, event); return super.onKeyUp(keyCode, event);
} }
private void initializeScreenshotSecurity() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH &&
TextSecurePreferences.isScreenSecurityEnabled(this))
{
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
} else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
}
/** /**
* Modified from: http://stackoverflow.com/a/13098824 * Modified from: http://stackoverflow.com/a/13098824
*/ */

@ -56,7 +56,6 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
protected void onResume() { protected void onResume() {
Log.w(TAG, "onResume()"); Log.w(TAG, "onResume()");
super.onResume(); super.onResume();
initializeScreenshotSecurity();
KeyCachingService.registerPassphraseActivityStarted(this); KeyCachingService.registerPassphraseActivityStarted(this);
MessageRetrievalService.registerActivityStarted(this); MessageRetrievalService.registerActivityStarted(this);
isVisible = true; isVisible = true;
@ -193,16 +192,6 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
return new Intent(this, ConversationListActivity.class); return new Intent(this, ConversationListActivity.class);
} }
private void initializeScreenshotSecurity() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH &&
TextSecurePreferences.isScreenSecurityEnabled(this))
{
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
} else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
}
private void initializeClearKeyReceiver() { private void initializeClearKeyReceiver() {
Log.w(TAG, "initializeClearKeyReceiver()"); Log.w(TAG, "initializeClearKeyReceiver()");
this.clearKeyReceiver = new BroadcastReceiver() { this.clearKeyReceiver = new BroadcastReceiver() {

Loading…
Cancel
Save