-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: techyminati <[email protected]>
- Loading branch information
1 parent
3b17eaf
commit ed9152b
Showing
15 changed files
with
8,674 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
Copyright 2019 - 2020 SKYHAWK RECOVERY PROJECT | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
using namespace std; | ||
class FileManager{ | ||
public: | ||
//Helper functions | ||
static bool isFile(string str); | ||
static bool isValidOp(string str); | ||
static string getFileName(string str); | ||
static string getFolderName(string str); | ||
static string getPrevFolderPath(string str); | ||
static bool isDirEmpty(string str); | ||
//Main Operations | ||
static string getSizeStr(string str); | ||
static bool copy(string from, string to, bool overwrite); | ||
static bool copy(string from, string to, int multiple, bool overwrite); | ||
static bool move(string from, string to, bool overwrite); | ||
static bool move(string from, string to, int multiple, bool overwrite); | ||
static bool rename(string from, string objName, bool overwrite); | ||
static bool removeFile(string path); | ||
static int removeFolder(string path); | ||
static bool remove(string path); | ||
static bool remove(string path, int multiple); | ||
static bool createFolder(string path); | ||
|
||
static string setPermission(string path, string chmod); | ||
static string setPermission(string path, int ownerR, int ownerW, int ownerX, int groupR, int groupW, int groupX, int globalR, int globalW, int globalX); | ||
static void UpdateGuiPerms(string path); | ||
static string getStrPermission(string path); | ||
|
||
//Utility Functions | ||
static string generate_Hash(string path, string hashAlgo);//hashAlgo can be md5, sha1, sha256 | ||
static string genarate_SHA1(string path); | ||
static string genarate_SHA256(string path); | ||
|
||
static bool compress(string path, string fileName, string compressionLvl = "0"); | ||
static bool compressEx(string path, string fileName, string to, string compressionLvl = "0"); | ||
static bool extract(string filePath); | ||
static bool extract(string filePath, string to); | ||
}; | ||
|
||
struct PermMode{ | ||
bool R,W,X; | ||
}; | ||
|
||
class Perm{ | ||
public: | ||
int chmod; | ||
PermMode Owner, Group, Global; | ||
|
||
void calculatePerm(int val); | ||
void calculatePerm(string path); | ||
int calculatePerm(int oR, int oW, int oX, int grR, int grW, int grX, int glR, int glW, int glX); | ||
void setPerm(int mode,int set); | ||
string getPermStr(); | ||
int getPermInt(); | ||
}; | ||
|
||
|
||
class TextTool{ | ||
public: | ||
vector<string>fileData; | ||
|
||
void getFileData(string path, bool addLineNo = false); | ||
void replaceLine(int lineNo, string lineStr); | ||
void addLine(int lineNo, string lineStr); | ||
void removeLine(int lineNo); | ||
string getLine(int lineNo); | ||
bool pushString(string path); | ||
string getDispLine(string str); | ||
~TextTool(); | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
Copyright 2019 - 2020 SKYHAWK RECOVERY PROJECT | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
#include <string> | ||
#include <iterator> | ||
#include <vector> | ||
#include <algorithm> | ||
#include "gui/gui.h" | ||
#include "gui/pages.hpp" | ||
#include "twcommon.h" | ||
#include "data.hpp" | ||
using namespace std; | ||
|
||
#include "SHRPTOOLS.hpp" | ||
#include "SHRPGUI.hpp" | ||
|
||
void processRefPlacement(int* var, bool isPlus, int refval){ | ||
int tmp=*var; | ||
if(isPlus){ | ||
*var = tmp + refval; | ||
}else{ | ||
*var = tmp - refval; | ||
} | ||
} | ||
|
||
vector<string> fetchExtn(string str){ | ||
vector<string> extensions; | ||
string tmp; | ||
int pos; | ||
if( (int)str.find_first_of(',') != -1){ | ||
do{ | ||
pos=str.find_first_of(','); | ||
extensions.push_back(str.substr(0,pos)); | ||
str=str.substr(pos+1,str.length()); | ||
}while( (int)str.find_first_of(',') != -1); | ||
pos=str.find_first_of(','); | ||
extensions.push_back(str.substr(0,pos)); | ||
}else{ | ||
extensions.push_back(str); | ||
} | ||
return extensions; | ||
} | ||
|
||
|
||
bool isExtnMatched(vector<string> extn,string fileName){ | ||
vector<string>::iterator ptr; | ||
string fileExtn=minUtils::getExtension(fileName); | ||
//LOGINFO("File Extension : %s\n",fileExtn.c_str()); | ||
for(ptr=extn.begin();ptr<extn.end();ptr++){ | ||
//LOGINFO("Comparing %s with %c\n",fileExtn.c_str(),*ptr->c_str()); | ||
if(minUtils::compare(fileExtn,*ptr)){ | ||
return true; | ||
} | ||
} | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
Copyright 2019 - 2020 SKYHAWK RECOVERY PROJECT | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
void processRefPlacement(int* var, bool isPlus, int refval); | ||
vector<string> fetchExtn(string str); | ||
vector<string> fetchExtn(string str); | ||
bool isExtnMatched(vector<string> extn,string fileName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
/* | ||
Copyright 2019 - 2020 SKYHAWK RECOVERY PROJECT | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
#include "gui/gui.hpp" | ||
#include "data.hpp" | ||
#include "partitions.hpp" | ||
#include <list> | ||
#include "twcommon.h" | ||
#include "cutils/properties.h" | ||
|
||
#include "SHRPINIT.hpp" | ||
|
||
void SHRP::INIT(){ | ||
printRecDetails(); | ||
genarateDate(); | ||
handleLock(); | ||
} | ||
|
||
|
||
void SHRP::printRecDetails(){ | ||
string tmp; | ||
gui_msg(Msg("|SKYHAWK RECOVERY PROJECT",0)); | ||
DataManager::GetValue("shrp_ver",tmp); | ||
tmp="|Version - "+tmp; | ||
gui_msg(Msg(tmp.c_str(),0)); | ||
if(DataManager::GetStrValue("is_Official") == "true"){ | ||
tmp="|Status - Official"; | ||
}else{ | ||
tmp="|Status - Unofficial"; | ||
} | ||
gui_msg(Msg(tmp.c_str(),0)); | ||
DataManager::GetValue("device_code_name",tmp); | ||
tmp="|Device - "+tmp; | ||
gui_msg(Msg(tmp.c_str(),0)); | ||
#ifdef SHRP_BUILD_DATE | ||
tmp="|Build - "+DataManager::GetStrValue("buildNo"); | ||
gui_msg(Msg(tmp.c_str(),0)); | ||
#endif | ||
} | ||
|
||
|
||
void SHRP::genarateDate(){ | ||
stringstream day; | ||
string Current_Date,month,week,main_result,day_s; | ||
time_t seconds = time(0); | ||
struct tm *t = localtime(&seconds); | ||
{ | ||
string time; | ||
DataManager::GetValue("tw_ls_time",time); | ||
DataManager::SetValue("tw_ls_time",time.c_str()); | ||
} | ||
int m=t->tm_mon+1; | ||
int y=t->tm_year+1900; | ||
int d=t->tm_mday; | ||
static int tmp[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; | ||
y -= m < 3; | ||
int w=( y + y / 4 - y / 100 + y / 400 + tmp[m - 1] + d) % 7; | ||
switch(t->tm_mon+1){ | ||
case 1:month=" Jan"; | ||
break; | ||
case 2:month=" Feb"; | ||
break; | ||
case 3:month=" Mar"; | ||
break; | ||
case 4:month=" Apr"; | ||
break; | ||
case 5:month=" May"; | ||
break; | ||
case 6:month=" Jun"; | ||
break; | ||
case 7:month=" Jul"; | ||
break; | ||
case 8:month=" Aug"; | ||
break; | ||
case 9:month=" Sep"; | ||
break; | ||
case 10:month=" Oct"; | ||
break; | ||
case 11:month=" Nov"; | ||
break; | ||
case 12:month=" Dec"; | ||
break; | ||
} | ||
switch(w){ | ||
case 0:week="Sun, "; | ||
break; | ||
case 1:week="Mon, "; | ||
break; | ||
case 2:week="Tue, "; | ||
break; | ||
case 3:week="Wed, "; | ||
break; | ||
case 4:week="Thu, "; | ||
break; | ||
case 5:week="Fri, "; | ||
break; | ||
case 6:week="Sat, "; | ||
break; | ||
} | ||
day<<t->tm_mday; | ||
day>>day_s; | ||
main_result=week+day_s+month; | ||
DataManager::SetValue("c_lock_screen_date",main_result); | ||
} | ||
|
||
|
||
void SHRP::handleLock(){ | ||
FILE *f; | ||
char hello[50]; | ||
f = fopen("/sdcard/SHRP/data/slts","r"); | ||
if(f == NULL){ | ||
f = fopen("/twres/slts","r"); | ||
} | ||
if(f != NULL){ | ||
fgets(hello, 50, f); | ||
fclose(f); | ||
if(hello[0] == '1'){ | ||
//Password Protected Recovery | ||
DataManager::SetValue("c_target_destination","c_pass_capture"); | ||
DataManager::SetValue("recLockStatus",1); | ||
property_set("shrp.lock","1"); | ||
PartitionManager.Disable_MTP(); | ||
}else if(hello[0] == '2'){ | ||
//Pattern Protected Recovery | ||
DataManager::SetValue("c_target_destination","c_patt_capture"); | ||
DataManager::SetValue("recLockStatus",2); | ||
property_set("shrp.lock","1"); | ||
PartitionManager.Disable_MTP(); | ||
}else{ | ||
//Unprotected Recovery | ||
DataManager::SetValue("c_target_destination","main2"); | ||
DataManager::SetValue("recLockStatus",0); | ||
property_set("shrp.lock","0"); | ||
} | ||
}else{ | ||
DataManager::SetValue("c_target_destination","c_recBlocked"); | ||
DataManager::SetValue("recLockStatus",69); | ||
property_set("shrp.lock","1"); | ||
PartitionManager.Disable_MTP(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
Copyright 2019 - 2020 SKYHAWK RECOVERY PROJECT | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
class SHRP{ | ||
public: | ||
static void INIT(); | ||
static bool isOfficial(string target); | ||
private: | ||
static void printRecDetails(); | ||
static void genarateDate(); | ||
static void handleLock(); | ||
}; |
Oops, something went wrong.