[daemon] Only package needed resources (#1508)

* [skip ci] Fix reRunDaemon task

* [daemon] Only package needed resources

* Shrink resources
This commit is contained in:
Nullptr 2021-12-31 01:31:34 +08:00 committed by GitHub
parent 16e1de76ff
commit 1f5dfbc1b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 93 additions and 84 deletions

View File

@ -6,6 +6,7 @@ on:
branches: [ master ]
paths:
- app/src/main/res/values/strings.xml
- daemon/src/main/res/values/strings.xml
jobs:
synchronize-with-crowdin:

View File

@ -86,14 +86,6 @@
<string name="enabled_verbose_log">Verbose log enabled</string>
<string name="disabled_verbose_log">Verbose log disabled</string>
<!-- Notification -->
<string name="module_is_not_activated_yet">Xposed module is not activated yet</string>
<string name="module_is_not_activated_yet_detailed">%s has been installed, but is not activated yet</string>
<string name="xposed_module_updated_notification_title">Xposed module updated</string>
<string name="xposed_module_updated_notification_content">%s has been updated, please force stop and restart apps in its scope</string>
<string name="xposed_module_updated_notification_title_system">Xposed module updated, system reboot required</string>
<string name="xposed_module_updated_notification_content_system">%s has been updated, since the scope contains System Framework, required reboot to apply changes</string>
<!-- ModulesActivity -->
<string name="module_empty_description">(no description provided)</string>
<string name="warning_xposed_min_version">This module requires a newer Xposed version (%d) and thus cannot be activated</string>
@ -138,6 +130,7 @@
<string name="use_recommended">Recommended</string>
<string name="no_scope_selected_has_recommended">You did not select any app. Select recommended apps?</string>
<string name="use_recommended_message">Select recommended apps?</string>
<string name="module_is_not_activated_yet">Xposed module is not activated yet</string>
<string name="requested_by_module">Recommended</string>
<string name="update_available">Update available: %1$s</string>
<string name="module_disabled_no_selection">Module %s has been disabled since no app selected.</string>

View File

@ -303,12 +303,12 @@ val killLspd = task<Exec>("killLspd") {
isIgnoreExitValue = true
}
val pushDaemon = task<Exec>("pushDaemon") {
dependsOn(":daemon:assembleRiruDebug")
dependsOn(":daemon:assembleDebug")
workingDir("${project(":daemon").buildDir}/outputs/apk/debug")
commandLine(adb, "push", "daemon-Zygisk-debug.apk", "/data/local/tmp/daemon.apk")
commandLine(adb, "push", "daemon-debug.apk", "/data/local/tmp/daemon.apk")
}
val pushDaemonNative = task<Exec>("pushDaemonNative") {
dependsOn("mergeRiruDebugNativeLibs")
dependsOn(":daemon:assembleDebug")
doFirst {
val abi: String = ByteArrayOutputStream().use { outputStream ->
exec {
@ -323,7 +323,7 @@ val pushDaemonNative = task<Exec>("pushDaemonNative") {
}
val reRunDaemon = task<Exec>("reRunDaemon") {
dependsOn(pushDaemon, pushDaemonNative, killLspd)
commandLine(adb, "shell", "su", "-c", "sh /data/adb/modules/*_lsposed/service.sh&")
commandLine(adb, "shell", "su", "-c", "sh `su -c magisk --path`/.magisk/modules/*_lsposed/service.sh&")
isIgnoreExitValue = true
}
val tmpApk = "/data/local/tmp/lsp.apk"

View File

@ -1,11 +1,11 @@
#
# Your Crowdin credentials
#
"project_id_env" : "CROWDIN_PROJECT_ID"
"api_token_env" : "CROWDIN_API_TOKEN"
"base_path" : "."
"base_url" : "https://lsposed.crowdin.com/api/v2"
"pull_request_title" : "[translation] Update translation from Crowdin"
"project_id_env": "CROWDIN_PROJECT_ID"
"api_token_env": "CROWDIN_API_TOKEN"
"base_path": "."
"base_url": "https://lsposed.crowdin.com/api/v2"
"pull_request_title": "[translation] Update translation from Crowdin"
#
# Choose file structure in Crowdin
# e.g. true or false
@ -16,11 +16,18 @@
# Files configuration
#
files: [
{
"source" : "/app/src/main/res/values/strings.xml",
"translation" : "/app/src/main/res/values-%two_letters_code%/%original_file_name%",
"type": "android",
"dest": "/app/strings.xml",
"skip_untranslated_strings": true
}
{
"source": "/app/src/main/res/values/strings.xml",
"translation": "/app/src/main/res/values-%two_letters_code%/%original_file_name%",
"type": "android",
"dest": "/app/strings.xml",
"skip_untranslated_strings": true
},
{
"source": "/daemon/src/main/res/values/strings.xml",
"translation": "/daemon/src/main/res/values-%two_letters_code%/%original_file_name%",
"type": "android",
"dest": "/daemon/strings.xml",
"skip_untranslated_strings": true
}
]

View File

@ -20,10 +20,7 @@
import com.android.build.gradle.BaseExtension
import com.android.ide.common.signing.KeystoreHelper
import java.io.PrintStream
import java.io.FileOutputStream
import java.util.Locale
import java.util.jar.JarFile
import java.util.zip.ZipOutputStream
import java.util.*
plugins {
id("com.android.application")
@ -123,34 +120,6 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
tasks["merge${variantCapped}JniLibFolders"].enabled = false
tasks["merge${variantCapped}NativeLibs"].enabled = false
task<Jar>("generateApp${variantLowered}RFile") {
dependsOn(":app:process${variantCapped}Resources")
doLast {
val rFile = JarFile(
File(
project(":app").buildDir,
"intermediates/compile_and_runtime_not_namespaced_r_class_jar/${variantLowered}/R.jar"
)
)
ZipOutputStream(
FileOutputStream(
File(
project.buildDir,
"tmp/${variantLowered}R.jar"
)
)
).use {
for (entry in rFile.entries()) {
if (entry.name.startsWith("org/lsposed/manager")) {
it.putNextEntry(entry)
rFile.getInputStream(entry).transferTo(it)
it.closeEntry()
}
}
}
}
}
val app = rootProject.project(":app").extensions.getByName<BaseExtension>("android")
val outSrcDir = file("$buildDir/generated/source/signInfo/${variantLowered}")
val outSrc = file("$outSrcDir/org/lsposed/lspd/util/SignInfo.java")
@ -195,9 +164,4 @@ dependencies {
implementation(project(":hiddenapi-bridge"))
implementation(project(":daemon-service"))
implementation(project(":manager-service"))
android.applicationVariants.all {
"${name}Implementation"(files(File(project.buildDir, "tmp/${name}R.jar")) {
builtBy("generateApp${name}RFile")
})
}
}

View File

@ -1,10 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.lsposed.daemon">
<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true" />
</manifest>
<manifest package="org.lsposed.daemon" />

View File

@ -51,6 +51,7 @@ import hidden.HiddenApiBridge;
public class ConfigFileManager {
static final Path basePath = Paths.get("/data/adb/lspd");
static final Path daemonApkPath = Paths.get(System.getProperty("java.class.path", null));
static final Path managerApkPath = basePath.resolve("manager.apk");
private static final Path lockPath = basePath.resolve("lock");
private static final Path configDirPath = basePath.resolve("config");
@ -96,7 +97,7 @@ public class ConfigFileManager {
Method addAssetPath = AssetManager.class.getDeclaredMethod("addAssetPath", String.class);
addAssetPath.setAccessible(true);
//noinspection ConstantConditions
if ((int) addAssetPath.invoke(am, managerApkPath.toString()) > 0)
if ((int) addAssetPath.invoke(am, daemonApkPath.toString()) > 0)
//noinspection deprecation
res = new Resources(am, null, null);
} catch (Throwable e) {

View File

@ -61,6 +61,7 @@ import android.view.IWindowManager;
import androidx.annotation.NonNull;
import org.lsposed.daemon.BuildConfig;
import org.lsposed.daemon.R;
import org.lsposed.lspd.ILSPManagerService;
import org.lsposed.lspd.models.Application;
import org.lsposed.lspd.models.UserInfo;
@ -220,13 +221,13 @@ public class LSPManagerService extends ILSPManagerService.Stub {
try {
var context = new FakeContext();
String title = context.getString(enabled ? systemModule ?
org.lsposed.manager.R.string.xposed_module_updated_notification_title_system :
org.lsposed.manager.R.string.xposed_module_updated_notification_title :
org.lsposed.manager.R.string.module_is_not_activated_yet);
R.string.xposed_module_updated_notification_title_system :
R.string.xposed_module_updated_notification_title :
R.string.module_is_not_activated_yet);
String content = context.getString(enabled ? systemModule ?
org.lsposed.manager.R.string.xposed_module_updated_notification_content_system :
org.lsposed.manager.R.string.xposed_module_updated_notification_content :
org.lsposed.manager.R.string.module_is_not_activated_yet_detailed, modulePackageName);
R.string.xposed_module_updated_notification_content_system :
R.string.xposed_module_updated_notification_content :
R.string.module_is_not_activated_yet_detailed, modulePackageName);
var style = new Notification.BigTextStyle();
style.bigText(content);
@ -235,7 +236,7 @@ public class LSPManagerService extends ILSPManagerService.Stub {
.setContentTitle(title)
.setContentText(content)
.setSmallIcon(android.R.drawable.ic_dialog_info)
.setColor(context.getResources().getColor(org.lsposed.manager.R.color.color_primary))
.setColor(context.getResources().getColor(R.color.color_primary))
.setContentIntent(getNotificationIntent(modulePackageName, moduleUserId))
.setAutoCancel(true)
.setStyle(style)

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ This file is part of LSPosed.
~
~ LSPosed is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ LSPosed is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
~
~ Copyright (C) 2021 LSPosed Contributors
-->
<resources>
<color name="color_primary">@color/color_primary_dark</color>
</resources>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ This file is part of LSPosed.
~
~ LSPosed is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ LSPosed is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
~
~ Copyright (C) 2021 LSPosed Contributors
-->
<resources>
<color name="color_primary_light">#1A73E8</color>
<color name="color_primary_dark">#8AB4F8</color>
<color name="color_primary">@color/color_primary_light</color>
</resources>

View File

@ -1,3 +1,9 @@
<resources>
<string name="app_name">LSPosed</string>
</resources>
<!-- Notification -->
<string name="module_is_not_activated_yet">Xposed module is not activated yet</string>
<string name="module_is_not_activated_yet_detailed">%s has been installed, but is not activated yet</string>
<string name="xposed_module_updated_notification_title">Xposed module updated</string>
<string name="xposed_module_updated_notification_content">%s has been updated, please force stop and restart apps in its scope</string>
<string name="xposed_module_updated_notification_title_system">Xposed module updated, system reboot required</string>
<string name="xposed_module_updated_notification_content_system">%s has been updated, since the scope contains System Framework, required reboot to apply changes</string>
</resources>

View File

@ -11,10 +11,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# disable new resource shinker since it will change the resources id
# which will be used by the core
# android.experimental.enableNewResourceShrinker=true
# android.experimental.enableNewResourceShrinker.preciseShrinking=true
android.experimental.enableNewResourceShrinker=true
android.experimental.enableNewResourceShrinker.preciseShrinking=true
android.enableAppCompileTimeRClass=true
android.nonTransitiveRClass=true
android.enableR8.fullMode=true