Skip to content

Commit

Permalink
1.优化打包,新增打包abi过滤,支持保存打包配置文件,可保存为项目。
Browse files Browse the repository at this point in the history
2.优化模板apk,与Autox.js共享二进制库和Assets, 以减少Autox.js Apk 大小
3.修改包名使Autox.js可以和Auto.js共存
  • Loading branch information
wilinz committed Aug 12, 2022
1 parent 3b2f58f commit 8b6776c
Show file tree
Hide file tree
Showing 406 changed files with 3,199 additions and 3,184 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.text.TextUtils;

import com.stardust.autojs.apkbuilder.util.StreamUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -34,19 +35,19 @@ public ApkPackager(String apkPath, String workspacePath) throws FileNotFoundExce
}

public void unzip() throws IOException {
ZipInputStream zis = new ZipInputStream(mApkInputStream);
for (ZipEntry e = zis.getNextEntry(); e != null; e = zis.getNextEntry()) {
String name = e.getName();
if (!e.isDirectory() && !TextUtils.isEmpty(name)) {
File file = new File(mWorkspacePath, name);
System.out.println(file);
file.getParentFile().mkdirs();
FileOutputStream fos = new FileOutputStream(file);
StreamUtils.write(zis, fos);
fos.close();
try (ZipInputStream zis = new ZipInputStream(mApkInputStream)) {
for (ZipEntry e = zis.getNextEntry(); e != null; e = zis.getNextEntry()) {
String name = e.getName();
if (!e.isDirectory() && !TextUtils.isEmpty(name)) {
File file = new File(mWorkspacePath, name);
System.out.println(file);
file.getParentFile().mkdirs();
FileOutputStream fos = new FileOutputStream(file);
StreamUtils.write(zis, fos);
fos.close();
}
}
}
zis.close();
}

public void repackage(String newApkPath) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,24 @@ public ManifestEditor setPackageName(String packageName) {
}

public ManifestEditor commit() throws IOException {
AxmlWriter writer = new MutableAxmlWriter();
AxmlReader reader = new AxmlReader(IOUtils.readFully(mManifestInputStream, mManifestInputStream.available()));
reader.accept(writer);
mManifestData = writer.toByteArray();
try {
AxmlWriter writer = new MutableAxmlWriter();
AxmlReader reader = new AxmlReader(IOUtils.readFully(mManifestInputStream, mManifestInputStream.available()));
reader.accept(writer);
mManifestData = writer.toByteArray();
} finally {
mManifestInputStream.close();
}
return this;
}


public void writeTo(OutputStream manifestOutputStream) throws IOException {
manifestOutputStream.write(mManifestData);
manifestOutputStream.close();
try {
manifestOutputStream.write(mManifestData);
} finally {
manifestOutputStream.close();
}
}

public void onAttr(AxmlWriter.Attr attr) {
Expand Down
48 changes: 23 additions & 25 deletions apkbuilder/src/main/java/zhao/arsceditor/ArscUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package zhao.arsceditor

import zhao.arsceditor.ResDecoder.ARSCCallBack
import zhao.arsceditor.ResDecoder.data.ResTable
import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.IOException
import java.io.InputStream
import java.io.*
import java.util.*

class ArscUtil {
Expand Down Expand Up @@ -50,20 +47,23 @@ class ArscUtil {
resFile: String,
callback: ((config: String, type: String, key: String, value: String) -> Unit)? = null
) {
when {
resFile.endsWith(".arsc") -> {
open(FileInputStream(resFile), ARSC, callback)
}
resFile.endsWith(".xml") -> {
open(FileInputStream(resFile), AXML)
}
resFile.endsWith(".dex") -> {
open(FileInputStream(resFile), DEX)
}
else -> {
throw IOException("Unsupported FileType")
FileInputStream(resFile).use { input->
when {
resFile.endsWith(".arsc") -> {
open(input, ARSC, callback)
}
resFile.endsWith(".xml") -> {
open(input, AXML)
}
resFile.endsWith(".dex") -> {
open(input, DEX)
}
else -> {
throw IOException("Unsupported FileType")
}
}
}

}

private fun open(
Expand Down Expand Up @@ -131,15 +131,13 @@ class ArscUtil {
}
}

fun saveArsc(file_name: String?, file_name1: String?) {
val fo1: FileOutputStream
try {
fo1 = FileOutputStream(file_name)
val fi1 = FileInputStream(file_name1)
mAndRes.mARSCDecoder.write(fo1, fi1, txtOriginal, txtTranslated)
fo1.close()
} catch (e: IOException) {
e.printStackTrace()
fun saveArsc(oldFileName: String, newFileName: String) {
val oldFile = File(oldFileName)
val newFile = File(newFileName)
oldFile.inputStream().use { input ->
newFile.outputStream().use { out ->
mAndRes.mARSCDecoder.write(out, input, txtOriginal, txtTranslated)
}
}
isChanged = false
}
Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android {
compileSdkVersion versions.compile
buildToolsVersion versions.buildTool
defaultConfig {
applicationId "org.autojs.autojs"
applicationId "org.autojs.autoxjs"
minSdkVersion versions.mini
targetSdkVersion versions.target
versionCode versions.appVersionCode
Expand Down Expand Up @@ -122,12 +122,12 @@ android {
manifestPlaceholders = [appName: "@string/app_name"]
}
v6 {
applicationIdSuffix ".dev"
applicationIdSuffix ".v6"
versionCode versions.devVersionCode
versionName versions.devVersionName
buildConfigField "String", "CHANNEL", '"v6"'
buildConfigField "String", "APPID", '"?id=23"'
manifestPlaceholders = [appName: "Autox6.js"]
manifestPlaceholders = [appName: "Autox.js v6"]
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.autojs.autojs.statics;
package org.autojs.autoxjs.statics;

import org.junit.Test;
import org.mozilla.javascript.Context;
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.autojs.autojs">
package="org.autojs.autoxjs">

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Expand Down Expand Up @@ -451,7 +451,7 @@
android:theme="@style/AppTheme.Settings" />
<activity android:name=".ui.error.ErrorReportActivity" />
<activity
android:name=".external.tasker.TaskerScriptEditActivity_"
android:name="TaskerScriptEditActivity_"
android:configChanges="orientation|screenSize" />
<activity android:name=".ui.edit.ViewSampleActivity" />
<activity
Expand Down Expand Up @@ -672,7 +672,7 @@
</intent-filter>
</receiver>
<receiver
android:name="org.autojs.autojs.ui.widget.DownloadReceiver"
android:name="org.autojs.autoxjs.ui.widget.DownloadReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
Expand Down
Loading

0 comments on commit 8b6776c

Please # to comment.