Skip to content

Commit

Permalink
Android M support
Browse files Browse the repository at this point in the history
  • Loading branch information
nelenkov committed Oct 22, 2015
1 parent 55b253b commit f0fadf8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.nick.cryptfs.passwdmanager"
android:versionCode="1230"
android:versionName="1.2.3" >
android:versionCode="1250"
android:versionName="1.2.5" >

<uses-sdk
android:minSdkVersion="11"
Expand Down
2 changes: 1 addition & 1 deletion project.properties
Expand Up @@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-21
target=android-23
12 changes: 9 additions & 3 deletions src/org/nick/cryptfs/passwdmanager/CryptfsCommands.java
Expand Up @@ -14,6 +14,8 @@ public class CryptfsCommands {

private static final boolean IS_JB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;

private static final boolean IS_M = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;

private static final String GET_PROP_CMD_PATH = "/system/bin/getprop";
private static final String CRYPTO_STATE_PROP = "ro.crypto.state";
private static final String CRYPTO_STATE_ENCRYPTED = "encrypted";
Expand Down Expand Up @@ -51,8 +53,9 @@ public static boolean checkCryptfsPassword(String password) {
}

public static boolean checkCryptfsPasswordLollipop(String password) {
String encodedPassword = IS_M ? password : toHexAscii(password);
List<String> response = SuShell.runWithSu(String.format(
CRYPTFS_VERIFYPW_LOLLIPOP_CMD, toHexAscii(password)));
CRYPTFS_VERIFYPW_LOLLIPOP_CMD, encodedPassword));
return checkVdcResponse(response);
}

Expand Down Expand Up @@ -155,12 +158,14 @@ public static boolean changeCryptfsPassword(String newPassword,

public static boolean changeCryptfsPasswordLollipop(String newPassword,
String oldPassword) {
String encodedNewPassword = IS_M ? newPassword : toHexAscii(newPassword);

String command = CRYPTFS_CHANGEPW_PASSWORD_CMD;
if (PIN_PATTERN.matcher(newPassword).matches()) {
command = CRYPTFS_CHANGEPW_PIN_CMD;
}
List<String> response = SuShell.run("su",
String.format(command, toHexAscii(newPassword)));
String.format(command, encodedNewPassword));

boolean changeResult = checkVdcResponse(response);
boolean verifyResult = checkCryptfsPasswordLollipop(newPassword);
Expand All @@ -183,12 +188,13 @@ private static boolean changePasswordNoVerify(String newPassword) {
}

private static boolean changePasswordNoVerifyLollipop(String newPassword) {
String encodedPassword = IS_M ? newPassword : toHexAscii(newPassword);
String command = CRYPTFS_CHANGEPW_PASSWORD_CMD;
if (PIN_PATTERN.matcher(newPassword).matches()) {
command = CRYPTFS_CHANGEPW_PIN_CMD;
}
List<String> response = SuShell.run("su",
String.format(command, toHexAscii(newPassword)));
String.format(command, encodedPassword));

return checkVdcResponse(response);
}
Expand Down
14 changes: 4 additions & 10 deletions src/org/nick/cryptfs/passwdmanager/SuShell.java
Expand Up @@ -21,7 +21,7 @@ public class SuShell {

// WARNING: setting this to true will dump passwords to logcat
// set to false for release
static final boolean DEBUG = true;
static final boolean DEBUG = false;

private static final String[] SU_PACKAGES = {
"com.noshufou.android.su",
Expand Down Expand Up @@ -212,22 +212,16 @@ public static boolean patchLollipopPolicy() {
}

public static boolean isCyanogenmod() {
if (!findInPath("uname")) {
if (!findInPath("grep")) {
return false;
}

String cmd = "uname -a";
String cmd = "grep ro.cm.version /system/build.prop";
List<String> output = runWithShell(cmd);
if (output.isEmpty()) {
return false;
}

for (String line : output) {
if (line.contains("-CM-") || line.contains("-cyanogenmod-")) {
return true;
}
}

return false;
return true;
}
}

0 comments on commit f0fadf8

Please sign in to comment.