Skip to content

V2 #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 12, 2024
Merged

V2 #40

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
7 changes: 4 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ android {
compileSdk 34
defaultConfig {
applicationId "com.wrbug.developerhelper"
minSdkVersion 21
minSdkVersion 23
targetSdkVersion 34
versionCode 100040
versionName "1.0.4"
Expand All @@ -44,14 +44,14 @@ android {
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
implementation 'com.google.code.gson:gson:2.10'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.github.yhaolpz:FloatWindow:1.0.9'
implementation project(':basecommon')
api project(':basecommon')
kapt "com.android.databinding:compiler:3.1.4"
implementation 'com.elvishew:xlog:1.6.1'
implementation 'org.jetbrains.anko:anko-commons:0.10.8'
Expand All @@ -64,6 +64,7 @@ dependencies {
implementation 'gdut.bsx:share2:0.9.3'
kapt 'com.google.dagger:dagger-compiler:2.16'
implementation 'de.blox:graphview:0.5.0'
implementation "com.google.android.material:material:1.12.0"
implementation project(':basemoduleimport')
implementation project(":commonwidget")
implementation project(':ipc')
Expand Down
20 changes: 14 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application
android:name=".DeveloperApplication"
Expand All @@ -21,8 +28,8 @@
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".ui.activity.main.MainActivity"
android:launchMode="singleTop"
android:exported="true">
android:exported="true"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand All @@ -32,8 +39,8 @@

<service
android:name=".service.DeveloperHelperAccessibilityService"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:exported="false">
android:exported="false"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
Expand All @@ -51,6 +58,7 @@
android:name=".service.FloatWindowService"
android:enabled="true"
android:exported="true"
android:foregroundServiceType="dataSync"
android:process=":floatWindow" />

<activity
Expand Down
Binary file removed app/src/main/assets/zip.dex
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class DeveloperApplication : BaseApp() {
)
registerIpcServer()
BaseModule.init(this)
releaseAssetsFile()
registerLifecycle()
AppStatusRegister.init(this)
}
Expand Down Expand Up @@ -91,18 +90,4 @@ class DeveloperApplication : BaseApp() {

})
}

private fun releaseAssetsFile() {
doAsync {
val inputStream = BaseApp.instance.assets.open("zip.dex")
val file = File(BaseApp.instance.cacheDir, "zip.dex")
if (file.exists().not()) {
file.createNewFile()
}
val fileOutputStream = FileOutputStream(file)
fileOutputStream.write(inputStream.readBytes())
fileOutputStream.flush()
fileOutputStream.close()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.wrbug.developerhelper.model.entity

data class BackupAppInfo(
var backupApk: Boolean = false,
var backupData: Boolean = false,
var backupAndroidData: Boolean = false,
var versionName: String = "",
var versionCode: Int = 0,
var packageName: String = ""
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package com.wrbug.developerhelper.service

import android.accessibilityservice.AccessibilityService
import android.content.BroadcastReceiver
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.graphics.Rect
import android.provider.Settings
import android.text.TextUtils
import android.util.Log
import android.view.accessibility.AccessibilityEvent
import android.view.accessibility.AccessibilityNodeInfo
import com.wrbug.developerhelper.R
Expand All @@ -29,6 +31,7 @@ class DeveloperHelperAccessibilityService : AccessibilityService() {
private var nodeId = 0L
private var currentAppInfo: ApkInfo? = null
private var topActivity: TopActivityInfo? = null
private val activityMap = hashMapOf<String, String>()

companion object {
internal var serviceRunning = false
Expand Down Expand Up @@ -72,7 +75,18 @@ class DeveloperHelperAccessibilityService : AccessibilityService() {
}

override fun onAccessibilityEvent(event: AccessibilityEvent?) {

if (event?.eventType != AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED || event.className.isNullOrEmpty() || event.packageName.isNullOrEmpty()) {
return
}
runCatching {
val info = packageManager.getActivityInfo(
ComponentName(
event.packageName.toString(),
event.className.toString()
), 0
)
activityMap[info.packageName] = info.name
}
}

fun readNode(): ArrayList<HierarchyNode> {
Expand All @@ -88,6 +102,7 @@ class DeveloperHelperAccessibilityService : AccessibilityService() {
return hierarchyNodes
}


private fun getDecorViewNode(node: AccessibilityNodeInfo): AccessibilityNodeInfo? {
for (index in 0 until node.childCount) {
val child = node.getChild(index)
Expand Down Expand Up @@ -204,8 +219,10 @@ class DeveloperHelperAccessibilityService : AccessibilityService() {


inner class DeveloperHelperAccessibilityReceiver : BroadcastReceiver() {
override fun onReceive(context: Context?, data: Intent?) {
override fun onReceive(context: Context, data: Intent?) {
val nodesInfo = readNode()
currentAppInfo?.topActivity =
activityMap[currentAppInfo?.packageInfo?.packageName].orEmpty()
HierarchyActivity.start(context, currentAppInfo, nodesInfo)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.ServiceInfo
import android.os.Build
import android.os.IBinder
import android.view.LayoutInflater
import android.widget.RemoteViews
import androidx.core.app.NotificationCompat
import androidx.core.app.ServiceCompat
import com.wrbug.developerhelper.R
import com.wrbug.developerhelper.commonutil.addTo
import com.wrbug.developerhelper.constant.ReceiverConstant
Expand Down Expand Up @@ -85,7 +87,16 @@ class FloatWindowService : Service() {
}

private fun updateNotification() {
startForeground(0x10000, notification)
val type = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
} else {
0
}
runCatching {
ServiceCompat.startForeground(this, 0x10000, notification, type)
}.getOrElse {
it.printStackTrace()
}
}

private fun updateNotificationContent(text: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class GuideStepAccessibilityFragment : GuideStepFragment() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
checkIsOpen()
binding.icoIv.setImageResource(R.drawable.ic_accessibility_black)
binding.icoIv.setImageResource(R.drawable.ic_accessibility)
binding.contentTv.setOnClickListener {
if (DeveloperHelperAccessibilityService.serviceRunning) {
return@setOnClickListener
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,25 @@
package com.wrbug.developerhelper.ui.activity.hierachy

import android.content.Context
import android.content.pm.ApplicationInfo
import android.content.pm.PackageInfo
import android.view.View
import android.view.ViewGroup
import androidx.annotation.Keep
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager.widget.PagerAdapter
import com.wrbug.developerhelper.R
import com.wrbug.developerhelper.basecommon.uiThread
import com.wrbug.developerhelper.commonutil.entity.ApkInfo
import com.wrbug.developerhelper.commonutil.entity.TopActivityInfo
import com.wrbug.developerhelper.commonutil.shell.ShellManager
import com.wrbug.developerhelper.ui.decoration.SpaceItemDecoration
import com.wrbug.developerhelper.ui.widget.appdatainfoview.AppDataInfoView
import com.wrbug.developerhelper.ui.widget.appsettingview.AppSettingView
import com.wrbug.developerhelper.ui.widget.layoutinfoview.infopage.InfoAdapter
import com.wrbug.developerhelper.ui.widget.layoutinfoview.infopage.ItemInfo
import com.wrbug.developerhelper.util.EnforceUtils
import com.wrbug.developerhelper.commonutil.UiUtils
import com.wrbug.developerhelper.commonutil.addTo
import com.wrbug.developerhelper.commonutil.shell.Callback
import com.wrbug.developerhelper.ipc.processshare.manager.AppXposedProcessDataManager
import com.wrbug.developerhelper.ui.widget.layoutinfoview.infopage.LoadingItem
import com.wrbug.developerhelper.util.format
import com.wrbug.developerhelper.util.getString
import io.reactivex.rxjava3.disposables.CompositeDisposable
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread
import java.lang.StringBuilder
import java.util.ArrayList

@Keep
Expand Down Expand Up @@ -89,9 +78,13 @@ class AppInfoPagerAdapter(
itemDecoration.setFirstTopPadding(UiUtils.dp2px(context, 10F))
rv.addItemDecoration(itemDecoration)
apkInfo?.let { it ->
itemInfos.add(ItemInfo("PackageName", it.packageInfo.packageName))
it.applicationInfo.className?.let { name ->
itemInfos.add(ItemInfo("Application", name))
}
it.topActivity.takeIf { it.isNotEmpty() }?.let {
itemInfos.add(ItemInfo("Activity", it))
}
itemInfos.add(ItemInfo("VersionName", it.packageInfo.versionName))
itemInfos.add(ItemInfo("VersionCode", it.packageInfo.versionCode))
itemInfos.add(ItemInfo("uid", it.applicationInfo.uid))
Expand All @@ -110,25 +103,9 @@ class AppInfoPagerAdapter(
)
itemInfos.add(ItemInfo("DataDir", it.applicationInfo.dataDir))
adapter.setItems(itemInfos)
loadTopActivityInfo()
}
}

private fun loadTopActivityInfo() {
ShellManager.getTopActivity().subscribe({ data ->
data.activity.takeIf { it.isNotEmpty() }?.let {
itemInfos.add(0, ItemInfo("Activity", it))
}
data.packageName.takeIf { it.isNotEmpty() }?.let {
itemInfos.add(0, ItemInfo("PackageName", it))
}
adapter.setItems(itemInfos)
}, {

}).addTo(disposable)

}

override fun isViewFromObject(view: View, o: Any): Boolean {
return view == o
}
Expand Down
Loading
Loading