Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
iBotPeaches authored Feb 27, 2019
2 parents db553eb + 53fdd9f commit 8e00de3
Show file tree
Hide file tree
Showing 58 changed files with 481 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ bin/
# IntelliJ
*.iml
.idea/*
/out
**/out/

# Patches
*.patch
29 changes: 18 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
env:
- TERM=dumb GROOVY_TURN_OFF_JAVA_WARNINGS=true
global:
- TERM=dumb
- GROOVY_TURN_OFF_JAVA_WARNINGS=true

language: java

dist: trusty

matrix:
include:
- os: linux
jdk: openjdk8
# - os: linux
# jdk: openjdk9
- os: linux
jdk: oraclejdk8
# - os: linux
# jdk: oraclejdk9
- os: osx
osx_image: xcode9.2
# - os: osx
# osx_image: xcode9.4
- os: windows
language: shell
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
install: ./gradlew clean
script: ./gradlew build shadowJar proguard

install:
- chmod +x ./scripts/travis-ci/clean-tests.sh
- ./scripts/travis-ci/clean-tests.sh

script:
- chmod +x ./scripts/travis-ci/run-tests.sh
- ./scripts/travis-ci/run-tests.sh

branches:
only:
- master
- stable
- master
9 changes: 5 additions & 4 deletions INTERNAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ is just a guideline but helps me to release a new version every 3 months.
### Social Spam

The final step is to send this release into the wild via some social posting. Head to the blog
where the release post was and send that link to Twiter, Google and whatever else you use.
where the release post was and send that link to Twitter, Google and whatever else you use.

Relax and watch the bug tracker.

Expand Down Expand Up @@ -225,8 +225,8 @@ we aren't building the entire AOSP package, the initial build is to just see if

We check out a certain tag. Currently we use

* aapt2 - `android-9.0.0_r3`.
* aapt1 - `android-9.0.0_r3`.
* aapt2 - `android-9.0.0_r22`.
* aapt1 - `android-9.0.0_r22`.

### Including our modified `frameworks/base` package.

Expand Down Expand Up @@ -254,6 +254,7 @@ we lose the ability to quickly build just the aapt binary. So the Windows proced
1. `source build/envsetup.sh`
2. `lunch sdk-eng`
3. `make OUT_DIR=out-x64 LOCAL_MULTILIB=64 USE_NINJA=false aapt`
4. `strip out-x64/host/darwin-x86/bin/aapt_64`

As of Android Oreo (API 26) all aapt binaries are 64 bit (With exception of Windows).

Expand All @@ -274,7 +275,7 @@ we lose the ability to quickly build just the aapt2 binary. So the Windows proce
1. `export ANDROID_JAVA_HOME=/Path/To/Jdk`
2. `source build/envsetup.sh`
3. `make OUT_DIR=out-x64 LOCAL_MULTILIB=64 USE_NINJA=false aapt2`
4. `strip out-x64/host/darwin-x86/bin/aapt2`
4. `strip out-x64/host/darwin-x86/bin/aapt2_64`

#### Confirming aapt/aapt2 builds are static

