Skip to content

Commit

Permalink
Prepare for release 1.9.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Iurii Makhno committed Mar 9, 2022
1 parent 2f2bb4b commit 9666988
Show file tree
Hide file tree
Showing 130 changed files with 7,257 additions and 1,725 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ https://developer.android.com/studio/command-line/bundletool

## Releases

Latest release: [1.8.2](https://github.com/google/bundletool/releases)
Latest release: [1.9.0](https://github.com/google/bundletool/releases)
2 changes: 2 additions & 0 deletions archive/com/google/android/archive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Source-code for java/com/android/tools/build/bundletool/archive/dex/classes.dex
which is used to build APKs with build-mode ARCHIVE.
119 changes: 119 additions & 0 deletions archive/com/google/android/archive/ReactivateActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/

package com.google.android.archive;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;

/** Activity that triggers the reactivation of an app through the app store. */
public class ReactivateActivity extends Activity implements DialogInterface.OnClickListener {

public static final String STORE_PACKAGE_NAME = "com.android.vending";

private boolean processingError;

@Override
public void onResume() {
super.onResume();
// Ensures we don't try to send another intent immediately after the first one failed, instead
// an error dialog is shown.
if (processingError) {
return;
}
Intent intent = new Intent();
intent.setAction("com.google.android.STORE_ARCHIVE");
intent.setPackage(STORE_PACKAGE_NAME);
try {
startActivityForResult(intent, /* flags= */ 0);
} catch (ActivityNotFoundException e) {
// We handle this case in onActivityResult, because a RESULT_CANCELED is emitted.
}
}

/** Returns true if the targeted Store is installed and enabled. */
private boolean isStoreInstalled() {
try {
return getPackageManager().getApplicationInfo(STORE_PACKAGE_NAME, 0).enabled;
} catch (NameNotFoundException e) {
return false;
}
}

private AlertDialog buildErrorDialog() {
AlertDialog.Builder dialog =
new AlertDialog.Builder(this)
.setTitle("Installation failed")
.setCancelable(false)
.setNeutralButton("Close", this)
.setMessage(
String.format(
"The app %s is currently archived and must be reinstalled from an"
+ " official app store.",
getAppName()));

if (isStoreInstalled()) {
dialog.setPositiveButton("Reinstall", this);
}

return dialog.create();
}

private String getAppName() {
return getApplicationInfo().loadLabel(getPackageManager()).toString();
}

@Override
public void onClick(DialogInterface ignored, int buttonType) {
processingError = false;
switch (buttonType) {
case DialogInterface.BUTTON_POSITIVE:
openStorePageForApp();
break;
case DialogInterface.BUTTON_NEUTRAL:
default:
// Nothing specific, just close the app.
finish();
break;
}
}

private void openStorePageForApp() {
Intent intent =
new Intent(Intent.ACTION_VIEW)
.setPackage(STORE_PACKAGE_NAME)
.setData(Uri.parse(String.format("market://details?id=%s", getPackageName())));

startActivity(intent);
}

@Override
public void onActivityResult(int ignored1, int resultCode, Intent ignored2) {
if (resultCode == Activity.RESULT_CANCELED) {
processingError = true;
buildErrorDialog().show();
} else {
// At this point the reactivation has completed and the app should be restarted immediately,
// if there is some delay here we don't want to show an empty activity.
finish();
}
}
}
43 changes: 43 additions & 0 deletions archive/com/google/android/archive/UpdateBroadcastReceiver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/

package com.google.android.archive;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import java.io.File;

/** Clears up the app's cache once it has been archived. */
public class UpdateBroadcastReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_MY_PACKAGE_REPLACED)) {
deleteDir(context.getCacheDir());
}
}

private static void deleteDir(File dir) {
File[] contents = dir.listFiles();
if (contents != null) {
for (File file : contents) {
deleteDir(file);
}
}
dir.delete();
}
}
141 changes: 84 additions & 57 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,34 @@ buildscript {
}
}
dependencies {
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.8"
classpath "com.github.jengelman.gradle.plugins:shadow:4.0.4"
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.13"
classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.1"
}
}

apply plugin: "com.github.johnrengelman.shadow"
apply plugin: "com.google.protobuf"
apply plugin: "java"
apply plugin: "maven"
apply plugin: "maven-publish"

repositories {
mavenCentral()
google()
}

