summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/launcher3/lineage/LineageUtils.java15
-rw-r--r--src/com/android/launcher3/lineage/trust/TrustAppsActivity.java4
-rw-r--r--src/com/android/launcher3/lineage/trust/TrustAppsAdapter.java10
3 files changed, 21 insertions, 8 deletions
diff --git a/src/com/android/launcher3/lineage/LineageUtils.java b/src/com/android/launcher3/lineage/LineageUtils.java
index d328dd896..75a9252dd 100644
--- a/src/com/android/launcher3/lineage/LineageUtils.java
+++ b/src/com/android/launcher3/lineage/LineageUtils.java
@@ -24,10 +24,7 @@ public class LineageUtils {
* device security or if lock screen is unlocked
*/
public static void showLockScreen(Context context, String title, Runnable successRunnable) {
- final KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(
- Context.KEYGUARD_SERVICE);
-
- if (keyguardManager.isKeyguardSecure()) {
+ if (hasSecureKeyguard(context)) {
final BiometricPrompt.AuthenticationCallback authenticationCallback =
new BiometricPrompt.AuthenticationCallback() {
@Override
@@ -45,6 +42,8 @@ public class LineageUtils {
final BiometricPrompt.Builder builder = new BiometricPrompt.Builder(context)
.setTitle(title);
+ final KeyguardManager keyguardManager = context.getSystemService(KeyguardManager.class);
+
if (keyguardManager.isDeviceSecure()) {
builder.setDeviceCredentialAllowed(true);
}
@@ -55,11 +54,19 @@ public class LineageUtils {
runnable -> handler.post(runnable),
authenticationCallback);
} else {
+ // Notify the user a secure keyguard is required for protected apps,
+ // but allow to set hidden apps
Toast.makeText(context, R.string.trust_apps_no_lock_error, Toast.LENGTH_LONG)
.show();
+ successRunnable.run();
}
}
+ public static boolean hasSecureKeyguard(Context context) {
+ final KeyguardManager keyguardManager = context.getSystemService(KeyguardManager.class);
+ return keyguardManager != null && keyguardManager.isKeyguardSecure();
+ }
+
public static boolean hasPackageInstalled(Context context, String pkgName) {
try {
ApplicationInfo ai = context.getPackageManager().getApplicationInfo(pkgName, 0);
diff --git a/src/com/android/launcher3/lineage/trust/TrustAppsActivity.java b/src/com/android/launcher3/lineage/trust/TrustAppsActivity.java
index 602c0907e..61bcc7910 100644
--- a/src/com/android/launcher3/lineage/trust/TrustAppsActivity.java
+++ b/src/com/android/launcher3/lineage/trust/TrustAppsActivity.java
@@ -37,6 +37,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
+import com.android.launcher3.lineage.LineageUtils;
import com.android.launcher3.lineage.trust.db.TrustComponent;
import com.android.launcher3.lineage.trust.db.TrustDatabaseHelper;
@@ -74,7 +75,8 @@ public class TrustAppsActivity extends Activity implements
mLoadingView.setVisibility(View.VISIBLE);
mProgressBar = findViewById(R.id.hidden_apps_progress_bar);
- mAdapter = new TrustAppsAdapter(this);
+ final boolean hasSecureKeyguard = LineageUtils.hasSecureKeyguard(this);
+ mAdapter = new TrustAppsAdapter(this, hasSecureKeyguard);
mDbHelper = TrustDatabaseHelper.getInstance(this);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
diff --git a/src/com/android/launcher3/lineage/trust/TrustAppsAdapter.java b/src/com/android/launcher3/lineage/trust/TrustAppsAdapter.java
index 3d57dc5c4..6b827d6e1 100644
--- a/src/com/android/launcher3/lineage/trust/TrustAppsAdapter.java
+++ b/src/com/android/launcher3/lineage/trust/TrustAppsAdapter.java
@@ -38,9 +38,11 @@ import java.util.List;
class TrustAppsAdapter extends RecyclerView.Adapter<TrustAppsAdapter.ViewHolder> {
private List<TrustComponent> mList = new ArrayList<>();
private Listener mListener;
+ private boolean mHasSecureKeyguard;
- TrustAppsAdapter(Listener listener) {
+ TrustAppsAdapter(Listener listener, boolean hasSecureKeyguard) {
mListener = listener;
+ mHasSecureKeyguard = hasSecureKeyguard;
}
public void update(List<TrustComponent> list) {
@@ -58,7 +60,7 @@ class TrustAppsAdapter extends RecyclerView.Adapter<TrustAppsAdapter.ViewHolder>
@Override
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {
- viewHolder.bind(mList.get(i));
+ viewHolder.bind(mList.get(i), mHasSecureKeyguard);
}
@Override
@@ -87,7 +89,7 @@ class TrustAppsAdapter extends RecyclerView.Adapter<TrustAppsAdapter.ViewHolder>
mProtectedView = itemView.findViewById(R.id.item_protected_app_switch);
}
- void bind(TrustComponent component) {
+ void bind(TrustComponent component, boolean hasSecureKeyguard) {
mIconView.setImageDrawable(component.getIcon());
mLabelView.setText(component.getLabel());
@@ -96,6 +98,8 @@ class TrustAppsAdapter extends RecyclerView.Adapter<TrustAppsAdapter.ViewHolder>
mProtectedView.setImageResource(component.isProtected() ?
R.drawable.ic_protected_locked : R.drawable.ic_protected_unlocked);
+ mProtectedView.setVisibility(hasSecureKeyguard ? View.VISIBLE : View.GONE);
+
mHiddenView.setOnClickListener(v -> {
component.invertVisibility();