add: apk builder plugin support; fix: inrt AutoJs.ensureServiceEnabled

This commit is contained in:
hyb1996
2017-11-29 16:07:52 +08:00
parent 028c5c91f4
commit 6dfd35683a
20 changed files with 393 additions and 388 deletions

View File

@@ -0,0 +1,36 @@
package com.stardust.scriptdroid.build;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import com.stardust.pio.UncheckedIOException;
import com.stardust.util.DeveloperUtils;
import java.io.IOException;
import java.io.InputStream;
/**
* Created by Stardust on 2017/11/29.
*/
public class ApkBuilderPluginHelper {
private static final String PLUGIN_PACKAGE_NAME = "org.autojs.apkbuilderplugin";
private static final String TEMPLATE_APK_PATH = "template.apk";
public static boolean checkPlugin(Context context) {
return DeveloperUtils.checkSignature(context, PLUGIN_PACKAGE_NAME);
}
public static InputStream openTemplateApk(Context context) {
try {
return context.getPackageManager().getResourcesForApplication(PLUGIN_PACKAGE_NAME)
.getAssets().open(TEMPLATE_APK_PATH);
} catch (IOException e) {
throw new UncheckedIOException(e);
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException(e);
}
}
}