修复 打包后ui脚本无法运行的问题

修复 打包后模块无法运行的问题
This commit is contained in:
hyb1996
2018-12-12 14:18:03 +08:00
parent c460425656
commit 05813499bc
33 changed files with 548 additions and 91 deletions

View File

@@ -31,7 +31,7 @@
android:name=".App"
android:allowBackup="false"
android:icon="@drawable/autojs_material"
android:label="@string/_app_name"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="@style/AppTheme"
@@ -45,7 +45,7 @@
<activity
android:name=".ui.splash.SplashActivity"
android:hardwareAccelerated="true"
android:label="@string/_app_name"
android:label="@string/app_name"
android:theme="@style/AppTheme.Splash">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
@@ -56,7 +56,7 @@
<activity
android:name=".ui.main.MainActivity_"
android:hardwareAccelerated="true"
android:label="@string/_app_name"
android:label="@string/app_name"
android:launchMode="singleTask"
android:theme="@style/AppTheme.FullScreen">
</activity>
@@ -164,7 +164,7 @@
android:name=".external.tasker.PluginActivity"
android:exported="true"
android:icon="@drawable/ic_android_eat_js"
android:label="@string/_app_name"
android:label="@string/app_name"
android:targetActivity=".external.tasker.TaskPrefEditActivity_"
tools:ignore="ExportedActivity">
<intent-filter>
@@ -277,7 +277,7 @@
</activity>
<service
android:name="com.stardust.notification.NotificationListenerService"
android:label="@string/_app_name"
android:label="@string/app_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService"/>

View File

