改为以插件方式打包,添加包名查询权限
改为以插件方式打包,避免增加APP体积; 通过包名判断相应插件应用是否存在,并添加包名查询权限。
This commit is contained in:
@@ -92,6 +92,9 @@
|
||||
android:name="android.permission.WRITE_SECURE_SETTINGS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||
tools:ignore="QueryAllPackagesPermission" />
|
||||
|
||||
<!-- 非 AutoJs6 运行必需, 不会主动申请, 脚本可自行申请 -->
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
|
||||
@@ -23,7 +23,13 @@ public class ApkBuilderPluginHelper {
|
||||
private static final boolean DEBUG_APK_PLUGIN = false;
|
||||
|
||||
public static boolean isPluginAvailable(Context context) {
|
||||
return DeveloperUtils.checkSignature(context, PLUGIN_PACKAGE_NAME);
|
||||
// return DeveloperUtils.checkSignature(context, PLUGIN_PACKAGE_NAME);
|
||||
try {
|
||||
context.getPackageManager().getPackageInfo(PLUGIN_PACKAGE_NAME, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static InputStream openTemplateApk(Context context) {
|
||||
|
||||
@@ -34,9 +34,7 @@ import org.autojs.autojs6.R;
|
||||
import org.autojs.autojs6.databinding.ActivityBuildBinding;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -98,7 +96,7 @@ public class BuildActivity extends BaseActivity implements ApkBuilder.ProgressCa
|
||||
if (mSource != null) {
|
||||
setupWithSourceFile(new ScriptFile(mSource));
|
||||
}
|
||||
// checkApkBuilderPlugin();
|
||||
checkApkBuilderPlugin();
|
||||
}
|
||||
|
||||
private void checkApkBuilderPlugin() {
|
||||
@@ -184,16 +182,8 @@ public class BuildActivity extends BaseActivity implements ApkBuilder.ProgressCa
|
||||
}
|
||||
|
||||
void buildApk() {
|
||||
// if (!ApkBuilderPluginHelper.isPluginAvailable(this)) {
|
||||
// ViewUtils.showToast(this, R.string.text_apk_builder_plugin_unavailable);
|
||||
// return;
|
||||
// }
|
||||
try {
|
||||
if (!Arrays.asList(getAssets().list("")).contains("template.apk")) {
|
||||
return;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(LOG_TAG, e.getMessage());
|
||||
if (!ApkBuilderPluginHelper.isPluginAvailable(this)) {
|
||||
ViewUtils.showToast(this, R.string.text_apk_builder_plugin_unavailable);
|
||||
return;
|
||||
}
|
||||
if (!checkInputs()) {
|
||||
@@ -270,8 +260,7 @@ public class BuildActivity extends BaseActivity implements ApkBuilder.ProgressCa
|
||||
}
|
||||
|
||||
private ApkBuilder callApkBuilder(File tmpDir, File outApk, ApkBuilder.AppConfig appConfig) throws Exception {
|
||||
// InputStream templateApk = ApkBuilderPluginHelper.openTemplateApk(BuildActivity.this);
|
||||
InputStream templateApk = getAssets().open("template.apk");
|
||||
InputStream templateApk = ApkBuilderPluginHelper.openTemplateApk(BuildActivity.this);
|
||||
return new ApkBuilder(templateApk, outApk, tmpDir.getPath())
|
||||
.setProgressCallback(BuildActivity.this)
|
||||
.prepare()
|
||||
|
||||
Reference in New Issue
Block a user