From 547824047250195b21943ab0450d74e4b2b472ad Mon Sep 17 00:00:00 2001 From: Orlando Aliaga Date: Thu, 19 Oct 2023 10:23:41 -0300 Subject: [PATCH] Open settings Open settings --- .../activities/CheckPasswordHtmlActivity.java | 31 +++++++++++++------ .../prey/activities/js/WebAppInterface.java | 4 +-- .../prey/events/factories/EventFactory.java | 4 ++- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/prey/activities/CheckPasswordHtmlActivity.java b/app/src/main/java/com/prey/activities/CheckPasswordHtmlActivity.java index 3c84bad4..d60139dc 100644 --- a/app/src/main/java/com/prey/activities/CheckPasswordHtmlActivity.java +++ b/app/src/main/java/com/prey/activities/CheckPasswordHtmlActivity.java @@ -10,8 +10,6 @@ import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Activity; -import android.app.NotificationManager; -import android.app.Service; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; @@ -30,12 +28,10 @@ import android.security.keystore.KeyGenParameterSpec; import android.security.keystore.KeyProperties; import android.util.Base64; -import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.webkit.WebSettings; import android.webkit.WebView; -import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -55,7 +51,6 @@ import com.prey.activities.js.CustomWebView; import com.prey.activities.js.WebAppInterface; import com.prey.backwardcompatibility.FroyoSupport; -import com.prey.events.factories.EventFactory; import com.prey.services.PreyAccessibilityService; import com.prey.services.PreyOverlayService; @@ -72,7 +67,6 @@ import java.security.spec.ECGenParameterSpec; import java.util.UUID; import java.util.concurrent.Executor; -import java.util.concurrent.Semaphore; public class CheckPasswordHtmlActivity extends AppCompatActivity { @@ -338,6 +332,20 @@ public void askForPermission() { } } + /** + * Method opens settings + */ + @TargetApi(Build.VERSION_CODES.M) + public void openSettings() { + PreyLogger.d("openSettings"); + Intent intentSetting = new Intent(); + intentSetting.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + Uri uri = Uri.fromParts("package", getPackageName(), null); + intentSetting.setData(uri); + intentSetting.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + startActivity(intentSetting); + finish(); + } public void deniedPermission() { PreyLogger.d("deniedPermission"); AlertDialog.Builder builder = new AlertDialog.Builder(this); @@ -694,17 +702,20 @@ public KeyPair getKeyPair(String keyName) throws Exception { return null; } - public void abrir(){ + /** + * Method opens biometric + */ + public void openBiometric(){ if (PreyPermission.checkBiometricSupport(this)) { // Check whether this device can authenticate with biometrics Signature signature; try { KeyPair keyPair = generateKeyPair(KEY_NAME, true); mToBeSignedMessage = Base64.encodeToString(keyPair.getPublic().getEncoded(), Base64.URL_SAFE) + ":" + - KEY_NAME + - ":" + + KEY_NAME ; + // ":" + // Generated by the server to protect against replay attack - "12345"; + // ""; signature = initSignature(KEY_NAME); } catch (Exception e) { throw new RuntimeException(e); diff --git a/app/src/main/java/com/prey/activities/js/WebAppInterface.java b/app/src/main/java/com/prey/activities/js/WebAppInterface.java index b7c84539..44f13abb 100644 --- a/app/src/main/java/com/prey/activities/js/WebAppInterface.java +++ b/app/src/main/java/com/prey/activities/js/WebAppInterface.java @@ -795,7 +795,7 @@ public void givePermissions() { PreyLogger.d("showWriteStorage:" + showStorage); PreyLogger.d("showDeniedPermission:" + showDeniedPermission); if (showDeniedPermission) { - mActivity.deniedPermission(); + mActivity.openSettings(); } else{ if (!canAccessFineLocation || !canAccessCoarseLocation || !canAccessCamera || !canAccessStorage ) { @@ -1369,7 +1369,7 @@ public void turnOnNotifications() { @JavascriptInterface public void openBiometric(String typeBiometric){ PreyConfig.getPreyConfig(mContext).setTypeBiometric(typeBiometric); - mActivity.abrir(); + mActivity.openBiometric(); } @JavascriptInterface diff --git a/app/src/main/java/com/prey/events/factories/EventFactory.java b/app/src/main/java/com/prey/events/factories/EventFactory.java index fd35db20..83ad53fa 100644 --- a/app/src/main/java/com/prey/events/factories/EventFactory.java +++ b/app/src/main/java/com/prey/events/factories/EventFactory.java @@ -13,6 +13,7 @@ import org.json.JSONObject; +import android.app.Activity; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; @@ -218,10 +219,11 @@ public static boolean isValidLowBattery(Context ctx) { * @return if you have all permissions */ public static boolean verifyNotification(Context ctx) { + boolean canAccessCamera = PreyPermission.canAccessCamera(ctx); boolean canAccessCoarseLocation = PreyPermission.canAccessCoarseLocation(ctx); boolean canAccessFineLocation = PreyPermission.canAccessFineLocation(ctx); boolean canAccessStorage = PreyPermission.canAccessStorage(ctx); - return (canAccessCoarseLocation || canAccessFineLocation) && canAccessStorage; + return canAccessCamera && (canAccessCoarseLocation || canAccessFineLocation) && canAccessStorage; } /**