73 lines
2.1 KiB
Java
73 lines
2.1 KiB
Java
package com.psmreborn.nopsmdrm;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Context;
|
|
import android.content.pm.PackageManager;
|
|
import android.os.AsyncTask;
|
|
import android.os.Environment;
|
|
import android.widget.Button;
|
|
import android.widget.TextView;
|
|
|
|
import eu.chainfire.libsuperuser.Shell;
|
|
import static com.psmreborn.nopsmdrm.Helper.*;
|
|
|
|
import java.io.File;
|
|
|
|
public class Startup extends AsyncTask<Void, Void, Void> {
|
|
private Context ctx;
|
|
|
|
private boolean wasError = false;
|
|
private String errorMsg = "";
|
|
|
|
public Startup(Context context) {
|
|
this.ctx = context;
|
|
}
|
|
@Override
|
|
protected Void doInBackground(Void... params) {
|
|
try {
|
|
|
|
if(!Shell.SU.available()){
|
|
wasError = true;
|
|
errorMsg = "Unable to get root permission.";
|
|
}
|
|
if(!Helper.isPsmInstalled()){
|
|
wasError = true;
|
|
errorMsg = "PSM Application is not installed, please install it first!";
|
|
}
|
|
if(!(getPsmApp().sourceDir.startsWith("/data/") || getPsmApp().sourceDir.startsWith("/system/"))){
|
|
wasError = true;
|
|
errorMsg = "PSM Application is installed to the SD Card not internal storage.";
|
|
}
|
|
if(!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
|
|
wasError = true;
|
|
errorMsg = "No SD Card inserted.";
|
|
}
|
|
Root.setContext(ctx);
|
|
|
|
} catch (Exception e) {
|
|
wasError = true;
|
|
errorMsg = e.getMessage();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
protected void onPostExecute(Void result) {
|
|
TextView statusTV = (TextView) ((Activity)ctx).findViewById(R.id.errorMsg);
|
|
Button installButton = (Button) ((Activity)ctx).findViewById(R.id.installPsm);
|
|
|
|
if(!wasError) {
|
|
statusTV.setText("");
|
|
|
|
if(isNoPsmDrmAlreadyInstalled()){
|
|
installButton.setText("Update NoPsmDrm");
|
|
};
|
|
|
|
installButton.setEnabled(true);
|
|
|
|
}
|
|
else{
|
|
statusTV.setText("Error: "+errorMsg);
|
|
}
|
|
}
|
|
} |