aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris \"Koying\" Browet <cbro@semperpax.com>2014-07-27 14:45:33 +0200
committerChris "Koying" Browet <cbro@semperpax.com>2014-10-22 18:02:45 +0200
commit5f5d8c86490510f49b82d05ff16011bfbf4cbfa8 (patch)
tree623d30a1f0d3ae7150c50641fc63d323a5d04599
parent34923de71b9e1597d5a610d9237c440909eaeb0c (diff)
CHG: [droid] refactor packaging to allow obb google extension apk
-rw-r--r--Makefile.in8
-rw-r--r--tools/android/packaging/Makefile.in116
-rwxr-xr-xtools/android/packaging/apksign10
-rw-r--r--tools/android/packaging/xbmc/AndroidManifest.xml.in2
-rw-r--r--tools/android/packaging/xbmc/src/org/xbmc/kodi/Splash.java.in52
5 files changed, 139 insertions, 49 deletions
diff --git a/Makefile.in b/Makefile.in
index 658745a8d1..8cb677c36b 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -554,11 +554,11 @@ ifeq ($(findstring osx,@ARCH@), osx)
else
install: install-binaries install-arch install-datas
-apk: apk-clean install
- make -C tools/android/packaging
+apk obb apk-unsigned apk-obb apk-obb-unsigned apk-noobb: install
+ make -C tools/android/packaging $@
-apk-clean:
- make -C tools/android/packaging clean
+apk-clean apk-sign:
+ make -C tools/android/packaging $@
install-binaries: install-scripts
@echo "Copying @APP_NAME_LC@ binary to $(DESTDIR)$(libdir)/@APP_NAME_LC@/"
diff --git a/tools/android/packaging/Makefile.in b/tools/android/packaging/Makefile.in
index c2b11244b1..e4dcc1bc65 100644
--- a/tools/android/packaging/Makefile.in
+++ b/tools/android/packaging/Makefile.in
@@ -13,6 +13,16 @@ EXCLUDED_ADDONS = screensaver.rsxs.euphoria visualization.dxspectrum visualizati
XBMCROOT = $(shell cd $(CURDIR)/../../..; pwd)
COPYDIRS = system addons language media
GCC_VERSION=$(shell $(CC) -dumpversion)
+ZIP=zip
+
+SIGN_STORE=~/.android/debug.keystore
+SIGN_STOREPASS=android
+SIGN_KEY=androiddebugkey
+SIGN_KEYPASS=
+
+ifneq ($(strip $(SIGN_KEYPASS)),)
+SIGN_KEYPASS_OPT=-keypass $(SIGN_KEYPASS)
+endif
X86OVERRIDES=XBMC_OVERRIDE_HOST=i686-android-linux XBMC_OVERRIDE_TOOLCHAIN=$(XBMC_X86_TOOLCHAIN)
ARMOVERRIDES=XBMC_OVERRIDE_HOST=arm-linux-androideabi XBMC_OVERRIDE_TOOLCHAIN=$(XBMC_ARM_TOOLCHAIN)
@@ -26,6 +36,7 @@ CPU=x86
endif
ifeq ($(findstring arm,$(CPU)),arm)
ARCH=arm
+CPU=armeabi-v7a
endif
#older ndk x86
@@ -41,57 +52,66 @@ ifneq ($(shell test -f $(GDBPATH) && echo 1),1)
GDBPATH=$(NDKROOT)/prebuilt/android-$(ARCH)/gdbserver/gdbserver
endif
-all: package
SRCLIBS = $(addprefix $(PREFIX)/lib/,$(OBJS)) $(addprefix $(PREFIX)/lib/$(SDK_PLATFORM)/,$(PLATFORM_OBJS))
DSTLIBS = $(CPU)/lib/lib@APP_NAME_LC@.so $(addprefix $(CPU)/lib/,$(OBJS)) $(addprefix $(CPU)/lib/,$(PLATFORM_OBJS))
libs= $(DSTLIBS)
-multi: x86 arm
- @cp images/@APP_NAME_LC@app-debug-skeleton.apk images/@APP_NAME_LC@app-debug-multi-unaligned.apk
- @cd xbmc; zip -r -q ../images/@APP_NAME_LC@app-debug-multi-unaligned.apk lib/ assets
- @jarsigner -sigalg MD5withRSA -digestalg SHA1 -keystore ~/.android/debug.keystore -storepass android images/@APP_NAME_LC@app-debug-multi-unaligned.apk androiddebugkey
- @$(ZIPALIGN) -f 4 images/@APP_NAME_LC@app-debug-multi-unaligned.apk $(XBMCROOT)/@APP_NAME_LC@app-multi-debug.apk
- @rm images/@APP_NAME_LC@app-debug-multi-unaligned.apk
- @echo "$(XBMCROOT)/@APP_NAME_LC@app-multi-debug.apk created"
+all: apk
-package: extras
- @cp images/@APP_NAME_LC@app-debug-skeleton.apk images/@APP_NAME_LC@app-debug-$(CPU)-unaligned.apk
- @javac -classpath $(SDKROOT)/platforms/$(SDK_PLATFORM)/android.jar:xbmc/obj -d xbmc/obj -sourcepath xbmc/src xbmc/src/*.java
- @javac -classpath $(SDKROOT)/platforms/$(SDK_PLATFORM)/android.jar:xbmc/obj -d xbmc/obj -sourcepath xbmc/src xbmc/src/org/xbmc/kodi/*.java
- @$(DX) --dex --output=xbmc/classes.dex xbmc/obj
- @cd xbmc; zip -r -q ../images/@APP_NAME_LC@app-debug-$(CPU)-unaligned.apk lib/$(CPU) assets classes.dex
- @jarsigner -sigalg MD5withRSA -digestalg SHA1 -keystore ~/.android/debug.keystore -storepass android images/@APP_NAME_LC@app-debug-$(CPU)-unaligned.apk androiddebugkey
- @$(ZIPALIGN) -f 4 images/@APP_NAME_LC@app-debug-$(CPU)-unaligned.apk $(XBMCROOT)/@APP_NAME_LC@app-$(CPU)-debug.apk
- @rm images/@APP_NAME_LC@app-debug-$(CPU)-unaligned.apk
- @echo "$(XBMCROOT)/@APP_NAME_LC@app-$(CPU)-debug.apk created"
+apk: apk-clean sharedapk package apk-sign
-extras: libs
- rm -rf xbmc/assets
- mkdir -p xbmc/assets xbmc/res xbmc/res/raw xbmc/assets/python2.6/lib/
- cp -rfp $(PREFIX)/share/@APP_NAME_LC@/* ./xbmc/assets
- find `pwd`/xbmc/assets/ -depth -name ".git" -exec rm -rf {} \;
- find `pwd`/xbmc/assets/system/ -name "*.so" -exec rm {} \;
- find `pwd`/xbmc/assets/addons/skin.*/media/* -depth -not -iname "Textures.xbt" -exec rm -rf {} \;
- find `pwd`/xbmc/assets/system/keymaps/ -depth -name "joystick*.xml" -exec rm {} \;
- mv -f `pwd`/xbmc/assets/system/keymaps/joystick.xml.sample `pwd`/xbmc/assets/system/keymaps/joystick.xml
- @echo "native_arch=$(ARCH)" > xbmc/res/raw/xbmc.properties
- cd xbmc/assets/addons; rm -rf $(EXCLUDED_ADDONS)
+obb: apk-clean sharedobb
+
+apk-unsigned: apk-clean sharedapk package
+
+apk-obb: apk-clean sharedobb package apk-sign
+
+apk-obb-unsigned: apk-clean sharedobb package
+
+apk-noobb: apk-clean package apk-sign
+
+xbmc/assets:
+ mkdir -p xbmc/assets
+
+shared:
+ mkdir -p assets
+ cp -rfp $(PREFIX)/share/@APP_NAME_LC@/* ./assets
+ find `pwd`/assets/ -depth -name ".git" -exec rm -rf {} \;
+ find `pwd`/assets/system/ -name "*.so" -exec rm {} \;
+ find `pwd`/assets/addons/skin.*/media/* -depth -not -iname "Textures.xbt" -exec rm -rf {} \;
+ find `pwd`/assets/system/keymaps/ -depth -name "joystick*.xml" ! -name "joystick.xml" -exec rm {} \;
+ cd assets; rm -rf $(EXCLUDED_ADDONS)
+
+sharedapk: shared | xbmc/assets
+ cp -rfp assets/* ./xbmc/assets
+
+sharedobb: shared
+ rm -f $(XBMCROOT)/main.@APP_NAME_LC@.obb
+ $(ZIP) -9 -q -r $(XBMCROOT)/main.@APP_NAME_LC@.obb assets
+ @echo "$(XBMCROOT)/main.@APP_NAME_LC@.obb created"
+
+python: | xbmc/assets
+ mkdir -p xbmc/assets/python2.6/lib/
cp -rfp $(PREFIX)/lib/python2.6 xbmc/assets/python2.6/lib/
+ cd xbmc/assets/python2.6/lib/python2.6/; rm -rf test config lib-dynload
+
+res:
+ mkdir -p xbmc/res xbmc/res/raw xbmc/res/values images
+ @echo "native_arch=$(ARCH)" > xbmc/res/raw/xbmc.properties
cp -fp $(XBMCROOT)/media/Splash.png xbmc/res/drawable/splash.png
cp -fp media/drawable-hdpi/ic_launcher.png xbmc/res/drawable-hdpi/ic_launcher.png
cp -fp media/drawable-ldpi/ic_launcher.png xbmc/res/drawable-ldpi/ic_launcher.png
cp -fp media/drawable-mdpi/ic_launcher.png xbmc/res/drawable-mdpi/ic_launcher.png
cp -fp media/drawable-xhdpi/ic_launcher.png xbmc/res/drawable-xhdpi/ic_launcher.png
cp -fp media/drawable-xxhdpi/ic_launcher.png xbmc/res/drawable-xxhdpi/ic_launcher.png
- cd xbmc/assets/python2.6/lib/python2.6/; rm -rf test config lib-dynload
- mkdir xbmc/res/values && mv xbmc/strings.xml xbmc/res/values/
+ cp xbmc/strings.xml xbmc/res/values/
mkdir -p tmp/res; $(AAPT) c -S xbmc/res -C tmp/res; cp -r -n xbmc/res tmp/ || true
$(AAPT) p -f -I $(SDKROOT)/platforms/$(SDK_PLATFORM)/android.jar -S tmp/res/ -M xbmc/AndroidManifest.xml -F images/@APP_NAME_LC@app-debug-skeleton.apk -J xbmc/src
@rm -rf tmp/
libs: $(PREFIX)/lib/@APP_NAME_LC@/lib@APP_NAME_LC@.so
rm -rf xbmc/lib/$(CPU) xbmc/libs/$(CPU) xbmc/obj/local/$(CPU)
- mkdir -p xbmc/lib/$(CPU) images xbmc/assets/python2.6/lib/ xbmc/libs/$(CPU) xbmc/obj/local/$(CPU)
+ mkdir -p xbmc/lib/$(CPU) xbmc/assets/python2.6/lib/ xbmc/libs/$(CPU) xbmc/obj/local/$(CPU)
cp -fp $(SRCLIBS) xbmc/obj/local/$(CPU)/
cp -fp $(PREFIX)/lib/@APP_NAME_LC@/lib@APP_NAME_LC@.so xbmc/obj/local/$(CPU)/
find $(PREFIX)/lib/@APP_NAME_LC@/addons -name "*.so" -exec cp -fp {} xbmc/obj/local/$(CPU)/ \;
@@ -105,20 +125,30 @@ libs: $(PREFIX)/lib/@APP_NAME_LC@/lib@APP_NAME_LC@.so
"$(NDKROOT)/sources/cxx-stl/gnu-libstdc++/$(GCC_VERSION)/include $(XBMCROOT) $(PREFIX)/include jni" >> ./xbmc/libs/$(CPU)/gdb.setup
cp -fp xbmc/libs/$(CPU)/* xbmc/lib/$(CPU)
-$(PREFIX)/lib/xbmc/lib@APP_NAME_LC@.so: $(SRCLIBS)
- $(MAKE) -C ../../depends/target/xbmc
+xbmc/classes.dex: res
+ mkdir -p xbmc/obj
+ @javac -classpath $(SDKROOT)/platforms/$(SDK_PLATFORM)/android.jar:xbmc/obj -d xbmc/obj -sourcepath xbmc/src xbmc/src/*.java
+ @javac -classpath $(SDKROOT)/platforms/$(SDK_PLATFORM)/android.jar:xbmc/obj -d xbmc/obj -sourcepath xbmc/src xbmc/src/org/xbmc/@APP_NAME_LC@/*.java
+ @$(DX) --dex --output=xbmc/classes.dex xbmc/obj
-$(SRCLIBS):
+package: libs python xbmc/classes.dex
+ @echo "Creating package..."
+ @cp images/@APP_NAME_LC@app-debug-skeleton.apk images/@APP_NAME_LC@app-debug-$(CPU)-unaligned.apk
+ @cd xbmc; $(ZIP) -r -q ../images/@APP_NAME_LC@app-debug-$(CPU)-unaligned.apk lib/$(CPU) assets classes.dex
-arm: armeabi-v7a
+apk-sign:
+ @echo "Signing..."
+ @jarsigner -sigalg MD5withRSA -digestalg SHA1 -keystore $(SIGN_STORE) -storepass $(SIGN_STOREPASS) $(SIGN_KEYPASS_OPT) images/@APP_NAME_LC@app-debug-$(CPU)-unaligned.apk $(SIGN_KEY)
+ @$(ZIPALIGN) -f 4 images/@APP_NAME_LC@app-debug-$(CPU)-unaligned.apk $(XBMCROOT)/@APP_NAME_LC@app-$(CPU)-debug.apk
+ @rm images/@APP_NAME_LC@app-debug-$(CPU)-unaligned.apk
+ @echo "$(XBMCROOT)/@APP_NAME_LC@app-$(CPU)-debug.apk created"
-armeabi-v7a: $(XBMC_ARM_TOOLCHAIN) force
- XBMC_OVERRIDE_PLATFORM=$@ $(ARMOVERRIDES) $(MAKE) package
+$(PREFIX)/lib/xbmc/libxbmc.so: $(SRCLIBS)
+ $(MAKE) -C ../../depends/target/xbmc
-x86: $(XBMC_X86_TOOLCHAIN) force
- XBMC_OVERRIDE_PLATFORM=$@ $(X86OVERRIDES) $(MAKE) package
+$(SRCLIBS):
-clean:
+apk-clean:
rm -rf images
rm -rf xbmc/lib
rm -rf xbmc/libs
@@ -130,5 +160,7 @@ clean:
rm -f xbmc/res/drawable/splash.png
rm -f xbmc/src/R.java
rm -f xbmc/classes.dex
+ rm -rf assets
+
+.PHONY: force libs assets python sharedapk sharedobb res package
-.PHONY: arm armeabi-v7a x86 force extras libs
diff --git a/tools/android/packaging/apksign b/tools/android/packaging/apksign
new file mode 100755
index 0000000000..0a2289b6c7
--- /dev/null
+++ b/tools/android/packaging/apksign
@@ -0,0 +1,10 @@
+#!/bin/bash
+usage(){
+ echo "Usage: $0 <keystore_filename> <keystore_password> <key_name> [<key_password>]"
+ exit 1
+}
+
+[[ $# -lt 3 ]] && usage
+
+make apk-sign SIGN_STORE=$1 SIGN_STOREPASS=$2 SIGN_KEY=$3 SIGN_KEYPASS=$4
+
diff --git a/tools/android/packaging/xbmc/AndroidManifest.xml.in b/tools/android/packaging/xbmc/AndroidManifest.xml.in
index 7624a0b49b..f3da501237 100644
--- a/tools/android/packaging/xbmc/AndroidManifest.xml.in
+++ b/tools/android/packaging/xbmc/AndroidManifest.xml.in
@@ -15,7 +15,7 @@
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
- <application android:icon="@drawable/ic_launcher" android:debuggable="true" android:label="@string/app_name" android:hasCode="true">
+ <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:hasCode="true">
<activity
android:name=".Splash"
android:configChanges="orientation|keyboard|keyboardHidden|navigation|touchscreen"
diff --git a/tools/android/packaging/xbmc/src/org/xbmc/kodi/Splash.java.in b/tools/android/packaging/xbmc/src/org/xbmc/kodi/Splash.java.in
index 0cad1b81c3..b5f46fcdda 100644
--- a/tools/android/packaging/xbmc/src/org/xbmc/kodi/Splash.java.in
+++ b/tools/android/packaging/xbmc/src/org/xbmc/kodi/Splash.java.in
@@ -14,6 +14,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import java.util.Arrays;
+import java.util.Comparator;
import java.util.Properties;
import java.util.Enumeration;
import java.util.ArrayList;
@@ -357,9 +359,55 @@ public class Splash extends Activity {
sXbmcHome = fCacheDir.getAbsolutePath() + "/apk";
}
- sPackagePath = getPackageResourcePath();
- fPackagePath = new File(sPackagePath);
fXbmcHome = new File(sXbmcHome);
+
+ try
+ {
+ sPackagePath = Environment.getExternalStorageDirectory()
+ + "/Android/obb/" + getPackageName() + "/main."
+ + getPackageManager().getPackageInfo(getPackageName(), 0).versionCode
+ + "." + getPackageName() + ".obb";
+ } catch (Exception e)
+ {
+ }
+
+ fPackagePath = new File(sPackagePath);
+ if (!fPackagePath.exists())
+ {
+ // Check for latest obb
+ String obbdir = Environment.getExternalStorageDirectory()
+ + "/Android/obb/" + getPackageName();
+ File[] obbfiles = new File(obbdir).listFiles();
+ if (obbfiles != null && obbfiles.length > 0)
+ {
+ Arrays.sort(obbfiles, new Comparator<File>()
+ {
+ public int compare(File f1, File f2)
+ {
+ // Sort by lastmodified descending
+ return Long.valueOf(f2.lastModified()).compareTo(f1.lastModified());
+ }
+ });
+ fPackagePath = obbfiles[0];
+ }
+ }
+
+ if (fPackagePath.exists())
+ {
+ sPackagePath = fPackagePath.getAbsolutePath();
+ Log.i(TAG, "Using OBB: " + sPackagePath);
+ } else
+ {
+ sPackagePath = getPackageResourcePath();
+ fPackagePath = new File(sPackagePath);
+ if (fPackagePath.length() < 50 * 1024 * 1024)
+ {
+ // No OBB and apk < 50Mb? Nah...
+ mErrorMsg = "OBB not yet present. Please retry later...";
+ Log.e(TAG, mErrorMsg);
+ mState = InError;
+ }
+ }
}
private void MigrateUserData() {