├── .gitignore
├── AndroidLibrary
└── GoogleExtras
│ ├── play_apk_expansion
│ ├── zip_file
│ │ ├── res
│ │ │ └── .nores
│ │ ├── gen
│ │ │ ├── R.java.d
│ │ │ └── com
│ │ │ │ └── android
│ │ │ │ └── vending
│ │ │ │ └── expansion
│ │ │ │ └── zipfile
│ │ │ │ └── BuildConfig.java
│ │ ├── .DS_Store
│ │ ├── .settings
│ │ │ └── org.eclipse.jdt.core.prefs
│ │ ├── AndroidManifest.xml
│ │ ├── local.properties
│ │ ├── project.properties
│ │ ├── .classpath
│ │ ├── proguard-project.txt
│ │ ├── .project
│ │ ├── src
│ │ │ └── com
│ │ │ │ └── android
│ │ │ │ └── vending
│ │ │ │ └── expansion
│ │ │ │ └── zipfile
│ │ │ │ └── APKExpansionSupport.java
│ │ └── build.xml
│ ├── downloader_library
│ │ ├── ant.properties
│ │ ├── libs
│ │ │ └── licensing_lib.jar
│ │ ├── .settings
│ │ │ └── org.eclipse.jdt.core.prefs
│ │ ├── build-extras.gradle
│ │ ├── res
│ │ │ ├── drawable-hdpi
│ │ │ │ └── notify_panel_notification_icon_bg.png
│ │ │ ├── drawable-mdpi
│ │ │ │ └── notify_panel_notification_icon_bg.png
│ │ │ ├── values-v11
│ │ │ │ └── styles.xml
│ │ │ ├── values-v9
│ │ │ │ └── styles.xml
│ │ │ ├── values
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ └── layout
│ │ │ │ └── status_bar_ongoing_event_progress_bar.xml
│ │ ├── gen
│ │ │ ├── com
│ │ │ │ └── android
│ │ │ │ │ └── vending
│ │ │ │ │ └── expansion
│ │ │ │ │ └── downloader
│ │ │ │ │ ├── BuildConfig.java
│ │ │ │ │ └── R.java
│ │ │ └── R.java.d
│ │ ├── AndroidManifest.xml
│ │ ├── local.properties
│ │ ├── project.properties
│ │ ├── .classpath
│ │ ├── proguard-project.txt
│ │ ├── .project
│ │ ├── src
│ │ │ └── com
│ │ │ │ └── google
│ │ │ │ └── android
│ │ │ │ └── vending
│ │ │ │ └── expansion
│ │ │ │ └── downloader
│ │ │ │ ├── impl
│ │ │ │ ├── CustomNotificationFactory.java
│ │ │ │ ├── DownloadInfo.java
│ │ │ │ ├── V14CustomNotification.java
│ │ │ │ ├── CustomIntentService.java
│ │ │ │ └── V3CustomNotification.java
│ │ │ │ ├── IStub.java
│ │ │ │ ├── DownloadProgressInfo.java
│ │ │ │ ├── IDownloaderService.java
│ │ │ │ ├── SystemFacade.java
│ │ │ │ ├── IDownloaderClient.java
│ │ │ │ └── DownloaderServiceMarshaller.java
│ │ └── build.xml
│ ├── downloader_sample
│ │ ├── res
│ │ │ ├── drawable-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ └── strings.xml
│ │ │ └── layout
│ │ │ │ └── main.xml
│ │ ├── project.properties
│ │ ├── src
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── expansion
│ │ │ │ └── downloader
│ │ │ │ ├── SampleAlarmReceiver.java
│ │ │ │ └── SampleDownloaderService.java
│ │ └── AndroidManifest.xml
│ └── README.txt
│ └── play_licensing
│ ├── library
│ ├── ant-build
│ │ ├── proguard.txt
│ │ ├── classes.jar
│ │ ├── classes
│ │ │ └── com
│ │ │ │ └── google
│ │ │ │ └── android
│ │ │ │ └── vending
│ │ │ │ └── licensing
│ │ │ │ ├── Policy.class
│ │ │ │ ├── BuildConfig.class
│ │ │ │ ├── Obfuscator.class
│ │ │ │ ├── util
│ │ │ │ ├── Base64.class
│ │ │ │ └── Base64DecoderException.class
│ │ │ │ ├── AESObfuscator.class
│ │ │ │ ├── DeviceLimiter.class
│ │ │ │ ├── LicenseChecker.class
│ │ │ │ ├── ResponseData.class
│ │ │ │ ├── StrictPolicy.class
│ │ │ │ ├── LicenseValidator.class
│ │ │ │ ├── APKExpansionPolicy.class
│ │ │ │ ├── ILicensingService.class
│ │ │ │ ├── NullDeviceLimiter.class
│ │ │ │ ├── ServerManagedPolicy.class
│ │ │ │ ├── ValidationException.class
│ │ │ │ ├── PreferenceObfuscator.class
│ │ │ │ ├── ILicenseResultListener.class
│ │ │ │ ├── ILicensingService$Stub.class
│ │ │ │ ├── LicenseCheckerCallback.class
│ │ │ │ ├── ILicenseResultListener$Stub.class
│ │ │ │ ├── ILicensingService$Stub$Proxy.class
│ │ │ │ ├── LicenseChecker$ResultListener.class
│ │ │ │ ├── LicenseChecker$ResultListener$1.class
│ │ │ │ ├── LicenseChecker$ResultListener$2.class
│ │ │ │ └── ILicenseResultListener$Stub$Proxy.class
│ │ ├── build.prop
│ │ ├── AndroidManifest.xml.d
│ │ └── AndroidManifest.xml
│ ├── gen
│ │ ├── R.java.d
│ │ └── com
│ │ │ └── google
│ │ │ └── android
│ │ │ └── vending
│ │ │ └── licensing
│ │ │ └── BuildConfig.java
│ ├── .settings
│ │ └── org.eclipse.jdt.core.prefs
│ ├── local.properties
│ ├── project.properties
│ ├── .classpath
│ ├── proguard-project.txt
│ ├── .project
│ ├── aidl
│ │ ├── ILicenseResultListener.aidl
│ │ └── ILicensingService.aidl
│ ├── src
│ │ └── com
│ │ │ └── google
│ │ │ └── android
│ │ │ └── vending
│ │ │ └── licensing
│ │ │ ├── util
│ │ │ └── Base64DecoderException.java
│ │ │ ├── ValidationException.java
│ │ │ ├── NullDeviceLimiter.java
│ │ │ ├── Obfuscator.java
│ │ │ ├── DeviceLimiter.java
│ │ │ ├── Policy.java
│ │ │ ├── StrictPolicy.java
│ │ │ ├── PreferenceObfuscator.java
│ │ │ ├── ResponseData.java
│ │ │ ├── LicenseCheckerCallback.java
│ │ │ ├── ILicenseResultListener.java
│ │ │ ├── ILicensingService.java
│ │ │ └── AESObfuscator.java
│ ├── AndroidManifest.xml
│ └── build.xml
│ ├── sample
│ ├── res
│ │ ├── drawable
│ │ │ └── icon.png
│ │ ├── layout
│ │ │ └── main.xml
│ │ └── values
│ │ │ └── strings.xml
│ ├── project.properties
│ └── AndroidManifest.xml
│ ├── test
│ ├── res
│ │ ├── drawable
│ │ │ └── icon.png
│ │ ├── values
│ │ │ └── strings.xml
│ │ └── layout
│ │ │ └── main.xml
│ ├── runTests.sh
│ ├── project.properties
│ ├── AndroidManifest.xml
│ └── src
│ │ └── com
│ │ └── android
│ │ └── vending
│ │ └── licensing
│ │ ├── StrictPolicyTest.java
│ │ ├── ObfuscatedPreferencesTest.java
│ │ ├── ServerManagedPolicyTest.java
│ │ ├── AESObfuscatorTest.java
│ │ └── APKExpansionPolicyTest.java
│ └── README.txt
├── src
└── android
│ ├── res
│ └── values
│ │ └── xapkreader.xml
│ ├── XAPKAlarmReceiver.java
│ ├── XAPKDownloaderService.java
│ └── XAPKReader.java
├── package.json
├── README.md
├── plugin.xml
└── www
└── xapkreader.js
/.gitignore:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/zip_file/res/.nores:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/proguard.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/ant.properties:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/gen/R.java.d:
--------------------------------------------------------------------------------
1 | : /Users/ajhomer/xapk/platforms/android/googleExtras/play_licensing/library/bin/AndroidManifest.xml \
2 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/zip_file/gen/R.java.d:
--------------------------------------------------------------------------------
1 | : /Users/ajhomer/xapk/platforms/android/googleExtras/play_apk_expansion/zip_file/bin/AndroidManifest.xml \
2 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/zip_file/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_apk_expansion/zip_file/.DS_Store
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/sample/res/drawable/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/sample/res/drawable/icon.png
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/test/res/drawable/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/test/res/drawable/icon.png
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes.jar
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/README.txt:
--------------------------------------------------------------------------------
1 | Client library for the Android Market licensing server.
2 |
3 | See the licensing documentation at http://developer.android.com/guide/publishing/licensing.html
4 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/libs/licensing_lib.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/libs/licensing_lib.jar
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/test/runTests.sh:
--------------------------------------------------------------------------------
1 | cd ../sample
2 | ant install
3 | cd ../test
4 | ant install
5 | adb shell am instrument -w com.example.android.market.licensing.test/android.test.InstrumentationTestRunner
6 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_sample/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_sample/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/test/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello World!
4 | MarketLicensingTest
5 |
6 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.source=1.6
5 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/zip_file/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.source=1.6
5 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.source=1.6
5 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/Policy.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/Policy.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/build-extras.gradle:
--------------------------------------------------------------------------------
1 | dependencies {
2 | debugCompile project(path: ':com.intel.xapkreader:library',configuration: "debug")
3 | releaseCompile project(path: ':com.intel.xapkreader:library',configuration: "release")
4 | }
5 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/res/drawable-hdpi/notify_panel_notification_icon_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/res/drawable-hdpi/notify_panel_notification_icon_bg.png
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/res/drawable-mdpi/notify_panel_notification_icon_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/res/drawable-mdpi/notify_panel_notification_icon_bg.png
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/build.prop:
--------------------------------------------------------------------------------
1 | #Last build type
2 | #Thu, 23 Oct 2014 14:44:21 -0400
3 |
4 | build.last.target=debug
5 |
6 | build.last.is.instrumented=false
7 |
8 | build.last.is.packaging.debug=true
9 |
10 | build.last.is.signing.debug=true
11 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/BuildConfig.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/BuildConfig.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/Obfuscator.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/Obfuscator.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/util/Base64.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/util/Base64.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/AESObfuscator.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/AESObfuscator.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/DeviceLimiter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/DeviceLimiter.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/LicenseChecker.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/LicenseChecker.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ResponseData.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ResponseData.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/StrictPolicy.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/StrictPolicy.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/gen/com/google/android/vending/licensing/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /** Automatically generated file. DO NOT MODIFY */
2 | package com.google.android.vending.licensing;
3 |
4 | public final class BuildConfig {
5 | public final static boolean DEBUG = true;
6 | }
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/zip_file/gen/com/android/vending/expansion/zipfile/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /** Automatically generated file. DO NOT MODIFY */
2 | package com.android.vending.expansion.zipfile;
3 |
4 | public final class BuildConfig {
5 | public final static boolean DEBUG = true;
6 | }
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/LicenseValidator.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/LicenseValidator.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/APKExpansionPolicy.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/APKExpansionPolicy.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ILicensingService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ILicensingService.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/NullDeviceLimiter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/NullDeviceLimiter.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ServerManagedPolicy.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ServerManagedPolicy.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ValidationException.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ValidationException.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/PreferenceObfuscator.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/PreferenceObfuscator.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ILicenseResultListener.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ILicenseResultListener.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ILicensingService$Stub.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ILicensingService$Stub.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/LicenseCheckerCallback.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/LicenseCheckerCallback.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/gen/com/android/vending/expansion/downloader/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /** Automatically generated file. DO NOT MODIFY */
2 | package com.android.vending.expansion.downloader;
3 |
4 | public final class BuildConfig {
5 | public final static boolean DEBUG = true;
6 | }
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ILicenseResultListener$Stub.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ILicenseResultListener$Stub.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ILicensingService$Stub$Proxy.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ILicensingService$Stub$Proxy.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/LicenseChecker$ResultListener.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/LicenseChecker$ResultListener.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/util/Base64DecoderException.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/util/Base64DecoderException.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/LicenseChecker$ResultListener$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/LicenseChecker$ResultListener$1.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/LicenseChecker$ResultListener$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/LicenseChecker$ResultListener$2.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ILicenseResultListener$Stub$Proxy.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/intel/APKexpansion/master/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/classes/com/google/android/vending/licensing/ILicenseResultListener$Stub$Proxy.class
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/res/values-v9/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/AndroidManifest.xml.d:
--------------------------------------------------------------------------------
1 | C:\Users\nlatif\Desktop\Containers\adt-bundle-windows-x86_64-20131030\sdk\extras\google\play_licensing\library\ant-build\AndroidManifest.xml : \
2 | C:\Users\nlatif\Desktop\Containers\adt-bundle-windows-x86_64-20131030\sdk\extras\google\play_licensing\library\AndroidManifest.xml \
3 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/zip_file/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/android/res/values/xapkreader.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Downloading assets…
4 | Preparing assets…
5 | Download failed
6 | Error
7 | Close
8 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/zip_file/local.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 |
7 | # location of the SDK. This is only used by Ant
8 | # For customization when using a Version Control System, please read the
9 | # header note.
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/local.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 |
7 | # location of the SDK. This is only used by Ant
8 | # For customization when using a Version Control System, please read the
9 | # header note.
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/local.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 |
7 | # location of the SDK. This is only used by Ant
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/test/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | android.library=true
11 | # Project target.
12 | target=android-17
13 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/zip_file/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-17
12 | android.library=true
13 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/test/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-15
12 | android.library.reference.1=../market_licensing
13 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-17
12 | android.library=true
13 | android.library.reference.1=../library
14 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/zip_file/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/sample/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-15
12 | android.library.reference.1=../../../../../../../Users/dgalpin/dev/apkx-downloader/market_licensing
13 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_sample/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-15
12 | android.library.reference.1=../apkx_downloader_library
13 | android.library.reference.2=../apkx_zip_file
14 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/test/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "com.intel.xapkreader",
3 | "version": "2.0.1",
4 | "description": "Access files into APK Expansion Files",
5 | "cordova": {
6 | "id": "com.intel.xapkreader",
7 | "platforms": [
8 | "android"
9 | ]
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": "git+https://github.com/01org/APKexpansion.git"
14 | },
15 | "keywords": [
16 | "cordova",
17 | "apk",
18 | "expansion",
19 | "file",
20 | "xapk",
21 | "xapkreader",
22 | "ecosystem:cordova",
23 | "cordova-android"
24 | ],
25 | "author": "Quentin Aupetit",
26 | "contributors": [
27 | {
28 | "name":"Nazia Latif",
29 | "name":"Ian Maffett"
30 | }
31 | ],
32 | "license": "MIT",
33 | "bugs": {
34 | "url": "https://github.com/01org/APKexpansion/issues"
35 | },
36 | "homepage": "https://github.com/01org/APKexpansion#readme"
37 | }
38 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/zip_file/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/zip_file/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | APK Expansion Zip Library
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Google Play License Library
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Google Play Downloader Library
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
15 |
16 |
20 |
21 |
24 |
25 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/aidl/ILicenseResultListener.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.android.vending.licensing;
18 |
19 | // Android library projects do not yet support AIDL, so this has been
20 | // precompiled into the src directory.
21 | oneway interface ILicenseResultListener {
22 | void verifyLicense(int responseCode, String signedData, String signature);
23 | }
24 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/aidl/ILicensingService.aidl:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.android.vending.licensing;
18 |
19 | import com.android.vending.licensing.ILicenseResultListener;
20 |
21 | // Android library projects do not yet support AIDL, so this has been
22 | // precompiled into the src directory.
23 | oneway interface ILicensingService {
24 | void checkLicense(long nonce, String packageName, in ILicenseResultListener listener);
25 | }
26 |
--------------------------------------------------------------------------------
/src/android/XAPKAlarmReceiver.java:
--------------------------------------------------------------------------------
1 | package org.apache.cordova.xapkreader;
2 |
3 | import com.google.android.vending.expansion.downloader.DownloaderClientMarshaller;
4 |
5 | import android.content.BroadcastReceiver;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.content.pm.PackageManager.NameNotFoundException;
9 |
10 | /**
11 | * You should start your derived downloader class when this receiver gets the message
12 | * from the alarm service using the provided service helper function within the
13 | * DownloaderClientMarshaller. This class must be then registered in your AndroidManifest.xml
14 | * file with a section like this:
15 | *
16 | */
17 | public class XAPKAlarmReceiver extends BroadcastReceiver {
18 |
19 | @Override
20 | public void onReceive(Context context, Intent intent) {
21 | try {
22 | DownloaderClientMarshaller.startDownloadServiceIfRequired(context, intent, XAPKDownloaderService.class);
23 | } catch (NameNotFoundException e) {
24 | e.printStackTrace();
25 | }
26 | }
27 |
28 | }
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/src/com/google/android/vending/licensing/util/Base64DecoderException.java:
--------------------------------------------------------------------------------
1 | // Copyright 2002, Google, Inc.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package com.google.android.vending.licensing.util;
16 |
17 | /**
18 | * Exception thrown when encountering an invalid Base64 input character.
19 | *
20 | * @author nelson
21 | */
22 | public class Base64DecoderException extends Exception {
23 | public Base64DecoderException() {
24 | super();
25 | }
26 |
27 | public Base64DecoderException(String s) {
28 | super(s);
29 | }
30 |
31 | private static final long serialVersionUID = 1L;
32 | }
33 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/gen/R.java.d:
--------------------------------------------------------------------------------
1 | /Users/ajhomer/xapk/platforms/android/googleExtras/play_apk_expansion/downloader_library/gen/com/android/vending/expansion/downloader/R.java \
2 | : /Users/ajhomer/xapk/platforms/android/googleExtras/play_apk_expansion/downloader_library/res/drawable-hdpi/notify_panel_notification_icon_bg.png \
3 | /Users/ajhomer/xapk/platforms/android/googleExtras/play_apk_expansion/downloader_library/res/drawable-mdpi/notify_panel_notification_icon_bg.png \
4 | /Users/ajhomer/xapk/platforms/android/googleExtras/play_apk_expansion/downloader_library/res/layout/status_bar_ongoing_event_progress_bar.xml \
5 | /Users/ajhomer/xapk/platforms/android/googleExtras/play_apk_expansion/downloader_library/res/values/strings.xml \
6 | /Users/ajhomer/xapk/platforms/android/googleExtras/play_apk_expansion/downloader_library/res/values/styles.xml \
7 | /Users/ajhomer/xapk/platforms/android/googleExtras/play_apk_expansion/downloader_library/res/values-v11/styles.xml \
8 | /Users/ajhomer/xapk/platforms/android/googleExtras/play_apk_expansion/downloader_library/res/values-v9/styles.xml \
9 | /Users/ajhomer/xapk/platforms/android/googleExtras/play_apk_expansion/downloader_library/bin/AndroidManifest.xml \
10 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_sample/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | APKX Downloader
5 | Would you like to enable downloading over cellular connections? Depending on your data plan, this may cost you money.
6 | If you choose not to enable downloading over cellular connections, the download will automatically resume when wi-fi is available.
7 | Resume download
8 | Wi-Fi settings
9 | Verifying Download
10 | XAPK File Validation Complete. Select OK to exit.
11 | XAPK File Validation Failed.
12 | Pause Download
13 | Resume Download
14 | Cancel
15 | Cancel Verification
16 |
17 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/src/com/google/android/vending/licensing/ValidationException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.licensing;
18 |
19 | /**
20 | * Indicates that an error occurred while validating the integrity of data managed by an
21 | * {@link Obfuscator}.}
22 | */
23 | public class ValidationException extends Exception {
24 | public ValidationException() {
25 | super();
26 | }
27 |
28 | public ValidationException(String s) {
29 | super(s);
30 | }
31 |
32 | private static final long serialVersionUID = 1L;
33 | }
34 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/ant-build/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/src/com/google/android/vending/licensing/NullDeviceLimiter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.licensing;
18 |
19 | /**
20 | * A DeviceLimiter that doesn't limit the number of devices that can use a
21 | * given user's license.
22 | *
23 | * Unless you have reason to believe that your application is being pirated
24 | * by multiple users using the same license (signing in to Market as the same
25 | * user), we recommend you use this implementation.
26 | */
27 | public class NullDeviceLimiter implements DeviceLimiter {
28 |
29 | public int isDeviceAllowed(String userId) {
30 | return Policy.LICENSED;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/src/com/google/android/vending/expansion/downloader/impl/CustomNotificationFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.expansion.downloader.impl;
18 |
19 | /**
20 | * Uses the class-loader model to utilize the updated notification builders in
21 | * Honeycomb while maintaining a compatible version for older devices.
22 | */
23 | public class CustomNotificationFactory {
24 | static public DownloadNotification.ICustomNotification createCustomNotification() {
25 | if (android.os.Build.VERSION.SDK_INT > 13)
26 | return new V14CustomNotification();
27 | else
28 | return new V3CustomNotification();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/sample/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
21 |
27 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/src/com/google/android/vending/expansion/downloader/IStub.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.expansion.downloader;
18 |
19 | import android.content.Context;
20 | import android.os.Messenger;
21 |
22 | /**
23 | * This is the interface that is used to connect/disconnect from the downloader
24 | * service.
25 | *
26 | * You should get a proxy object that implements this interface by calling
27 | * {@link DownloaderClientMarshaller#CreateStub} in your activity when the
28 | * downloader service starts. Then, call {@link #connect} during your activity's
29 | * onResume() and call {@link #disconnect} during onStop().
30 | *
31 | * Then during the {@link IDownloaderClient#onServiceConnected} callback, you
32 | * should call {@link #getMessenger} to pass the stub's Messenger object to
33 | * {@link IDownloaderService#onClientUpdated}.
34 | */
35 | public interface IStub {
36 | Messenger getMessenger();
37 |
38 | void connect(Context c);
39 |
40 | void disconnect(Context c);
41 | }
42 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/sample/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
20 |
21 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/android/XAPKDownloaderService.java:
--------------------------------------------------------------------------------
1 | package org.apache.cordova.xapkreader;
2 |
3 | import com.google.android.vending.expansion.downloader.impl.DownloaderService;
4 |
5 | /**
6 | * This class demonstrates the minimal client implementation of the
7 | * DownloaderService from the Downloader library.
8 | */
9 | public class XAPKDownloaderService extends DownloaderService {
10 |
11 | // stuff for LVL -- MODIFY FOR YOUR APPLICATION!
12 | private final String BASE64_PUBLIC_KEY = getResources().getString(getResources().getIdentifier("your_publickey", "string", getPackageName()));
13 |
14 |
15 | // used by the preference obfuscater
16 | private static final byte[] SALT = new byte[] {
17 | 1, 43, -12, -1, 54, 98, -100, -12, 43, 2, -8, -4, 9, 5, -106, -108, -33, 45, -1, 84
18 | };
19 |
20 | /**
21 | * This public key comes from your Android Market publisher account, and it
22 | * used by the LVL to validate responses from Market on your behalf.
23 | */
24 | @Override
25 | public String getPublicKey() {
26 | return BASE64_PUBLIC_KEY;
27 | }
28 |
29 | /**
30 | * This is used by the preference obfuscater to make sure that your
31 | * obfuscated preferences are different than the ones used by other
32 | * applications.
33 | */
34 | @Override
35 | public byte[] getSALT() {
36 | return SALT;
37 | }
38 |
39 | /**
40 | * Fill this in with the class name for your alarm receiver. We do this
41 | * because receivers must be unique across all of Android (it's a good idea
42 | * to make sure that your receiver is in your unique package)
43 | */
44 | @Override
45 | public String getAlarmReceiverClassName() {
46 | return XAPKAlarmReceiver.class.getName();
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/sample/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 | Market Licensing Example
18 |
19 |
20 | Check license
21 | Checking license...
22 | Don\'t allow the user access
23 | Allow the user access
24 | Application error: %1$s
25 |
26 |
27 | Application not licensed
28 | This application is not licensed. Please purchase it from Android Market.
29 | Unable to validate license. Check to see if a network connection is available.
30 | Buy app
31 | Retry
32 | Exit
33 |
34 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_sample/src/com/example/expansion/downloader/SampleAlarmReceiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.expansion.downloader;
18 |
19 | import com.google.android.vending.expansion.downloader.DownloaderClientMarshaller;
20 |
21 | import android.content.BroadcastReceiver;
22 | import android.content.Context;
23 | import android.content.Intent;
24 | import android.content.pm.PackageManager.NameNotFoundException;
25 |
26 | /**
27 | * You should start your derived downloader class when this receiver gets the message
28 | * from the alarm service using the provided service helper function within the
29 | * DownloaderClientMarshaller. This class must be then registered in your AndroidManifest.xml
30 | * file with a section like this:
31 | *
32 | */
33 | public class SampleAlarmReceiver extends BroadcastReceiver {
34 |
35 | @Override
36 | public void onReceive(Context context, Intent intent) {
37 | try {
38 | DownloaderClientMarshaller.startDownloadServiceIfRequired(context, intent, SampleDownloaderService.class);
39 | } catch (NameNotFoundException e) {
40 | e.printStackTrace();
41 | }
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/src/com/google/android/vending/licensing/Obfuscator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.licensing;
18 |
19 | /**
20 | * Interface used as part of a {@link Policy} to allow application authors to obfuscate
21 | * licensing data that will be stored into a SharedPreferences file.
22 | *
23 | * Any transformation scheme must be reversable. Implementing classes may optionally implement an
24 | * integrity check to further prevent modification to preference data. Implementing classes
25 | * should use device-specific information as a key in the obfuscation algorithm to prevent
26 | * obfuscated preferences from being shared among devices.
27 | */
28 | public interface Obfuscator {
29 |
30 | /**
31 | * Obfuscate a string that is being stored into shared preferences.
32 | *
33 | * @param original The data that is to be obfuscated.
34 | * @param key The key for the data that is to be obfuscated.
35 | * @return A transformed version of the original data.
36 | */
37 | String obfuscate(String original, String key);
38 |
39 | /**
40 | * Undo the transformation applied to data by the obfuscate() method.
41 | *
42 | * @param original The data that is to be obfuscated.
43 | * @param key The key for the data that is to be obfuscated.
44 | * @return A transformed version of the original data.
45 | * @throws ValidationException Optionally thrown if a data integrity check fails.
46 | */
47 | String unobfuscate(String obfuscated, String key) throws ValidationException;
48 | }
49 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/src/com/google/android/vending/licensing/DeviceLimiter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.licensing;
18 |
19 | /**
20 | * Allows the developer to limit the number of devices using a single license.
21 | *
22 | * The LICENSED response from the server contains a user identifier unique to
23 | * the <application, user> pair. The developer can send this identifier
24 | * to their own server along with some device identifier (a random number
25 | * generated and stored once per application installation,
26 | * {@link android.telephony.TelephonyManager#getDeviceId getDeviceId},
27 | * {@link android.provider.Settings.Secure#ANDROID_ID ANDROID_ID}, etc).
28 | * The more sources used to identify the device, the harder it will be for an
29 | * attacker to spoof.
30 | *
31 | * The server can look at the <application, user, device id> tuple and
32 | * restrict a user's application license to run on at most 10 different devices
33 | * in a week (for example). We recommend not being too restrictive because a
34 | * user might legitimately have multiple devices or be in the process of
35 | * changing phones. This will catch egregious violations of multiple people
36 | * sharing one license.
37 | */
38 | public interface DeviceLimiter {
39 |
40 | /**
41 | * Checks if this device is allowed to use the given user's license.
42 | *
43 | * @param userId the user whose license the server responded with
44 | * @return LICENSED if the device is allowed, NOT_LICENSED if not, RETRY if an error occurs
45 | */
46 | int isDeviceAllowed(String userId);
47 | }
48 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/src/com/google/android/vending/licensing/Policy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.licensing;
18 |
19 | /**
20 | * Policy used by {@link LicenseChecker} to determine whether a user should have
21 | * access to the application.
22 | */
23 | public interface Policy {
24 |
25 | /**
26 | * Change these values to make it more difficult for tools to automatically
27 | * strip LVL protection from your APK.
28 | */
29 |
30 | /**
31 | * LICENSED means that the server returned back a valid license response
32 | */
33 | public static final int LICENSED = 0x0100;
34 | /**
35 | * NOT_LICENSED means that the server returned back a valid license response
36 | * that indicated that the user definitively is not licensed
37 | */
38 | public static final int NOT_LICENSED = 0x0231;
39 | /**
40 | * RETRY means that the license response was unable to be determined ---
41 | * perhaps as a result of faulty networking
42 | */
43 | public static final int RETRY = 0x0123;
44 |
45 | /**
46 | * Provide results from contact with the license server. Retry counts are
47 | * incremented if the current value of response is RETRY. Results will be
48 | * used for any future policy decisions.
49 | *
50 | * @param response the result from validating the server response
51 | * @param rawData the raw server response data, can be null for RETRY
52 | */
53 | void processServerResponse(int response, ResponseData rawData);
54 |
55 | /**
56 | * Check if the user should be allowed access to the application.
57 | */
58 | boolean allowAccess();
59 | }
60 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/test/src/com/android/vending/licensing/StrictPolicyTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.android.vending.licensing;
18 |
19 | import com.google.android.vending.licensing.Policy;
20 | import com.google.android.vending.licensing.StrictPolicy;
21 |
22 | import junit.framework.TestCase;
23 |
24 | /**
25 | * Test suite for StrictPolicy.
26 | */
27 | public class StrictPolicyTest extends TestCase {
28 |
29 | /**
30 | * Verify that initial response is to deny access.
31 | */
32 | public void testInitialResponse() {
33 | StrictPolicy p = new StrictPolicy();
34 | boolean result = p.allowAccess();
35 | assertFalse(result);
36 | }
37 |
38 | /**
39 | * Verify that after receiving a LICENSED response, the policy grants
40 | * access.
41 | */
42 | public void testLicensedResonse() {
43 | StrictPolicy p = new StrictPolicy();
44 | p.processServerResponse(Policy.LICENSED, null);
45 | boolean result = p.allowAccess();
46 | assertTrue(result);
47 | }
48 |
49 | /**
50 | * Verify that after receiving a NOT_LICENSED response, the policy denies
51 | * access.
52 | */
53 | public void testNotLicensedResponse() {
54 | StrictPolicy p = new StrictPolicy();
55 | p.processServerResponse(Policy.NOT_LICENSED, null);
56 | boolean result = p.allowAccess();
57 | assertFalse(result);
58 | }
59 |
60 | /**
61 | * Verify that after receiving a RETRY response, the policy denies
62 | * access.
63 | */
64 | public void testRetryResponse() {
65 | StrictPolicy p = new StrictPolicy();
66 | p.processServerResponse(Policy.RETRY, null);
67 | boolean result = p.allowAccess();
68 | assertFalse(result);
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_sample/src/com/example/expansion/downloader/SampleDownloaderService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.expansion.downloader;
18 |
19 | import com.google.android.vending.expansion.downloader.impl.DownloaderService;
20 |
21 | /**
22 | * This class demonstrates the minimal client implementation of the
23 | * DownloaderService from the Downloader library.
24 | */
25 | public class SampleDownloaderService extends DownloaderService {
26 | // stuff for LVL -- MODIFY FOR YOUR APPLICATION!
27 | private static final String BASE64_PUBLIC_KEY = "REPLACE THIS WITH YOUR PUBLIC KEY";
28 | // used by the preference obfuscater
29 | private static final byte[] SALT = new byte[] {
30 | 1, 43, -12, -1, 54, 98,
31 | -100, -12, 43, 2, -8, -4, 9, 5, -106, -108, -33, 45, -1, 84
32 | };
33 |
34 | /**
35 | * This public key comes from your Android Market publisher account, and it
36 | * used by the LVL to validate responses from Market on your behalf.
37 | */
38 | @Override
39 | public String getPublicKey() {
40 | return BASE64_PUBLIC_KEY;
41 | }
42 |
43 | /**
44 | * This is used by the preference obfuscater to make sure that your
45 | * obfuscated preferences are different than the ones used by other
46 | * applications.
47 | */
48 | @Override
49 | public byte[] getSALT() {
50 | return SALT;
51 | }
52 |
53 | /**
54 | * Fill this in with the class name for your alarm receiver. We do this
55 | * because receivers must be unique across all of Android (it's a good idea
56 | * to make sure that your receiver is in your unique package)
57 | */
58 | @Override
59 | public String getAlarmReceiverClassName() {
60 | return SampleAlarmReceiver.class.getName();
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/README.txt:
--------------------------------------------------------------------------------
1 | Client library for the Google Market APK Expansion files.
2 |
3 | Changelog
4 | ---------
5 |
6 | Version 3
7 | * Directory structure corrected in distribution. No code changes.
8 |
9 | Version 2
10 | * Patch file now gets downloaded.
11 | * Honeycomb devices now supported with ICS-like notifications
12 | * CRC check (from sample) now supports compressed Zip files
13 | * Use of reflection removed to allow easy obfuscation
14 | * Service leak fixed
15 | * Unprintable character removed from ZipResourceFile
16 | * Minor formatting changes
17 | * Additional comments and edits to this file
18 |
19 | Packages
20 | --------
21 |
22 | downloader_library
23 | A library that works with the google_market_licensing library to download APK Expansion files in a background service. This library depends on the licensing library, and must be built as a library project.
24 | zip_file
25 | A library that uses multiple zip files as a virtual read-only filesystem with hooks to support APK Expansion lies. This also must be built as an Android library project.
26 | downloader_sample
27 | A sample application that assumes that zip format files have been uploaded as the main/patch file(s) on Android Market. It downloads these files and then validates that the CRC's for every entry in the zip match. This application depends on the downloader_library and the zip_file library. Because of dependency issues involving multiple libraries, you may have to do a clean build after creating each project.
28 |
29 | IMPORTANT THINGS TO KNOW
30 | ------------------------
31 |
32 | 1) Do not plan to extract the contents of an APK Expansion file. They are intended to be used in-place. By not compressing audio and video files and storing them in a Zip file they can be played from within an expansion file.
33 | 2) See com.google.android.vending.expansion.downloader/Constants.java to turn on verbose logging in the library. Please turn it off when you publish
34 | 3) You must add your SALT and Public key to the SampleDownloaderService and update the xAPKS structure in SampleDownloaderActivity in order to test with the sample code
35 | 4) There is no strong need to include the validator with your Android applications. It is included as a demonstration, and can be used if you wish.
36 |
37 | For more information, see the documentation at http://developer.android.com/guide/market/expansion-files.html
38 |
39 | This library requires the Android License Verification Library.
40 |
41 | See the licensing documentation at http://developer.android.com/guide/publishing/licensing.html
42 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/src/com/google/android/vending/licensing/StrictPolicy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.licensing;
18 |
19 | /**
20 | * Non-caching policy. All requests will be sent to the licensing service,
21 | * and no local caching is performed.
22 | *
23 | * Using a non-caching policy ensures that there is no local preference data
24 | * for malicious users to tamper with. As a side effect, applications
25 | * will not be permitted to run while offline. Developers should carefully
26 | * weigh the risks of using this Policy over one which implements caching,
27 | * such as ServerManagedPolicy.
28 | *
29 | * Access to the application is only allowed if a LICESNED response is.
30 | * received. All other responses (including RETRY) will deny access.
31 | */
32 | public class StrictPolicy implements Policy {
33 |
34 | private int mLastResponse;
35 |
36 | public StrictPolicy() {
37 | // Set default policy. This will force the application to check the policy on launch.
38 | mLastResponse = Policy.RETRY;
39 | }
40 |
41 | /**
42 | * Process a new response from the license server. Since we aren't
43 | * performing any caching, this equates to reading the LicenseResponse.
44 | * Any ResponseData provided is ignored.
45 | *
46 | * @param response the result from validating the server response
47 | * @param rawData the raw server response data
48 | */
49 | public void processServerResponse(int response, ResponseData rawData) {
50 | mLastResponse = response;
51 | }
52 |
53 | /**
54 | * {@inheritDoc}
55 | *
56 | * This implementation allows access if and only if a LICENSED response
57 | * was received the last time the server was contacted.
58 | */
59 | public boolean allowAccess() {
60 | return (mLastResponse == Policy.LICENSED);
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/src/com/google/android/vending/licensing/PreferenceObfuscator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.licensing;
18 |
19 | import android.content.SharedPreferences;
20 | import android.util.Log;
21 |
22 | /**
23 | * An wrapper for SharedPreferences that transparently performs data obfuscation.
24 | */
25 | public class PreferenceObfuscator {
26 |
27 | private static final String TAG = "PreferenceObfuscator";
28 |
29 | private final SharedPreferences mPreferences;
30 | private final Obfuscator mObfuscator;
31 | private SharedPreferences.Editor mEditor;
32 |
33 | /**
34 | * Constructor.
35 | *
36 | * @param sp A SharedPreferences instance provided by the system.
37 | * @param o The Obfuscator to use when reading or writing data.
38 | */
39 | public PreferenceObfuscator(SharedPreferences sp, Obfuscator o) {
40 | mPreferences = sp;
41 | mObfuscator = o;
42 | mEditor = null;
43 | }
44 |
45 | public void putString(String key, String value) {
46 | if (mEditor == null) {
47 | mEditor = mPreferences.edit();
48 | }
49 | String obfuscatedValue = mObfuscator.obfuscate(value, key);
50 | mEditor.putString(key, obfuscatedValue);
51 | }
52 |
53 | public String getString(String key, String defValue) {
54 | String result;
55 | String value = mPreferences.getString(key, null);
56 | if (value != null) {
57 | try {
58 | result = mObfuscator.unobfuscate(value, key);
59 | } catch (ValidationException e) {
60 | // Unable to unobfuscate, data corrupt or tampered
61 | Log.w(TAG, "Validation error while reading preference: " + key);
62 | result = defValue;
63 | }
64 | } else {
65 | // Preference not found
66 | result = defValue;
67 | }
68 | return result;
69 | }
70 |
71 | public void commit() {
72 | if (mEditor != null) {
73 | mEditor.commit();
74 | mEditor = null;
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 | Download complete
10 |
11 |
16 | Download unsuccessful
17 |
18 |
19 | Starting..."
20 | Waiting for download to start
21 | Looking for resources to download
22 | Connecting to the download server
23 | Downloading resources
24 | Download finished
25 | Download paused because no network is available
26 | Download paused. Test a website in browser
27 | Download paused
28 | Download paused because wifi is unavailable
29 | Download paused because wifi is disabled
30 | Download paused because you are roaming
31 | Download paused because the external storage is unavailable
32 | Download failed because you may not have purchased this app
33 | Download failed because the resources could not be found
34 | Download failed because the external storage is full
35 | Download cancelled
36 | Download failed
37 |
38 | %1$s KB/s
39 | Time remaining: %1$s
40 | %1$s left
41 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/src/com/google/android/vending/licensing/ResponseData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.licensing;
18 |
19 | import java.util.regex.Pattern;
20 |
21 | import android.text.TextUtils;
22 |
23 | /**
24 | * ResponseData from licensing server.
25 | */
26 | public class ResponseData {
27 |
28 | public int responseCode;
29 | public int nonce;
30 | public String packageName;
31 | public String versionCode;
32 | public String userId;
33 | public long timestamp;
34 | /** Response-specific data. */
35 | public String extra;
36 |
37 | /**
38 | * Parses response string into ResponseData.
39 | *
40 | * @param responseData response data string
41 | * @throws IllegalArgumentException upon parsing error
42 | * @return ResponseData object
43 | */
44 | public static ResponseData parse(String responseData) {
45 | // Must parse out main response data and response-specific data.
46 | int index = responseData.indexOf(':');
47 | String mainData, extraData;
48 | if ( -1 == index ) {
49 | mainData = responseData;
50 | extraData = "";
51 | } else {
52 | mainData = responseData.substring(0, index);
53 | extraData = index >= responseData.length() ? "" : responseData.substring(index+1);
54 | }
55 |
56 | String [] fields = TextUtils.split(mainData, Pattern.quote("|"));
57 | if (fields.length < 6) {
58 | throw new IllegalArgumentException("Wrong number of fields.");
59 | }
60 |
61 | ResponseData data = new ResponseData();
62 | data.extra = extraData;
63 | data.responseCode = Integer.parseInt(fields[0]);
64 | data.nonce = Integer.parseInt(fields[1]);
65 | data.packageName = fields[2];
66 | data.versionCode = fields[3];
67 | // Application-specific user identifier.
68 | data.userId = fields[4];
69 | data.timestamp = Long.parseLong(fields[5]);
70 |
71 | return data;
72 | }
73 |
74 | @Override
75 | public String toString() {
76 | return TextUtils.join("|", new Object [] { responseCode, nonce, packageName, versionCode,
77 | userId, timestamp });
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/src/com/google/android/vending/licensing/LicenseCheckerCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.licensing;
18 |
19 | /**
20 | * Callback for the license checker library.
21 | *
22 | * Upon checking with the Market server and conferring with the {@link Policy},
23 | * the library calls the appropriate callback method to communicate the result.
24 | *
25 | * The callback does not occur in the original checking thread. Your
26 | * application should post to the appropriate handling thread or lock
27 | * accordingly.
28 | *
29 | * The reason that is passed back with allow/dontAllow is the base status handed
30 | * to the policy for allowed/disallowing the license. Policy.RETRY will call
31 | * allow or dontAllow depending on other statistics associated with the policy,
32 | * while in most cases Policy.NOT_LICENSED will call dontAllow and
33 | * Policy.LICENSED will Allow.
34 | */
35 | public interface LicenseCheckerCallback {
36 |
37 | /**
38 | * Allow use. App should proceed as normal.
39 | *
40 | * @param reason Policy.LICENSED or Policy.RETRY typically. (although in
41 | * theory the policy can return Policy.NOT_LICENSED here as well)
42 | */
43 | public void allow(int reason);
44 |
45 | /**
46 | * Don't allow use. App should inform user and take appropriate action.
47 | *
48 | * @param reason Policy.NOT_LICENSED or Policy.RETRY. (although in theory
49 | * the policy can return Policy.LICENSED here as well ---
50 | * perhaps the call to the LVL took too long, for example)
51 | */
52 | public void dontAllow(int reason);
53 |
54 | /** Application error codes. */
55 | public static final int ERROR_INVALID_PACKAGE_NAME = 1;
56 | public static final int ERROR_NON_MATCHING_UID = 2;
57 | public static final int ERROR_NOT_MARKET_MANAGED = 3;
58 | public static final int ERROR_CHECK_IN_PROGRESS = 4;
59 | public static final int ERROR_INVALID_PUBLIC_KEY = 5;
60 | public static final int ERROR_MISSING_PERMISSION = 6;
61 |
62 | /**
63 | * Error in application code. Caller did not call or set up license checker
64 | * correctly. Should be considered fatal.
65 | */
66 | public void applicationError(int errorCode);
67 | }
68 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/src/com/google/android/vending/expansion/downloader/DownloadProgressInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.expansion.downloader;
18 |
19 | import android.os.Parcel;
20 | import android.os.Parcelable;
21 |
22 |
23 | /**
24 | * This class contains progress information about the active download(s).
25 | *
26 | * When you build the Activity that initiates a download and tracks the
27 | * progress by implementing the {@link IDownloaderClient} interface, you'll
28 | * receive a DownloadProgressInfo object in each call to the {@link
29 | * IDownloaderClient#onDownloadProgress} method. This allows you to update
30 | * your activity's UI with information about the download progress, such
31 | * as the progress so far, time remaining and current speed.
32 | */
33 | public class DownloadProgressInfo implements Parcelable {
34 | public long mOverallTotal;
35 | public long mOverallProgress;
36 | public long mTimeRemaining; // time remaining
37 | public float mCurrentSpeed; // speed in KB/S
38 |
39 | @Override
40 | public int describeContents() {
41 | return 0;
42 | }
43 |
44 | @Override
45 | public void writeToParcel(Parcel p, int i) {
46 | p.writeLong(mOverallTotal);
47 | p.writeLong(mOverallProgress);
48 | p.writeLong(mTimeRemaining);
49 | p.writeFloat(mCurrentSpeed);
50 | }
51 |
52 | public DownloadProgressInfo(Parcel p) {
53 | mOverallTotal = p.readLong();
54 | mOverallProgress = p.readLong();
55 | mTimeRemaining = p.readLong();
56 | mCurrentSpeed = p.readFloat();
57 | }
58 |
59 | public DownloadProgressInfo(long overallTotal, long overallProgress,
60 | long timeRemaining,
61 | float currentSpeed) {
62 | this.mOverallTotal = overallTotal;
63 | this.mOverallProgress = overallProgress;
64 | this.mTimeRemaining = timeRemaining;
65 | this.mCurrentSpeed = currentSpeed;
66 | }
67 |
68 | public static final Creator CREATOR = new Creator() {
69 | @Override
70 | public DownloadProgressInfo createFromParcel(Parcel parcel) {
71 | return new DownloadProgressInfo(parcel);
72 | }
73 |
74 | @Override
75 | public DownloadProgressInfo[] newArray(int i) {
76 | return new DownloadProgressInfo[i];
77 | }
78 | };
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_sample/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
43 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
56 |
57 |
58 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/zip_file/src/com/android/vending/expansion/zipfile/APKExpansionSupport.java:
--------------------------------------------------------------------------------
1 | package com.android.vending.expansion.zipfile;
2 | /*
3 | * Copyright (C) 2012 The Android Open Source Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | import java.io.File;
18 | import java.io.FileFilter;
19 | import java.io.IOException;
20 | import java.util.Vector;
21 | import java.util.regex.Matcher;
22 | import java.util.regex.Pattern;
23 |
24 | import android.content.Context;
25 | import android.os.Environment;
26 |
27 | public class APKExpansionSupport {
28 | // The shared path to all app expansion files
29 | private final static String EXP_PATH = "/Android/obb/";
30 |
31 | static String[] getAPKExpansionFiles(Context ctx, int mainVersion, int patchVersion) {
32 | String packageName = ctx.getPackageName();
33 | Vector ret = new Vector();
34 | if (Environment.getExternalStorageState().equals(
35 | Environment.MEDIA_MOUNTED)) {
36 | // Build the full path to the app's expansion files
37 | File root = Environment.getExternalStorageDirectory();
38 | File expPath = new File(root.toString() + EXP_PATH + packageName);
39 |
40 | // Check that expansion file path exists
41 | if (expPath.exists()) {
42 | if ( mainVersion > 0 ) {
43 | String strMainPath = expPath + File.separator + "main." + mainVersion + "." + packageName + ".obb";
44 | File main = new File(strMainPath);
45 | if ( main.isFile() ) {
46 | ret.add(strMainPath);
47 | }
48 | }
49 | if ( patchVersion > 0 ) {
50 | String strPatchPath = expPath + File.separator + "patch." + mainVersion + "." + packageName + ".obb";
51 | File main = new File(strPatchPath);
52 | if ( main.isFile() ) {
53 | ret.add(strPatchPath);
54 | }
55 | }
56 | }
57 | }
58 | String[] retArray = new String[ret.size()];
59 | ret.toArray(retArray);
60 | return retArray;
61 | }
62 |
63 | static public ZipResourceFile getResourceZipFile(String[] expansionFiles) throws IOException {
64 | ZipResourceFile apkExpansionFile = null;
65 | for (String expansionFilePath : expansionFiles) {
66 | if ( null == apkExpansionFile ) {
67 | apkExpansionFile = new ZipResourceFile(expansionFilePath);
68 | } else {
69 | apkExpansionFile.addPatchFile(expansionFilePath);
70 | }
71 | }
72 | return apkExpansionFile;
73 | }
74 |
75 | static public ZipResourceFile getAPKExpansionZipFile(Context ctx, int mainVersion, int patchVersion) throws IOException{
76 | String[] expansionFiles = getAPKExpansionFiles(ctx, mainVersion, patchVersion);
77 | return getResourceZipFile(expansionFiles);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/src/com/google/android/vending/expansion/downloader/IDownloaderService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.expansion.downloader;
18 |
19 | import com.google.android.vending.expansion.downloader.impl.DownloaderService;
20 | import android.os.Messenger;
21 |
22 | /**
23 | * This interface is implemented by the DownloaderService and by the
24 | * DownloaderServiceMarshaller. It contains functions to control the service.
25 | * When a client binds to the service, it must call the onClientUpdated
26 | * function.
27 | *
28 | * You can acquire a proxy that implements this interface for your service by
29 | * calling {@link DownloaderServiceMarshaller#CreateProxy} during the
30 | * {@link IDownloaderClient#onServiceConnected} callback. At which point, you
31 | * should immediately call {@link #onClientUpdated}.
32 | */
33 | public interface IDownloaderService {
34 | /**
35 | * Set this flag in response to the
36 | * IDownloaderClient.STATE_PAUSED_NEED_CELLULAR_PERMISSION state and then
37 | * call RequestContinueDownload to resume a download
38 | */
39 | public static final int FLAGS_DOWNLOAD_OVER_CELLULAR = 1;
40 |
41 | /**
42 | * Request that the service abort the current download. The service should
43 | * respond by changing the state to {@link IDownloaderClient.STATE_ABORTED}.
44 | */
45 | void requestAbortDownload();
46 |
47 | /**
48 | * Request that the service pause the current download. The service should
49 | * respond by changing the state to
50 | * {@link IDownloaderClient.STATE_PAUSED_BY_REQUEST}.
51 | */
52 | void requestPauseDownload();
53 |
54 | /**
55 | * Request that the service continue a paused download, when in any paused
56 | * or failed state, including
57 | * {@link IDownloaderClient.STATE_PAUSED_BY_REQUEST}.
58 | */
59 | void requestContinueDownload();
60 |
61 | /**
62 | * Set the flags for this download (e.g.
63 | * {@link DownloaderService.FLAGS_DOWNLOAD_OVER_CELLULAR}).
64 | *
65 | * @param flags
66 | */
67 | void setDownloadFlags(int flags);
68 |
69 | /**
70 | * Requests that the download status be sent to the client.
71 | */
72 | void requestDownloadStatus();
73 |
74 | /**
75 | * Call this when you get {@link
76 | * IDownloaderClient.onServiceConnected(Messenger m)} from the
77 | * DownloaderClient to register the client with the service. It will
78 | * automatically send the current status to the client.
79 | *
80 | * @param clientMessenger
81 | */
82 | void onClientUpdated(Messenger clientMessenger);
83 | }
84 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/src/com/google/android/vending/expansion/downloader/impl/DownloadInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.expansion.downloader.impl;
18 |
19 | import com.google.android.vending.expansion.downloader.Constants;
20 | import com.google.android.vending.expansion.downloader.Helpers;
21 |
22 | import android.util.Log;
23 |
24 | /**
25 | * Representation of information about an individual download from the database.
26 | */
27 | public class DownloadInfo {
28 | public String mUri;
29 | public final int mIndex;
30 | public final String mFileName;
31 | public String mETag;
32 | public long mTotalBytes;
33 | public long mCurrentBytes;
34 | public long mLastMod;
35 | public int mStatus;
36 | public int mControl;
37 | public int mNumFailed;
38 | public int mRetryAfter;
39 | public int mRedirectCount;
40 |
41 | boolean mInitialized;
42 |
43 | public int mFuzz;
44 |
45 | public DownloadInfo(int index, String fileName, String pkg) {
46 | mFuzz = Helpers.sRandom.nextInt(1001);
47 | mFileName = fileName;
48 | mIndex = index;
49 | }
50 |
51 | public void resetDownload() {
52 | mCurrentBytes = 0;
53 | mETag = "";
54 | mLastMod = 0;
55 | mStatus = 0;
56 | mControl = 0;
57 | mNumFailed = 0;
58 | mRetryAfter = 0;
59 | mRedirectCount = 0;
60 | }
61 |
62 | /**
63 | * Returns the time when a download should be restarted.
64 | */
65 | public long restartTime(long now) {
66 | if (mNumFailed == 0) {
67 | return now;
68 | }
69 | if (mRetryAfter > 0) {
70 | return mLastMod + mRetryAfter;
71 | }
72 | return mLastMod +
73 | Constants.RETRY_FIRST_DELAY *
74 | (1000 + mFuzz) * (1 << (mNumFailed - 1));
75 | }
76 |
77 | public void logVerboseInfo() {
78 | Log.v(Constants.TAG, "Service adding new entry");
79 | Log.v(Constants.TAG, "FILENAME: " + mFileName);
80 | Log.v(Constants.TAG, "URI : " + mUri);
81 | Log.v(Constants.TAG, "FILENAME: " + mFileName);
82 | Log.v(Constants.TAG, "CONTROL : " + mControl);
83 | Log.v(Constants.TAG, "STATUS : " + mStatus);
84 | Log.v(Constants.TAG, "FAILED_C: " + mNumFailed);
85 | Log.v(Constants.TAG, "RETRY_AF: " + mRetryAfter);
86 | Log.v(Constants.TAG, "REDIRECT: " + mRedirectCount);
87 | Log.v(Constants.TAG, "LAST_MOD: " + mLastMod);
88 | Log.v(Constants.TAG, "TOTAL : " + mTotalBytes);
89 | Log.v(Constants.TAG, "CURRENT : " + mCurrentBytes);
90 | Log.v(Constants.TAG, "ETAG : " + mETag);
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | phonegap-xapkreader
2 | ===================
3 |
4 | Cordova plugin to access files in APK Expansion Files for Cordova/Phonegap Android application.
5 |
6 | The plugin is an implementation of the process described here : [APK Expansion Files](http://developer.android.com/google/play/expansion-files.html)
7 |
8 | # Installation
9 |
10 | This plugin use the Cordova CLI's plugin command. To install it to your application, simply execute the following (and replace variables).
11 |
12 | ```
13 | cordova plugin add com.intel.xapkreader --variable MAIN_VERSION=1 --variable MAIN_FILESIZE=12345 --variable PATCH_VERSION=0 --variable PATCH_FILESIZE=0 --variable YOUR_PUBLICKEY="your own application publickkey" --variable DOWNLOAD_OPTION=true
14 | ```
15 |
16 | - `MAIN_VERSION` : The version of your main expansion file. Can be 1 or >1.
17 | - `PATCH_VERSION` : The version of your patch expansion file. Should be 0 if no patch exists.
18 | - `MAIN_FILESIZE` : The byte size of your main expansion file. This is used to verify the intégrity of the file after downloading.
19 | - `PATCH_FILESIZE` : The byte size of your patch expansion file. Should be 0, if no patch exists.
20 | - `YOUR_PUBLICKEY` : Your own application public key.
21 | - `DOWNLOAD_OPTION` : Can be `true` or `false`. Define if your APK expansion file is downloaded from the play store(true) or manually add it(false). The false option is mainly for testing purpose.
22 |
23 |
24 | # Using
25 |
26 | The file is returned to a success callback as URL object that you can use like in the example below or with the File API.
27 |
28 | ```
29 | XAPKReader.get(filename, successCallback, [errorCallback], [fileType]);
30 | ```
31 |
32 | ## Parameters
33 |
34 | - **filename** : The name of the file to load form the expansion file
35 | - **successCallback** : The callback that executes when the file is loaded.
36 | - **errorCallback** (Optional) : The callback that executes if an error occurs.
37 | - **fileType** (Optional) : The file type.
38 |
39 | ## Example
40 |
41 | ```javascript
42 | XAPKReader.get(
43 | 'image.jpg',
44 | function (url) {
45 | var img = new Image();
46 | img.src = url;
47 | document.body.appendChild(img);
48 | },
49 | function (error) {
50 | console.error(error);
51 | },
52 | 'image/jpeg'
53 | );
54 | ```
55 |
56 | # Licence MIT
57 |
58 | Copyright (c) 2015 Intel Corporation
59 |
60 | Copyright 2013 Quentin Aupetit
61 |
62 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
63 |
64 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
65 |
66 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
67 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/src/com/google/android/vending/licensing/ILicenseResultListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is auto-generated. DO NOT MODIFY.
3 | * Original file: aidl/ILicenseResultListener.aidl
4 | */
5 | package com.google.android.vending.licensing;
6 | import java.lang.String;
7 | import android.os.RemoteException;
8 | import android.os.IBinder;
9 | import android.os.IInterface;
10 | import android.os.Binder;
11 | import android.os.Parcel;
12 | public interface ILicenseResultListener extends android.os.IInterface
13 | {
14 | /** Local-side IPC implementation stub class. */
15 | public static abstract class Stub extends android.os.Binder implements com.google.android.vending.licensing.ILicenseResultListener
16 | {
17 | private static final java.lang.String DESCRIPTOR = "com.android.vending.licensing.ILicenseResultListener";
18 | /** Construct the stub at attach it to the interface. */
19 | public Stub()
20 | {
21 | this.attachInterface(this, DESCRIPTOR);
22 | }
23 | /**
24 | * Cast an IBinder object into an ILicenseResultListener interface,
25 | * generating a proxy if needed.
26 | */
27 | public static com.google.android.vending.licensing.ILicenseResultListener asInterface(android.os.IBinder obj)
28 | {
29 | if ((obj==null)) {
30 | return null;
31 | }
32 | android.os.IInterface iin = (android.os.IInterface)obj.queryLocalInterface(DESCRIPTOR);
33 | if (((iin!=null)&&(iin instanceof com.google.android.vending.licensing.ILicenseResultListener))) {
34 | return ((com.google.android.vending.licensing.ILicenseResultListener)iin);
35 | }
36 | return new com.google.android.vending.licensing.ILicenseResultListener.Stub.Proxy(obj);
37 | }
38 | public android.os.IBinder asBinder()
39 | {
40 | return this;
41 | }
42 | public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
43 | {
44 | switch (code)
45 | {
46 | case INTERFACE_TRANSACTION:
47 | {
48 | reply.writeString(DESCRIPTOR);
49 | return true;
50 | }
51 | case TRANSACTION_verifyLicense:
52 | {
53 | data.enforceInterface(DESCRIPTOR);
54 | int _arg0;
55 | _arg0 = data.readInt();
56 | java.lang.String _arg1;
57 | _arg1 = data.readString();
58 | java.lang.String _arg2;
59 | _arg2 = data.readString();
60 | this.verifyLicense(_arg0, _arg1, _arg2);
61 | return true;
62 | }
63 | }
64 | return super.onTransact(code, data, reply, flags);
65 | }
66 | private static class Proxy implements com.google.android.vending.licensing.ILicenseResultListener
67 | {
68 | private android.os.IBinder mRemote;
69 | Proxy(android.os.IBinder remote)
70 | {
71 | mRemote = remote;
72 | }
73 | public android.os.IBinder asBinder()
74 | {
75 | return mRemote;
76 | }
77 | public java.lang.String getInterfaceDescriptor()
78 | {
79 | return DESCRIPTOR;
80 | }
81 | public void verifyLicense(int responseCode, java.lang.String signedData, java.lang.String signature) throws android.os.RemoteException
82 | {
83 | android.os.Parcel _data = android.os.Parcel.obtain();
84 | try {
85 | _data.writeInterfaceToken(DESCRIPTOR);
86 | _data.writeInt(responseCode);
87 | _data.writeString(signedData);
88 | _data.writeString(signature);
89 | mRemote.transact(Stub.TRANSACTION_verifyLicense, _data, null, IBinder.FLAG_ONEWAY);
90 | }
91 | finally {
92 | _data.recycle();
93 | }
94 | }
95 | }
96 | static final int TRANSACTION_verifyLicense = (IBinder.FIRST_CALL_TRANSACTION + 0);
97 | }
98 | public void verifyLicense(int responseCode, java.lang.String signedData, java.lang.String signature) throws android.os.RemoteException;
99 | }
100 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/src/com/google/android/vending/expansion/downloader/impl/V14CustomNotification.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.expansion.downloader.impl;
18 |
19 | import com.android.vending.expansion.downloader.R;
20 | import com.google.android.vending.expansion.downloader.Helpers;
21 |
22 | import android.app.Notification;
23 | import android.app.PendingIntent;
24 | import android.content.Context;
25 |
26 | public class V14CustomNotification implements DownloadNotification.ICustomNotification {
27 |
28 | CharSequence mTitle;
29 | CharSequence mTicker;
30 | int mIcon;
31 | long mTotalKB = -1;
32 | long mCurrentKB = -1;
33 | long mTimeRemaining;
34 | PendingIntent mPendingIntent;
35 |
36 | @Override
37 | public void setIcon(int icon) {
38 | mIcon = icon;
39 | }
40 |
41 | @Override
42 | public void setTitle(CharSequence title) {
43 | mTitle = title;
44 | }
45 |
46 | @Override
47 | public void setTotalBytes(long totalBytes) {
48 | mTotalKB = totalBytes;
49 | }
50 |
51 | @Override
52 | public void setCurrentBytes(long currentBytes) {
53 | mCurrentKB = currentBytes;
54 | }
55 |
56 | void setProgress(Notification.Builder builder) {
57 |
58 | }
59 |
60 | @Override
61 | public Notification updateNotification(Context c) {
62 | Notification.Builder builder = new Notification.Builder(c);
63 | builder.setContentTitle(mTitle);
64 | if (mTotalKB > 0 && -1 != mCurrentKB) {
65 | builder.setProgress((int) (mTotalKB >> 8), (int) (mCurrentKB >> 8), false);
66 | } else {
67 | builder.setProgress(0, 0, true);
68 | }
69 | builder.setContentText(Helpers.getDownloadProgressString(mCurrentKB, mTotalKB));
70 | builder.setContentInfo(c.getString(R.string.time_remaining_notification,
71 | Helpers.getTimeRemaining(mTimeRemaining)));
72 | if (mIcon != 0) {
73 | builder.setSmallIcon(mIcon);
74 | } else {
75 | int iconResource = android.R.drawable.stat_sys_download;
76 | builder.setSmallIcon(iconResource);
77 | }
78 | builder.setOngoing(true);
79 | builder.setTicker(mTicker);
80 | builder.setContentIntent(mPendingIntent);
81 | builder.setOnlyAlertOnce(true);
82 |
83 | return builder.getNotification();
84 | }
85 |
86 | @Override
87 | public void setPendingIntent(PendingIntent contentIntent) {
88 | mPendingIntent = contentIntent;
89 | }
90 |
91 | @Override
92 | public void setTicker(CharSequence ticker) {
93 | mTicker = ticker;
94 | }
95 |
96 | @Override
97 | public void setTimeRemaining(long timeRemaining) {
98 | mTimeRemaining = timeRemaining;
99 | }
100 |
101 | }
102 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/test/src/com/android/vending/licensing/ObfuscatedPreferencesTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.android.vending.licensing;
18 |
19 | import com.example.android.market.licensing.MainActivity;
20 | import com.google.android.vending.licensing.AESObfuscator;
21 | import com.google.android.vending.licensing.Obfuscator;
22 | import com.google.android.vending.licensing.PreferenceObfuscator;
23 |
24 | import android.app.Activity;
25 | import android.content.Context;
26 | import android.content.SharedPreferences;
27 | import android.provider.Settings;
28 | import android.test.ActivityInstrumentationTestCase2;
29 |
30 | /**
31 | * Test suite for PreferenceObfuscator.
32 | */
33 | public class ObfuscatedPreferencesTest extends ActivityInstrumentationTestCase2 {
34 |
35 | private static final String filename =
36 | "com.android.vending.licnese.test.ObfuscatedPreferencePopulatedTest";
37 | private Activity a;
38 | private SharedPreferences sp;
39 | private PreferenceObfuscator op;
40 |
41 | public ObfuscatedPreferencesTest() {
42 | super("com.example.android.market.licensing", MainActivity.class);
43 | }
44 |
45 | @Override
46 | public void setUp() {
47 | final byte[] SALT = new byte[] {
48 | 104, -12, 112, 82, -85, -10, -11, 61, 15, 54, 44, -66, -117, -89, -64, 110, -53, 123, 33
49 | };
50 |
51 | // Prepare PreferenceObfuscator instance
52 | a = getActivity();
53 | sp = a.getSharedPreferences(filename, Context.MODE_PRIVATE);
54 | String deviceId = Settings.Secure.getString(
55 | a.getApplicationContext().getContentResolver(),
56 | Settings.Secure.ANDROID_ID);
57 | Obfuscator o = new AESObfuscator(SALT, a.getPackageName(), deviceId);
58 | op = new PreferenceObfuscator(sp, o);
59 |
60 | // Populate with test data
61 | op.putString("testString", "Hello world");
62 | op.commit();
63 | }
64 |
65 | public void cleanup() {
66 | // Manually clear out any saved preferences
67 | SharedPreferences.Editor spe = sp.edit();
68 | spe.clear();
69 | spe.commit();
70 | }
71 |
72 | public void testGetString() {
73 | assertEquals("Hello world", op.getString("testString", "fail"));
74 | }
75 |
76 | public void testGetDefaultString() {
77 | assertEquals("Android rocks", op.getString("noExist", "Android rocks"));
78 | }
79 |
80 | public void testGetDefaultNullString() {
81 | assertEquals(null, op.getString("noExist", null));
82 | }
83 |
84 | public void testCorruptDataRetunsDefaultString() {
85 | // Insert non-obfuscated string
86 | SharedPreferences.Editor spe = sp.edit();
87 | spe.putString("corruptData", "foo");
88 | spe.commit();
89 |
90 | // Read back contents
91 | assertEquals("Android rocks", op.getString("corruptdata", "Android rocks"));
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/src/com/google/android/vending/licensing/ILicensingService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is auto-generated. DO NOT MODIFY.
3 | * Original file: aidl/ILicensingService.aidl
4 | */
5 | package com.google.android.vending.licensing;
6 | import java.lang.String;
7 | import android.os.RemoteException;
8 | import android.os.IBinder;
9 | import android.os.IInterface;
10 | import android.os.Binder;
11 | import android.os.Parcel;
12 | public interface ILicensingService extends android.os.IInterface
13 | {
14 | /** Local-side IPC implementation stub class. */
15 | public static abstract class Stub extends android.os.Binder implements com.google.android.vending.licensing.ILicensingService
16 | {
17 | private static final java.lang.String DESCRIPTOR = "com.android.vending.licensing.ILicensingService";
18 | /** Construct the stub at attach it to the interface. */
19 | public Stub()
20 | {
21 | this.attachInterface(this, DESCRIPTOR);
22 | }
23 | /**
24 | * Cast an IBinder object into an ILicensingService interface,
25 | * generating a proxy if needed.
26 | */
27 | public static com.google.android.vending.licensing.ILicensingService asInterface(android.os.IBinder obj)
28 | {
29 | if ((obj==null)) {
30 | return null;
31 | }
32 | android.os.IInterface iin = (android.os.IInterface)obj.queryLocalInterface(DESCRIPTOR);
33 | if (((iin!=null)&&(iin instanceof com.google.android.vending.licensing.ILicensingService))) {
34 | return ((com.google.android.vending.licensing.ILicensingService)iin);
35 | }
36 | return new com.google.android.vending.licensing.ILicensingService.Stub.Proxy(obj);
37 | }
38 | public android.os.IBinder asBinder()
39 | {
40 | return this;
41 | }
42 | public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException
43 | {
44 | switch (code)
45 | {
46 | case INTERFACE_TRANSACTION:
47 | {
48 | reply.writeString(DESCRIPTOR);
49 | return true;
50 | }
51 | case TRANSACTION_checkLicense:
52 | {
53 | data.enforceInterface(DESCRIPTOR);
54 | long _arg0;
55 | _arg0 = data.readLong();
56 | java.lang.String _arg1;
57 | _arg1 = data.readString();
58 | com.google.android.vending.licensing.ILicenseResultListener _arg2;
59 | _arg2 = com.google.android.vending.licensing.ILicenseResultListener.Stub.asInterface(data.readStrongBinder());
60 | this.checkLicense(_arg0, _arg1, _arg2);
61 | return true;
62 | }
63 | }
64 | return super.onTransact(code, data, reply, flags);
65 | }
66 | private static class Proxy implements com.google.android.vending.licensing.ILicensingService
67 | {
68 | private android.os.IBinder mRemote;
69 | Proxy(android.os.IBinder remote)
70 | {
71 | mRemote = remote;
72 | }
73 | public android.os.IBinder asBinder()
74 | {
75 | return mRemote;
76 | }
77 | public java.lang.String getInterfaceDescriptor()
78 | {
79 | return DESCRIPTOR;
80 | }
81 | public void checkLicense(long nonce, java.lang.String packageName, com.google.android.vending.licensing.ILicenseResultListener listener) throws android.os.RemoteException
82 | {
83 | android.os.Parcel _data = android.os.Parcel.obtain();
84 | try {
85 | _data.writeInterfaceToken(DESCRIPTOR);
86 | _data.writeLong(nonce);
87 | _data.writeString(packageName);
88 | _data.writeStrongBinder((((listener!=null))?(listener.asBinder()):(null)));
89 | mRemote.transact(Stub.TRANSACTION_checkLicense, _data, null, IBinder.FLAG_ONEWAY);
90 | }
91 | finally {
92 | _data.recycle();
93 | }
94 | }
95 | }
96 | static final int TRANSACTION_checkLicense = (IBinder.FIRST_CALL_TRANSACTION + 0);
97 | }
98 | public void checkLicense(long nonce, java.lang.String packageName, com.google.android.vending.licensing.ILicenseResultListener listener) throws android.os.RemoteException;
99 | }
100 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/gen/com/android/vending/expansion/downloader/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * aapt tool from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 |
8 | package com.android.vending.expansion.downloader;
9 |
10 | public final class R {
11 | public static final class attr {
12 | }
13 | public static final class drawable {
14 | public static int notify_panel_notification_icon_bg=0x7f020000;
15 | }
16 | public static final class id {
17 | public static int appIcon=0x7f060001;
18 | public static int description=0x7f060007;
19 | public static int notificationLayout=0x7f060000;
20 | public static int progress_bar=0x7f060006;
21 | public static int progress_bar_frame=0x7f060005;
22 | public static int progress_text=0x7f060002;
23 | public static int time_remaining=0x7f060004;
24 | public static int title=0x7f060003;
25 | }
26 | public static final class layout {
27 | public static int status_bar_ongoing_event_progress_bar=0x7f030000;
28 | }
29 | public static final class string {
30 | public static int kilobytes_per_second=0x7f040014;
31 | /** When a download completes, a notification is displayed, and this
32 | string is used to indicate that the download successfully completed.
33 | Note that such a download could have been initiated by a variety of
34 | applications, including (but not limited to) the browser, an email
35 | application, a content marketplace.
36 | */
37 | public static int notification_download_complete=0x7f040000;
38 | /** When a download completes, a notification is displayed, and this
39 | string is used to indicate that the download failed.
40 | Note that such a download could have been initiated by a variety of
41 | applications, including (but not limited to) the browser, an email
42 | application, a content marketplace.
43 | */
44 | public static int notification_download_failed=0x7f040001;
45 | public static int state_completed=0x7f040007;
46 | public static int state_connecting=0x7f040005;
47 | public static int state_downloading=0x7f040006;
48 | public static int state_failed=0x7f040013;
49 | public static int state_failed_cancelled=0x7f040012;
50 | public static int state_failed_fetching_url=0x7f040010;
51 | public static int state_failed_sdcard_full=0x7f040011;
52 | public static int state_failed_unlicensed=0x7f04000f;
53 | public static int state_fetching_url=0x7f040004;
54 | public static int state_idle=0x7f040003;
55 | public static int state_paused_by_request=0x7f04000a;
56 | public static int state_paused_network_setup_failure=0x7f040009;
57 | public static int state_paused_network_unavailable=0x7f040008;
58 | public static int state_paused_roaming=0x7f04000d;
59 | public static int state_paused_sdcard_unavailable=0x7f04000e;
60 | public static int state_paused_wifi_disabled=0x7f04000c;
61 | public static int state_paused_wifi_unavailable=0x7f04000b;
62 | public static int state_unknown=0x7f040002;
63 | public static int time_remaining=0x7f040015;
64 | public static int time_remaining_notification=0x7f040016;
65 | }
66 | public static final class style {
67 | public static int ButtonBackground=0x7f050003;
68 | public static int NotificationText=0x7f050000;
69 | public static int NotificationTextSecondary=0x7f050004;
70 | public static int NotificationTextShadow=0x7f050001;
71 | public static int NotificationTitle=0x7f050002;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 | XAPKReader
8 | Access files into APK Expansion Files
9 | Apache 2.0
10 | cordova,apk,expansion,file,xapk,xapkreader
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | $MAIN_VERSION
39 | $PATCH_VERSION
40 | $MAIN_FILESIZE
41 | $PATCH_FILESIZE
42 | $YOUR_PUBLICKEY
43 | $DOWNLOAD_OPTION
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/test/src/com/android/vending/licensing/ServerManagedPolicyTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.android.vending.licensing;
18 |
19 |
20 | import com.example.android.market.licensing.MainActivity;
21 | import com.google.android.vending.licensing.AESObfuscator;
22 | import com.google.android.vending.licensing.Policy;
23 | import com.google.android.vending.licensing.ResponseData;
24 | import com.google.android.vending.licensing.ServerManagedPolicy;
25 |
26 | import android.provider.Settings;
27 | import android.test.ActivityInstrumentationTestCase2;
28 |
29 | /**
30 | * Test suite for StrictPolicy.
31 | */
32 | public class ServerManagedPolicyTest extends ActivityInstrumentationTestCase2 {
33 |
34 | ServerManagedPolicy p;
35 |
36 | public ServerManagedPolicyTest() {
37 | super("com.example.android.market.licensing", MainActivity.class);
38 | }
39 |
40 | public void setUp() {
41 | final byte[] SALT = new byte[] {
42 | 104, -12, 112, 82, -85, -10, -11, 61, 15, 54, 44, -66, -117, -89, -64, 110, -53, 123, 33
43 | };
44 |
45 | String deviceId = Settings.Secure.getString(
46 | getActivity().getApplicationContext().getContentResolver(),
47 | Settings.Secure.ANDROID_ID);
48 | p = new ServerManagedPolicy(getActivity().getApplicationContext(),
49 | new AESObfuscator(SALT, getActivity().getPackageName(), deviceId));
50 | }
51 |
52 | /**
53 | * Verify that extra data is parsed correctly on a LICENSED resopnse..
54 | */
55 | public void testExtraDataParsed() {
56 |
57 | String sampleResponse = "0|1579380448|com.example.android.market.licensing|1|" +
58 | "ADf8I4ajjgc1P5ZI1S1DN/YIPIUNPECLrg==|1279578835423:VT=11>=22&GR=33";
59 | p.processServerResponse(Policy.LICENSED,
60 | ResponseData.parse(sampleResponse));
61 | assertEquals(11l, p.getValidityTimestamp());
62 | assertEquals(22l, p.getRetryUntil());
63 | assertEquals(33l, p.getMaxRetries());
64 | }
65 |
66 | /**
67 | * Verify that retry counts are cleared after getting a NOT_LICENSED response.
68 | */
69 | public void testRetryCountsCleared() {
70 | String sampleResponse = "0|1579380448|com.example.android.market.licensing|1|" +
71 | "ADf8I4ajjgc1P5ZI1S1DN/YIPIUNPECLrg==|1279578835423:VT=1>=2&GR=3";
72 | p.processServerResponse(Policy.LICENSED,
73 | ResponseData.parse(sampleResponse));
74 | // Sanity test
75 | assertTrue(0l != p.getValidityTimestamp());
76 | assertTrue(0l != p.getRetryUntil());
77 | assertTrue(0l != p.getMaxRetries());
78 |
79 | // Actual test
80 | p.processServerResponse(Policy.NOT_LICENSED, null);
81 | assertEquals(0l, p.getValidityTimestamp());
82 | assertEquals(0l, p.getRetryUntil());
83 | assertEquals(0l, p.getMaxRetries());
84 | }
85 |
86 | public void testNoFailureOnEncodedExtras() {
87 | String sampleResponse = "0|1579380448|com.example.android.market.licensing|1|" +
88 | "ADf8I4ajjgc1P5ZI1S1DN/YIPIUNPECLrg==|1279578835423:VT=1&test=hello%20world%20%26" +
89 | "%20friends>=2&GR=3";
90 | p.processServerResponse(Policy.LICENSED,
91 | ResponseData.parse(sampleResponse));
92 | assertEquals(1l, p.getValidityTimestamp());
93 | assertEquals(2l, p.getRetryUntil());
94 | assertEquals(3l, p.getMaxRetries());
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
29 |
30 |
31 |
35 |
36 |
37 |
38 |
39 |
40 |
49 |
50 |
51 |
52 |
56 |
57 |
69 |
70 |
71 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/zip_file/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
29 |
30 |
31 |
35 |
36 |
37 |
38 |
39 |
40 |
49 |
50 |
51 |
52 |
56 |
57 |
69 |
70 |
71 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/res/layout/status_bar_ongoing_event_progress_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
24 |
25 |
30 |
31 |
39 |
40 |
50 |
51 |
52 |
61 |
62 |
69 |
70 |
77 |
78 |
79 |
84 |
85 |
91 |
92 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/src/com/google/android/vending/expansion/downloader/impl/CustomIntentService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.expansion.downloader.impl;
18 |
19 | import android.app.Service;
20 | import android.content.Intent;
21 | import android.os.Handler;
22 | import android.os.HandlerThread;
23 | import android.os.IBinder;
24 | import android.os.Looper;
25 | import android.os.Message;
26 | import android.util.Log;
27 |
28 | /**
29 | * This service differs from IntentService in a few minor ways/ It will not
30 | * auto-stop itself after the intent is handled unless the target returns "true"
31 | * in should stop. Since the goal of this service is to handle a single kind of
32 | * intent, it does not queue up batches of intents of the same type.
33 | */
34 | public abstract class CustomIntentService extends Service {
35 | private String mName;
36 | private boolean mRedelivery;
37 | private volatile ServiceHandler mServiceHandler;
38 | private volatile Looper mServiceLooper;
39 | private static final String LOG_TAG = "CancellableIntentService";
40 | private static final int WHAT_MESSAGE = -10;
41 |
42 | public CustomIntentService(String paramString) {
43 | this.mName = paramString;
44 | }
45 |
46 | @Override
47 | public IBinder onBind(Intent paramIntent) {
48 | return null;
49 | }
50 |
51 | @Override
52 | public void onCreate() {
53 | super.onCreate();
54 | HandlerThread localHandlerThread = new HandlerThread("IntentService["
55 | + this.mName + "]");
56 | localHandlerThread.start();
57 | this.mServiceLooper = localHandlerThread.getLooper();
58 | this.mServiceHandler = new ServiceHandler(this.mServiceLooper);
59 | }
60 |
61 | @Override
62 | public void onDestroy() {
63 | Thread localThread = this.mServiceLooper.getThread();
64 | if ((localThread != null) && (localThread.isAlive())) {
65 | localThread.interrupt();
66 | }
67 | this.mServiceLooper.quit();
68 | Log.d(LOG_TAG, "onDestroy");
69 | }
70 |
71 | protected abstract void onHandleIntent(Intent paramIntent);
72 |
73 | protected abstract boolean shouldStop();
74 |
75 | @Override
76 | public void onStart(Intent paramIntent, int startId) {
77 | if (!this.mServiceHandler.hasMessages(WHAT_MESSAGE)) {
78 | Message localMessage = this.mServiceHandler.obtainMessage();
79 | localMessage.arg1 = startId;
80 | localMessage.obj = paramIntent;
81 | localMessage.what = WHAT_MESSAGE;
82 | this.mServiceHandler.sendMessage(localMessage);
83 | }
84 | }
85 |
86 | @Override
87 | public int onStartCommand(Intent paramIntent, int flags, int startId) {
88 | onStart(paramIntent, startId);
89 | return mRedelivery ? START_REDELIVER_INTENT : START_NOT_STICKY;
90 | }
91 |
92 | public void setIntentRedelivery(boolean enabled) {
93 | this.mRedelivery = enabled;
94 | }
95 |
96 | private final class ServiceHandler extends Handler {
97 | public ServiceHandler(Looper looper) {
98 | super(looper);
99 | }
100 |
101 | @Override
102 | public void handleMessage(Message paramMessage) {
103 | CustomIntentService.this
104 | .onHandleIntent((Intent) paramMessage.obj);
105 | if (shouldStop()) {
106 | Log.d(LOG_TAG, "stopSelf");
107 | CustomIntentService.this.stopSelf(paramMessage.arg1);
108 | Log.d(LOG_TAG, "afterStopSelf");
109 | }
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/src/com/google/android/vending/expansion/downloader/impl/V3CustomNotification.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.expansion.downloader.impl;
18 |
19 | import com.android.vending.expansion.downloader.R;
20 | import com.google.android.vending.expansion.downloader.Helpers;
21 |
22 | import android.app.Notification;
23 | import android.app.PendingIntent;
24 | import android.content.Context;
25 | import android.graphics.BitmapFactory;
26 | import android.view.View;
27 | import android.widget.RemoteViews;
28 |
29 | public class V3CustomNotification implements DownloadNotification.ICustomNotification {
30 |
31 | CharSequence mTitle;
32 | CharSequence mTicker;
33 | int mIcon;
34 | long mTotalBytes = -1;
35 | long mCurrentBytes = -1;
36 | long mTimeRemaining;
37 | PendingIntent mPendingIntent;
38 | Notification mNotification = new Notification();
39 |
40 | @Override
41 | public void setIcon(int icon) {
42 | mIcon = icon;
43 | }
44 |
45 | @Override
46 | public void setTitle(CharSequence title) {
47 | mTitle = title;
48 | }
49 |
50 | @Override
51 | public void setTotalBytes(long totalBytes) {
52 | mTotalBytes = totalBytes;
53 | }
54 |
55 | @Override
56 | public void setCurrentBytes(long currentBytes) {
57 | mCurrentBytes = currentBytes;
58 | }
59 |
60 | @Override
61 | public Notification updateNotification(Context c) {
62 | Notification n = mNotification;
63 |
64 | n.icon = mIcon;
65 |
66 | n.flags |= Notification.FLAG_ONGOING_EVENT;
67 |
68 | if (android.os.Build.VERSION.SDK_INT > 10) {
69 | n.flags |= Notification.FLAG_ONLY_ALERT_ONCE; // only matters for
70 | // Honeycomb
71 | }
72 |
73 | // Build the RemoteView object
74 | RemoteViews expandedView = new RemoteViews(
75 | c.getPackageName(),
76 | R.layout.status_bar_ongoing_event_progress_bar);
77 |
78 | expandedView.setTextViewText(R.id.title, mTitle);
79 | // look at strings
80 | expandedView.setViewVisibility(R.id.description, View.VISIBLE);
81 | expandedView.setTextViewText(R.id.description,
82 | Helpers.getDownloadProgressString(mCurrentBytes, mTotalBytes));
83 | expandedView.setViewVisibility(R.id.progress_bar_frame, View.VISIBLE);
84 | expandedView.setProgressBar(R.id.progress_bar,
85 | (int) (mTotalBytes >> 8),
86 | (int) (mCurrentBytes >> 8),
87 | mTotalBytes <= 0);
88 | expandedView.setViewVisibility(R.id.time_remaining, View.VISIBLE);
89 | expandedView.setTextViewText(
90 | R.id.time_remaining,
91 | c.getString(R.string.time_remaining_notification,
92 | Helpers.getTimeRemaining(mTimeRemaining)));
93 | expandedView.setTextViewText(R.id.progress_text,
94 | Helpers.getDownloadProgressPercent(mCurrentBytes, mTotalBytes));
95 | expandedView.setImageViewResource(R.id.appIcon, mIcon);
96 | n.contentView = expandedView;
97 | n.contentIntent = mPendingIntent;
98 | return n;
99 | }
100 |
101 | @Override
102 | public void setPendingIntent(PendingIntent contentIntent) {
103 | mPendingIntent = contentIntent;
104 | }
105 |
106 | @Override
107 | public void setTicker(CharSequence ticker) {
108 | mTicker = ticker;
109 | }
110 |
111 | @Override
112 | public void setTimeRemaining(long timeRemaining) {
113 | mTimeRemaining = timeRemaining;
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/src/com/google/android/vending/expansion/downloader/SystemFacade.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.expansion.downloader;
18 |
19 | import android.app.Notification;
20 | import android.app.NotificationManager;
21 | import android.content.Context;
22 | import android.content.Intent;
23 | import android.content.pm.PackageManager.NameNotFoundException;
24 | import android.net.ConnectivityManager;
25 | import android.net.NetworkInfo;
26 | import android.telephony.TelephonyManager;
27 | import android.util.Log;
28 |
29 | /**
30 | * Contains useful helper functions, typically tied to the application context.
31 | */
32 | class SystemFacade {
33 | private Context mContext;
34 | private NotificationManager mNotificationManager;
35 |
36 | public SystemFacade(Context context) {
37 | mContext = context;
38 | mNotificationManager = (NotificationManager)
39 | mContext.getSystemService(Context.NOTIFICATION_SERVICE);
40 | }
41 |
42 | public long currentTimeMillis() {
43 | return System.currentTimeMillis();
44 | }
45 |
46 | public Integer getActiveNetworkType() {
47 | ConnectivityManager connectivity =
48 | (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
49 | if (connectivity == null) {
50 | Log.w(Constants.TAG, "couldn't get connectivity manager");
51 | return null;
52 | }
53 |
54 | NetworkInfo activeInfo = connectivity.getActiveNetworkInfo();
55 | if (activeInfo == null) {
56 | if (Constants.LOGVV) {
57 | Log.v(Constants.TAG, "network is not available");
58 | }
59 | return null;
60 | }
61 | return activeInfo.getType();
62 | }
63 |
64 | public boolean isNetworkRoaming() {
65 | ConnectivityManager connectivity =
66 | (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
67 | if (connectivity == null) {
68 | Log.w(Constants.TAG, "couldn't get connectivity manager");
69 | return false;
70 | }
71 |
72 | NetworkInfo info = connectivity.getActiveNetworkInfo();
73 | boolean isMobile = (info != null && info.getType() == ConnectivityManager.TYPE_MOBILE);
74 | TelephonyManager tm = (TelephonyManager) mContext
75 | .getSystemService(Context.TELEPHONY_SERVICE);
76 | if (null == tm) {
77 | Log.w(Constants.TAG, "couldn't get telephony manager");
78 | return false;
79 | }
80 | boolean isRoaming = isMobile && tm.isNetworkRoaming();
81 | if (Constants.LOGVV && isRoaming) {
82 | Log.v(Constants.TAG, "network is roaming");
83 | }
84 | return isRoaming;
85 | }
86 |
87 | public Long getMaxBytesOverMobile() {
88 | return (long) Integer.MAX_VALUE;
89 | }
90 |
91 | public Long getRecommendedMaxBytesOverMobile() {
92 | return 2097152L;
93 | }
94 |
95 | public void sendBroadcast(Intent intent) {
96 | mContext.sendBroadcast(intent);
97 | }
98 |
99 | public boolean userOwnsPackage(int uid, String packageName) throws NameNotFoundException {
100 | return mContext.getPackageManager().getApplicationInfo(packageName, 0).uid == uid;
101 | }
102 |
103 | public void postNotification(long id, Notification notification) {
104 | /**
105 | * TODO: The system notification manager takes ints, not longs, as IDs,
106 | * but the download manager uses IDs take straight from the database,
107 | * which are longs. This will have to be dealt with at some point.
108 | */
109 | mNotificationManager.notify((int) id, notification);
110 | }
111 |
112 | public void cancelNotification(long id) {
113 | mNotificationManager.cancel((int) id);
114 | }
115 |
116 | public void cancelAllNotifications() {
117 | mNotificationManager.cancelAll();
118 | }
119 |
120 | public void startThread(Thread thread) {
121 | thread.start();
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/www/xapkreader.js:
--------------------------------------------------------------------------------
1 | var exec = require("cordova/exec");
2 | var getQueue = [];
3 | var inProgress = 0;
4 |
5 | module.exports = {
6 |
7 | /**
8 | * Get a file immediately in expansion file
9 | *
10 | * @param filename The file name
11 | * @param fileType The file type (eg: "image/jpeg")
12 | * @param successCallback The callback to be called when the file is found.
13 | * successCallback()
14 | * @param errorCallback The callback to be called if there is an error.
15 | * errorCallback(int errorCode) - OPTIONAL
16 | **/
17 | getImmediate: function(filename, successCallback, errorCallback, fileType) {
18 | // only for android
19 | if (!navigator.userAgent.match(/Android/i)) {
20 | return successCallback(filename);
21 | }
22 |
23 | if (null === filename) {
24 | console.error("XAPKReader.get failure: filename parameter needed");
25 | return;
26 | }
27 |
28 | var context = this;
29 |
30 | var success = function (result) {
31 | try {
32 | var url = context.arrayBufferToURL(result, fileType);
33 | successCallback(url);
34 | }
35 | catch (e) {
36 | errorCallback(e);
37 | }
38 | };
39 |
40 | cordova.exec(success, errorCallback, "XAPKReader", "get", [filename]);
41 | },
42 |
43 | /**
44 | * Adds queue to retrieve at most 10 get’s simultaneously.
45 | **/
46 | processQueue: function() {
47 | while (inProgress < 10) {
48 | var e = getQueue.pop();
49 | if (!e) break;
50 | inProgress = inProgress + 1;
51 | this.getImmediate(e.filename, e.successCallback, e.errorCallBack, e.fileType);
52 | }
53 | },
54 |
55 | /**
56 | * Get a file in expansion file and return it as data base64 encoded
57 | *
58 | * @param filename The file name
59 | * @param fileType The file type (eg: "image/jpeg")
60 | * @param successCallback The callback to be called when the file is found.
61 | * successCallback()
62 | * @param errorCallback The callback to be called if there is an error.
63 | * errorCallback(int errorCode) - OPTIONAL
64 | **/
65 | get: function(filename, successCallback, errorCallBack, fileType) {
66 | var self = this;
67 |
68 | getQueue.push({filename: filename,
69 | successCallback: function (x) {
70 | successCallback(x);
71 | self.getFinished();
72 | },
73 | errorCallBack: function(x) {
74 | errorCallBack(x);
75 | self.getFinished();
76 | },
77 | fileType: fileType});
78 |
79 | this.processQueue();
80 | },
81 |
82 | /**
83 | * Progress queue termination of 10 gets
84 | **/
85 | getFinished: function() {
86 | console.log('getfinished');
87 | inProgress = inProgress - 1;
88 | this.processQueue();
89 | },
90 |
91 | /**
92 | * Convert ArrayBuffer to URL
93 | *
94 | * @param arrayBuffer ArrayBuffer to convert
95 | * @param fileType (optional) The file type (eg: "image/jpeg")
96 | * @return URL URL string
97 | **/
98 | arrayBufferToURL: function (arrayBuffer, fileType) {
99 | var blob = this.createBlob(arrayBuffer);
100 | window.URL = window.URL || window.webkitURL;
101 | return window.URL.createObjectURL(blob);
102 | },
103 |
104 | /**
105 | * Create Blob from data
106 | *
107 | * @param part ArrayBuffer, ArrayBufferView, Blob or DOMString part
108 | * @param fileType (optional) The file type (eg: "image/jpeg")
109 | **/
110 | createBlob: function (part, fileType) {
111 | var blob;
112 | try {
113 | var properties = {};
114 | if (fileType) {
115 | properties.type = fileType;
116 | }
117 | blob = new Blob([part], properties);
118 | }
119 | catch (e) {
120 | // TypeError try old constructor
121 | window.BlobBuilder = window.BlobBuilder ||
122 | window.WebKitBlobBuilder;
123 |
124 | if (e.name == 'TypeError' && !window.BlobBuilder) {
125 | throw new Error('This platform does not support Blob type.');
126 | }
127 |
128 | var bb = new BlobBuilder();
129 | bb.append(part);
130 | blob = bb.getBlob(fileType);
131 | }
132 | return blob;
133 | }
134 |
135 | };
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
29 |
30 |
31 |
32 |
36 |
37 |
38 |
39 |
40 |
41 |
50 |
51 |
52 |
53 |
57 |
58 |
70 |
71 |
72 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/library/src/com/google/android/vending/licensing/AESObfuscator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.licensing;
18 |
19 | import com.google.android.vending.licensing.util.Base64;
20 | import com.google.android.vending.licensing.util.Base64DecoderException;
21 |
22 | import java.io.UnsupportedEncodingException;
23 | import java.security.GeneralSecurityException;
24 | import java.security.spec.KeySpec;
25 |
26 | import javax.crypto.BadPaddingException;
27 | import javax.crypto.Cipher;
28 | import javax.crypto.IllegalBlockSizeException;
29 | import javax.crypto.SecretKey;
30 | import javax.crypto.SecretKeyFactory;
31 | import javax.crypto.spec.IvParameterSpec;
32 | import javax.crypto.spec.PBEKeySpec;
33 | import javax.crypto.spec.SecretKeySpec;
34 |
35 | /**
36 | * An Obfuscator that uses AES to encrypt data.
37 | */
38 | public class AESObfuscator implements Obfuscator {
39 | private static final String UTF8 = "UTF-8";
40 | private static final String KEYGEN_ALGORITHM = "PBEWITHSHAAND256BITAES-CBC-BC";
41 | private static final String CIPHER_ALGORITHM = "AES/CBC/PKCS5Padding";
42 | private static final byte[] IV =
43 | { 16, 74, 71, -80, 32, 101, -47, 72, 117, -14, 0, -29, 70, 65, -12, 74 };
44 | private static final String header = "com.android.vending.licensing.AESObfuscator-1|";
45 |
46 | private Cipher mEncryptor;
47 | private Cipher mDecryptor;
48 |
49 | /**
50 | * @param salt an array of random bytes to use for each (un)obfuscation
51 | * @param applicationId application identifier, e.g. the package name
52 | * @param deviceId device identifier. Use as many sources as possible to
53 | * create this unique identifier.
54 | */
55 | public AESObfuscator(byte[] salt, String applicationId, String deviceId) {
56 | try {
57 | SecretKeyFactory factory = SecretKeyFactory.getInstance(KEYGEN_ALGORITHM);
58 | KeySpec keySpec =
59 | new PBEKeySpec((applicationId + deviceId).toCharArray(), salt, 1024, 256);
60 | SecretKey tmp = factory.generateSecret(keySpec);
61 | SecretKey secret = new SecretKeySpec(tmp.getEncoded(), "AES");
62 | mEncryptor = Cipher.getInstance(CIPHER_ALGORITHM);
63 | mEncryptor.init(Cipher.ENCRYPT_MODE, secret, new IvParameterSpec(IV));
64 | mDecryptor = Cipher.getInstance(CIPHER_ALGORITHM);
65 | mDecryptor.init(Cipher.DECRYPT_MODE, secret, new IvParameterSpec(IV));
66 | } catch (GeneralSecurityException e) {
67 | // This can't happen on a compatible Android device.
68 | throw new RuntimeException("Invalid environment", e);
69 | }
70 | }
71 |
72 | public String obfuscate(String original, String key) {
73 | if (original == null) {
74 | return null;
75 | }
76 | try {
77 | // Header is appended as an integrity check
78 | return Base64.encode(mEncryptor.doFinal((header + key + original).getBytes(UTF8)));
79 | } catch (UnsupportedEncodingException e) {
80 | throw new RuntimeException("Invalid environment", e);
81 | } catch (GeneralSecurityException e) {
82 | throw new RuntimeException("Invalid environment", e);
83 | }
84 | }
85 |
86 | public String unobfuscate(String obfuscated, String key) throws ValidationException {
87 | if (obfuscated == null) {
88 | return null;
89 | }
90 | try {
91 | String result = new String(mDecryptor.doFinal(Base64.decode(obfuscated)), UTF8);
92 | // Check for presence of header. This serves as a final integrity check, for cases
93 | // where the block size is correct during decryption.
94 | int headerIndex = result.indexOf(header+key);
95 | if (headerIndex != 0) {
96 | throw new ValidationException("Header not found (invalid data or key)" + ":" +
97 | obfuscated);
98 | }
99 | return result.substring(header.length()+key.length(), result.length());
100 | } catch (Base64DecoderException e) {
101 | throw new ValidationException(e.getMessage() + ":" + obfuscated);
102 | } catch (IllegalBlockSizeException e) {
103 | throw new ValidationException(e.getMessage() + ":" + obfuscated);
104 | } catch (BadPaddingException e) {
105 | throw new ValidationException(e.getMessage() + ":" + obfuscated);
106 | } catch (UnsupportedEncodingException e) {
107 | throw new RuntimeException("Invalid environment", e);
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/test/src/com/android/vending/licensing/AESObfuscatorTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.android.vending.licensing;
18 |
19 | import com.google.android.vending.licensing.AESObfuscator;
20 | import com.google.android.vending.licensing.Obfuscator;
21 | import com.google.android.vending.licensing.ValidationException;
22 |
23 | import android.util.Log;
24 |
25 | import java.util.Arrays;
26 |
27 | import junit.framework.TestCase;
28 |
29 | public class AESObfuscatorTest extends TestCase {
30 | private static final String TAG = "AESObfuscatorTest";
31 | private static final byte[] SALT = new byte[] {
32 | 104, -12, 112, 82, -85, -10, -11, 61, 15, 54, 44, -66, -117, -89, -64, 110, -53, 123, 33
33 | };
34 | private static final String PACKAGE = "package";
35 | private static final String DEVICE = "device";
36 |
37 | private Obfuscator mObfuscator;
38 |
39 | @Override
40 | protected void setUp() throws Exception{
41 | super.setUp();
42 | mObfuscator = new AESObfuscator(SALT, PACKAGE, DEVICE);
43 | }
44 |
45 | public void testObfuscateUnobfuscate() throws Exception {
46 | testInvertible(null);
47 | testInvertible("");
48 | testInvertible(
49 | "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*-=/\\|~`,.;:"
50 | + "()[]{}<>\u00F6");
51 | }
52 |
53 | public void testUnobfuscate_invalid() throws Exception {
54 | try {
55 | mObfuscator.unobfuscate("invalid", "testKey");
56 | fail("Should have thrown ValidationException");
57 | } catch (ValidationException expected) {
58 | }
59 | }
60 |
61 | public void testUnobfuscate_differentSalt() throws Exception {
62 | String obfuscated = mObfuscator.obfuscate("test", "testKey");
63 | Obfuscator differentSalt = new AESObfuscator(new byte[] { 1 }, PACKAGE, DEVICE);
64 | try {
65 | differentSalt.unobfuscate(obfuscated, "testKey");
66 | fail("Should have thrown ValidationException");
67 | } catch (ValidationException expected) {
68 | }
69 | }
70 |
71 | public void testUnobfuscate_avoidBadPaddingException() throws Exception {
72 | // Length should be equal to the cipher block size, to make sure that all padding lengths
73 | // are accounted for.
74 | for (int length = 0; length < 255; length++) {
75 | char[] data = new char[length];
76 | Arrays.fill(data, '0');
77 | String input = String.valueOf(data);
78 | Log.d(TAG, "Input: (" + length + ")" + input);
79 | String obfuscated = mObfuscator.obfuscate(input, "testKey");
80 | Obfuscator differentSalt = new AESObfuscator(new byte[] { 1 }, PACKAGE, DEVICE);
81 | try {
82 | differentSalt.unobfuscate(obfuscated, "testKey");
83 | fail("Should have thrown ValidationException");
84 | } catch (ValidationException expected) {
85 | }
86 | }
87 | }
88 |
89 | public void testUnobfuscate_differentDevice() throws Exception {
90 | String obfuscated = mObfuscator.obfuscate("test", "testKey");
91 | Obfuscator differentDevice = new AESObfuscator(SALT, PACKAGE, "device2");
92 | try {
93 | differentDevice.unobfuscate(obfuscated, "testKey");
94 | fail("Should have thrown ValidationException");
95 | } catch (ValidationException expected) {
96 | }
97 | }
98 |
99 | public void testUnobfuscate_differentPackage() throws Exception {
100 | String obfuscated = mObfuscator.obfuscate("test", "testKey");
101 | Obfuscator differentPackage = new AESObfuscator(SALT, "package2", DEVICE);
102 | try {
103 | differentPackage.unobfuscate(obfuscated, "testKey");
104 | fail("Should have thrown ValidationException");
105 | } catch (ValidationException expected) {
106 | }
107 | }
108 |
109 | public void testUnobfuscate_differentKey() throws Exception {
110 | String obfuscated = mObfuscator.obfuscate("test", "testKey");
111 | Obfuscator differentPackage = new AESObfuscator(SALT, "package2", DEVICE);
112 | try {
113 | differentPackage.unobfuscate(obfuscated, "notMyKey");
114 | fail("Should have thrown ValidationException");
115 | } catch (ValidationException expected) {
116 | }
117 | }
118 |
119 | public void testObfuscate_same() throws Exception {
120 | String obfuscated = mObfuscator.obfuscate("test", "testKey");
121 | assertEquals(obfuscated, mObfuscator.obfuscate("test", "testKey"));
122 |
123 | Obfuscator same = new AESObfuscator(SALT, PACKAGE, DEVICE);
124 | assertEquals(obfuscated, same.obfuscate("test", "testKey"));
125 | assertEquals("test", same.unobfuscate(obfuscated, "testKey"));
126 | }
127 |
128 | private void testInvertible(String original) throws Exception {
129 | assertEquals(original, mObfuscator.unobfuscate(mObfuscator.obfuscate(original, original+"Key"), original+"Key"));
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_licensing/test/src/com/android/vending/licensing/APKExpansionPolicyTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.android.vending.licensing;
18 |
19 |
20 | import com.example.android.market.licensing.MainActivity;
21 | import com.google.android.vending.licensing.AESObfuscator;
22 | import com.google.android.vending.licensing.APKExpansionPolicy;
23 | import com.google.android.vending.licensing.Policy;
24 | import com.google.android.vending.licensing.ResponseData;
25 |
26 | import android.provider.Settings;
27 | import android.test.ActivityInstrumentationTestCase2;
28 |
29 | /**
30 | * Test suite for StrictPolicy.
31 | */
32 | public class APKExpansionPolicyTest extends ActivityInstrumentationTestCase2 {
33 |
34 | APKExpansionPolicy p;
35 |
36 | public APKExpansionPolicyTest() {
37 | super("com.example.android.market.licensing", MainActivity.class);
38 | }
39 |
40 | public void setUp() {
41 | final byte[] SALT = new byte[] {
42 | 104, -12, 112, 82, -85, -10, -11, 61, 15, 54, 44, -66, -117, -89, -64, 110, -53, 123, 33
43 | };
44 |
45 | String deviceId = Settings.Secure.getString(
46 | getActivity().getApplicationContext().getContentResolver(),
47 | Settings.Secure.ANDROID_ID);
48 | p = new APKExpansionPolicy(getActivity().getApplicationContext(),
49 | new AESObfuscator(SALT, getActivity().getPackageName(), deviceId));
50 | }
51 |
52 | /**
53 | * Verify that extra data is parsed correctly on a LICENSED resopnse..
54 | */
55 | public void testExtraDataParsed() {
56 | String sampleResponse = "0|1579380448|com.example.android.market.licensing|1|" +
57 | "ADf8I4ajjgc1P5ZI1S1DN/YIPIUNPECLrg==|1279578835423:VT=11>=22&GR=33" +
58 | "&FILE_URL1=http://jmt17.google.com/vending_kila/download/AppDownload?packageName%3Dcom.example.android.market.licensing%26versionCode%3D3%26ft%3Do%26token%3DAOTCm0RwlzqFYylBNSCTLJApGH0cYtm9g8mGMdUhKLSLJW4v9VM8GLj4GVlGU5oyW6y3FsXrJiQqMunTGw9B" +
59 | "&FILE_NAME1=main.3.com.example.android.market.licensing.obb&FILE_SIZE1=687801613" +
60 | "&FILE_URL2=http://jmt17.google.com/vending_kila/download/AppDownload?packageName%3Dcom.example.android.market.licensing%26versionCode%3D3%26ft%3Do%26token%3DAOTCm0RwlzqFYylBNSCTLJApGH0cYtm9g8mGMdUhKLSLJW4v9VM8GLsdSDjefsdfEKdVaseEsfaMeifTek9B" +
61 | "&FILE_NAME2=patch.3.com.example.android.market.licensing.obb&FILE_SIZE2=204233";
62 | p.processServerResponse(Policy.LICENSED,
63 | ResponseData.parse(sampleResponse));
64 | assertEquals(11l, p.getValidityTimestamp());
65 | assertEquals(22l, p.getRetryUntil());
66 | assertEquals(33l, p.getMaxRetries());
67 | assertEquals(2, p.getExpansionURLCount());
68 | assertEquals("main.3.com.example.android.market.licensing.obb",p.getExpansionFileName(0));
69 | assertEquals(687801613l,p.getExpansionFileSize(0));
70 | assertEquals("http://jmt17.google.com/vending_kila/download/AppDownload?packageName%3Dcom.example.android.market.licensing%26versionCode%3D3%26ft%3Do%26token%3DAOTCm0RwlzqFYylBNSCTLJApGH0cYtm9g8mGMdUhKLSLJW4v9VM8GLj4GVlGU5oyW6y3FsXrJiQqMunTGw9B",
71 | p.getExpansionURL(0));
72 | assertEquals("patch.3.com.example.android.market.licensing.obb",p.getExpansionFileName(1));
73 | assertEquals(204233,p.getExpansionFileSize(1));
74 | assertEquals("http://jmt17.google.com/vending_kila/download/AppDownload?packageName%3Dcom.example.android.market.licensing%26versionCode%3D3%26ft%3Do%26token%3DAOTCm0RwlzqFYylBNSCTLJApGH0cYtm9g8mGMdUhKLSLJW4v9VM8GLsdSDjefsdfEKdVaseEsfaMeifTek9B",
75 | p.getExpansionURL(1));
76 | }
77 |
78 | /**
79 | * Verify that retry counts are cleared after getting a NOT_LICENSED response.
80 | */
81 | public void testRetryCountsCleared() {
82 | String sampleResponse = "0|1579380448|com.example.android.market.licensing|1|" +
83 | "ADf8I4ajjgc1P5ZI1S1DN/YIPIUNPECLrg==|1279578835423:VT=1>=2&GR=3";
84 | p.processServerResponse(Policy.LICENSED,
85 | ResponseData.parse(sampleResponse));
86 | // Sanity test
87 | assertTrue(0l != p.getValidityTimestamp());
88 | assertTrue(0l != p.getRetryUntil());
89 | assertTrue(0l != p.getMaxRetries());
90 |
91 | // Actual test
92 | p.processServerResponse(Policy.NOT_LICENSED, null);
93 | assertEquals(0l, p.getValidityTimestamp());
94 | assertEquals(0l, p.getRetryUntil());
95 | assertEquals(0l, p.getMaxRetries());
96 | }
97 |
98 | public void testNoFailureOnEncodedExtras() {
99 | String sampleResponse = "0|1579380448|com.example.android.market.licensing|1|" +
100 | "ADf8I4ajjgc1P5ZI1S1DN/YIPIUNPECLrg==|1279578835423:VT=1&test=hello%20world%20%26" +
101 | "%20friends>=2&GR=3";
102 | p.processServerResponse(Policy.LICENSED,
103 | ResponseData.parse(sampleResponse));
104 | assertEquals(1l, p.getValidityTimestamp());
105 | assertEquals(2l, p.getRetryUntil());
106 | assertEquals(3l, p.getMaxRetries());
107 | }
108 |
109 | }
110 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/src/com/google/android/vending/expansion/downloader/IDownloaderClient.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.expansion.downloader;
18 |
19 | import android.os.Messenger;
20 |
21 | /**
22 | * This interface should be implemented by the client activity for the
23 | * downloader. It is used to pass status from the service to the client.
24 | */
25 | public interface IDownloaderClient {
26 | static final int STATE_IDLE = 1;
27 | static final int STATE_FETCHING_URL = 2;
28 | static final int STATE_CONNECTING = 3;
29 | static final int STATE_DOWNLOADING = 4;
30 | static final int STATE_COMPLETED = 5;
31 |
32 | static final int STATE_PAUSED_NETWORK_UNAVAILABLE = 6;
33 | static final int STATE_PAUSED_BY_REQUEST = 7;
34 |
35 | /**
36 | * Both STATE_PAUSED_WIFI_DISABLED_NEED_CELLULAR_PERMISSION and
37 | * STATE_PAUSED_NEED_CELLULAR_PERMISSION imply that Wi-Fi is unavailable and
38 | * cellular permission will restart the service. Wi-Fi disabled means that
39 | * the Wi-Fi manager is returning that Wi-Fi is not enabled, while in the
40 | * other case Wi-Fi is enabled but not available.
41 | */
42 | static final int STATE_PAUSED_WIFI_DISABLED_NEED_CELLULAR_PERMISSION = 8;
43 | static final int STATE_PAUSED_NEED_CELLULAR_PERMISSION = 9;
44 |
45 | /**
46 | * Both STATE_PAUSED_WIFI_DISABLED and STATE_PAUSED_NEED_WIFI imply that
47 | * Wi-Fi is unavailable and cellular permission will NOT restart the
48 | * service. Wi-Fi disabled means that the Wi-Fi manager is returning that
49 | * Wi-Fi is not enabled, while in the other case Wi-Fi is enabled but not
50 | * available.
51 | *
52 | * The service does not return these values. We recommend that app
53 | * developers with very large payloads do not allow these payloads to be
54 | * downloaded over cellular connections.
55 | */
56 | static final int STATE_PAUSED_WIFI_DISABLED = 10;
57 | static final int STATE_PAUSED_NEED_WIFI = 11;
58 |
59 | static final int STATE_PAUSED_ROAMING = 12;
60 |
61 | /**
62 | * Scary case. We were on a network that redirected us to another website
63 | * that delivered us the wrong file.
64 | */
65 | static final int STATE_PAUSED_NETWORK_SETUP_FAILURE = 13;
66 |
67 | static final int STATE_PAUSED_SDCARD_UNAVAILABLE = 14;
68 |
69 | static final int STATE_FAILED_UNLICENSED = 15;
70 | static final int STATE_FAILED_FETCHING_URL = 16;
71 | static final int STATE_FAILED_SDCARD_FULL = 17;
72 | static final int STATE_FAILED_CANCELED = 18;
73 |
74 | static final int STATE_FAILED = 19;
75 |
76 | /**
77 | * Called internally by the stub when the service is bound to the client.
78 | *
79 | * Critical implementation detail. In onServiceConnected we create the
80 | * remote service and marshaler. This is how we pass the client information
81 | * back to the service so the client can be properly notified of changes. We
82 | * must do this every time we reconnect to the service.
83 | *
84 | * That is, when you receive this callback, you should call
85 | * {@link DownloaderServiceMarshaller#CreateProxy} to instantiate a member
86 | * instance of {@link IDownloaderService}, then call
87 | * {@link IDownloaderService#onClientUpdated} with the Messenger retrieved
88 | * from your {@link IStub} proxy object.
89 | *
90 | * @param m the service Messenger. This Messenger is used to call the
91 | * service API from the client.
92 | */
93 | void onServiceConnected(Messenger m);
94 |
95 | /**
96 | * Called when the download state changes. Depending on the state, there may
97 | * be user requests. The service is free to change the download state in the
98 | * middle of a user request, so the client should be able to handle this.
99 | *
100 | * The Downloader Library includes a collection of string resources that
101 | * correspond to each of the states, which you can use to provide users a
102 | * useful message based on the state provided in this callback. To fetch the
103 | * appropriate string for a state, call
104 | * {@link Helpers#getDownloaderStringResourceIDFromState}.
105 | *
106 | * What this means to the developer: The application has gotten a message
107 | * that the download has paused due to lack of WiFi. The developer should
108 | * then show UI asking the user if they want to enable downloading over
109 | * cellular connections with appropriate warnings. If the application
110 | * suddenly starts downloading, the application should revert to showing the
111 | * progress again, rather than leaving up the download over cellular UI up.
112 | *
113 | * @param newState one of the STATE_* values defined in IDownloaderClient
114 | */
115 | void onDownloadStateChanged(int newState);
116 |
117 | /**
118 | * Shows the download progress. This is intended to be used to fill out a
119 | * client UI. This progress should only be shown in a few states such as
120 | * STATE_DOWNLOADING.
121 | *
122 | * @param progress the DownloadProgressInfo object containing the current
123 | * progress of all downloads.
124 | */
125 | void onDownloadProgress(DownloadProgressInfo progress);
126 | }
127 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_library/src/com/google/android/vending/expansion/downloader/DownloaderServiceMarshaller.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2012 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.google.android.vending.expansion.downloader;
18 |
19 | import com.google.android.vending.expansion.downloader.impl.DownloaderService;
20 |
21 | import android.content.Context;
22 | import android.os.Bundle;
23 | import android.os.Handler;
24 | import android.os.Message;
25 | import android.os.Messenger;
26 | import android.os.RemoteException;
27 |
28 |
29 |
30 | /**
31 | * This class is used by the client activity to proxy requests to the Downloader
32 | * Service.
33 | *
34 | * Most importantly, you must call {@link #CreateProxy} during the {@link
35 | * IDownloaderClient#onServiceConnected} callback in your activity in order to instantiate
36 | * an {@link IDownloaderService} object that you can then use to issue commands to the {@link
37 | * DownloaderService} (such as to pause and resume downloads).
38 | */
39 | public class DownloaderServiceMarshaller {
40 |
41 | public static final int MSG_REQUEST_ABORT_DOWNLOAD =
42 | 1;
43 | public static final int MSG_REQUEST_PAUSE_DOWNLOAD =
44 | 2;
45 | public static final int MSG_SET_DOWNLOAD_FLAGS =
46 | 3;
47 | public static final int MSG_REQUEST_CONTINUE_DOWNLOAD =
48 | 4;
49 | public static final int MSG_REQUEST_DOWNLOAD_STATE =
50 | 5;
51 | public static final int MSG_REQUEST_CLIENT_UPDATE =
52 | 6;
53 |
54 | public static final String PARAMS_FLAGS = "flags";
55 | public static final String PARAM_MESSENGER = DownloaderService.EXTRA_MESSAGE_HANDLER;
56 |
57 | private static class Proxy implements IDownloaderService {
58 | private Messenger mMsg;
59 |
60 | private void send(int method, Bundle params) {
61 | Message m = Message.obtain(null, method);
62 | m.setData(params);
63 | try {
64 | mMsg.send(m);
65 | } catch (RemoteException e) {
66 | e.printStackTrace();
67 | }
68 | }
69 |
70 | public Proxy(Messenger msg) {
71 | mMsg = msg;
72 | }
73 |
74 | @Override
75 | public void requestAbortDownload() {
76 | send(MSG_REQUEST_ABORT_DOWNLOAD, new Bundle());
77 | }
78 |
79 | @Override
80 | public void requestPauseDownload() {
81 | send(MSG_REQUEST_PAUSE_DOWNLOAD, new Bundle());
82 | }
83 |
84 | @Override
85 | public void setDownloadFlags(int flags) {
86 | Bundle params = new Bundle();
87 | params.putInt(PARAMS_FLAGS, flags);
88 | send(MSG_SET_DOWNLOAD_FLAGS, params);
89 | }
90 |
91 | @Override
92 | public void requestContinueDownload() {
93 | send(MSG_REQUEST_CONTINUE_DOWNLOAD, new Bundle());
94 | }
95 |
96 | @Override
97 | public void requestDownloadStatus() {
98 | send(MSG_REQUEST_DOWNLOAD_STATE, new Bundle());
99 | }
100 |
101 | @Override
102 | public void onClientUpdated(Messenger clientMessenger) {
103 | Bundle bundle = new Bundle(1);
104 | bundle.putParcelable(PARAM_MESSENGER, clientMessenger);
105 | send(MSG_REQUEST_CLIENT_UPDATE, bundle);
106 | }
107 | }
108 |
109 | private static class Stub implements IStub {
110 | private IDownloaderService mItf = null;
111 | final Messenger mMessenger = new Messenger(new Handler() {
112 | @Override
113 | public void handleMessage(Message msg) {
114 | switch (msg.what) {
115 | case MSG_REQUEST_ABORT_DOWNLOAD:
116 | mItf.requestAbortDownload();
117 | break;
118 | case MSG_REQUEST_CONTINUE_DOWNLOAD:
119 | mItf.requestContinueDownload();
120 | break;
121 | case MSG_REQUEST_PAUSE_DOWNLOAD:
122 | mItf.requestPauseDownload();
123 | break;
124 | case MSG_SET_DOWNLOAD_FLAGS:
125 | mItf.setDownloadFlags(msg.getData().getInt(PARAMS_FLAGS));
126 | break;
127 | case MSG_REQUEST_DOWNLOAD_STATE:
128 | mItf.requestDownloadStatus();
129 | break;
130 | case MSG_REQUEST_CLIENT_UPDATE:
131 | mItf.onClientUpdated((Messenger) msg.getData().getParcelable(
132 | PARAM_MESSENGER));
133 | break;
134 | }
135 | }
136 | });
137 |
138 | public Stub(IDownloaderService itf) {
139 | mItf = itf;
140 | }
141 |
142 | @Override
143 | public Messenger getMessenger() {
144 | return mMessenger;
145 | }
146 |
147 | @Override
148 | public void connect(Context c) {
149 |
150 | }
151 |
152 | @Override
153 | public void disconnect(Context c) {
154 |
155 | }
156 | }
157 |
158 | /**
159 | * Returns a proxy that will marshall calls to IDownloaderService methods
160 | *
161 | * @param ctx
162 | * @return
163 | */
164 | public static IDownloaderService CreateProxy(Messenger msg) {
165 | return new Proxy(msg);
166 | }
167 |
168 | /**
169 | * Returns a stub object that, when connected, will listen for marshalled
170 | * IDownloaderService methods and translate them into calls to the supplied
171 | * interface.
172 | *
173 | * @param itf An implementation of IDownloaderService that will be called
174 | * when remote method calls are unmarshalled.
175 | * @return
176 | */
177 | public static IStub CreateStub(IDownloaderService itf) {
178 | return new Stub(itf);
179 | }
180 |
181 | }
182 |
--------------------------------------------------------------------------------
/AndroidLibrary/GoogleExtras/play_apk_expansion/downloader_sample/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
21 |
22 |
28 |
29 |
33 |
34 |
42 |
43 |
44 |
51 |
52 |
63 |
64 |
72 |
73 |
80 |
81 |
82 |
87 |
88 |
101 |
102 |
116 |
117 |
118 |
119 |
120 |
127 |
128 |
134 |
135 |
141 |
142 |
147 |
148 |
155 |
156 |
163 |
164 |
165 |
166 |
--------------------------------------------------------------------------------
/src/android/XAPKReader.java:
--------------------------------------------------------------------------------
1 | package org.apache.cordova.xapkreader;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.content.res.AssetFileDescriptor;
6 | import android.os.Bundle;
7 | import android.util.Base64;
8 | import android.util.Log;
9 |
10 | import com.android.vending.expansion.zipfile.APKExpansionSupport;
11 | import com.android.vending.expansion.zipfile.ZipResourceFile;
12 | import com.google.android.vending.expansion.downloader.Helpers;
13 |
14 | import java.io.ByteArrayOutputStream;
15 | import java.io.IOException;
16 | import java.io.InputStream;
17 | import java.net.URLConnection;
18 |
19 | import org.apache.cordova.CordovaInterface;
20 | import org.apache.cordova.CordovaPlugin;
21 | import org.apache.cordova.CallbackContext;
22 | import org.apache.cordova.CordovaWebView;
23 | import org.apache.cordova.PluginResult;
24 | import org.json.JSONArray;
25 | import org.json.JSONException;
26 |
27 | public class XAPKReader extends CordovaPlugin {
28 |
29 | private static final String LOG_TAG = "XAPKReader";
30 |
31 | private int mainVersion = 1;
32 |
33 | private long mainFileSize = 0L;
34 |
35 | private int patchVersion = 0;
36 |
37 | private long patchFileSize = 0L;
38 |
39 | private boolean downloadOption = true;
40 |
41 | /**
42 | * Executes the request.
43 | *
44 | * This method is called from the WebView thread. To do a non-trivial amount of work, use:
45 | * cordova.getThreadPool().execute(runnable);
46 | *
47 | * To run on the UI thread, use:
48 | * cordova.getActivity().runOnUiThread(runnable);
49 | *
50 | * @param action The action to execute.
51 | * @param args The exec() arguments.
52 | * @param callbackContext The callback context used when calling back into JavaScript.
53 | * @return Whether the action was valid.
54 | * @throws JSONException
55 | *
56 | * @sa https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaPlugin.java
57 | */
58 | @Override
59 | public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
60 |
61 | int downloadOptionId = cordova.getActivity().getResources().getIdentifier("download_option", "bool", cordova.getActivity().getPackageName());
62 | downloadOption = cordova.getActivity().getResources().getBoolean(downloadOptionId);
63 |
64 | int mainversionCodeId = cordova.getActivity().getResources().getIdentifier("main_version", "integer", cordova.getActivity().getPackageName());
65 | mainVersion = cordova.getActivity().getResources().getInteger(mainversionCodeId);
66 |
67 | int mainFileSizeId = cordova.getActivity().getResources().getIdentifier("main_filesize", "integer", cordova.getActivity().getPackageName());
68 | mainFileSize = cordova.getActivity().getResources().getInteger(mainFileSizeId);
69 |
70 | //This is where the error may occur.
71 | int patchVersionCodeId = cordova.getActivity().getResources().getIdentifier("patch_version", "integer", cordova.getActivity().getPackageName());
72 | patchVersion = cordova.getActivity().getResources().getInteger(patchVersionCodeId);
73 |
74 | int patchFileSizeId = cordova.getActivity().getResources().getIdentifier("patch_filesize", "integer", cordova.getActivity().getPackageName());
75 | patchFileSize = cordova.getActivity().getResources().getInteger(patchFileSizeId);
76 |
77 | final Bundle bundle = new Bundle();
78 | bundle.putInt("mainVersion", mainVersion);
79 | bundle.putInt("patchVersion", patchVersion);
80 | bundle.putLong("mainFileSize", mainFileSize);
81 | bundle.putLong("patchFileSize", patchFileSize);
82 | bundle.putBoolean("downloadOption", downloadOption);
83 |
84 | if (action.equals("get")) {
85 | final String filename = args.getString(0);
86 | final Context ctx = cordova.getActivity().getApplicationContext();
87 | cordova.getThreadPool().execute(new Runnable() {
88 | public void run() {
89 | try {
90 | Context context = cordova.getActivity().getApplicationContext();
91 | Intent intent = new Intent(context, XAPKDownloaderActivity.class);
92 | intent.putExtras(bundle);
93 | cordova.getActivity().startActivity(intent);
94 | // Read file
95 | PluginResult result = XAPKReader.readFile(ctx, filename, mainVersion, patchVersion, PluginResult.MESSAGE_TYPE_ARRAYBUFFER);
96 | callbackContext.sendPluginResult(result);
97 | }
98 | catch(Exception e) {
99 | e.printStackTrace();
100 | callbackContext.error(e.getLocalizedMessage());
101 | }
102 | }
103 | });
104 | return true;
105 | }
106 | return false;
107 | }
108 |
109 | /**
110 | * Read file in APK Expansion file.
111 | *
112 | * @param ctx The context of the main Activity.
113 | * @param filename The filename to read
114 | * @return PluginResult
115 | */
116 | private static PluginResult readFile(Context ctx, String filename, int mainVersion, int patchVersion, final int resultType) throws IOException {
117 | // Get APKExpensionFile
118 | ZipResourceFile expansionFile = APKExpansionSupport.getAPKExpansionZipFile(ctx, mainVersion, patchVersion);
119 |
120 | if (null == expansionFile) {
121 | Log.e(LOG_TAG, "APKExpansionFile not found.");
122 | return null;
123 | }
124 |
125 | // Find file in ExpansionFile
126 | String fileName = Helpers.getExpansionAPKFileName(ctx, true, mainVersion);
127 | fileName = fileName.substring(0, fileName.lastIndexOf("."));
128 | AssetFileDescriptor fileDescriptor = expansionFile.getAssetFileDescriptor(fileName + "/" + filename);
129 |
130 | if (null == fileDescriptor) {
131 | fileDescriptor = expansionFile.getAssetFileDescriptor(filename);
132 | if (null == fileDescriptor) {
133 | Log.e(LOG_TAG, "File not found (" + filename + ").");
134 | return null;
135 | }
136 | }
137 |
138 | // Read file
139 | InputStream inputStream = fileDescriptor.createInputStream();
140 | ByteArrayOutputStream os = new ByteArrayOutputStream();
141 | byte[] buffer = new byte[1024];
142 | int read = 0;
143 | while ((read = inputStream.read(buffer, 0, buffer.length)) != -1) {
144 | os.write(buffer, 0, read);
145 | }
146 | os.flush();
147 |
148 | // get file content type
149 | String contentType = URLConnection.guessContentTypeFromStream(inputStream);
150 |
151 | PluginResult result;
152 | switch (resultType) {
153 | case PluginResult.MESSAGE_TYPE_STRING:
154 | result = new PluginResult(PluginResult.Status.OK, os.toString("UTF-8"));
155 | break;
156 | case PluginResult.MESSAGE_TYPE_ARRAYBUFFER:
157 | result = new PluginResult(PluginResult.Status.OK, os.toByteArray());
158 | break;
159 | case PluginResult.MESSAGE_TYPE_BINARYSTRING:
160 | result = new PluginResult(PluginResult.Status.OK, os.toByteArray(), true);
161 | break;
162 | default: // Base64.
163 | byte[] base64 = Base64.encode(os.toByteArray(), Base64.NO_WRAP);
164 | String s = "data:" + contentType + ";base64," + new String(base64, "US-ASCII");
165 | result = new PluginResult(PluginResult.Status.OK, s);
166 | }
167 |
168 | return result;
169 | }
170 |
171 | }
--------------------------------------------------------------------------------