Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
R3.13.1
Browse files Browse the repository at this point in the history
使用AspectJ修复Wear OS上apuut-page的闪退bug
  • Loading branch information
ryuunoakaihitomi committed Nov 3, 2021
1 parent 6bbdbde commit f2acf64
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 8 deletions.
12 changes: 10 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'android-aspectjx'

apply from: "${rootProject.file('loadProperties.gradle')}"

Expand All @@ -19,9 +20,9 @@ android {
//targetSdkVersion compileSdkVersion
targetSdkVersion 31
// 版本号:发布日期
versionCode 20211103
versionCode 20211104
// 版本名说明: R3.x.y.z (R3:Refactoring 第三次重构,z:Quick Fix序号)
versionName 'R3.13.0.1'
versionName 'R3.13.1'
resConfigs "en", "zh-rCN"

buildConfigField 'String', 'BUILD_TIME', '\"' + new Date() + '\"'
Expand Down Expand Up @@ -153,6 +154,8 @@ dependencies {
implementation 'com.google.zxing:core:3.4.1'
implementation 'org.cyanogenmod:platform.sdk:6.0'
implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:2.0'
implementation "org.aspectj:aspectjrt:1.9.7"

debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
// 最新版是v2.1.0,仅支持android-support
//noinspection GradleDependency
Expand Down Expand Up @@ -184,4 +187,9 @@ repositories {
maven {
url 'https://raw.githubusercontent.com/ryuunoakaihitomi/maven-repository/master'
}
}

// 配置入口和作用点都要制定
aspectjx {
include 'custom_aspect', 'com.drakeet.about'
}
8 changes: 8 additions & 0 deletions app/src/main/assets/dependency_list/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"author": "wurensen",
"name": "AspectJX",
"type": "Apache Software License 2.0",
"url": "https://github.com/wurensen/gradle_plugin_android_aspectjx"
}
]
33 changes: 33 additions & 0 deletions app/src/main/java/custom_aspect/A.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package custom_aspect

import android.content.ActivityNotFoundException
import android.view.View
import com.drakeet.about.ClickableViewHolder
import org.aspectj.lang.ProceedingJoinPoint
import org.aspectj.lang.annotation.Around
import org.aspectj.lang.annotation.Aspect

@Suppress("unused", "SpellCheckingInspection")
@Aspect
class A {

/**
* 修复about-page在Wear OS上的崩溃
* 原因:在WearOS上打开链接会抛出不是[ActivityNotFoundException]的一场
*
* `Permission Denial: starting Intent { act=... dat=... cmp=com.google.android.wearable.app/com.google.android.clockwork.wcs.remoteintent.UriRedirectActivity } from ProcessRecord ... requires com.google.android.wearable.READ_SETTINGS`
* @see ClickableViewHolder
*/
@Around("call(* setOnClickListener(..)) && this(com.drakeet.about.ClickableViewHolder)")
fun fixAboutPageCrashOnWatch(pjp: ProceedingJoinPoint) {
val rewListener = pjp.args[0] as View.OnClickListener
pjp.proceed(arrayOf(OnClickListenerSafeProxy(rewListener)))
}

private class OnClickListenerSafeProxy(private val l: View.OnClickListener) :
View.OnClickListener {
override fun onClick(v: View?) {
runCatching { l.onClick(v) }.onFailure { it.printStackTrace() }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ import com.google.gson.JsonParser
import com.topjohnwu.superuser.Shell
import github.ryuunoakaihitomi.powerpanel.BuildConfig
import github.ryuunoakaihitomi.powerpanel.R
import github.ryuunoakaihitomi.powerpanel.util.BlackMagic
import github.ryuunoakaihitomi.powerpanel.util.RC
import github.ryuunoakaihitomi.powerpanel.util.openUrlInBrowser
import github.ryuunoakaihitomi.powerpanel.util.uiLog
import github.ryuunoakaihitomi.powerpanel.util.*
import org.apache.commons.io.IOUtils
import timber.log.Timber
import java.io.IOException
Expand Down Expand Up @@ -80,6 +77,7 @@ class OpenSourceLibDependencyActivity : AbsAboutActivity() {
inflateJsonData(items, "debugImplementation", "debug")
// 给个位置给Firebase
inflateJsonData(items, "non-free", "free")
inflateJsonData(items, "Gradle plugin", "plugin")
}

private fun inflateJsonData(l: MutableList<Any>, title: String, ep: String = title) = try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ fun Context.openUrlInBrowser(url: String) {
runCatching {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
}.onFailure {
Timber.e(it)
Toasty.info(this, url).show()
// 分享到其他地方,这个方法catch了ActivityNotFoundException,所以不用担心崩溃问题
Browser.sendString(this, url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object AppCenterCompat {
}

/**
* 和Firebase.Analytics的数据类型有差异
* 和Firebase Analytics的数据类型有差异
*/
fun trackEvent(tag: String, bundle: Bundle) = launch {
val map = ArrayMap<String, String>()
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ buildscript {
/* Crashlytics */
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.0'

classpath 'io.github.wurensen:gradle-android-plugin-aspectjx:2.0.11'
}
}

Expand Down

0 comments on commit f2acf64

Please sign in to comment.