Updater: Android Studio support
See README-STUDIO.txt for more info. Change-Id: Ie673bba5618b0f00a585049cd85687a64db2b420
This commit is contained in:
parent
7005b005d9
commit
3fc17494eb
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
.idea
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
/gradle
|
||||
/gradlew
|
||||
/gradlew.bat
|
||||
/system_libs/*.jar
|
||||
/keystore.properties
|
||||
*.jks
|
21
Android.mk
21
Android.mk
@ -35,3 +35,24 @@ LOCAL_PRIVILEGED_MODULE := true
|
||||
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := UpdaterStudio
|
||||
LOCAL_MODULE_CLASS := FAKE
|
||||
LOCAL_MODULE_SUFFIX := -timestamp
|
||||
updater_system_deps := $(call java-lib-deps,framework)
|
||||
updater_system_libs_path := $(abspath $(LOCAL_PATH))/system_libs
|
||||
|
||||
include $(BUILD_SYSTEM)/base_rules.mk
|
||||
|
||||
.PHONY: copy_updater_system_deps
|
||||
copy_updater_system_deps: $(updater_system_deps)
|
||||
$(hide) mkdir -p $(updater_system_libs_path)
|
||||
$(hide) rm -rf $(updater_system_libs_path)/*.jar
|
||||
$(hide) cp $(updater_system_deps) $(updater_system_libs_path)/framework.jar
|
||||
|
||||
$(LOCAL_BUILT_MODULE): copy_updater_system_deps
|
||||
$(hide) echo "Fake: $@"
|
||||
$(hide) mkdir -p $(dir $@)
|
||||
$(hide) touch $@
|
||||
|
14
README-STUDIO.txt
Normal file
14
README-STUDIO.txt
Normal file
@ -0,0 +1,14 @@
|
||||
How to build with Android Studio
|
||||
================================
|
||||
|
||||
Updater needs access to the system API, therefore it can't be built only using
|
||||
the public SDK. You first need to generate the libraries with all the needed
|
||||
classes. The application also needs elevated privileges, so you need to sign
|
||||
it with the right key to update the one in the system partition. To do this:
|
||||
|
||||
- Generate a keystore and keystore.properties using gen-keystore.sh
|
||||
- Build the dependencies running 'make UpdaterStudio'. This command will add
|
||||
the needed libraries in system_libraries/.
|
||||
|
||||
You need to do the above once, unless Android Studio can't find some symbol.
|
||||
In this case, rebuild the system libraries with 'make UpdaterStudio'.
|
70
build.gradle
Normal file
70
build.gradle
Normal file
@ -0,0 +1,70 @@
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||
}
|
||||
}
|
||||
|
||||
def keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||
def keystoreProperties = new Properties()
|
||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 24
|
||||
buildToolsVersion '26.0.3'
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 24
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
ignore 'ProtectedPermissions'
|
||||
// These depend on translations
|
||||
ignore 'ExtraTranslation', 'ImpliedQuantity', 'MissingQuantity', 'MissingTranslation'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
res.srcDirs = ['res']
|
||||
java.srcDirs = ['src']
|
||||
manifest.srcFile 'AndroidManifest.xml'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
debug {
|
||||
keyAlias keystoreProperties['keyAlias']
|
||||
keyPassword keystoreProperties['keyPassword']
|
||||
storeFile file(keystoreProperties['storeFile'])
|
||||
storePassword keystoreProperties['storePassword']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly fileTree(dir: 'system_libs/', include: ['*.jar'])
|
||||
|
||||
def supportLibVersion = "24.2.1"
|
||||
implementation "com.android.support:appcompat-v7:${supportLibVersion}"
|
||||
implementation "com.android.support:cardview-v7:${supportLibVersion}"
|
||||
implementation "com.android.support:design:${supportLibVersion}"
|
||||
implementation "com.android.support:preference-v7:${supportLibVersion}"
|
||||
implementation "com.android.support:recyclerview-v7:${supportLibVersion}"
|
||||
}
|
67
gen-keystore.sh
Executable file
67
gen-keystore.sh
Executable file
@ -0,0 +1,67 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ $# -ne 6 ]; then
|
||||
echo "Usage: `basename $0` PRIVATE_KEY CERTIFICATE \\"
|
||||
echo " KEYSTORE_PASSWRD KEY_PASSWORD KEY_ALIAS \\"
|
||||
echo " OUTPUT_KEYSTORE_PATH"
|
||||
echo
|
||||
echo "Example:"
|
||||
echo " `basename $0` \\"
|
||||
echo " ../../../build/target/product/security/testkey.pk8 \\"
|
||||
echo " ../../../build/target/product/security/testkey.x509.pem \\"
|
||||
echo " keystore-password key-password android testkey.jks"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
PRIVATE_KEY="$1"
|
||||
CERTIFICATE="$2"
|
||||
KEYSTORE_PASSWORD="$3"
|
||||
KEY_PASSWORD="$4"
|
||||
KEY_ALIAS="$5"
|
||||
KEYSTORE_PATH="$6"
|
||||
|
||||
if [ -f "$KEYSTORE_PATH" ]; then
|
||||
echo "$KEYSTORE_PATH already exists"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tmpdir=`mktemp -d`
|
||||
trap 'rm -rf $tmpdir;' 0
|
||||
|
||||
key="$tmpdir/platform.key"
|
||||
pk12="$tmpdir/platform.pk12"
|
||||
openssl pkcs8 -in "$PRIVATE_KEY" -inform DER -outform PEM -nocrypt -out "$key"
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
openssl pkcs12 -export -in "$CERTIFICATE" -inkey "$key" -name "$KEY_ALIAS" \
|
||||
-out "$pk12" -password pass:"$KEY_PASSWORD"
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
keytool -importkeystore \
|
||||
-srckeystore "$pk12" -srcstoretype pkcs12 -srcstorepass "$KEY_PASSWORD" \
|
||||
-destkeystore "$KEYSTORE_PATH" -deststorepass "$KEYSTORE_PASSWORD" \
|
||||
-destkeypass "$KEY_PASSWORD"
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
echo
|
||||
echo "Generating keystore.properties..."
|
||||
if [ -f keystore.properties ]; then
|
||||
echo "keystore.properties already exists, overwrite it? [Y/n]"
|
||||
read reply
|
||||
if [ "$reply" = "n" -o "$reply" = "N" ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
cat > keystore.properties <<EOF
|
||||
keyAlias=$KEY_ALIAS
|
||||
keyPassword=$KEY_PASSWORD
|
||||
storeFile=$KEYSTORE_PATH
|
||||
storePassword=$KEYSTORE_PASSWORD
|
||||
EOF
|
4
keystore.properties.sample
Normal file
4
keystore.properties.sample
Normal file
@ -0,0 +1,4 @@
|
||||
keyAlias=android
|
||||
keyPassword=android
|
||||
storeFile=testkey.jks
|
||||
storePassword=android
|
Loading…
Reference in New Issue
Block a user