Skip to content

Commit

Permalink
Merge branch 'master' into fcm_push_notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
avazirna committed Jul 24, 2023
2 parents 9558b83 + c1483f5 commit 065c2c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/src/org/commcare/activities/CommCareActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.commcare.activities;

import static org.commcare.preferences.HiddenPreferences.isFlagSecureEnabled;

import android.annotation.TargetApi;
import android.content.Context;
import android.content.DialogInterface;
Expand All @@ -18,6 +20,7 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;

Expand Down Expand Up @@ -127,6 +130,10 @@ public abstract class CommCareActivity<R> extends AppCompatActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (isFlagSecureEnabled()) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
}

FragmentManager fm = this.getSupportFragmentManager();

stateHolder = (TaskConnectorFragment<R>)fm.findFragmentByTag("state");
Expand Down
9 changes: 8 additions & 1 deletion app/src/org/commcare/preferences/HiddenPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.content.SharedPreferences;

import org.commcare.AppUtils;
import org.commcare.CommCareApp;
import org.commcare.CommCareApplication;
import org.commcare.activities.GeoPointActivity;
Expand Down Expand Up @@ -95,9 +94,13 @@ public class HiddenPreferences {
private static final String DISABLE_BACKGROUND_WORK_TIME = "disable-background-work-time";

private static final long NO_OF_HOURS_TO_WAIT_TO_RESUME_BACKGROUND_WORK = 36;

// This is to be used by CommCareFirebaseMessagingService to schedule a sync after the next Login
public final static String PENDING_SYNC_REQUEST_FROM_SERVER = "pending-sync-request-from-server";

private static final String ENABLE_ANDROID_WINDOW_SECURE_FLAG = "cc-enable-android-window-secure-flag";



/**
* @return How many seconds should a user session remain open before expiring?
Expand Down Expand Up @@ -562,4 +565,8 @@ public static void setPendingSyncRequestFromServer(boolean syncNeeded) {
.putBoolean(PENDING_SYNC_REQUEST_FROM_SERVER, syncNeeded)
.apply();
}

public static boolean isFlagSecureEnabled() {
return DeveloperPreferences.doesPropertyMatch(ENABLE_ANDROID_WINDOW_SECURE_FLAG, PrefValues.NO, PrefValues.YES);
}
}

0 comments on commit 065c2c9

Please sign in to comment.