99 lines
3.3 KiB
Java
99 lines
3.3 KiB
Java
package com.psmreborn.nopsmdrm.pscertified;
|
|
|
|
import static com.psmreborn.nopsmdrm.Root.*;
|
|
|
|
import com.psmreborn.nopsmdrm.MainActivity;
|
|
import com.psmreborn.nopsmdrm.NoPsmDrmInstaller;
|
|
import com.psmreborn.nopsmdrm.R;
|
|
import com.psmreborn.nopsmdrm.Root;
|
|
|
|
import android.app.Activity;
|
|
import android.app.AlertDialog;
|
|
import android.app.ProgressDialog;
|
|
import android.content.Context;
|
|
import android.content.DialogInterface;
|
|
import android.os.AsyncTask;
|
|
import android.os.PowerManager;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
|
|
import eu.chainfire.libsuperuser.Shell;
|
|
|
|
public class PsCertificatesInstaller extends AsyncTask<Void, Void, Void> {
|
|
private ProgressDialog dialog = null;
|
|
private boolean wasError = false;
|
|
private String errorMsg = "";
|
|
Context ctx = null;
|
|
|
|
public void installPlaystationCertification() throws IOException, Shell.ShellDiedException {
|
|
// remount /system as read-write
|
|
remountRw("/system");
|
|
|
|
String psCertifiedPermissionFile = "/system/etc/permissions/com.playstation.playstationcertified.xml";
|
|
String psCertifiedJarFile = "/system/framework/com.playstation.playstationcertified.jar";
|
|
|
|
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");
|
|
}
|
|
|
|
public PsCertificatesInstaller(Context context) {
|
|
this.ctx = context;
|
|
}
|
|
|
|
@Override
|
|
protected void onPreExecute() {
|
|
Shell.setRedirectDeprecated(false);
|
|
|
|
dialog = new ProgressDialog(ctx);
|
|
dialog.setTitle("Installing PlayStation Certificates ...");
|
|
dialog.setMessage("Please Wait ...");
|
|
dialog.setIndeterminate(true);
|
|
dialog.setCancelable(false);
|
|
dialog.show();
|
|
}
|
|
@Override
|
|
protected Void doInBackground(Void... voids) {
|
|
try {
|
|
Root.setContext(ctx);
|
|
installPlaystationCertification();
|
|
}
|
|
catch(Exception e){
|
|
this.wasError = true;
|
|
this.errorMsg = e.getMessage();
|
|
return null;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
protected void onPostExecute(Void result) {
|
|
dialog.dismiss();
|
|
|
|
if(wasError) {
|
|
new AlertDialog.Builder((Activity)ctx)
|
|
.setTitle("Error Occurred.")
|
|
.setMessage(this.errorMsg)
|
|
.setCancelable(false)
|
|
.setPositiveButton("Ok",null).show();
|
|
}
|
|
else{
|
|
new AlertDialog.Builder((Activity)ctx)
|
|
.setTitle("Installed!")
|
|
.setMessage("Your device is now \"Playstation Certified\"\n(You may have to reboot for changes to take effect)\n\nWould you like to patch the PSM application also?")
|
|
.setCancelable(false)
|
|
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
|
(new NoPsmDrmInstaller(PsCertificatesInstaller.this.ctx)).execute();
|
|
}
|
|
})
|
|
.setNegativeButton("No", null).show();
|
|
}
|
|
}
|
|
}
|