Skip to content

Commit

Permalink
结构调整
Browse files Browse the repository at this point in the history
  • Loading branch information
WrBug committed Feb 28, 2019
1 parent b6fa0e8 commit 241c125
Show file tree
Hide file tree
Showing 40 changed files with 200 additions and 127 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle
Expand Up @@ -66,7 +66,8 @@ dependencies {
kapt 'com.google.dagger:dagger-compiler:2.16'
implementation project(':xposedmodule')
implementation 'de.blox:graphview:0.5.0'
implementation project(':basewidgetimport')
implementation project(':basemoduleimport')
implementation project(':ipc')
}
kapt {
generateStubs = true
Expand Down
Expand Up @@ -10,9 +10,7 @@ import com.elvishew.xlog.LogLevel
import com.elvishew.xlog.XLog
import com.elvishew.xlog.internal.DefaultsFactory
import com.wrbug.developerhelper.basecommon.BaseApp
import com.wrbug.developerhelper.basewidgetimport.BaseWidget
import com.wrbug.developerhelper.commonutil.CommonUtils
import com.wrbug.developerhelper.mmkv.manager.MMKVManager
import com.wrbug.developerhelper.basewidgetimport.BaseModule
import java.io.File
import java.io.FileOutputStream
import kotlin.concurrent.thread
Expand Down Expand Up @@ -43,7 +41,7 @@ class DeveloperApplication : BaseApp() {
}
override fun onCreate() {
super.onCreate()
BaseWidget.init(this)
BaseModule.init(this)
instance = this
XLog.init(
LogConfiguration.Builder().logLevel(LogLevel.ALL).tag("developerHelper.print-->").build(),
Expand Down
Expand Up @@ -11,8 +11,8 @@ import com.wrbug.developerhelper.R
import com.wrbug.developerhelper.commonutil.entity.ApkInfo
import com.wrbug.developerhelper.ui.widget.bottommenu.BottomMenu
import com.wrbug.developerhelper.ui.widget.bottommenu.OnItemClickListener
import com.wrbug.developerhelper.xposed.processshare.DumpDexListProcessData
import com.wrbug.developerhelper.xposed.processshare.ProcessDataManager
import com.wrbug.developerhelper.ipc.processshare.DumpDexListProcessData
import com.wrbug.developerhelper.ipc.processshare.ProcessDataManager

class ShellAppListAdapter(val context: Context) : RecyclerView.Adapter<ShellAppListAdapter.ViewHolder>() {
private val list = ArrayList<ApkInfo>()
Expand Down
Expand Up @@ -10,8 +10,8 @@ import com.wrbug.developerhelper.basecommon.BaseActivity
import com.wrbug.developerhelper.basecommon.setupActionBar
import com.wrbug.developerhelper.commonutil.AppInfoManager
import com.wrbug.developerhelper.commonutil.entity.ApkInfo
import com.wrbug.developerhelper.xposed.processshare.DumpDexListProcessData
import com.wrbug.developerhelper.xposed.processshare.ProcessDataManager
import com.wrbug.developerhelper.ipc.processshare.DumpDexListProcessData
import com.wrbug.developerhelper.ipc.processshare.ProcessDataManager
import kotlinx.android.synthetic.main.activity_shell_app_manager.*
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread
Expand Down
Expand Up @@ -22,7 +22,7 @@ import com.wrbug.developerhelper.basecommon.BaseActivity
import com.wrbug.developerhelper.commonutil.shell.ShellManager
import com.wrbug.developerhelper.commonutil.zip
import com.wrbug.developerhelper.util.BackupUtils
import com.wrbug.developerhelper.util.toUri
import com.wrbug.developerhelper.commonutil.toUri
import gdut.bsx.share2.Share2
import gdut.bsx.share2.ShareContentType
import org.jetbrains.anko.doAsync
Expand Down Expand Up @@ -102,7 +102,7 @@ class AppSettingView : ScrollView {
if (ShellManager.cpFile(dexDir, dir.absolutePath)) {
val zipFile = File(context.externalCacheDir, "${apkInfo?.getAppName() ?: ""}-dex.zip")
dir.zip(zipFile)
val uri = zipFile.toUri()
val uri = zipFile.toUri(context)
if (uri == null) {
showToast(R.string.export_failed)
return@doAsync
Expand Down Expand Up @@ -209,7 +209,7 @@ class AppSettingView : ScrollView {
override fun granted() {
val zipFile = File(context.externalCacheDir, "${apkInfo?.getAppName() ?: ""}-data.zip")
backupAppData.zip(zipFile)
val uri = zipFile.toUri()
val uri = zipFile.toUri(context)
if (uri == null) {
showToast(context.getString(R.string.share_failed))
return
Expand Down
Expand Up @@ -2,8 +2,10 @@ package com.wrbug.developerhelper.util

import android.net.Uri
import android.os.Environment
import com.wrbug.developerhelper.basecommon.BaseApp
import com.wrbug.developerhelper.commonutil.shell.ShellManager
import com.wrbug.developerhelper.commonutil.zip
import com.wrbug.developerhelper.commonutil.toUri
import com.wrbug.developerhelper.xposed.developerhelper.DeveloperHelper
import java.io.File

object BackupUtils {
Expand All @@ -18,7 +20,7 @@ object BackupUtils {
fun backupApk(packageName: String, apkPath: String, fileName: String): Uri? {
val apkDir = File(backupDir, "apks/$packageName/$fileName")
if (ShellManager.cpFile(apkPath, apkDir.absolutePath)) {
return apkDir.toUri()
return apkDir.toUri(BaseApp.instance)
}
return null
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -5,7 +5,7 @@ import com.github.megatronking.netbare.NetBare
import com.wrbug.developerhelper.commonutil.CommonUtils
import com.wrbug.developerhelper.mmkv.manager.MMKVManager

object BaseWidget {
object BaseModule {
fun init(application: Application) {
MMKVManager.register(application)
CommonUtils.register(application)
Expand Down
6 changes: 3 additions & 3 deletions commonutil/build.gradle
Expand Up @@ -27,16 +27,16 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.jaredrummler:android-shell:1.0.0'
api 'com.jaredrummler:android-shell:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation project(':mmkv')
implementation "org.jetbrains.anko:anko-commons:0.10.8"
api "org.jetbrains.anko:anko-commons:0.10.8"
api 'com.google.code.gson:gson:2.8.5'
implementation 'com.elvishew:xlog:1.6.1'
api 'com.elvishew:xlog:1.6.1'
api 'com.squareup.okhttp3:okhttp:3.12.1'
api group: 'org.jsoup', name: 'jsoup', version: '1.11.3'
}
Expand Down
@@ -1,14 +1,10 @@
package com.wrbug.developerhelper.util
package com.wrbug.developerhelper.commonutil

import android.content.Context
import android.media.MediaMetadataRetriever
import android.net.Uri
import android.os.Build
import androidx.core.content.FileProvider
import com.wrbug.developerhelper.basecommon.BaseApp
import org.dom4j.Document
import org.dom4j.io.OutputFormat
import org.dom4j.io.XMLWriter

import java.io.*


Expand All @@ -17,6 +13,17 @@ import java.io.*
*/
object FileUtils {


fun writeByteToFile(data: ByteArray, path: String) {
try {
val localFileOutputStream = FileOutputStream(path)
localFileOutputStream.write(data)
localFileOutputStream.close()
} catch (e: Exception) {
}
}


fun inputstreamtofile(ins: InputStream, file: File) {
try {
if (file.exists()) {
Expand All @@ -33,21 +40,6 @@ object FileUtils {
}


fun whiteXml(file: File, document: Document) {
try {
if (!file.exists()) {
file.createNewFile()
}
val format = OutputFormat.createPrettyPrint()
format.encoding = "utf-8"
val writer = XMLWriter(OutputStreamWriter(FileOutputStream(file), "utf-8"), format)
writer.write(document)
writer.close()
} catch (e: IOException) {
}

}

fun inputStream2String(ins: InputStream): String {
val out = StringBuffer()
val b = ByteArray(4096)
Expand Down Expand Up @@ -85,11 +77,39 @@ object FileUtils {
return mime
}

fun readFile(file: File): String {
val builder = StringBuilder()
try {
val fr = FileReader(file)
var ch = fr.read()
while (ch != -1) {
builder.append(ch.toChar())
ch = fr.read()
}
} catch (e: IOException) {
}

return builder.toString()
}

fun whiteFile(file: File, data: String) {
try {
if (!file.exists()) {
file.createNewFile()
}
val fw = FileWriter(file)
fw.write(data)
fw.flush()
} catch (e: IOException) {
}

}
}

fun File.toUri(): Uri? {

fun File.toUri(context: Context): Uri? {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
FileProvider.getUriForFile(BaseApp.instance, "com.wrbug.developerhelper.fileprovider", this)
FileProvider.getUriForFile(context, "com.wrbug.developerhelper.fileprovider", this)
} else {
Uri.fromFile(this)
}
Expand Down
1 change: 1 addition & 0 deletions ipc/.gitignore
@@ -0,0 +1 @@
/build
41 changes: 41 additions & 0 deletions ipc/build.gradle
@@ -0,0 +1,41 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 28



defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation project(':commonutil')
}
repositories {
mavenCentral()
}
21 changes: 21 additions & 0 deletions ipc/proguard-rules.pro
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
@@ -0,0 +1,26 @@
package com.wrbug.developerhelper.ipc;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.wrbug.developerhelper.ipc.test", appContext.getPackageName());
}
}
2 changes: 2 additions & 0 deletions ipc/src/main/AndroidManifest.xml
@@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wrbug.developerhelper.ipc" />
@@ -1,4 +1,4 @@
package com.wrbug.developerhelper.xposed.processshare
package com.wrbug.developerhelper.ipc.processshare

import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
Expand Down
@@ -1,4 +1,4 @@
package com.wrbug.developerhelper.xposed.processshare
package com.wrbug.developerhelper.ipc.processshare

interface DumpDexListProcessData : ProcessData {

Expand Down
@@ -1,4 +1,4 @@
package com.wrbug.developerhelper.xposed.processshare
package com.wrbug.developerhelper.ipc.processshare

interface GlobalConfigProcessData : ProcessData {
@DefaultValue("true")
Expand Down
@@ -0,0 +1,4 @@
package com.wrbug.developerhelper.ipc.processshare

interface ProcessData {
}
@@ -1,10 +1,10 @@
package com.wrbug.developerhelper.xposed.processshare
package com.wrbug.developerhelper.ipc.processshare

import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.jaredrummler.android.shell.Shell
import com.wrbug.developerhelper.commonutil.*
import com.wrbug.developerhelper.xposed.util.FileUtils
import com.wrbug.developerhelper.commonutil.Base64
import com.wrbug.developerhelper.commonutil.FileUtils
import java.io.File
import java.lang.reflect.InvocationHandler
import java.lang.reflect.Method
Expand Down
@@ -1,12 +1,12 @@
@file:Suppress("UNCHECKED_CAST")

package com.wrbug.developerhelper.xposed.processshare
package com.wrbug.developerhelper.ipc.processshare

import android.util.ArrayMap
import androidx.collection.ArrayMap
import java.lang.reflect.Proxy

object ProcessDataManager {
private val map = ArrayMap<Class<*>, Any>()
private val map = ArrayMap<Class<*>, Any>()
fun <T : ProcessData> get(clazz: Class<T>): T {
if (map.containsKey(clazz)) {
return map[clazz] as T
Expand Down
3 changes: 3 additions & 0 deletions ipc/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">ipc</string>
</resources>

0 comments on commit 241c125

Please sign in to comment.