Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions app/src/main/java/org/lsposed/manager/util/UpdateUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@

import org.lsposed.manager.App;
import org.lsposed.manager.BuildConfig;
import org.lsposed.manager.ConfigManager;

import java.io.File;
import java.io.IOException;
import java.time.Instant;
import java.time.ZoneOffset;
import java.util.Locale;
import java.util.regex.Pattern;

import okhttp3.Call;
import okhttp3.Callback;
Expand All @@ -44,9 +42,11 @@
import okio.Okio;

public class UpdateUtil {
private static final Pattern VERSION_CODE_PATTERN = Pattern.compile("-(\\d+)(?=[-.])");

public static void loadRemoteVersion() {
var request = new Request.Builder()
.url("https://api.github.com/repos/JingMatrix/LSPosed/releases/latest")
.url("https://api.github.com/repos/JingMatrix/Vector/releases/latest")
.addHeader("Accept", "application/vnd.github.v3+json")
.build();
var callback = new Callback() {
Expand Down Expand Up @@ -81,18 +81,20 @@ public void onFailure(@NonNull Call call, @NonNull IOException e) {
private static void checkAssets(JsonObject assets, String releaseNotes) {
var pref = App.getPreferences();
var name = assets.get("name").getAsString();
var splitName = name.split("-");
var versionCode = parseVersionCode(name);
if (versionCode == null) return;
var updatedAt = Instant.parse(assets.get("updated_at").getAsString());
var downloadUrl = assets.get("browser_download_url").getAsString();
var zipTime = pref.getLong("zip_time", 0);
var hasNewAsset = !updatedAt.equals(Instant.ofEpochSecond(zipTime));
pref.edit()
.putInt("latest_version", Integer.parseInt(splitName[2]))
.putInt("latest_version", versionCode)
.putLong("latest_check", Instant.now().getEpochSecond())
.putString("release_notes", releaseNotes)
.putString("zip_file", null)
.putBoolean("checked", true)
.apply();
var updatedAt = Instant.parse(assets.get("updated_at").getAsString());
var downloadUrl = assets.get("browser_download_url").getAsString();
var zipTime = pref.getLong("zip_time", 0);
if (!updatedAt.equals(Instant.ofEpochSecond(zipTime))) {
if (hasNewAsset) {
pref.edit().putString("zip_file", null).apply();
var zip = downloadNewZipSync(downloadUrl, name);
var size = assets.get("size").getAsLong();
if (zip != null && zip.length() == size) {
Expand All @@ -107,17 +109,18 @@ private static void checkAssets(JsonObject assets, String releaseNotes) {
public static boolean needUpdate() {
var pref = App.getPreferences();
if (!pref.getBoolean("checked", false)) return false;
var now = Instant.now();
var buildTime = Instant.ofEpochSecond(BuildConfig.BUILD_TIME);
var check = pref.getLong("latest_check", 0);
if (check > 0) {
var checkTime = Instant.ofEpochSecond(check);
if (checkTime.atOffset(ZoneOffset.UTC).plusDays(30).toInstant().isBefore(now))
return true;
var code = pref.getInt("latest_version", 0);
return code > BuildConfig.VERSION_CODE;
var code = pref.getInt("latest_version", 0);
return code > BuildConfig.VERSION_CODE;
}

@Nullable
private static Integer parseVersionCode(String name) {
var matcher = VERSION_CODE_PATTERN.matcher(name);
Integer versionCode = null;
while (matcher.find()) {
versionCode = Integer.parseInt(matcher.group(1));
}
return buildTime.atOffset(ZoneOffset.UTC).plusDays(30).toInstant().isBefore(now);
return versionCode;
}

@Nullable
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings_untranslatable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<resources>
<string name="app_name" translatable="false">LSPosed</string>
<string name="install_url" translatable="false">https://github.com/JingMatrix/LSPosed#install</string>
<string name="latest_url" translatable="false">https://github.com/JingMatrix/LSPosed/releases/latest</string>
<string name="install_url" translatable="false">https://github.com/JingMatrix/Vector#install</string>
<string name="latest_url" translatable="false">https://github.com/JingMatrix/Vector/releases/latest</string>
<string name="settings_group_repo" translatable="false">@string/module_repo</string>
</resources>
10 changes: 2 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,19 @@ subprojects {
versionName = versionNameProvider.get()
}

val flags =
listOf(
"-DVERSION_CODE=${versionCodeProvider.get()}",
"-DVERSION_NAME='\"${versionNameProvider.get()}\"'",
)

val args =
listOf(
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
"-DVECTOR_ROOT=${rootDir.absolutePath}",
"-DVECTOR_VERSION_CODE=${versionCodeProvider.get()}",
"-DVECTOR_VERSION_NAME=${versionNameProvider.get()}",
// Enforce 16 KB page size alignment for Android 15+ compatibility
"-DCMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=16384",
"-DCMAKE_EXE_LINKER_FLAGS=-Wl,-z,max-page-size=16384",
)

externalNativeBuild {
cmake {
cFlags.addAll(flags)
cppFlags.addAll(flags)
arguments.addAll(args)
}
}
Expand Down
4 changes: 2 additions & 2 deletions magisk-loader/update/zygisk.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "v2.0",
"versionCode": 3021,
"zipUrl": "https://github.com/JingMatrix/LSPosed/releases/download/v2.0/Vector-v2.0-Release.zip",
"changelog": "https://raw.githubusercontent.com/JingMatrix/LSPosed/master/zygisk/changelog.md"
"zipUrl": "https://github.com/JingMatrix/Vector/releases/download/v2.0/Vector-v2.0-3021-Release.zip",
"changelog": "https://raw.githubusercontent.com/JingMatrix/Vector/master/zygisk/changelog.md"
}
5 changes: 5 additions & 0 deletions native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ add_subdirectory(${VECTOR_ROOT}/external external)
file(GLOB_RECURSE NATIVE_SOURCES "src/*.cpp")
add_library(${PROJECT_NAME} STATIC ${NATIVE_SOURCES})

target_compile_definitions(${PROJECT_NAME} PUBLIC
VERSION_CODE=${VECTOR_VERSION_CODE}
VERSION_NAME="${VECTOR_VERSION_NAME}"
)

set(IGNORED_WARNINGS
-Wno-c99-extensions
-Wno-extra-semi
Expand Down
16 changes: 7 additions & 9 deletions zygisk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@ android {
buildConfigField("String", "InjectedPackageName", """"${injectedPackageName}"""")
buildConfigField("String", "ManagerPackageName", """"${defaultManagerPackageName}"""")

val flags =
listOf(
"-DINJECTED_PACKAGE_NAME='\"${injectedPackageName}\"'",
"-DINJECTED_PACKAGE_UID=${injectedPackageUid}",
"-DMANAGER_PACKAGE_NAME='\"${defaultManagerPackageName}\"'",
)

externalNativeBuild {
cmake {
cFlags.addAll(flags)
cppFlags.addAll(flags)
arguments.addAll(
listOf(
"-DVECTOR_INJECTED_PACKAGE_NAME=${injectedPackageName}",
"-DVECTOR_INJECTED_PACKAGE_UID=${injectedPackageUid}",
"-DVECTOR_MANAGER_PACKAGE_NAME=${defaultManagerPackageName}",
)
)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion zygisk/module/module.prop
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ version=${versionName} (${versionCode})
versionCode=${versionCode}
author=JingMatrix
description=A modern, Xposed-compatible framework for Android application hooking. (Android 8.1 ~ 16)
updateJson=https://raw.githubusercontent.com/JingMatrix/LSPosed/master/zygisk/update.json
updateJson=https://raw.githubusercontent.com/JingMatrix/Vector/master/zygisk/update.json
5 changes: 5 additions & 0 deletions zygisk/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ add_subdirectory(${VECTOR_ROOT}/native native)

add_library(${PROJECT_NAME} SHARED module.cpp ipc_bridge.cpp)
target_include_directories(${PROJECT_NAME} PUBLIC include)
target_compile_definitions(${PROJECT_NAME} PRIVATE
INJECTED_PACKAGE_NAME="${VECTOR_INJECTED_PACKAGE_NAME}"
INJECTED_PACKAGE_UID=${VECTOR_INJECTED_PACKAGE_UID}
MANAGER_PACKAGE_NAME="${VECTOR_MANAGER_PACKAGE_NAME}"
)

target_link_libraries(${PROJECT_NAME} native log)

Expand Down
4 changes: 2 additions & 2 deletions zygisk/update.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "v2.0",
"versionCode": 3021,
"zipUrl": "https://github.com/JingMatrix/LSPosed/releases/download/v2.0/Vector-v2.0-Release.zip",
"changelog": "https://raw.githubusercontent.com/JingMatrix/LSPosed/master/zygisk/changelog.md"
"zipUrl": "https://github.com/JingMatrix/Vector/releases/download/v2.0/Vector-v2.0-3021-Release.zip",
"changelog": "https://raw.githubusercontent.com/JingMatrix/Vector/master/zygisk/changelog.md"
}