summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoey <joey@lineageos.org>2020-04-04 08:57:37 (GMT)
committerLuca Stefani <luca.stefani.ge1@gmail.com>2020-06-02 20:01:14 (GMT)
commitb0838b261a6fb447fe9c4cf2513236a0736be209 (patch)
treef9372025a8a6ceb5bec5b7ca5051e5908d9c7c3d
parent4447a63df5306b7966a52116247f1c51c83a08d0 (diff)
downloadandroid_packages_apps_Trebuchet-b0838b261a6fb447fe9c4cf2513236a0736be209.zip
android_packages_apps_Trebuchet-b0838b261a6fb447fe9c4cf2513236a0736be209.tar.gz
android_packages_apps_Trebuchet-b0838b261a6fb447fe9c4cf2513236a0736be209.tar.bz2
Trebuchet: only allow hidden apps when no secure keyguard is set
Change-Id: I670a61ff3fee4d7c7d9623ce8810790f1b25224a Signed-off-by: Joey <joey@lineageos.org>
-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 d328dd8..75a9252 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 602c090..61bcc79 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 3d57dc5..6b827d6 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();