Expand Down
16 changes: 16 additions & 0 deletions brut.apktool/apktool-cli/src/main/java/brut/apktool/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
public class Main {
public static void main(String[] args) throws IOException, InterruptedException, BrutException {

// headless
System.setProperty("java.awt.headless", "true");

// set verbosity default
Verbosity verbosity = Verbosity.NORMAL;

Expand Down Expand Up @@ -218,12 +221,18 @@ private static void cmdBuild(CommandLine cli) throws BrutException {
if (cli.hasOption("p") || cli.hasOption("frame-path")) {
apkOptions.frameworkFolderLocation = cli.getOptionValue("p");
}
if (cli.hasOption("nc") || cli.hasOption("no-crunch")) {
apkOptions.noCrunch = true;
}

// Temporary flag to enable the use of aapt2. This will tranform in time to a use-aapt1 flag, which will be
// legacy and eventually removed.
if (cli.hasOption("use-aapt2")) {
apkOptions.useAapt2 = true;
}
if (cli.hasOption("api") || cli.hasOption("api-level")) {
apkOptions.forceApi = Integer.parseInt(cli.getOptionValue("api"));
}
if (cli.hasOption("o") || cli.hasOption("output")) {
outFile = new File(cli.getOptionValue("o"));
} else {
Expand Down Expand Up @@ -397,6 +406,11 @@ private static void _Options() {
.desc("Copies original AndroidManifest.xml and META-INF. See project page for more info.")
.build();

Option noCrunchOption = Option.builder("nc")
.longOpt("no-crunch")
.desc("Disable crunching of resource files during the build step.")
.build();

Option tagOption = Option.builder("t")
.longOpt("tag")
.desc("Tag frameworks using <tag>.")
Expand Down Expand Up @@ -439,6 +453,7 @@ private static void _Options() {
BuildOptions.addOption(aaptOption);
BuildOptions.addOption(originalOption);
BuildOptions.addOption(aapt2Option);
BuildOptions.addOption(noCrunchOption);
}

// add global options
Expand Down Expand Up @@ -492,6 +507,7 @@ private static void _Options() {
allOptions.addOption(verboseOption);
allOptions.addOption(quietOption);
allOptions.addOption(aapt2Option);
allOptions.addOption(noCrunchOption);
}

private static String verbosityHelp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public boolean buildSourcesSmali(File appDir, String folder, String filename)
if (apkOptions.forceBuildAll || isModified(smaliDir, dex)) {
LOGGER.info("Smaling " + folder + " folder into " + filename + "...");
dex.delete();
SmaliBuilder.build(smaliDir, dex, mMinSdkVersion);
SmaliBuilder.build(smaliDir, dex, apkOptions.forceApi > 0 ? apkOptions.forceApi : mMinSdkVersion);
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,25 @@ private void putUsesFramework(MetaInfo meta) throws AndrolibException {
private void putSdkInfo(MetaInfo meta) throws AndrolibException {
Map<String, String> info = getResTable().getSdkInfo();
if (info.size() > 0) {
String refValue;
if (info.get("minSdkVersion") != null) {
refValue = ResXmlPatcher.pullValueFromIntegers(mOutDir, info.get("minSdkVersion"));
if (refValue != null) {
info.put("minSdkVersion", refValue);
}
}
if (info.get("targetSdkVersion") != null) {
refValue = ResXmlPatcher.pullValueFromIntegers(mOutDir, info.get("targetSdkVersion"));
if (refValue != null) {
info.put("targetSdkVersion", refValue);
}
}
if (info.get("maxSdkVersion") != null) {
refValue = ResXmlPatcher.pullValueFromIntegers(mOutDir, info.get("maxSdkVersion"));
if (refValue != null) {
info.put("maxSdkVersion", refValue);
}
}
meta.sdkInfo = info;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class ApkOptions {
public boolean isFramework = false;
public boolean resourcesAreCompressed = false;
public boolean useAapt2 = false;
public boolean noCrunch = false;
public int forceApi = 0;
public Collection<String> doNotCompress;

public String frameworkFolderLocation = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright (C) 2018 Ryszard Wiśniewski <[email protected]>
* Copyright (C) 2018 Connor Tumbleson <[email protected]>
*
* 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 brut.androlib.err;

import brut.androlib.AndrolibException;

public class AXmlDecodingException extends AndrolibException {

public AXmlDecodingException(Throwable cause) {
super(cause);
}

public AXmlDecodingException(String message, Throwable cause) {
super(message, cause);
}

public AXmlDecodingException(String message) {
super(message);
}

public AXmlDecodingException() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright (C) 2018 Ryszard Wiśniewski <[email protected]>
* Copyright (C) 2018 Connor Tumbleson <[email protected]>
*
* 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 brut.androlib.err;

import brut.androlib.AndrolibException;

public class RawXmlEncounteredException extends AndrolibException {

public RawXmlEncounteredException(Throwable cause) {
super(cause);
}

public RawXmlEncounteredException(String message, Throwable cause) {
super(message, cause);
}

public RawXmlEncounteredException(String message) {
super(message);
}

public RawXmlEncounteredException() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
*/
public class SmaliMod {

public static boolean assembleSmaliFile(String smali, DexBuilder dexBuilder, boolean verboseErrors,
public static boolean assembleSmaliFile(String smali, DexBuilder dexBuilder, int apiLevel, boolean verboseErrors,
boolean printTokens, File smaliFile) throws IOException, RuntimeException, RecognitionException {

InputStream is = new ByteArrayInputStream(smali.getBytes());
return assembleSmaliFile(is, dexBuilder, verboseErrors, printTokens, smaliFile);
return assembleSmaliFile(is, dexBuilder, apiLevel, verboseErrors, printTokens, smaliFile);
}

public static boolean assembleSmaliFile(InputStream is,DexBuilder dexBuilder, boolean verboseErrors,
public static boolean assembleSmaliFile(InputStream is,DexBuilder dexBuilder, int apiLevel, boolean verboseErrors,
boolean printTokens, File smaliFile) throws IOException, RecognitionException {

// copy our filestream into a tmp file, so we don't overwrite
Expand All @@ -47,10 +47,10 @@ public static boolean assembleSmaliFile(InputStream is,DexBuilder dexBuilder, bo
IOUtils.copy(is, os);
os.close();

return assembleSmaliFile(tmp,dexBuilder, verboseErrors, printTokens);
return assembleSmaliFile(tmp,dexBuilder, apiLevel, verboseErrors, printTokens);
}

public static boolean assembleSmaliFile(File smaliFile,DexBuilder dexBuilder, boolean verboseErrors,
public static boolean assembleSmaliFile(File smaliFile,DexBuilder dexBuilder, int apiLevel, boolean verboseErrors,
boolean printTokens) throws IOException, RecognitionException {

CommonTokenStream tokens;
Expand All @@ -77,6 +77,7 @@ public static boolean assembleSmaliFile(File smaliFile,DexBuilder dexBuilder, bo
}

smaliParser parser = new smaliParser(tokens);
parser.setApiLevel(apiLevel);
parser.setVerboseErrors(verboseErrors);

smaliParser.smali_file_return result = parser.smali_file();
Expand All @@ -93,7 +94,7 @@ public static boolean assembleSmaliFile(File smaliFile,DexBuilder dexBuilder, bo
treeStream.setTokenStream(tokens);

smaliTreeWalker dexGen = new smaliTreeWalker(treeStream);

dexGen.setApiLevel(apiLevel);
dexGen.setVerboseErrors(verboseErrors);
dexGen.setDexBuilder(dexBuilder);
dexGen.smali_file();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ private void aapt2Package(File apkFile, File manifest, File resDir, File rawDir,
cmd.add("-v");
}

if (apkOptions.noCrunch) {
cmd.add("--no-crunch");
}

try {
OS.exec(cmd.toArray(new String[0]));
LOGGER.fine("aapt2 compile command ran: ");
Expand Down Expand Up @@ -485,6 +489,9 @@ private void aapt1Package(File apkFile, File manifest, File resDir, File rawDir,
if (apkOptions.debugMode) { // inject debuggable="true" into manifest
cmd.add("--debug-mode");
}
if (apkOptions.noCrunch) {
cmd.add("--no-crunch");
}
// force package id so that some frameworks build with correct id
// disable if user adds own aapt (can't know if they have this feature)
if (mPackageId != null && ! customAapt && ! mSharedLibrary) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
* @author Ryszard Wiśniewski <[email protected]>
*/
public final class ResTypeSpec {

public static final String RES_TYPE_NAME_ARRAY = "array";
public static final String RES_TYPE_NAME_PLURALS = "plurals";
public static final String RES_TYPE_NAME_STYLES = "style";

private final String mName;
private final Map<String, ResResSpec> mResSpecs = new LinkedHashMap<String, ResResSpec>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ public void serializeToResValuesXml(XmlSerializer serializer,
}
}

// Android does not allow values (false) for ids.xml anymore
// https://issuetracker.google.com/issues/80475496
// But it decodes as a ResBoolean, which makes no sense. So force it to empty
if (type.equalsIgnoreCase("id") && !body.isEmpty()) {
body = "";
}

// check for using attrib as node or item
String tagName = item ? "item" : type;

Expand Down
Loading

0 comments on commit 8e00de3

Please sign in to comment.