Fix telemetry version for debug build (#1566)
This commit is contained in:
parent
05d93b85ec
commit
f02712ce5c
|
|
@ -113,13 +113,6 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sourceSets {
|
|
||||||
named("release") {
|
|
||||||
java {
|
|
||||||
srcDirs("src/release/java")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val optimizeReleaseRes = task("optimizeReleaseRes").doLast {
|
val optimizeReleaseRes = task("optimizeReleaseRes").doLast {
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,53 @@
|
||||||
package org.lsposed.manager.util;
|
package org.lsposed.manager.util;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.microsoft.appcenter.AppCenter;
|
import com.microsoft.appcenter.AppCenter;
|
||||||
import com.microsoft.appcenter.crashes.AbstractCrashesListener;
|
import com.microsoft.appcenter.channel.AbstractChannelListener;
|
||||||
|
import com.microsoft.appcenter.channel.Channel;
|
||||||
import com.microsoft.appcenter.crashes.Crashes;
|
import com.microsoft.appcenter.crashes.Crashes;
|
||||||
import com.microsoft.appcenter.crashes.model.ErrorReport;
|
|
||||||
|
|
||||||
|
import org.lsposed.manager.App;
|
||||||
import org.lsposed.manager.BuildConfig;
|
import org.lsposed.manager.BuildConfig;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class Telemetry {
|
public class Telemetry {
|
||||||
|
static Channel.Listener patchDeviceListener = new AbstractChannelListener() {
|
||||||
|
@Override
|
||||||
|
public void onPreparedLog(@NonNull com.microsoft.appcenter.ingestion.models.Log log, @NonNull String groupName, int flags) {
|
||||||
|
var d = log.getDevice();
|
||||||
|
d.setAppVersion(BuildConfig.VERSION_NAME);
|
||||||
|
d.setAppBuild(String.valueOf(BuildConfig.VERSION_CODE));
|
||||||
|
d.setAppNamespace(BuildConfig.APPLICATION_ID);
|
||||||
|
log.setDevice(d);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void addPatchDeviceListener() {
|
||||||
|
try {
|
||||||
|
var channel = AppCenter.class.getDeclaredField("mChannel");
|
||||||
|
channel.setAccessible(true);
|
||||||
|
((Channel) channel.get(AppCenter.getInstance())).addListener(patchDeviceListener);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Log.e(App.TAG, "add listener", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void patchDevice() throws Throwable {
|
||||||
|
var handle = AppCenter.class.getDeclaredField("mHandler");
|
||||||
|
handle.setAccessible(true);
|
||||||
|
((Handler) handle.get(AppCenter.getInstance())).post(Telemetry::addPatchDeviceListener);
|
||||||
|
}
|
||||||
|
|
||||||
public static void start(Application app) {
|
public static void start(Application app) {
|
||||||
Crashes.setListener(new AbstractCrashesListener() {
|
|
||||||
@Override
|
|
||||||
public void onBeforeSending(ErrorReport report) {
|
|
||||||
var d = report.getDevice();
|
|
||||||
d.setAppVersion(BuildConfig.VERSION_NAME);
|
|
||||||
d.setAppBuild(String.valueOf(BuildConfig.VERSION_CODE));
|
|
||||||
d.setAppNamespace(BuildConfig.APPLICATION_ID);
|
|
||||||
report.setDevice(d);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
AppCenter.start(app, "eb3c4175-e879-4312-a72e-b0e64bca142c", Crashes.class);
|
AppCenter.start(app, "eb3c4175-e879-4312-a72e-b0e64bca142c", Crashes.class);
|
||||||
|
try {
|
||||||
|
patchDevice();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Log.w(App.TAG, "patch device", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,9 @@ val zipAll = task("zipAll") {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val apkDir: String
|
||||||
|
get() = if (rootProject.extra.properties["android.injected.invoked.from.ide"] == "true") "intermediates" else "outputs"
|
||||||
|
|
||||||
fun afterEval() = android.applicationVariants.forEach { variant ->
|
fun afterEval() = android.applicationVariants.forEach { variant ->
|
||||||
val variantCapped = variant.name.capitalize(Locale.ROOT)
|
val variantCapped = variant.name.capitalize(Locale.ROOT)
|
||||||
val variantLowered = variant.name.toLowerCase(Locale.ROOT)
|
val variantLowered = variant.name.toLowerCase(Locale.ROOT)
|
||||||
|
|
@ -235,11 +238,11 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
|
||||||
filter<FixCrLfFilter>("eol" to FixCrLfFilter.CrLf.newInstance("lf"))
|
filter<FixCrLfFilter>("eol" to FixCrLfFilter.CrLf.newInstance("lf"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
from("${project(":app").buildDir}/outputs/apk/${buildTypeLowered}") {
|
from("${project(":app").buildDir}/$apkDir/apk/${buildTypeLowered}") {
|
||||||
include("*.apk")
|
include("*.apk")
|
||||||
rename(".*\\.apk", "manager.apk")
|
rename(".*\\.apk", "manager.apk")
|
||||||
}
|
}
|
||||||
from("${project(":daemon").buildDir}/outputs/apk/${buildTypeLowered}") {
|
from("${project(":daemon").buildDir}/$apkDir/apk/${buildTypeLowered}") {
|
||||||
include("*.apk")
|
include("*.apk")
|
||||||
rename(".*\\.apk", "daemon.apk")
|
rename(".*\\.apk", "daemon.apk")
|
||||||
}
|
}
|
||||||
|
|
@ -305,7 +308,7 @@ val killLspd = task<Exec>("killLspd") {
|
||||||
}
|
}
|
||||||
val pushDaemon = task<Exec>("pushDaemon") {
|
val pushDaemon = task<Exec>("pushDaemon") {
|
||||||
dependsOn(":daemon:assembleDebug")
|
dependsOn(":daemon:assembleDebug")
|
||||||
workingDir("${project(":daemon").buildDir}/outputs/apk/debug")
|
workingDir("${project(":daemon").buildDir}/$apkDir/apk/debug")
|
||||||
commandLine(adb, "push", "daemon-debug.apk", "/data/local/tmp/daemon.apk")
|
commandLine(adb, "push", "daemon-debug.apk", "/data/local/tmp/daemon.apk")
|
||||||
}
|
}
|
||||||
val pushDaemonNative = task<Exec>("pushDaemonNative") {
|
val pushDaemonNative = task<Exec>("pushDaemonNative") {
|
||||||
|
|
@ -330,7 +333,7 @@ val reRunDaemon = task<Exec>("reRunDaemon") {
|
||||||
val tmpApk = "/data/local/tmp/lsp.apk"
|
val tmpApk = "/data/local/tmp/lsp.apk"
|
||||||
val pushApk = task<Exec>("pushApk") {
|
val pushApk = task<Exec>("pushApk") {
|
||||||
dependsOn(":app:assembleDebug")
|
dependsOn(":app:assembleDebug")
|
||||||
workingDir("${project(":app").buildDir}/outputs/apk/debug")
|
workingDir("${project(":app").buildDir}/$apkDir/apk/debug")
|
||||||
commandLine(adb, "push", "app-debug.apk", tmpApk)
|
commandLine(adb, "push", "app-debug.apk", tmpApk)
|
||||||
}
|
}
|
||||||
val openApp = task<Exec>("openApp") {
|
val openApp = task<Exec>("openApp") {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue