111 lines
3.8 KiB
Java
111 lines
3.8 KiB
Java
package com.psmreborn.pscertified;
|
|
|
|
import static com.psmreborn.shared.Root.*;
|
|
|
|
import com.psmreborn.nopsmdrm.R;
|
|
import com.psmreborn.shared.Files;
|
|
import com.psmreborn.shared.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.Build;
|
|
import android.os.Handler;
|
|
|
|
|
|
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 = "";
|
|
private Context ctx = null;
|
|
|
|
public void installPlaystationCertificationMagisk() throws Exception {
|
|
File magiskZip = new File(ctx.getCacheDir(), "MagiskCertify.zip");
|
|
Files.unpackResource(ctx, R.raw.magiskcertify, magiskZip);
|
|
Root.installMagiskModule(magiskZip.getAbsolutePath());
|
|
}
|
|
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";
|
|
|
|
Root.unpackResourceToLocationRoot(ctx, R.raw.ps_certified_permission, psCertifiedPermissionFile, 644, "0");
|
|
Root.unpackResourceToLocationRoot(ctx, R.raw.ps_certified_jar, psCertifiedJarFile, 644, "0");
|
|
|
|
// make it read-only again.
|
|
remountRo("/system");
|
|
}
|
|
|
|
public PsCertificatesInstaller(Context context) {
|
|
this.ctx = context;
|
|
}
|
|
|
|
@Override
|
|
protected void onPreExecute() {
|
|
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 {
|
|
if(Build.VERSION.SDK_INT >= 23) {
|
|
installPlaystationCertificationMagisk();
|
|
}
|
|
else{
|
|
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 have to reboot for changes to take effect)\nDo you want to reboot?")
|
|
.setCancelable(false)
|
|
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
Handler handler = new Handler(PsCertificatesInstaller.this.ctx.getMainLooper());
|
|
handler.post(() -> {
|
|
try {
|
|
Root.reboot();
|
|
} catch (Shell.ShellDiedException e) {}
|
|
});
|
|
}
|
|
})
|
|
.setNegativeButton("No", null).show();
|
|
}
|
|
}
|
|
}
|