summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorSultan Qasim Khan <sultanqasim@gmail.com>2016-02-13 01:17:38 +0100
committerDees Troy <dees_troy@teamw.in>2016-02-17 22:45:21 +0100
commit7a48a664fd00a188044da348f34cc2e800b8a3fe (patch)
treec1d1d306b315369153bec37b81a987f51a74e5fe /gui
parentRestore some old decrypt functionality (diff)
downloadandroid_bootable_recovery-7a48a664fd00a188044da348f34cc2e800b8a3fe.tar
android_bootable_recovery-7a48a664fd00a188044da348f34cc2e800b8a3fe.tar.gz
android_bootable_recovery-7a48a664fd00a188044da348f34cc2e800b8a3fe.tar.bz2
android_bootable_recovery-7a48a664fd00a188044da348f34cc2e800b8a3fe.tar.lz
android_bootable_recovery-7a48a664fd00a188044da348f34cc2e800b8a3fe.tar.xz
android_bootable_recovery-7a48a664fd00a188044da348f34cc2e800b8a3fe.tar.zst
android_bootable_recovery-7a48a664fd00a188044da348f34cc2e800b8a3fe.zip
Diffstat (limited to 'gui')
-rw-r--r--gui/patternpassword.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/gui/patternpassword.cpp b/gui/patternpassword.cpp
index 96054c15f..90566e219 100644
--- a/gui/patternpassword.cpp
+++ b/gui/patternpassword.cpp
@@ -15,7 +15,7 @@ extern "C" {
#include "../twcommon.h"
}
#include "../minuitwrp/minui.h"
-
+#include "../twrp-functions.hpp"
#include "rapidxml.hpp"
#include "objects.hpp"
@@ -403,6 +403,17 @@ int GUIPatternPassword::NotifyVarChange(const std::string& varName, const std::s
return 0;
}
+static unsigned int getSDKVersion(void) {
+ unsigned int sdkver = 23;
+ string sdkverstr = TWFunc::System_Property_Get("ro.build.version.sdk");
+ if (!sdkverstr.empty()) {
+ sdkver = (unsigned int)strtoull(sdkverstr.c_str(), NULL, 10);
+ sdkver = (sdkver != 0) ? sdkver : 23;
+ }
+ LOGINFO("sdk version is %u\n", sdkver);
+ return sdkver;
+}
+
std::string GUIPatternPassword::GeneratePassphrase()
{
char pattern[mConnectedDotsLen];
@@ -411,12 +422,17 @@ std::string GUIPatternPassword::GeneratePassphrase()
}
std::stringstream pass;
+ char buffer[3] = {0};
- for(size_t i = 0; i < mConnectedDotsLen; i++) {
- int digit = pattern[i] & 0xff;
-
+ if ((mGridSize == 3) || (getSDKVersion() >= 23)) {
+ // Marshmallow uses a consistent method
+ for (size_t i = 0; i < mConnectedDotsLen; i++) {
+ buffer[0] = (pattern[i] & 0xff) + '1';
+ pass << std::string(buffer);
+ }
+ } else {
/*
- * Okay, rant time.
+ * Okay, rant time for pre-Marshmallow ROMs.
* It turns out that Android and CyanogenMod have *two* separate methods
* for generating passphrases from patterns. This is a legacy issue, as
* Android only supports 3x3 grids, and so we need to support both.
@@ -431,14 +447,8 @@ std::string GUIPatternPassword::GeneratePassphrase()
* they are generated by taking "%.2x" for each dot index and
* concatenating the results (without adding 1).
*/
-
- if(mGridSize == 3)
- // Android (legacy) 3x3 grids.
- pass << digit + 1;
- else {
- // Other NxN grids.
- char buffer[3];
- snprintf(buffer, 3, "%.2x", digit);
+ for (size_t i = 0; i < mConnectedDotsLen; i++) {
+ snprintf(buffer, 3, "%.2x", pattern[i] & 0xff);
pass << std::string(buffer);
}
}