make code a bit easier to follow
This commit is contained in:
parent
7f57193a8f
commit
b80248c069
|
@ -26,13 +26,11 @@ import eu.chainfire.libsuperuser.Shell;
|
|||
// Sorry if this is kinda hard to follow ...
|
||||
|
||||
public class NoPsmDrmInstaller extends AsyncTask<Void, Void, Void> {
|
||||
protected static Boolean psCertify = false;
|
||||
private boolean wasError = false;
|
||||
private String errorMsg = "";
|
||||
private ProgressDialog dialog = null;
|
||||
private Context ctx = null;
|
||||
private StringEncryptor stringEncryptor = null;
|
||||
private PlayStationCertified playStationCertified = null;
|
||||
|
||||
public NoPsmDrmInstaller(Context context){
|
||||
this.ctx = context;
|
||||
|
@ -122,6 +120,7 @@ public class NoPsmDrmInstaller extends AsyncTask<Void, Void, Void> {
|
|||
}
|
||||
|
||||
private void makeDirs() throws PackageManager.NameNotFoundException, Shell.ShellDiedException {
|
||||
mkdirAndChmodChown(new File(getPsmApp().dataDir, "cache").getAbsolutePath(), 771, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
mkdirAndChmodChown(new File(getPsmApp().dataDir, "shared_prefs").getAbsolutePath(), 771, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
mkdirAndChmodChown(new File(getPsmApp().dataDir, "files").getAbsolutePath(), 771, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
mkdirAndChmodChown(new File(new File(getPsmApp().dataDir, "files"), "kdc").getAbsolutePath(), 771, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
|
@ -146,27 +145,27 @@ public class NoPsmDrmInstaller extends AsyncTask<Void, Void, Void> {
|
|||
String tmpPrefsFolder = ctx.getCacheDir().getAbsolutePath();
|
||||
|
||||
// work out paths to each file ...
|
||||
String csigninInfo = new File(tmpPrefsFolder, "SigninInfo.xml").getAbsolutePath();
|
||||
String cpsstorePrefs = new File(tmpPrefsFolder, "com.playstation.psstore_preferences.xml").getAbsolutePath();
|
||||
String crunningContentInfo = new File(tmpPrefsFolder, "RunningContentInfo.xml").getAbsolutePath();
|
||||
String clocalLibrary = new File(tmpPrefsFolder, "LocalLibrary.xml").getAbsolutePath();
|
||||
String c_signinInfo = new File(tmpPrefsFolder, "SigninInfo.xml").getAbsolutePath();
|
||||
String c_psstorePrefs = new File(tmpPrefsFolder, "com.playstation.psstore_preferences.xml").getAbsolutePath();
|
||||
String c_runningContentInfo = new File(tmpPrefsFolder, "RunningContentInfo.xml").getAbsolutePath();
|
||||
String c_localLibrary = new File(tmpPrefsFolder, "LocalLibrary.xml").getAbsolutePath();
|
||||
|
||||
String rsigninInfo = new File(sharedPrefsPath, "SigninInfo.xml").getAbsolutePath();
|
||||
String rpsstorePrefs = new File(sharedPrefsPath, "com.playstation.psstore_preferences.xml").getAbsolutePath();
|
||||
String rrunningContentInfo = new File(sharedPrefsPath, "RunningContentInfo.xml").getAbsolutePath();
|
||||
String rlocalLibrary = new File(sharedPrefsPath, "LocalLibrary.xml").getAbsolutePath();
|
||||
String r_signinInfo = new File(sharedPrefsPath, "SigninInfo.xml").getAbsolutePath();
|
||||
String r_psstorePrefs = new File(sharedPrefsPath, "com.playstation.psstore_preferences.xml").getAbsolutePath();
|
||||
String r_runningContentInfo = new File(sharedPrefsPath, "RunningContentInfo.xml").getAbsolutePath();
|
||||
String r_localLibrary = new File(sharedPrefsPath, "LocalLibrary.xml").getAbsolutePath();
|
||||
|
||||
// generate shared_prefs
|
||||
writeTxtFile(csigninInfo, "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n<map>\n<string name=\"SignedInUsername\">"+emailAddress+"</string>\n<boolean name=\"PassSave\" value=\"true\" />\n<string name=\"Password\">"+password+"</string>\n<boolean name=\"AutoSignIn\" value=\"true\" />\n</map>\n");
|
||||
writeTxtFile(cpsstorePrefs, "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n<map>\n<boolean name=\"key_upgradeDownloadTableForNeedWifi\" value=\"true\" />\n<string name=\"last_signin_account_id\">"+accountId+"</string>\n<long name=\"last_signin_account_region\" value=\"2\" />\n<int name=\"key_psstore\" value=\"1\" />\n<int name=\"key_downloader\" value=\"1\" />\n<int name=\"psm_license_agree_version_code\" value=\"1170\" />\n<boolean name=\"key_notDisplayAgainEndOfSupportPreNavi\" value=\"true\" />\n<int name=\"key_xmlcache\" value=\"1\" />\n<string name=\"last_signin_account_country\">US</string>\n<boolean name=\"key_notDisplayAgainContentStartNavi\" value=\"true\" />\n<int name=\"key_startcontent\" value=\"1\" />\n<int name=\"key_nsxevent\" value=\"1\" />\n<boolean name=\"key_upgradeLibraryTableForLocationUseConfirmationDate\" value=\"true\" />\n<int name=\"key_install\" value=\"1\" />\n<string name=\"update_md5\">387ce7e424258aef426aaa5be8a1638a</string>\n<boolean name=\"psm_license_agree\" value=\"true\" />\n<int name=\"key_guestinfo\" value=\"1\" />\n<string name=\"last_signin_account_language\">en</string>\n<int name=\"key_cache\" value=\"2\" />\n<int name=\"key_signinfo\" value=\"2\" />\n</map>\n");
|
||||
writeTxtFile(crunningContentInfo, "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n<map>\n<null name=\"title_id\" />\n<null name=\"next_title_id\" />\n</map>\n");
|
||||
writeTxtFile(clocalLibrary, "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n<map>\n<boolean name=\"notDisplayAgain\" value=\"true\" />\n<int name=\"sortType\" value=\"0\" />\n<boolean name=\"isList\" value=\"false\" />\n</map>\n");
|
||||
writeTxtFile(c_signinInfo, "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n<map>\n<string name=\"SignedInUsername\">"+emailAddress+"</string>\n<boolean name=\"PassSave\" value=\"true\" />\n<string name=\"Password\">"+password+"</string>\n<boolean name=\"AutoSignIn\" value=\"true\" />\n</map>\n");
|
||||
writeTxtFile(c_psstorePrefs, "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n<map>\n<boolean name=\"key_upgradeDownloadTableForNeedWifi\" value=\"true\" />\n<string name=\"last_signin_account_id\">"+accountId+"</string>\n<long name=\"last_signin_account_region\" value=\"2\" />\n<int name=\"key_psstore\" value=\"1\" />\n<int name=\"key_downloader\" value=\"1\" />\n<int name=\"psm_license_agree_version_code\" value=\"1170\" />\n<boolean name=\"key_notDisplayAgainEndOfSupportPreNavi\" value=\"true\" />\n<int name=\"key_xmlcache\" value=\"1\" />\n<string name=\"last_signin_account_country\">US</string>\n<boolean name=\"key_notDisplayAgainContentStartNavi\" value=\"true\" />\n<int name=\"key_startcontent\" value=\"1\" />\n<int name=\"key_nsxevent\" value=\"1\" />\n<boolean name=\"key_upgradeLibraryTableForLocationUseConfirmationDate\" value=\"true\" />\n<int name=\"key_install\" value=\"1\" />\n<string name=\"update_md5\">387ce7e424258aef426aaa5be8a1638a</string>\n<boolean name=\"psm_license_agree\" value=\"true\" />\n<int name=\"key_guestinfo\" value=\"1\" />\n<string name=\"last_signin_account_language\">en</string>\n<int name=\"key_cache\" value=\"2\" />\n<int name=\"key_signinfo\" value=\"2\" />\n</map>\n");
|
||||
writeTxtFile(c_runningContentInfo, "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n<map>\n<null name=\"title_id\" />\n<null name=\"next_title_id\" />\n</map>\n");
|
||||
writeTxtFile(c_localLibrary, "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n<map>\n<boolean name=\"notDisplayAgain\" value=\"true\" />\n<int name=\"sortType\" value=\"0\" />\n<boolean name=\"isList\" value=\"false\" />\n</map>\n");
|
||||
|
||||
// copy to the correct place and set permissions properly.
|
||||
copyChmodAndChown(csigninInfo, rsigninInfo, 660, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
copyChmodAndChown(cpsstorePrefs, rpsstorePrefs, 660, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
copyChmodAndChown(crunningContentInfo, rrunningContentInfo, 660, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
copyChmodAndChown(clocalLibrary, rlocalLibrary, 660, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
copyChmodAndChown(c_signinInfo, r_signinInfo, 660, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
copyChmodAndChown(c_psstorePrefs, r_psstorePrefs, 660, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
copyChmodAndChown(c_runningContentInfo, r_runningContentInfo, 660, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
copyChmodAndChown(c_localLibrary, r_localLibrary, 660, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
|
||||
}
|
||||
|
||||
|
@ -175,55 +174,37 @@ public class NoPsmDrmInstaller extends AsyncTask<Void, Void, Void> {
|
|||
private void installNoPsmDrmModules() throws Exception {
|
||||
String nativeLibsFolder = getPsmApp().nativeLibraryDir;
|
||||
|
||||
String rlibPsmKdcFile = new File(nativeLibsFolder, "libpsmkdc_jni.so").getAbsolutePath();
|
||||
String rlibDefaultFile = new File(nativeLibsFolder, "libdefault.so").getAbsolutePath();
|
||||
String libPsmKdcFile = new File(nativeLibsFolder, "libpsmkdc_jni.so").getAbsolutePath();
|
||||
String libDefaultFile = new File(nativeLibsFolder, "libdefault.so").getAbsolutePath();
|
||||
String realLibDefaultFile = new File(nativeLibsFolder, "libdefault_real.so").getAbsolutePath();
|
||||
boolean realLibDefaultExist = fileExistRoot(realLibDefaultFile);
|
||||
|
||||
if(!realLibDefaultExist) {
|
||||
if(!fileExistRoot(realLibDefaultFile)) {
|
||||
// if libdefault_real.so not found, then rename libdefault.so to libdefault_real.so ...
|
||||
moveFileRoot(rlibDefaultFile, realLibDefaultFile);
|
||||
moveFileRoot(libDefaultFile, realLibDefaultFile);
|
||||
}
|
||||
|
||||
String clibDefault = new File(ctx.getCacheDir(), "libdefault.so").getAbsolutePath();
|
||||
String clibPsmKdc = new File(ctx.getCacheDir(), "libpsmkdc_jni.so").getAbsolutePath();
|
||||
|
||||
// unpack the library files ...
|
||||
unpackResource(R.raw.libdefault, new File(clibDefault));
|
||||
unpackResource(R.raw.libpsmkdc_jni, new File(clibPsmKdc));
|
||||
|
||||
copyChmodAndChown(clibDefault, rlibDefaultFile, 755, "system");
|
||||
copyChmodAndChown(clibPsmKdc, rlibPsmKdcFile, 755, "system");
|
||||
|
||||
unpackResourceToLocationRoot(R.raw.libdefault, libDefaultFile, 755, "system");
|
||||
unpackResourceToLocationRoot(R.raw.libpsmkdc_jni, libPsmKdcFile, 755, "system");
|
||||
}
|
||||
private void installDatabase() throws Exception {
|
||||
String libraryDbFile = new File(ctx.getCacheDir(), "library.db").getAbsolutePath();
|
||||
|
||||
String databasesFolder = new File(getPsmApp().dataDir, "databases").getAbsolutePath();
|
||||
String rlibraryDbFile = new File(databasesFolder, "library.db").getAbsolutePath();
|
||||
String libraryDbFile = new File(databasesFolder, "library.db").getAbsolutePath();
|
||||
|
||||
unpackResource(R.raw.library, new File(libraryDbFile));
|
||||
copyChmodAndChown(libraryDbFile, rlibraryDbFile, 660, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
unpackResourceToLocationRoot(R.raw.library, libraryDbFile, 660, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
}
|
||||
|
||||
private void installDeviceList() throws PackageManager.NameNotFoundException, IOException, Shell.ShellDiedException {
|
||||
String cacheFolder = new File(getPsmApp().dataDir, "cache").getAbsolutePath();
|
||||
|
||||
// extract the regular device list ...
|
||||
String rdeviceList2 = new File(cacheFolder, "deviceList2.dat").getAbsolutePath();
|
||||
String cdeviceList2 = new File(ctx.getCacheDir(), "deviceList2.dat").getAbsolutePath();
|
||||
|
||||
unpackResource(R.raw.device_list2, new File(cdeviceList2));
|
||||
copyChmodAndChown(cdeviceList2, rdeviceList2, 660, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
String deviceList2File = new File(cacheFolder, "deviceList2.dat").getAbsolutePath();
|
||||
unpackResourceToLocationRoot(R.raw.device_list2, deviceList2File, 660, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
|
||||
|
||||
// extract the additional certified devices list ...
|
||||
String radditionalCerts = new File(cacheFolder, "addtionalCertifiedDevList.dat").getAbsolutePath();
|
||||
String cadditionalCerts = new File(ctx.getCacheDir(), "addtionalCertifiedDevList.dat").getAbsolutePath();
|
||||
|
||||
unpackResource(R.raw.aditional_certified_devices_list, new File(cadditionalCerts));
|
||||
copyChmodAndChown(cadditionalCerts, radditionalCerts, 660, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
|
||||
String additionalCertsFile = new File(cacheFolder, "addtionalCertifiedDevList.dat").getAbsolutePath();
|
||||
unpackResourceToLocationRoot(R.raw.aditional_certified_devices_list, additionalCertsFile, 660, String.valueOf(stringEncryptor.getPsmUid()));
|
||||
}
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
|
|
|
@ -84,11 +84,21 @@ public class Root {
|
|||
|
||||
outStream.flush();
|
||||
}
|
||||
public static void unpackResource(int resourceId, File outputFile) throws IOException {
|
||||
public static void unpackResourceToLocationRoot(int resourceId, String outputDir, int chmod, String chown) throws IOException, Shell.ShellDiedException {
|
||||
Log.i("ROOT", "Unpacking resource and root copying to : " + outputDir);
|
||||
File tmpFile = File.createTempFile("tmp", "file", ctx.getCacheDir());
|
||||
tmpFile.createNewFile();
|
||||
|
||||
unpackResource(resourceId, tmpFile);
|
||||
copyChmodAndChown(tmpFile.getAbsolutePath(), outputDir, chmod, chown);
|
||||
|
||||
tmpFile.delete();
|
||||
}
|
||||
private static void unpackResource(int resourceId, File outputFile) throws IOException {
|
||||
Log.i("ROOT", "Unpacking resource to : " + outputFile);
|
||||
InputStream resourceStream = ctx.getResources().openRawResource(resourceId);
|
||||
|
||||
FileOutputStream fs = new FileOutputStream(outputFile);
|
||||
FileOutputStream fs = new FileOutputStream(outputFile, false);
|
||||
copyTo(resourceStream, fs);
|
||||
fs.close();
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ public class PlayStationCertified {
|
|||
}
|
||||
|
||||
public boolean isPlaystationCertified() {
|
||||
// check for signature file
|
||||
HashSet installedFrameworks = new HashSet(Arrays.asList(ctx.getPackageManager().getSystemSharedLibraryNames()));
|
||||
if(installedFrameworks.contains("com.playstation.playstationcertified")){
|
||||
return true;
|
||||
|
|
|
@ -31,17 +31,11 @@ public class PsCertificatesInstaller extends AsyncTask<Void, Void, Void> {
|
|||
// remount /system as read-write
|
||||
remountRw("/system");
|
||||
|
||||
String cpsCertifiedPerms = new File(ctx.getCacheDir(), "com.playstation.playstationcertified.xml").getAbsolutePath();
|
||||
String cpsCertifiedjar = new File(ctx.getCacheDir(), "com.playstation.playstationcertified.jar").getAbsolutePath();
|
||||
String psCertifiedPermissionFile = "/system/etc/permissions/com.playstation.playstationcertified.xml";
|
||||
String psCertifiedJarFile = "/system/framework/com.playstation.playstationcertified.jar";
|
||||
|
||||
unpackResource(R.raw.ps_certified_permission, new File(cpsCertifiedPerms));
|
||||
unpackResource(R.raw.ps_certified_jar, new File(cpsCertifiedjar));
|
||||
|
||||
String rpsCertifiedPerms = "/system/etc/permissions/com.playstation.playstationcertified.xml";
|
||||
String rpsCertifiedJar = "/system/framework/com.playstation.playstationcertified.jar";
|
||||
|
||||
copyChmodAndChown(cpsCertifiedPerms, rpsCertifiedPerms, 644, "root");
|
||||
copyChmodAndChown(cpsCertifiedjar, rpsCertifiedJar, 644, "root");
|
||||
unpackResourceToLocationRoot(R.raw.ps_certified_permission, psCertifiedPermissionFile, 644, "root");
|
||||
unpackResourceToLocationRoot(R.raw.ps_certified_jar, psCertifiedJarFile, 644, "root");
|
||||
|
||||
// make it read-only again.
|
||||
remountRo("/system");
|
||||
|
|
Loading…
Reference in New Issue