Skip to content

Commit

Permalink
Open settings
Browse files Browse the repository at this point in the history
Open settings
  • Loading branch information
oaliaga committed Oct 19, 2023
1 parent 256979a commit 5478240
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;

Expand All @@ -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 {

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/prey/activities/js/WebAppInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -1369,7 +1369,7 @@ public void turnOnNotifications() {
@JavascriptInterface
public void openBiometric(String typeBiometric){
PreyConfig.getPreyConfig(mContext).setTypeBiometric(typeBiometric);
mActivity.abrir();
mActivity.openBiometric();
}

@JavascriptInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import org.json.JSONObject;

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
Expand Down Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 5478240

Please sign in to comment.