// Path: android/PythonCommon/src/com/googlecode/android_scripting/pythoncommon/PythonConstants.java
// public class PythonConstants {
//   static public final String ACTION_FILE_BROWSER = "com.googlecode.pythonforandroid.action.FILEBROWSER";
//   static public final String SL4A = "com.googlecode.android_scripting";
//   static public final String SL4A_MANAGER = "com.googlecode.android_scripting.activity.ScriptManager";
//   static public final String INSTALLED_VERSION_KEY = "py4a.installed.version";
//   static public final String INSTALLED_EXTRAS_KEY = "py4a.installed.extras";
//   static public final String INSTALLED_SCRIPTS_KEY = "py4a.installed.scripts";
//   static public final String AVAIL_VERSION_KEY = "py4a.available.version";
//   static public final String AVAIL_EXTRAS_KEY = "py4a.available.extras";
//   static public final String AVAIL_SCRIPTS_KEY = "py4a.available.scripts";
//     static public final String PREFFERED_PYEXT = "py4a.preffered.pyext";
// 
//   static public final String ENV_HOME = "PYTHONHOME";
//   static public final String ENV_PATH = "PYTHONPATH";
//   static public final String ENV_TEMP = "TEMP";
//   static public final String ENV_LD = "LD_LIBRARY_PATH";
//   static public final String ENV_EXTRAS = "PY4A_EXTRAS";
//   static public final String ENV_EGGS = "PYTHON_EGG_CACHE";
//     static public final String ENV_USERBASE = "PYTHONUSERBASE";
// }


import java.io.File;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;
import com.googlecode.android_scripting.AsyncTaskListener;
import com.googlecode.android_scripting.InterpreterInstaller;
import com.googlecode.android_scripting.Log;
import com.googlecode.android_scripting.exception.Sl4aException;
import com.googlecode.android_scripting.interpreter.InterpreterConstants;
import com.googlecode.android_scripting.interpreter.InterpreterDescriptor;
import com.googlecode.android_scripting.pythoncommon.PythonConstants;
    }
  }

  @Override
  protected boolean isInstalled() {
    if (mPreferences == null) {
      mPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
      if (mDescriptor instanceof Python3Descriptor) {
        ((Python3Descriptor) mDescriptor).setSharedPreferences(mPreferences);
      }
    }
    return mPreferences.getBoolean(InterpreterConstants.INSTALLED_PREFERENCE_KEY, false);
  }

  @Override
  protected boolean setup() {
    File tmp =
        new File(InterpreterConstants.SDCARD_ROOT + getClass().getPackage().getName()
            + InterpreterConstants.INTERPRETER_EXTRAS_ROOT, mDescriptor.getName() + "/tmp");
        if (tmp.isDirectory()) {
            // TODO: check some permissions.
        } else try {
            tmp.mkdir();
      } catch (SecurityException e) {
        Log.e(mContext, "Setup failed.", e);
        return false;
      }
      if (mDescriptor instanceof Python3Descriptor) {
        Python3Descriptor descriptor = (Python3Descriptor) mDescriptor;
        Editor editor = mPreferences.edit();
// Path: android/PythonCommon/src/com/googlecode/android_scripting/pythoncommon/PythonConstants.java
// public class PythonConstants {
//   static public final String ACTION_FILE_BROWSER = "com.googlecode.pythonforandroid.action.FILEBROWSER";
//   static public final String SL4A = "com.googlecode.android_scripting";
//   static public final String SL4A_MANAGER = "com.googlecode.android_scripting.activity.ScriptManager";
//   static public final String INSTALLED_VERSION_KEY = "py4a.installed.version";
//   static public final String INSTALLED_EXTRAS_KEY = "py4a.installed.extras";
//   static public final String INSTALLED_SCRIPTS_KEY = "py4a.installed.scripts";
//   static public final String AVAIL_VERSION_KEY = "py4a.available.version";
//   static public final String AVAIL_EXTRAS_KEY = "py4a.available.extras";
//   static public final String AVAIL_SCRIPTS_KEY = "py4a.available.scripts";
//     static public final String PREFFERED_PYEXT = "py4a.preffered.pyext";
// 
//   static public final String ENV_HOME = "PYTHONHOME";
//   static public final String ENV_PATH = "PYTHONPATH";
//   static public final String ENV_TEMP = "TEMP";
//   static public final String ENV_LD = "LD_LIBRARY_PATH";
//   static public final String ENV_EXTRAS = "PY4A_EXTRAS";
//   static public final String ENV_EGGS = "PYTHON_EGG_CACHE";
//     static public final String ENV_USERBASE = "PYTHONUSERBASE";
// }


// Path: android/Python3ForAndroid/src/com/googlecode/python3forandroid/Python3Installer.java
import java.io.File;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;
import com.googlecode.android_scripting.AsyncTaskListener;
import com.googlecode.android_scripting.InterpreterInstaller;
import com.googlecode.android_scripting.Log;
import com.googlecode.android_scripting.exception.Sl4aException;
import com.googlecode.android_scripting.interpreter.InterpreterConstants;
import com.googlecode.android_scripting.interpreter.InterpreterDescriptor;
import com.googlecode.android_scripting.pythoncommon.PythonConstants;

    }
  }

  @Override
  protected boolean isInstalled() {
    if (mPreferences == null) {
      mPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
      if (mDescriptor instanceof Python3Descriptor) {
        ((Python3Descriptor) mDescriptor).setSharedPreferences(mPreferences);
      }
    }
    return mPreferences.getBoolean(InterpreterConstants.INSTALLED_PREFERENCE_KEY, false);
  }

  @Override
  protected boolean setup() {
    File tmp =
        new File(InterpreterConstants.SDCARD_ROOT + getClass().getPackage().getName()
            + InterpreterConstants.INTERPRETER_EXTRAS_ROOT, mDescriptor.getName() + "/tmp");
        if (tmp.isDirectory()) {
            // TODO: check some permissions.
        } else try {
            tmp.mkdir();
      } catch (SecurityException e) {
        Log.e(mContext, "Setup failed.", e);
        return false;
      }
      if (mDescriptor instanceof Python3Descriptor) {
        Python3Descriptor descriptor = (Python3Descriptor) mDescriptor;
        Editor editor = mPreferences.edit();
        editor.putInt(PythonConstants.INSTALLED_VERSION_KEY, descriptor.getVersion());