Skip to content

Commit d1c54ac

Browse files
author
littleWhiteDuck
committed
Initial commit
0 parents  commit d1c54ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1477
-0
lines changed

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'kotlin-android'
4+
}
5+
6+
android {
7+
compileSdkVersion 30
8+
buildToolsVersion "30.0.2"
9+
10+
defaultConfig {
11+
applicationId "me.dumpIntent"
12+
minSdkVersion 21
13+
targetSdkVersion 30
14+
versionCode 1
15+
versionName "1.0-duck"
16+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17+
}
18+
19+
buildTypes {
20+
release {
21+
minifyEnabled true
22+
shrinkResources true
23+
zipAlignEnabled true
24+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
25+
}
26+
}
27+
compileOptions {
28+
sourceCompatibility JavaVersion.VERSION_1_8
29+
targetCompatibility JavaVersion.VERSION_1_8
30+
}
31+
kotlinOptions {
32+
jvmTarget = '1.8'
33+
}
34+
buildFeatures {
35+
viewBinding true
36+
}
37+
}
38+
39+
dependencies {
40+
41+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
42+
implementation 'androidx.core:core-ktx:1.3.1'
43+
implementation 'androidx.appcompat:appcompat:1.2.0'
44+
implementation 'com.google.android.material:material:1.2.1'
45+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
46+
testImplementation 'junit:junit:4.13.2'
47+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
48+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
49+
50+
// xposed
51+
compileOnly 'de.robv.android.xposed:api:82'
52+
53+
//json
54+
implementation 'com.google.code.gson:gson:2.8.5'
55+
}

app/proguard-rules.pro

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
22+
-repackageclasses "littleWhiteDuck"
23+
24+
-keep class * implements de.robv.android.xposed.IXposedHookLoadPackage {
25+
public void *(de.robv.android.xposed.callbacks.XC_LoadPackage$LoadPackageParam);
26+
}

app/release/app-release.apk

2 MB
Binary file not shown.