@@ -9,6 +9,8 @@ import com.stardust.autojs.apkbuilder.ManifestEditor;
import com.stardust.autojs.apkbuilder.util.StreamUtils;
import com.stardust.autojs.project.BuildInfo;
import com.stardust.autojs.project.ProjectConfig;
import com.stardust.autojs.script.EncryptedScriptFileHeader;
import com.stardust.autojs.script.JavaScriptFileSource;
import com.stardust.pio.PFiles;
import com.stardust.util.AdvancedEncryptionStandard;
import com.stardust.util.MD5;
@@ -198,12 +200,16 @@ public class ApkBuilder {
}
private void encrypt(File toDir, File file) throws IOException {
PFiles.writeBytes(new File(toDir, file.getName()).getPath(), encrypt(file));
FileOutputStream fos = new FileOutputStream(new File(toDir, file.getName()));
EncryptedScriptFileHeader.INSTANCE.writeHeader(fos, (short) new JavaScriptFileSource(file).getExecutionMode());
encrypt(fos, file);
}
private byte[] encrypt(File file) throws IOException {
private void encrypt(FileOutputStream fos, File file) throws IOException {
try {
return new AdvancedEncryptionStandard(mKey.getBytes(), mInitVector).encrypt(PFiles.readBytes(file.getPath()));
byte[] bytes = new AdvancedEncryptionStandard(mKey.getBytes(), mInitVector).encrypt(PFiles.readBytes(file.getPath()));
fos.write(bytes);
fos.close();
} catch (Exception e) {
throw new IOException(e);
}
@@ -212,7 +218,7 @@ public class ApkBuilder {
public ApkBuilder replaceFile(String relativePath, String newFilePath) throws IOException {
if (newFilePath.endsWith(".js")) {
PFiles.writeBytes(new File(mWorkspacePath, relativePath).getPath(), encrypt(new File(newFilePath)));
encrypt(new FileOutputStream(new File(mWorkspacePath, relativePath)), new File(newFilePath));
} else {
StreamUtils.write(new FileInputStream(newFilePath), new FileOutputStream(new File(mWorkspacePath, relativePath)));
}

View File

@@ -5,6 +5,7 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import com.stardust.pio.UncheckedIOException;
import org.autojs.autojs.BuildConfig;
import com.stardust.util.DeveloperUtils;
@@ -20,6 +21,7 @@ public class ApkBuilderPluginHelper {
private static final String PLUGIN_PACKAGE_NAME = "org.autojs.apkbuilderplugin";
private static final String TEMPLATE_APK_PATH = "template.apk";
private static final boolean DEBUG_APK_PLUGIN = false;
public static boolean isPluginAvailable(Context context) {
return DeveloperUtils.checkSignature(context, PLUGIN_PACKAGE_NAME);
@@ -27,9 +29,9 @@ public class ApkBuilderPluginHelper {
public static InputStream openTemplateApk(Context context) {
try {
//if (BuildConfig.DEBUG) {
// return context.getAssets().open(TEMPLATE_APK_PATH);
//}
if (DEBUG_APK_PLUGIN && BuildConfig.DEBUG) {
return context.getAssets().open(TEMPLATE_APK_PATH);
}
return context.getPackageManager().getResourcesForApplication(PLUGIN_PACKAGE_NAME)
.getAssets().open(TEMPLATE_APK_PATH);
} catch (IOException e) {

View File

@@ -28,7 +28,6 @@ public class ScriptIntents {
public static final String EXTRA_KEY_LOOP_INTERVAL = "interval";
public static final String EXTRA_KEY_DELAY = "delay";
public static boolean isTaskerBundleValid(Bundle bundle) {
return bundle.containsKey(ScriptIntents.EXTRA_KEY_PATH) || bundle.containsKey(EXTRA_KEY_PRE_EXECUTE_SCRIPT);
}

View File

@@ -6,7 +6,6 @@ import android.text.TextUtils;
import com.stardust.app.GlobalAppContext;
import org.autojs.autojs.Pref;
import org.autojs.autojs.App;
import org.autojs.autojs.R;
import com.stardust.autojs.core.accessibility.AccessibilityService;
@@ -36,12 +35,12 @@ public class AccessibilityServiceTool {
public static void goToAccessibilitySetting() {
Context context = GlobalAppContext.get();
if (Pref.isFirstGoToAccessibilitySetting()) {
GlobalAppContext.toast(context.getString(R.string.text_please_choose) + context.getString(R.string._app_name));
GlobalAppContext.toast(context.getString(R.string.text_please_choose) + context.getString(R.string.app_name));
}
try {
AccessibilityServiceUtils.INSTANCE.goToAccessibilitySetting(context);
} catch (ActivityNotFoundException e) {
GlobalAppContext.toast(context.getString(R.string.go_to_accessibility_settings) + context.getString(R.string._app_name));
GlobalAppContext.toast(context.getString(R.string.go_to_accessibility_settings) + context.getString(R.string.app_name));
}
}

View File

@@ -158,7 +158,7 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
private void setUpToolbar() {
Toolbar toolbar = $(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setTitle(R.string._app_name);
toolbar.setTitle(R.string.app_name);
ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.text_drawer_open,
R.string.text_drawer_close);
drawerToggle.syncState();

View File

@@ -26,7 +26,7 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ToolBarStyle"
android:title="@string/_app_name"
android:title="@string/app_name"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay"/>

View File

@@ -19,7 +19,7 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:title="@string/_app_name">
app:title="@string/app_name">
</com.stardust.theme.widget.ThemeColorToolbar>

View File

@@ -17,7 +17,7 @@
android:layout_width="match_parent"
android:theme="@style/ToolBarStyle"
android:layout_height="?attr/actionBarSize"
android:title="@string/_app_name"
android:title="@string/app_name"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay"/>

View File

@@ -19,7 +19,7 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:title="@string/_app_name">
app:title="@string/app_name">
</com.stardust.theme.widget.ThemeColorToolbar>

View File

@@ -19,7 +19,7 @@
android:theme="@style/ToolBarStyle"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:title="@string/_app_name"
android:title="@string/app_name"
app:popupTheme="@style/AppTheme.PopupOverlay">
<LinearLayout

View File

@@ -51,7 +51,7 @@
android:layout_marginTop="8dp"
android:gravity="center"
android:minHeight="60dp"
android:text="@string/_app_name"
android:text="@string/app_name"
android:textColor="@android:color/primary_text_light"/>
</LinearLayout>

View File

@@ -17,7 +17,7 @@
android:layout_height="?attr/actionBarSize"
android:theme="@style/ToolBarStyle"
android:background="?attr/colorPrimary"
android:title="@string/_app_name"
android:title="@string/app_name"
app:popupTheme="@style/AppTheme.PopupOverlay">
<FrameLayout

View File

@@ -1,5 +1,5 @@
<resources>
<string name="_app_name">Auto.js</string>
<string name="app_name">Auto.js</string>
<string name="text_accessibility_service_description">Required by the script automatic operation (click, long press, slide, etc.).</string>
<string name="text_new_file">New File</string>
<string name="text_create_fail">Creation failed</string>

View File

@@ -1,11 +1,11 @@
<resources>
<string name="_app_name">Auto.js</string>
<string name="app_name">Auto.js</string>
<string name="text_new_file">新建文件</string>
<string name="text_create_fail">创建失败</string>
<string name="text_please_input_name">请输入名称</string>
<string name="text_name">名称</string>
<string name="text_go_to_setting">去设置</string>
<string name="explain_accessibility_permission">软件需要打开\"无障碍服务\"才能运行,请在随后的设置中选择\"AutoJs\"并开启服务。\n您也可以稍后在侧拉菜单中设置。</string>
<string name="explain_accessibility_permission">软件需要打开\"无障碍服务\"才能运行,请在随后的设置中选择\"Auto.js\"并开启服务。\n您也可以稍后在侧拉菜单中设置。</string>
<string name="text_cancel">取消</string>
<string name="text_path_is_empty">路径为空</string>
<string name="text_file_not_exists">文件不存在</string>
@@ -27,7 +27,7 @@
<string name="text_about">关于</string>
<string name="text_licenses">开放源代码许可</string>
<string name="text_do_not_remind_again">不再提示</string>
<string name="copyright">Copyright©2016 All right reserves.</string>
<string name="copyright">Copyright©2018-2019 All right reserves.</string>
<string name="developer">星尘幻影</string>
<string name="qq" translatable="false">2732014414</string>
<string name="email" translatable="false">hybbbb1996@gmail.com</string>
@@ -35,7 +35,7 @@
<string name="text_already_copy_to_clip">已复制到剪贴板</string>
<string name="donate_developer">打赏作者</string>
<string name="my_github">https://github.com/hyb1996/NoRootScriptDroid</string>
<string name="share_app">[AutoJs]下载地址http://www.coolapk.com/apk/org.autojs.autojs </string>
<string name="share_app">[Auto.js]下载地址http://www.coolapk.com/apk/org.autojs.autojs </string>
<string name="text_floating_window">悬浮窗</string>
<string name="text_error_report">错误报告</string>
<string name="text_press_again_to_exit">再按一次退出程序</string>
@@ -99,7 +99,7 @@
<string name="text_import_succeed">导入成功</string>
<string name="text_current_activity">当前活动:</string>
<string name="text_current_package">当前应用包名:</string>
<string name="go_to_accessibility_settings"><![CDATA[请打开设置->无障碍服务->AutoJs并开启]]></string>
<string name="go_to_accessibility_settings"><![CDATA[请打开设置->无障碍服务->Auto.js并开启]]></string>
<string name="text_script_running">脚本运行</string>
<string name="key_use_volume_control_running">key_use_volume_control_running</string>
<string name="text_use_volume_to_stop_running">音量上键停止所有脚本</string>