Actually check if an OTA is encrypted

This commit is contained in:
Gabriele M
2017-07-26 11:57:32 +02:00
parent d854c6377b
commit 13f3849b96
2 changed files with 5 additions and 8 deletions

View File

@@ -181,8 +181,7 @@ public class UpdaterService extends Service {
update.getFile().getAbsolutePath() + Constants.UNCRYPT_FILE_EXT);
update.getFile().renameTo(uncrytpFile);
installPackage(uncrytpFile);
} else if (update.getFile().getAbsolutePath().startsWith("/data/") &&
Utils.isDeviceEncrypted(this)) {
} else if (Utils.isEncrypted(this, update.getFile())) {
// uncrypt rewrites the file so that it can be read without mounting
// the filesystem, so create a copy of it.
File uncrytpFile = new File(

View File

@@ -15,7 +15,6 @@
*/
package org.lineageos.updater.misc;
import android.app.admin.DevicePolicyManager;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
@@ -26,6 +25,7 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Environment;
import android.os.SystemProperties;
import android.os.storage.StorageManager;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
@@ -327,10 +327,8 @@ public class Utils {
Toast.makeText(context, toastMessage, Toast.LENGTH_SHORT).show();
}
public static boolean isDeviceEncrypted(Context context) {
DevicePolicyManager dpm =
(DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
int status = dpm.getStorageEncryptionStatus();
return status == DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE;
public static boolean isEncrypted(Context context, File file) {
StorageManager sm = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
return sm.isEncrypted(file);
}
}