Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {

targetSdk 35

versionCode 391
versionName '2.6.12'
versionCode 395
versionName '2.6.13'

multiDexEnabled true

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.internal
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {

targetSdkVersion 33

versionCode 1001
versionName '2.6.12'
versionCode 1002
versionName '2.6.13'

multiDexEnabled true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.prey.PreyUtils;
import com.prey.R;
import com.prey.exceptions.PreyException;
import com.prey.exceptions.PreyFirebaseCrashlytics;
import com.prey.json.actions.Lock;
import com.prey.receivers.PreyDeviceAdmin;

Expand Down Expand Up @@ -123,9 +124,36 @@ public Intent getAskForAdminPrivilegesIntent() {
return intent;
}

/**
* Performs a factory reset/wipe of the device data.
* <p>
* This method attempts to wipe all data from the device using the DevicePolicyManager.
* It first tries to use the standard {@code wipeData(0)} method. If that fails and the device
* is running Android 14 (API 34, Upside Down Cake) or later, it will attempt to use
* the newer {@code wipeDevice(WIPE_RESET_PROTECTION_DATA)} method as a fallback.
*
* @throws Exception if the device administrator is not active or if the wipe operation fails.
* The exception message will contain a localized error string explaining
* the reason for the failure.
* @throws SecurityException if the caller does not have the required permissions to perform
* a device wipe operation.
*
* @see DevicePolicyManager#wipeData(int)
* @see DevicePolicyManager#wipeDevice(int)
* @see #isAdminActive()
*/
public void wipe() throws Exception {
if (isAdminActive())
policyManager.wipeData(0);
try {
policyManager.wipeData(0);
} catch (Exception e) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
policyManager.wipeDevice(DevicePolicyManager.WIPE_RESET_PROTECTION_DATA);
} else {
PreyFirebaseCrashlytics.getInstance(ctx).recordException(e);
throw e;
}
}
else
throw new Exception(ctx.getString(R.string.administrator_disabled));
}
Expand Down