forked from CodingGay/BlackDex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
efc3907
commit f8e7c18
Showing
49 changed files
with
1,273 additions
and
368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
app/src/androidTest/java/top/niunaijun/blackdex/ExampleInstrumentedTest.java
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
app/src/androidTest/java/top/niunaijun/blackdex/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package top.niunaijun.blackdex | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("top.niunaijun.blackdex", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package top.niunaijun.blackdex | ||
|
||
import android.app.Application | ||
import android.content.Context | ||
import top.niunaijun.blackbox.BlackDexCore | ||
import top.niunaijun.blackbox.app.configuration.ClientConfiguration | ||
import top.niunaijun.blackdex.data.BlackDexConfiguration | ||
|
||
/** | ||
* | ||
* @Description: | ||
* @Author: wukaicheng | ||
* @CreateDate: 2021/5/23 14:00 | ||
*/ | ||
class App : Application() { | ||
|
||
override fun attachBaseContext(base: Context?) { | ||
super.attachBaseContext(base) | ||
BlackDexCore.get().doAttachBaseContext(base,BlackDexConfiguration(base!!)) | ||
} | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
BlackDexCore.get().doCreate() | ||
} | ||
} |
45 changes: 0 additions & 45 deletions
45
app/src/main/java/top/niunaijun/blackdex/MainActivity.java
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
app/src/main/java/top/niunaijun/blackdex/data/BlackDexConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package top.niunaijun.blackdex.data | ||
|
||
import android.content.Context | ||
import top.niunaijun.blackbox.app.configuration.ClientConfiguration | ||
|
||
/** | ||
* | ||
* @Description: 启动配置文件 | ||
* @Author: wukaicheng | ||
* @CreateDate: 2021/5/23 14:04 | ||
*/ | ||
class BlackDexConfiguration(private val context: Context) : ClientConfiguration() { | ||
override fun getHostPackageName(): String { | ||
return context.packageName | ||
} | ||
|
||
|
||
} |
88 changes: 88 additions & 0 deletions
88
app/src/main/java/top/niunaijun/blackdex/data/DexDumpRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package top.niunaijun.blackdex.data | ||
|
||
import android.content.pm.ApplicationInfo | ||
import android.net.Uri | ||
import android.webkit.URLUtil | ||
import androidx.lifecycle.MutableLiveData | ||
import kotlinx.coroutines.GlobalScope | ||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.launch | ||
import top.niunaijun.blackbox.BlackBoxCore | ||
import top.niunaijun.blackbox.BlackBoxCore.getPackageManager | ||
import top.niunaijun.blackbox.BlackDexCore | ||
import top.niunaijun.blackbox.utils.AbiUtils | ||
import top.niunaijun.blackbox.utils.FileUtils | ||
import top.niunaijun.blackdex.data.entity.AppInfo | ||
import top.niunaijun.blackdex.data.entity.DumpInfo | ||
import java.io.File | ||
|
||
/** | ||
* | ||
* @Description: | ||
* @Author: wukaicheng | ||
* @CreateDate: 2021/5/23 14:29 | ||
*/ | ||
class DexDumpRepository { | ||
|
||
private var dumpTaskId = 0 | ||
|
||
fun getAppList(mAppListLiveData: MutableLiveData<List<AppInfo>>) { | ||
|
||
val installedApplications: List<ApplicationInfo> = getPackageManager().getInstalledApplications(0) | ||
val installedList = mutableListOf<AppInfo>() | ||
|
||
for (installedApplication in installedApplications) { | ||
val file = File(installedApplication.sourceDir) | ||
|
||
if ((installedApplication.flags and ApplicationInfo.FLAG_SYSTEM) != 0) continue | ||
|
||
if (!AbiUtils.isSupport(file)) continue | ||
|
||
|
||
val info = AppInfo( | ||
installedApplication.loadLabel(getPackageManager()).toString(), | ||
installedApplication.packageName, | ||
installedApplication.loadIcon(getPackageManager()) | ||
) | ||
installedList.add(info) | ||
} | ||
|
||
mAppListLiveData.postValue(installedList) | ||
} | ||
|
||
fun dumpDex(source: String, dexDumpLiveData: MutableLiveData<DumpInfo>) { | ||
|
||
dexDumpLiveData.postValue(DumpInfo(DumpInfo.LOADING)) | ||
|
||
val result = if (URLUtil.isValidUrl(source)) { | ||
BlackDexCore.get().dumpDex(Uri.parse(source)) | ||
} else { | ||
BlackDexCore.get().dumpDex(source) | ||
} | ||
|
||
if(result){ | ||
dumpTaskId++ | ||
startCountdown(dexDumpLiveData) | ||
}else{ | ||
dexDumpLiveData.postValue(DumpInfo(DumpInfo.TIMEOUT)) | ||
} | ||
|
||
} | ||
|
||
|
||
fun dumpSuccess(){ | ||
dumpTaskId++ | ||
} | ||
|
||
private fun startCountdown(dexDumpLiveData: MutableLiveData<DumpInfo>){ | ||
GlobalScope.launch { | ||
val tempId = dumpTaskId | ||
delay(10000) | ||
|
||
if(tempId == dumpTaskId){ | ||
dexDumpLiveData.postValue(DumpInfo(DumpInfo.TIMEOUT)) | ||
} | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.