configurations {
compileWindows
compileMacOs
compileLinux
implementationWindows
implementationMacOs
implementationLinux
}

// The repackaging rules are defined in the "shadowJar" task below.
dependencies {
compile "com.android.tools:common:30.1.0-alpha07"
compile "com.android.tools:r8:2.2.64"
compile "com.android.tools.build:apkzlib:4.2.0-alpha13"
compile "com.android.tools.build:apksig:4.2.0-alpha13"
compile "com.android.tools.ddms:ddmlib:30.1.0-alpha07"
compile "com.android:zipflinger:7.1.0-alpha07"
implementation "com.android.tools:common:30.1.0-alpha07"
implementation "com.android.tools:r8:2.2.64"
implementation "com.android.tools.build:apksig:4.2.0-alpha13"
implementation "com.android.tools.ddms:ddmlib:30.1.0-alpha07"
implementation "com.android:zipflinger:7.1.0-alpha07"

shadow "com.android.tools.build:aapt2-proto:7.0.0-beta04-7396180"
shadow "com.google.auto.value:auto-value-annotations:1.6.2"
Expand All @@ -53,39 +52,43 @@ dependencies {
}
shadow "org.slf4j:slf4j-api:1.7.30"

compileWindows "com.android.tools.build:aapt2:7.0.0-beta04-7396180:windows"
compileMacOs "com.android.tools.build:aapt2:7.0.0-beta04-7396180:osx"
compileLinux "com.android.tools.build:aapt2:7.0.0-beta04-7396180:linux"
implementationWindows "com.android.tools.build:aapt2:7.0.0-beta04-7396180:windows"
implementationMacOs "com.android.tools.build:aapt2:7.0.0-beta04-7396180:osx"
implementationLinux "com.android.tools.build:aapt2:7.0.0-beta04-7396180:linux"

runtime "org.slf4j:slf4j-jdk14:1.7.30"
compileOnly "org.bouncycastle:bcprov-jdk15on:1.56"
compileOnly "org.bouncycastle:bcpkix-jdk15on:1.56"
runtimeOnly "org.slf4j:slf4j-jdk14:1.7.30"

testCompile "com.android.tools.build:aapt2-proto:7.0.0-beta04-7396180"
testCompile "com.google.auto.value:auto-value-annotations:1.6.2"
testImplementation "com.android.tools.build:aapt2-proto:7.0.0-beta04-7396180"
testImplementation "com.google.auto.value:auto-value-annotations:1.6.2"
testAnnotationProcessor "com.google.auto.value:auto-value:1.6.2"
testCompile "com.google.errorprone:error_prone_annotations:2.3.1"
testCompile "com.google.guava:guava:30.1-jre"
testCompile "com.google.truth.extensions:truth-java8-extension:0.45"
testCompile "com.google.truth.extensions:truth-proto-extension:0.45"
testCompile "com.google.jimfs:jimfs:1.1"
testCompile "com.google.protobuf:protobuf-java:3.10.0"
testCompile "com.google.protobuf:protobuf-java-util:3.10.0"
testCompile "org.mockito:mockito-core:2.18.3"
testCompile "junit:junit:4.12"
testCompile "org.junit.jupiter:junit-jupiter-api:5.2.0"
testCompile "org.junit.vintage:junit-vintage-engine:5.2.0"
testRuntime "org.junit.jupiter:junit-jupiter-engine:5.2.0"
testCompile "org.junit.platform:junit-platform-runner:1.2.0"
testCompile "com.google.dagger:dagger:2.28.3"
testImplementation "com.google.errorprone:error_prone_annotations:2.3.1"
testImplementation "com.google.guava:guava:30.1-jre"
testImplementation "com.google.truth.extensions:truth-java8-extension:0.45"
testImplementation "com.google.truth.extensions:truth-proto-extension:0.45"
testImplementation "com.google.jimfs:jimfs:1.1"
testImplementation "com.google.protobuf:protobuf-java:3.10.0"
testImplementation "com.google.protobuf:protobuf-java-util:3.10.0"
testImplementation "org.mockito:mockito-core:2.18.3"
testImplementation "junit:junit:4.12"
testImplementation "org.bouncycastle:bcprov-jdk15on:1.56"
testImplementation "org.bouncycastle:bcpkix-jdk15on:1.56"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.2.0"
testImplementation "org.junit.vintage:junit-vintage-engine:5.2.0"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.2.0"
testImplementation "org.junit.platform:junit-platform-runner:1.2.0"
testImplementation "com.google.dagger:dagger:2.28.3"
testAnnotationProcessor "com.google.dagger:dagger-compiler:2.28.3"
testCompile "javax.inject:javax.inject:1"
testCompile("org.smali:dexlib2:2.3.4") {
testImplementation "javax.inject:javax.inject:1"
testImplementation("org.smali:dexlib2:2.3.4") {
exclude group: "com.google.guava", module: "guava"
}
testCompile("org.bitbucket.b_c:jose4j:0.7.0") {
testImplementation("org.bitbucket.b_c:jose4j:0.7.0") {
exclude group: "org.slf4j", module: "slf4j-api"
}
testCompile "org.slf4j:slf4j-api:1.7.30"
testRuntime "org.slf4j:slf4j-jdk14:1.7.30"
testImplementation "org.slf4j:slf4j-api:1.7.30"
testRuntimeOnly "org.slf4j:slf4j-jdk14:1.7.30"
}

def osName = System.getProperty("os.name").toLowerCase()
Expand Down Expand Up @@ -122,25 +125,45 @@ protobuf {
}
}

uploadShadow {
repositories {
mavenDeployer {
def localRepo = project.hasProperty('localRepo') ?
project.localRepo : "$buildDir/repo"
repository(url: "file://" + localRepo)
pom.project {
groupId 'com.android.tools.build'
artifactId 'bundletool'
version project.release_version
publishing {
publications {
shadow(MavenPublication) { publication ->
project.shadow.component(publication)

groupId = 'com.android.tools.build'
artifactId = 'bundletool'
version = project.release_version

pom {
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
}

pom.withXml { xml ->
def jose4jDependencyNode = xml.asNode().dependencies.'*'.find {
it.artifactId.text() == 'jose4j'
}
if (jose4jDependencyNode != null) {
def exclusionNode = jose4jDependencyNode
.appendNode('exclusions')
.appendNode('exclusion');
exclusionNode.appendNode('groupId', 'org.slf4j')
exclusionNode.appendNode('artifactId', 'slf4j-api')
}
}
}
}
repositories {
maven {
def localRepo = project.hasProperty('localRepo') ?
project.localRepo : "$buildDir/repo"

url = "file://$localRepo"
}
}
}
Expand Down Expand Up @@ -183,11 +206,11 @@ task executableJar(type: ShadowJar) {
baseName = 'bundletool'
classifier = 'all'
from sourceSets.main.output
from({ zipTree(project.configurations.compileWindows.singleFile) }) { into 'windows/' }
from({ zipTree(project.configurations.compileMacOs.singleFile) }) { into 'macos/' }
from({ zipTree(project.configurations.compileLinux.singleFile) }) { into 'linux/' }
from({ zipTree(project.configurations.implementationWindows.singleFile) }) { into 'windows/' }
from({ zipTree(project.configurations.implementationMacOs.singleFile) }) { into 'macos/' }
from({ zipTree(project.configurations.implementationLinux.singleFile) }) { into 'linux/' }
configurations = [
project.configurations.runtime,
project.configurations.runtimeClasspath,
project.configurations.shadow
]
manifest {
Expand All @@ -201,19 +224,23 @@ task executableJar(type: ShadowJar) {
// Unzip the aapt2 dependency jar.
task unzipAapt2Jar(type: Copy) {
if (osName.contains("linux")) {
from zipTree(project.configurations.compileLinux.singleFile)
from zipTree(project.configurations.implementationLinux.singleFile)
into('build/resources/main/linux')
}

if (osName.contains("windows")) {
from zipTree(project.configurations.compileWindows.singleFile)
from zipTree(project.configurations.implementationWindows.singleFile)
into('build/resources/main/windows')
}

if (osName.contains("mac")) {
from zipTree(project.configurations.compileMacOs.singleFile)
from zipTree(project.configurations.implementationMacOs.singleFile)
into('build/resources/main/macos')
}
}

task uploadShadow {
dependsOn ':publishShadowPublicationToMavenRepository'
}

compileTestJava.dependsOn(unzipAapt2Jar)
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release_version = 1.8.2
release_version = 1.9.0
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
Loading

0 comments on commit 9666988

Please sign in to comment.