6.7.0 - Alpha11 - 移除 Flurry 及 Bugly 相关代码
This commit is contained in:
@@ -14,11 +14,8 @@ import androidx.multidex.MultiDexApplication
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.target.CustomViewTarget
|
||||
import com.bumptech.glide.request.transition.Transition
|
||||
import com.flurry.android.FlurryAgent
|
||||
import com.google.mlkit.common.sdkinternal.MlKitContext
|
||||
import com.hjq.toast.Toaster
|
||||
import com.tencent.bugly.Bugly
|
||||
import com.tencent.bugly.crashreport.CrashReport
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import org.autojs.autojs.app.GlobalAppContext
|
||||
import org.autojs.autojs.core.pref.Pref
|
||||
@@ -36,7 +33,6 @@ import org.autojs.autojs.tool.CrashHandler
|
||||
import org.autojs.autojs.ui.error.CrashReportActivity
|
||||
import org.autojs.autojs.ui.floating.FloatyWindowManger
|
||||
import org.autojs.autojs.util.ViewUtils
|
||||
import org.autojs.autojs6.BuildConfig
|
||||
import org.autojs.autojs6.R
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.lang.ref.WeakReference
|
||||
@@ -68,7 +64,6 @@ class App : MultiDexApplication() {
|
||||
else /* Main process. */ -> {
|
||||
devPluginService = DevPluginService(this)
|
||||
|
||||
setUpStaticsTool()
|
||||
setUpDebugEnvironment()
|
||||
setUpLeakCanary()
|
||||
|
||||
@@ -91,25 +86,8 @@ class App : MultiDexApplication() {
|
||||
Log.d("Shizuku", "${App::class.java.simpleName} attachBaseContext | Process=${getProcessNameCompat()}")
|
||||
}
|
||||
|
||||
private fun setUpStaticsTool() {
|
||||
if (!BuildConfig.DEBUG) {
|
||||
@Suppress("SpellCheckingInspection")
|
||||
FlurryAgent.Builder()
|
||||
.withLogEnabled(false)
|
||||
.build(this, "D42MH48ZN4PJC5TKNYZD")
|
||||
}
|
||||
}
|
||||
|
||||
private fun setUpDebugEnvironment() {
|
||||
Bugly.isDev = false
|
||||
val crashHandler = CrashHandler(CrashReportActivity::class.java)
|
||||
val strategy = CrashReport.UserStrategy(applicationContext).apply {
|
||||
crashHandleCallback = crashHandler
|
||||
}
|
||||
|
||||
CrashReport.initCrashReport(applicationContext, BUGLY_APP_ID, false, strategy)
|
||||
|
||||
crashHandler.setBuglyHandler(Thread.getDefaultUncaughtExceptionHandler())
|
||||
Thread.setDefaultUncaughtExceptionHandler(crashHandler)
|
||||
}
|
||||
|
||||
@@ -267,8 +245,6 @@ class App : MultiDexApplication() {
|
||||
|
||||
companion object {
|
||||
|
||||
private const val BUGLY_APP_ID = "19b3607b53"
|
||||
|
||||
private lateinit var instance: WeakReference<App>
|
||||
|
||||
val app: App
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package org.autojs.autojs.groundwork;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.tencent.bugly.crashreport.BuglyLog;
|
||||
|
||||
public class WrapContentGridLayoutManger extends GridLayoutManager {
|
||||
|
||||
private String mDebugInfo;
|
||||
|
||||
public WrapContentGridLayoutManger(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public WrapContentGridLayoutManger(Context context, int spanCount) {
|
||||
super(context, spanCount);
|
||||
}
|
||||
|
||||
public WrapContentGridLayoutManger(Context context, int spanCount, int orientation, boolean reverseLayout) {
|
||||
super(context, spanCount, orientation, reverseLayout);
|
||||
}
|
||||
|
||||
public void setDebugInfo(String debugInfo) {
|
||||
mDebugInfo = debugInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
|
||||
try {
|
||||
super.onLayoutChildren(recycler, state);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
BuglyLog.e("GridLayoutManager", "Android bug: debug info = " + mDebugInfo, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,9 @@ package org.autojs.autojs.tool
|
||||
import android.content.Intent
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import com.tencent.bugly.crashreport.BuglyLog
|
||||
import com.tencent.bugly.crashreport.CrashReport
|
||||
import com.tencent.bugly.crashreport.CrashReport.CrashHandleCallback
|
||||
import org.autojs.autojs.app.GlobalAppContext
|
||||
import org.autojs.autojs.core.accessibility.AccessibilityService
|
||||
import org.autojs.autojs.runtime.ScriptRuntime
|
||||
import org.autojs.autojs6.BuildConfig
|
||||
import org.mozilla.javascript.RhinoException
|
||||
import java.lang.Thread.UncaughtExceptionHandler
|
||||
import java.lang.ref.WeakReference
|
||||
import kotlin.system.exitProcess
|
||||
@@ -20,29 +15,14 @@ import kotlin.system.exitProcess
|
||||
* Modified by SuperMonster003 as of Dec 1, 2021.
|
||||
* Transformed by SuperMonster003 on Nov 28, 2023.
|
||||
*/
|
||||
class CrashHandler(private val errorReportClass: Class<*>) : CrashHandleCallback(), UncaughtExceptionHandler {
|
||||
class CrashHandler(private val errorReportClass: Class<*>) : UncaughtExceptionHandler {
|
||||
|
||||
private var mBuglyHandler: UncaughtExceptionHandler? = null
|
||||
private val mSystemHandler: UncaughtExceptionHandler? by lazy {
|
||||
Thread.getDefaultUncaughtExceptionHandler()
|
||||
}
|
||||
|
||||
private var mCachedExceptionMessage: MutableList<WeakReference<Throwable>> = ArrayList()
|
||||
|
||||
@Synchronized
|
||||
override fun onCrashHandleStart(crashType: Int, errorType: String?, errorMessage: String?, errorStack: String?): MutableMap<String, String>? {
|
||||
Log.d(TAG, "onCrashHandleStart: crashType = $crashType, errorType = $errorType, msg = $errorMessage, stack = $errorStack")
|
||||
try {
|
||||
if (crashTooManyTimes()) {
|
||||
return super.onCrashHandleStart(crashType, errorType, errorMessage, errorStack)
|
||||
}
|
||||
startCrashReportActivity("$errorType: $errorMessage", errorStack ?: "[ No stack message ]")
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return super.onCrashHandleStart(crashType, errorType, errorMessage, errorStack)
|
||||
}
|
||||
|
||||
override fun uncaughtException(thread: Thread, ex: Throwable) {
|
||||
Log.e(TAG, "Uncaught Exception", ex)
|
||||
// ScriptRuntime.popException(ex.message ?: "Uncaught Exception")
|
||||
@@ -50,33 +30,21 @@ class CrashHandler(private val errorReportClass: Class<*>) : CrashHandleCallback
|
||||
if (mCachedExceptionMessage.size > 4) {
|
||||
if (mCachedExceptionMessage.all { it.get()?.message == latestMessage } || mCachedExceptionMessage.size > 20) {
|
||||
ScriptRuntime.popException(latestMessage)
|
||||
// ClipboardUtils.setClip(GlobalAppContext.get(), ex.stackTraceToString())
|
||||
startCrashReportActivity("Uncaught Exception", ex.stackTraceToString())
|
||||
exitProcess(1)
|
||||
}
|
||||
}
|
||||
mCachedExceptionMessage.add(WeakReference(ex))
|
||||
if (thread != Looper.getMainLooper().thread) {
|
||||
if (ex !is RhinoException) {
|
||||
CrashReport.postCatchedException(ex, thread)
|
||||
}
|
||||
return
|
||||
}
|
||||
val service = AccessibilityService.instance
|
||||
if (service != null && AccessibilityService.stop()) {
|
||||
Log.d(TAG, "Service disabled: $service")
|
||||
} else {
|
||||
BuglyLog.d(TAG, "Failed to disable service: ${AccessibilityService::class.java.simpleName}")
|
||||
Log.d(TAG, "Failed to disable service: ${AccessibilityService::class.java.simpleName}")
|
||||
}
|
||||
if (BuildConfig.DEBUG) {
|
||||
mSystemHandler?.uncaughtException(thread, ex)
|
||||
} else {
|
||||
mBuglyHandler?.uncaughtException(thread, ex)
|
||||
}
|
||||
}
|
||||
|
||||
fun setBuglyHandler(buglyHandler: UncaughtExceptionHandler?) {
|
||||
mBuglyHandler = buglyHandler
|
||||
mSystemHandler?.uncaughtException(thread, ex)
|
||||
}
|
||||
|
||||
private fun startCrashReportActivity(msg: String, detail: String) {
|
||||
@@ -87,22 +55,8 @@ class CrashHandler(private val errorReportClass: Class<*>) : CrashHandleCallback
|
||||
}.let { GlobalAppContext.get().startActivity(it) }
|
||||
}
|
||||
|
||||
private fun crashTooManyTimes() = when {
|
||||
crashIntervalTooLong() -> false.also { resetCrashCount() }
|
||||
else -> ++crashCount >= 5
|
||||
}
|
||||
|
||||
private fun resetCrashCount() {
|
||||
firstCrashMillis = System.currentTimeMillis()
|
||||
crashCount = 0
|
||||
}
|
||||
|
||||
private fun crashIntervalTooLong() = System.currentTimeMillis() - firstCrashMillis > 3000
|
||||
|
||||
companion object {
|
||||
private const val TAG = "CrashHandler"
|
||||
private var crashCount = 0
|
||||
private var firstCrashMillis = 0L
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import androidx.annotation.Nullable;
|
||||
import androidx.core.content.pm.ShortcutManagerCompat;
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.tencent.bugly.crashreport.BuglyLog;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.internal.functions.ObjectHelper;
|
||||
@@ -450,7 +449,7 @@ public class ScriptOperations {
|
||||
}
|
||||
|
||||
public Observable<ScriptFile> download(String url) {
|
||||
BuglyLog.i(LOG_TAG, "dir = " + WorkingDirectoryUtils.getPath() + ", sdcard = " + Environment.getExternalStorageDirectory() + ", url = " + url);
|
||||
Log.i(LOG_TAG, "dir = " + WorkingDirectoryUtils.getPath() + ", sdcard = " + Environment.getExternalStorageDirectory() + ", url = " + url);
|
||||
String fileName = DownloadManager.parseFileNameLocally(url);
|
||||
return new FileChooserDialogBuilder(mContext)
|
||||
.title(R.string.text_save_to)
|
||||
|
||||
@@ -20,7 +20,6 @@ import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.autojs.autojs.groundwork.WrapContentGridLayoutManger;
|
||||
import org.autojs.autojs.model.indices.Module;
|
||||
import org.autojs.autojs.model.indices.Modules;
|
||||
import org.autojs.autojs.model.indices.Property;
|
||||
@@ -95,8 +94,7 @@ public class FunctionsKeyboardView extends FrameLayout {
|
||||
|
||||
private void initPropertiesView(FunctionsKeyboardViewBinding binding) {
|
||||
mPropertiesView = binding.properties;
|
||||
WrapContentGridLayoutManger manager = new WrapContentGridLayoutManger(getContext(), SPAN_COUNT);
|
||||
manager.setDebugInfo("FunctionsKeyboardView");
|
||||
GridLayoutManager manager = new GridLayoutManager(getContext(), SPAN_COUNT);
|
||||
mPropertiesView.setLayoutManager(manager);
|
||||
mPropertiesView.setAdapter(new PropertiesAdapter());
|
||||
manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.autojs.autojs.core.pref.Pref.putLinkedList
|
||||
import org.autojs.autojs.core.pref.Pref.putString
|
||||
import org.autojs.autojs.core.pref.Pref.remove
|
||||
import org.autojs.autojs.extension.ViewExtensions.setForceShowIconCompat
|
||||
import org.autojs.autojs.groundwork.WrapContentGridLayoutManger
|
||||
import org.autojs.autojs.model.explorer.Explorer
|
||||
import org.autojs.autojs.model.explorer.ExplorerChangeEvent
|
||||
import org.autojs.autojs.model.explorer.ExplorerDirPage
|
||||
@@ -142,8 +141,7 @@ open class ExplorerView : ThemeColorSwipeRefreshLayout, SwipeRefreshLayout.OnRef
|
||||
this.explorerItemListView = it
|
||||
it.adapter = mExplorerAdapter
|
||||
it.setHasFixedSize(true)
|
||||
it.layoutManager = WrapContentGridLayoutManger(this.context, 2).also { manager ->
|
||||
manager.setDebugInfo(ExplorerView::class.java.simpleName)
|
||||
it.layoutManager = GridLayoutManager(this.context, 2).also { manager ->
|
||||
manager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
||||
override fun getSpanSize(position: Int) = when {
|
||||
position > positionOfCategoryDir && position < positionOfCategoryFile() -> {
|
||||
|
||||
@@ -19,9 +19,9 @@ import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.autojs.autojs.groundwork.WrapContentGridLayoutManger;
|
||||
import org.autojs.autojs.runtime.api.Mime;
|
||||
import org.autojs.autojs.ui.BaseActivity;
|
||||
import org.autojs.autojs.util.ViewUtils;
|
||||
@@ -65,8 +65,7 @@ public class AppsIconSelectActivity extends BaseActivity {
|
||||
|
||||
ViewUtils.excludePaddingClippableViewFromBottomNavigationBar(mAppsRecyclerView);
|
||||
|
||||
WrapContentGridLayoutManger manager = new WrapContentGridLayoutManger(this, 5);
|
||||
manager.setDebugInfo("IconSelectView");
|
||||
GridLayoutManager manager = new GridLayoutManager(this, 5);
|
||||
mAppsRecyclerView.setLayoutManager(manager);
|
||||
|
||||
loadApps();
|
||||
|
||||
Reference in New Issue
Block a user