NoPssDrm/app/src/main/java/com/psmreborn/nopsmdrm/MainActivity.java
2024-05-17 17:32:46 +12:00

117 lines
4.7 KiB
Java

package com.psmreborn.nopsmdrm;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import com.psmreborn.pscertified.PlayStationCertified;
import com.psmreborn.pscertified.PsCertificatesInstaller;
import com.psmreborn.shared.Downloader;
import com.psmreborn.shared.Helper;
import java.io.File;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
(new Startup(this)).execute();
}
@Override
public void onBackPressed(){
finish();
System.exit(0);
super.onBackPressed();
}
private void downloadPsmAlert() {
new AlertDialog.Builder((Activity)this)
.setTitle("PSM App not found!")
.setMessage("Would you like to download and install the PlayStation Mobile app?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Downloader.downloadAndInstall(MainActivity.this,
"http://psmreborn.com/psm-android/Psm1.7.0.apk");
}
})
.setNegativeButton("No", null).show();
}
private void psCertifiedAlert(){
new AlertDialog.Builder(this)
.setTitle("PS Certification Missing")
.setMessage((Build.VERSION.SDK_INT >= 23) ? "Your device appears to not be \"PlayStation Certified\"\nOn android 6+ this requires installing a Magisk module\nWould you like to install \"MagiskCertify.zip\"" :
"Your device appears to not be \"PlayStation Certified\"\nDo you want to install them?\n(Warning: modifies /system/)")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
(new PsCertificatesInstaller(MainActivity.this)).execute();
}
})
.setNegativeButton("No", null).show();
}
public void installStart(View view) {;
if(Permissions.checkPermsAlert(this)){
if(!PlayStationCertified.isPlaystationCertified(this.getApplicationContext())){
psCertifiedAlert();
}
else if(!Helper.isPsmInstalled(this)) {
downloadPsmAlert();
}
else {
new NoPsmDrmInstaller(this).execute();
}
}
}
public void dumpAllRifs(View view){
if(Permissions.checkPermsAlert(this)){
String rifOutput = new File(Environment.getExternalStorageDirectory(), "psm").getAbsolutePath();
new AlertDialog.Builder(this)
.setTitle("Backup licenses")
.setMessage("This will show a black screen for awhile\nthen a PlayStation Mobile game will start\nOnce the game starts, a backup of all your PSM licenses can be found at\n\""+rifOutput+"\"\nDo you want to do this?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
DumpAllRifs.setDumpAllFlagAndStartPsm(MainActivity.this);
}
})
.setNegativeButton("No", null).show();
}
}
public void givePsmOwnership(View view){
if(Permissions.checkPermsAlert(this)){
new AlertDialog.Builder(this)
.setTitle("Fix permissions")
.setMessage("On android 10+, games wont always show up in PSM when placed in \"com.playstation.psstore\" folder due to file permissions.\nWould you like to fix all the file permissions for PSM Games? (can take awhile)")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
FixPermissions.changePermissionsToPsm(MainActivity.this);
}
})
.setNegativeButton("No", null).show();
}
}
}