app/release/output-metadata.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": 2,
3+
"artifactType": {
4+
"type": "APK",
5+
"kind": "Directory"
6+
},
7+
"applicationId": "me.dumpIntent",
8+
"variantName": "release",
9+
"elements": [
10+
{
11+
"type": "SINGLE",
12+
"filters": [],
13+
"versionCode": 1,
14+
"versionName": "1.0-duck",
15+
"outputFile": "app-release.apk"
16+
}
17+
]
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package me.dumpIntent
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("me.dumpIntent", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="me.dumpIntent">
5+
6+
<application
7+
android:allowBackup="true"
8+
android:icon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:roundIcon="@mipmap/ic_launcher_round"
11+
android:supportsRtl="true"
12+
android:theme="@style/Theme.IntentDump"
13+
tools:ignore="AllowBackup">
14+
<activity android:name=".MainActivity">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN" />
17+
18+
<category android:name="android.intent.category.LAUNCHER" />
19+
</intent-filter>
20+
</activity>
21+
<provider
22+
android:authorities="me.dumpIntent.provider"
23+
android:name="me.dumpIntent.provider.ConfigProvider"
24+
android:exported="true"
25+
tools:ignore="ExportedContentProvider" />
26+
<meta-data
27+
android:name="xposedmodule"
28+
android:value="true" />
29+
<meta-data
30+
android:name="xposeddescription"
31+
android:value="获取常用启动Activity时的信息" />
32+
<meta-data
33+
android:name="xposedminversion"
34+
android:value="53" />
35+
</application>
36+
37+
</manifest>

app/src/main/assets/xposed_init

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
me.dumpIntent.hook.HookInit
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
package me.dumpIntent
2+
3+
import android.annotation.SuppressLint
4+
import android.content.Intent
5+
import android.net.Uri
6+
import android.os.Bundle
7+
import android.view.Menu
8+
import android.view.MenuItem
9+
import androidx.annotation.Keep
10+
import androidx.appcompat.app.AppCompatActivity
11+
import androidx.recyclerview.widget.LinearLayoutManager
12+
import com.google.android.material.dialog.MaterialAlertDialogBuilder
13+
import com.google.android.material.snackbar.Snackbar
14+
import com.google.gson.Gson
15+
import me.dumpIntent.adapter.ConfigAdapter
16+
import me.dumpIntent.bean.*
17+
import me.dumpIntent.databinding.ActivityMainBinding
18+
import me.dumpIntent.util.AppUtils
19+
import me.dumpIntent.util.CipherUtils
20+
import me.dumpIntent.util.ToolUtils
21+
22+
class MainActivity : AppCompatActivity() {
23+
private val uri = Uri.parse("content://me.dumpIntent.provider/configs")
24+
private lateinit var binding: ActivityMainBinding
25+
26+
private val mAdapter by lazy { ConfigAdapter { onItemClick(it) } }
27+
override fun onCreate(savedInstanceState: Bundle?) {
28+
super.onCreate(savedInstanceState)
29+
binding = ActivityMainBinding.inflate(layoutInflater)
30+
setContentView(binding.root)
31+
val moduleLiveTip = if (isModuleLive()) "模块已激活" else "模块未激活"
32+
Snackbar.make(binding.rev, moduleLiveTip, Snackbar.LENGTH_SHORT).show()
33+
initView()
34+
fetchData()
35+
}
36+
37+
private fun initView() {
38+
binding.apply {
39+
rev.apply {
40+
adapter = mAdapter
41+
layoutManager = LinearLayoutManager(this@MainActivity)
42+
}
43+
}
44+
}
45+
46+
@SuppressLint("SetTextI18n")
47+
private fun onItemClick(mainItem: MainItem) {
48+
val configBean = mainItem.configBean
49+
var extraStr = ""
50+
if (configBean.extras.isNotEmpty()) {
51+
configBean.extras.forEach {
52+
extraStr += "key:${it.key}, value:${it.value}\n"
53+
}
54+
extraStr = extraStr.substring(0, extraStr.length - 1)
55+
}
56+
val message =
57+
"应用名: ${mainItem.appName}\n包名: ${configBean.packageName}\n类名: ${configBean.className}\n" +
58+
"Action:${configBean.action}\nData: ${configBean.data}\nExtras: $extraStr"
59+
MaterialAlertDialogBuilder(this)
60+
.setTitle("详情")
61+
.setMessage(message)
62+
.setPositiveButton("复制为Anywhere配置") { dialog, _ ->
63+
val bean2 = Bean2(configBean.data, configBean.action, "", configBean.extras)
64+
val bean1 = Bean1(
65+
app_name = mainItem.appName,
66+
id = (System.currentTimeMillis()).toString(),
67+
param_1 = configBean.packageName,
68+
param_2 = configBean.className,
69+
param_3 = Gson().toJson(bean2),
70+
time_stamp = (System.currentTimeMillis()).toString()
71+
)
72+
CipherUtils.encrypt(Gson().toJson(bean1))?.let { ToolUtils.toClip(this, it) }
73+
dialog.dismiss()
74+
}
75+
.setNegativeButton("取消", null)
76+
.show()
77+
}
78+
79+
private fun fetchData() {
80+
val dataList = ArrayList<MainItem>()
81+
contentResolver.query(uri, null, null, null, "ID DESC")?.apply {
82+
while (moveToNext()) {
83+
val config = getString(getColumnIndex("config"))
84+
val id = getInt(getColumnIndex("id"))
85+
val configBean = Gson().fromJson(config, ConfigBean::class.java)
86+
dataList.add(
87+
MainItem(
88+
id,
89+
AppUtils.getAppName(this@MainActivity, configBean.packageName),
90+
AppUtils.getIcon(this@MainActivity, configBean.packageName),
91+
configBean
92+
)
93+
)
94+
}
95+
close()
96+
}
97+
mAdapter.submitList(dataList)
98+
if(dataList.size >= 50) Snackbar.make(binding.rev, "请及时清理数据,以免加载数据过慢", Snackbar.LENGTH_SHORT).show()
99+
}
100+
101+
@Keep
102+
private fun isModuleLive() = false
103+
104+
override fun onCreateOptionsMenu(menu: Menu): Boolean {
105+
menuInflater.inflate(R.menu.menu_main, menu)
106+
return true
107+
}
108+
109+
override fun onOptionsItemSelected(item: MenuItem): Boolean {
110+
when (item.itemId) {
111+
R.id.delete -> {
112+
contentResolver.delete(uri, null, null)
113+
fetchData()
114+
}
115+
R.id.refresh -> fetchData()
116+
R.id.github -> {
117+
val intent = Intent()
118+
intent.data = Uri.parse("https://github.com/littleWhiteDuck/IntentDump")
119+
startActivity(intent)
120+
}
121+
R.id.about -> showAboutMe()
122+
}
123+
return true
124+
}
125+
126+
private fun showAboutMe() {
127+
MaterialAlertDialogBuilder(this)
128+
.setTitle("关于")
129+
.setMessage(R.string.aboutMe)
130+
.setPositiveButton("确认", null)
131+
.setNegativeButton("取消", null)
132+
.show()
133+
}
134+
135+
136+
override fun onRestart() {
137+
super.onRestart()
138+
fetchData()
139+
}
140+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package me.dumpIntent.adapter
2+
3+
import android.view.LayoutInflater
4+
import android.view.ViewGroup
5+
import androidx.recyclerview.widget.DiffUtil
6+
import androidx.recyclerview.widget.ListAdapter
7+
import androidx.recyclerview.widget.RecyclerView
8+
import me.dumpIntent.R
9+
import me.dumpIntent.bean.MainItem
10+
import me.dumpIntent.databinding.ItemMainLayoutBinding
11+
12+
class ConfigAdapter(private val onClick: (MainItem) -> Unit) :
13+
ListAdapter<MainItem, ConfigAdapter.ViewHolder>(MainDiff) {
14+
15+
class ViewHolder(binding: ItemMainLayoutBinding) : RecyclerView.ViewHolder(binding.root) {
16+
val tvAppName = binding.tvAppName
17+
val tvPackageName = binding.tvPackageName
18+
val tvClassName = binding.tvClassName
19+
val ivIcon = binding.ivIcon
20+
}
21+
22+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
23+
val binding =
24+
ItemMainLayoutBinding.inflate(LayoutInflater.from(parent.context), parent, false)
25+
val holder = ViewHolder(binding)
26+
holder.itemView.setOnClickListener {
27+
val mainItem = it.getTag(R.id.main_item_position) as MainItem
28+
onClick(mainItem)
29+
}
30+
return holder
31+
}
32+
33+
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
34+
val item = getItem(position)
35+
holder.itemView.setTag(R.id.main_item_position, item)
36+
holder.apply {
37+
item.apply {
38+
tvAppName.text = appName
39+
tvPackageName.text = configBean.packageName
40+
tvClassName.text = configBean.className
41+
ivIcon.setImageDrawable(appIcon)
42+
}
43+
}
44+
}
45+
46+
47+
object MainDiff : DiffUtil.ItemCallback<MainItem>() {
48+
49+
override fun areItemsTheSame(oldItem: MainItem, newItem: MainItem) =
50+
oldItem.id == newItem.id
51+
52+
override fun areContentsTheSame(oldItem: MainItem, newItem: MainItem) =
53+
oldItem.configBean == newItem.configBean
54+
}
55+
56+
}

0 commit comments

Comments
 (0)