fix race condition
This commit is contained in:
parent
b363371fe6
commit
dd58d20549
|
@ -17,7 +17,7 @@ public class Helper {
|
|||
|
||||
private static Context ctx;
|
||||
public static void setContext(Context context){
|
||||
ctx = context;
|
||||
ctx = context.getApplicationContext();
|
||||
}
|
||||
public static boolean isNoPsmDrmAlreadyInstalled() {
|
||||
try {
|
||||
|
|
|
@ -3,17 +3,9 @@ package com.psmreborn.nopsmdrm;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
|
@ -41,9 +33,9 @@ public class MainActivity extends Activity {
|
|||
super.onBackPressed();
|
||||
}
|
||||
|
||||
public void setPsmInstalled(){
|
||||
Button installButton = (Button) this.findViewById(R.id.installPsm);
|
||||
Button backupGamesButton = (Button) this.findViewById(R.id.dumpGames);
|
||||
public static void setPsmInstalled(Activity activity){
|
||||
Button installButton = (Button) activity.findViewById(R.id.installPsm);
|
||||
Button backupGamesButton = (Button) activity.findViewById(R.id.dumpGames);
|
||||
|
||||
installButton.setText("Update NoPsmDrm");
|
||||
backupGamesButton.setEnabled(true);
|
||||
|
|
|
@ -301,7 +301,6 @@ public class NoPsmDrmInstaller extends AsyncTask<Void, Void, Void> {
|
|||
protected Void doInBackground(Void... voids) {
|
||||
|
||||
try {
|
||||
Root.setContext(ctx);
|
||||
Helper.killPsm();
|
||||
|
||||
if (isPsmInstalled()) {
|
||||
|
@ -339,7 +338,7 @@ public class NoPsmDrmInstaller extends AsyncTask<Void, Void, Void> {
|
|||
else{
|
||||
handler.post(() ->{
|
||||
dialog.dismiss();
|
||||
((MainActivity)ctx).setPsmInstalled();
|
||||
MainActivity.setPsmInstalled((Activity)ctx);
|
||||
});
|
||||
|
||||
new AlertDialog.Builder((Activity)ctx)
|
||||
|
|
|
@ -174,7 +174,7 @@ public class Root {
|
|||
}
|
||||
|
||||
public static void setContext(Context context) throws IOException {
|
||||
ctx = context;
|
||||
ctx = context.getApplicationContext();
|
||||
Shell.setRedirectDeprecated(false);
|
||||
setupBusyBox();
|
||||
}
|
||||
|
|
|
@ -19,11 +19,12 @@ import java.io.File;
|
|||
|
||||
public class Startup extends AsyncTask<Void, Void, Void> {
|
||||
private Context ctx;
|
||||
|
||||
private Handler handler;
|
||||
private boolean wasError = false;
|
||||
private String errorMsg = "";
|
||||
|
||||
public Startup(Context context) {
|
||||
this.handler = new Handler(context.getMainLooper());
|
||||
this.ctx = context;
|
||||
}
|
||||
@Override
|
||||
|
@ -59,14 +60,14 @@ public class Startup extends AsyncTask<Void, Void, Void> {
|
|||
protected void onPostExecute(Void result) {
|
||||
TextView statusTV = (TextView) ((Activity)ctx).findViewById(R.id.errorMsg);
|
||||
Button installButton = (Button) ((Activity)ctx).findViewById(R.id.installPsm);
|
||||
Handler handler = new Handler(this.ctx.getMainLooper());
|
||||
|
||||
|
||||
if(!wasError) {
|
||||
handler.post(() -> {
|
||||
statusTV.setText("");
|
||||
|
||||
if(Helper.isNoPsmDrmAlreadyInstalled()){
|
||||
((MainActivity)ctx).setPsmInstalled();
|
||||
MainActivity.setPsmInstalled((Activity)ctx);
|
||||
};
|
||||
|
||||
installButton.setEnabled(true);
|
||||
|
@ -77,6 +78,5 @@ public class Startup extends AsyncTask<Void, Void, Void> {
|
|||
statusTV.setText("Error: " + errorMsg);
|
||||
});
|
||||
}
|
||||
this.ctx = null;
|
||||
}
|
||||
}
|
|
@ -48,8 +48,6 @@ public class PsCertificatesInstaller extends AsyncTask<Void, Void, Void> {
|
|||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
Shell.setRedirectDeprecated(false);
|
||||
|
||||
dialog = new ProgressDialog(ctx);
|
||||
dialog.setTitle("Installing PlayStation Certificates ...");
|
||||
dialog.setMessage("Please Wait ...");
|
||||
|
@ -60,7 +58,6 @@ public class PsCertificatesInstaller extends AsyncTask<Void, Void, Void> {
|
|||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
try {
|
||||
Root.setContext(ctx);
|
||||
installPlaystationCertification();
|
||||
}
|
||||
catch(Exception e){
|
||||
|
|
Loading…
Reference in New Issue
Block a user