aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris "Koying" Browet <cbro@semperpax.com>2014-01-23 13:49:08 +0100
committerChris "Koying" Browet <cbro@semperpax.com>2014-01-23 13:53:23 +0100
commita73c371c051f91ac2677d9af8706dbafdf9ebf18 (patch)
tree88abbd7aa8a78aac9819564e24ed9efec4a3ea5b
parent1ae61a61c184fc46b7d8665919557bfdd85bd0e3 (diff)
ADD: [droid] backdoor to define XBMC_HOME and HOME on android
-rw-r--r--tools/android/packaging/xbmc/src/org/xbmc/xbmc/Splash.java76
-rw-r--r--xbmc/android/activity/XBMCApp.cpp31
2 files changed, 78 insertions, 29 deletions
diff --git a/tools/android/packaging/xbmc/src/org/xbmc/xbmc/Splash.java b/tools/android/packaging/xbmc/src/org/xbmc/xbmc/Splash.java
index 8ecc127540..bdfadf0330 100644
--- a/tools/android/packaging/xbmc/src/org/xbmc/xbmc/Splash.java
+++ b/tools/android/packaging/xbmc/src/org/xbmc/xbmc/Splash.java
@@ -3,16 +3,19 @@ package org.xbmc.xbmc;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Enumeration;
+import java.lang.System;
+import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.Properties;
+import java.util.Enumeration;
import android.os.AsyncTask;
import android.os.Build;
@@ -49,10 +52,10 @@ public class Splash extends Activity {
private State mState = State.Uninitialized;
public AlertDialog myAlertDialog;
- private String sPackagePath;
- private String sApkDir;
- private File fPackagePath;
- private File fApkDir;
+ private String sPackagePath = "";
+ private String sXbmcHome = "";
+ private File fPackagePath = null;
+ private File fXbmcHome = null;
public void showErrorDialog(Context context, String title, String message) {
if (myAlertDialog != null && myAlertDialog.isShowing())
@@ -98,15 +101,15 @@ public class Splash extends Activity {
@Override
protected Integer doInBackground(Void... param) {
- if (fApkDir.exists()) {
+ if (fXbmcHome.exists()) {
// Remove existing files
- Log.d(TAG, "Removing existing " + fApkDir.toString());
- DeleteRecursive(fApkDir);
+ Log.d(TAG, "Removing existing " + fXbmcHome.toString());
+ DeleteRecursive(fXbmcHome);
}
- fApkDir.mkdirs();
+ fXbmcHome.mkdirs();
// Log.d(TAG, "apk: " + sPackagePath);
- // Log.d(TAG, "output: " + sApkDir);
+ // Log.d(TAG, "output: " + sXbmcHome);
ZipFile zip;
byte[] buf = new byte[4096];
@@ -130,7 +133,7 @@ public class Splash extends Activity {
if (e.getName().startsWith("assets/python2.6"))
continue;
- String sFullPath = sApkDir + "/" + e.getName();
+ String sFullPath = sXbmcHome + "/" + e.getName();
File fFullPath = new File(sFullPath);
if (e.isDirectory()) {
// Log.d(TAG, "creating dir: " + sFullPath);
@@ -156,7 +159,7 @@ public class Splash extends Activity {
zip.close();
- fApkDir.setLastModified(fPackagePath.lastModified());
+ fXbmcHome.setLastModified(fPackagePath.lastModified());
} catch (FileNotFoundException e1) {
e1.printStackTrace();
@@ -205,6 +208,45 @@ public class Splash extends Activity {
}
}
+ private void SetupEnvironment() {
+ File fProp = new File("/sdcard/xbmc_env.properties");
+ if (fProp.exists()) {
+ try {
+ Properties sysProp = new Properties(System.getProperties());
+ FileInputStream xbmcenvprop = new FileInputStream(fProp);
+ sysProp.load(xbmcenvprop);
+ System.setProperties(sysProp);
+
+ sXbmcHome = System.getProperty("xbmc.home", "");
+ fXbmcHome = new File(sXbmcHome);
+ fXbmcHome.mkdir();
+ if (!fXbmcHome.exists())
+ sXbmcHome = "";
+
+ String sXbmcdata = System.getProperty("xbmc.data", "");
+ if (!sXbmcdata.isEmpty()) {
+ File fXbmcData = new File(sXbmcdata);
+ fXbmcData.mkdir();
+ if (!fXbmcData.exists())
+ sXbmcdata = "";
+ }
+
+ } catch (NotFoundException e) {
+ Log.e(TAG, "Cannot find xbmc_env properties file");
+ } catch (IOException e) {
+ Log.e(TAG, "Failed to open xbmc_env properties file");
+ }
+ }
+ if (sXbmcHome.isEmpty()) {
+ File fCacheDir = getCacheDir();
+ sXbmcHome = fCacheDir.getAbsolutePath() + "/apk";
+ }
+
+ sPackagePath = getPackageResourcePath();
+ fPackagePath = new File(sPackagePath);
+ fXbmcHome = new File(sXbmcHome);
+ }
+
private boolean ParseCpuFeature() {
ProcessBuilder cmd;
@@ -319,14 +361,10 @@ public class Splash extends Activity {
}
if (mState != State.InError) {
- sPackagePath = getPackageResourcePath();
- fPackagePath = new File(sPackagePath);
- File fCacheDir = getCacheDir();
- sApkDir = fCacheDir.getAbsolutePath() + "/apk";
- fApkDir = new File(sApkDir);
+ SetupEnvironment();
- if (fApkDir.exists()
- && fApkDir.lastModified() >= fPackagePath.lastModified()) {
+ if (fXbmcHome.exists()
+ && fXbmcHome.lastModified() >= fPackagePath.lastModified()) {
mState = State.StartingXBMC;
}
}
diff --git a/xbmc/android/activity/XBMCApp.cpp b/xbmc/android/activity/XBMCApp.cpp
index 1b95381410..beaa577c20 100644
--- a/xbmc/android/activity/XBMCApp.cpp
+++ b/xbmc/android/activity/XBMCApp.cpp
@@ -587,21 +587,32 @@ void CXBMCApp::onNewIntent(CJNIIntent intent)
void CXBMCApp::SetupEnv()
{
setenv("XBMC_ANDROID_SYSTEM_LIBS", CJNISystem::getProperty("java.library.path").c_str(), 0);
- setenv("XBMC_ANDROID_DATA", getApplicationInfo().dataDir.c_str(), 0);
setenv("XBMC_ANDROID_LIBS", getApplicationInfo().nativeLibraryDir.c_str(), 0);
setenv("XBMC_ANDROID_APK", getPackageResourcePath().c_str(), 0);
- std::string cacheDir = getCacheDir().getAbsolutePath();
- setenv("XBMC_BIN_HOME", (cacheDir + "/apk/assets").c_str(), 0);
- setenv("XBMC_HOME", (cacheDir + "/apk/assets").c_str(), 0);
+ std::string xbmcHome = CJNISystem::getProperty("xbmc.home", "");
+ if (xbmcHome.empty())
+ {
+ std::string cacheDir = getCacheDir().getAbsolutePath();
+ setenv("XBMC_BIN_HOME", (cacheDir + "/apk/assets").c_str(), 0);
+ setenv("XBMC_HOME", (cacheDir + "/apk/assets").c_str(), 0);
+ }
+ else
+ {
+ setenv("XBMC_BIN_HOME", (xbmcHome + "/assets").c_str(), 0);
+ setenv("XBMC_HOME", (xbmcHome + "/assets").c_str(), 0);
+ }
- std::string externalDir;
- CJNIFile androidPath = getExternalFilesDir("");
- if (!androidPath)
- androidPath = getDir("org.xbmc.xbmc", 1);
+ std::string externalDir = CJNISystem::getProperty("xbmc.data", "");
+ if (externalDir.empty())
+ {
+ CJNIFile androidPath = getExternalFilesDir("");
+ if (!androidPath)
+ androidPath = getDir("org.xbmc.xbmc", 1);
- if (androidPath)
- externalDir = androidPath.getAbsolutePath();
+ if (androidPath)
+ externalDir = androidPath.getAbsolutePath();
+ }
if (!externalDir.empty())
setenv("HOME", externalDir.c_str(), 0);