mirror of
https://github.com/MatsuriDayo/NekoBoxForAndroid.git
synced 2025-12-19 22:50:05 +08:00
Replace apkScanner with packageNameList
This commit is contained in:
parent
1ab62da5a3
commit
7d34af2122
@ -65,9 +65,6 @@ dependencies {
|
||||
exclude(group = "androidx.recyclerview")
|
||||
exclude(group = "androidx.appcompat")
|
||||
}
|
||||
implementation("org.smali:dexlib2:2.5.2") {
|
||||
exclude(group = "com.google.guava", module = "guava")
|
||||
}
|
||||
|
||||
implementation("androidx.room:room-runtime:2.5.1")
|
||||
kapt("androidx.room:room-compiler:2.5.1")
|
||||
|
||||
370
app/src/main/assets/proxy_packagename.txt
Normal file
370
app/src/main/assets/proxy_packagename.txt
Normal file
@ -0,0 +1,370 @@
|
||||
amanita_design.samorost3.gp
|
||||
android
|
||||
au.com.shiftyjelly.pocketcasts
|
||||
bbc.mobile.news.ww
|
||||
be.mygod.vpnhotspot
|
||||
ch.protonmail.android
|
||||
cm.aptoide.pt
|
||||
co.wanqu.android
|
||||
com.alphainventor.filemanager
|
||||
com.amazon.kindle
|
||||
com.amazon.mshop.android.shopping
|
||||
com.android.chrome
|
||||
com.android.providers.downloads
|
||||
com.android.providers.downloads.ui
|
||||
com.android.providers.telephony
|
||||
com.android.settings
|
||||
com.android.vending
|
||||
com.android6park.m6park
|
||||
com.apkpure.aegon
|
||||
com.apkupdater
|
||||
com.app.pornhub
|
||||
com.arthurivanets.owly
|
||||
com.asahi.tida.tablet
|
||||
com.authy.authy
|
||||
com.avmovie
|
||||
com.ballistiq.artstation
|
||||
com.binance.dev
|
||||
com.bitly.app
|
||||
com.brave.browser
|
||||
com.brave.browser_beta
|
||||
com.breel.wallpapers18
|
||||
com.bvanced.android.youtube
|
||||
com.chrome.beta
|
||||
com.chrome.canary
|
||||
com.chrome.dev
|
||||
com.cl.newt66y
|
||||
com.cradle.iitc_mobile
|
||||
org.exarhteam.iitc_mobile
|
||||
com.cygames.shadowverse
|
||||
com.dcard.freedom
|
||||
com.devhd.feedly
|
||||
com.devolver.reigns2
|
||||
com.discord
|
||||
com.downloader.video.tumblr
|
||||
com.driverbrowser
|
||||
com.dropbox.android
|
||||
com.duolingo
|
||||
com.duckduckgo.mobile.android
|
||||
com.dv.adm
|
||||
com.estrongs.android.pop
|
||||
com.estrongs.android.pop.pro
|
||||
com.evernote
|
||||
com.facebook.katana
|
||||
com.facebook.lite
|
||||
com.facebook.mlite
|
||||
com.facebook.orca
|
||||
com.facebook.services
|
||||
com.facebook.system
|
||||
com.fastaccess.github
|
||||
com.felixfilip.scpae
|
||||
com.fireproofstudios.theroom4
|
||||
com.firstrowria.pushnotificationtester
|
||||
com.flyersoft.moonreaderp
|
||||
com.fooview.android.fooview
|
||||
com.fvd.eversync
|
||||
com.gameloft.android.anmp.glofta8hm
|
||||
com.gameloft.android.anmp.glofta9hm
|
||||
com.gianlu.aria2app
|
||||
com.github.yeriomin.yalpstore
|
||||
com.google.android.apps.adm
|
||||
com.google.android.apps.books
|
||||
com.google.android.apps.docs
|
||||
com.google.android.apps.docs.editors.sheets
|
||||
com.google.android.apps.fitness
|
||||
com.google.android.apps.googleassistant
|
||||
com.google.android.apps.googlevoice
|
||||
com.google.android.apps.hangoutsdialer
|
||||
com.google.android.apps.inbox
|
||||
com.google.android.apps.magazines
|
||||
com.google.android.apps.maps
|
||||
com.google.android.apps.nbu.files
|
||||
com.google.android.apps.paidtasks
|
||||
com.google.android.apps.pdfviewer
|
||||
com.google.android.apps.photos
|
||||
com.google.android.apps.plus
|
||||
com.google.android.apps.translate
|
||||
com.google.android.gm
|
||||
com.google.android.gms
|
||||
com.google.android.gms.setup
|
||||
com.google.android.googlequicksearchbox
|
||||
com.google.android.gsf
|
||||
com.google.android.gsf.login
|
||||
com.google.android.ims
|
||||
com.google.android.inputmethod.latin
|
||||
com.google.android.instantapps.supervisor
|
||||
com.google.android.keep
|
||||
com.google.android.music
|
||||
com.google.android.ogyoutube
|
||||
com.google.android.partnersetup
|
||||
com.google.android.play.games
|
||||
com.google.android.street
|
||||
com.google.android.syncadapters.calendar
|
||||
com.google.android.syncadapters.contacts
|
||||
com.google.android.talk
|
||||
com.google.android.tts
|
||||
com.google.android.videos
|
||||
com.google.android.youtube
|
||||
com.google.ar.lens
|
||||
com.hochan.coldsoup
|
||||
com.ifttt.ifttt
|
||||
com.imgur.mobile
|
||||
com.innologica.inoreader
|
||||
com.instagram.android
|
||||
com.instagram.lite
|
||||
com.instapaper.android
|
||||
com.jarvanh.vpntether
|
||||
com.kapp.youtube.final
|
||||
com.klinker.android.twitter_l
|
||||
com.lastpass.lpandroid
|
||||
com.linecorp.linelite
|
||||
com.lingodeer
|
||||
com.ltnnews.news
|
||||
com.mediapods.tumbpods
|
||||
com.mgoogle.android.gms
|
||||
com.microsoft.emmx
|
||||
com.microsoft.office.powerpoint
|
||||
com.microsoft.skydrive
|
||||
com.mixplorer
|
||||
com.msd.consumerchinese
|
||||
com.msd.professionalchinese
|
||||
com.mss2011c.sharehelper
|
||||
com.netflix.mediaclient
|
||||
com.newin.nplayer.pro
|
||||
com.nianticlabs.ingress.prime.qa
|
||||
com.nianticproject.ingress
|
||||
com.ninefolders.hd3
|
||||
com.ninegag.android.app
|
||||
com.nintendo.zara
|
||||
com.nytimes.cn
|
||||
com.oasisfeng.island
|
||||
com.ocnt.liveapp.hw
|
||||
com.orekie.search
|
||||
com.patreon.android
|
||||
com.paypal.android.p2pmobile
|
||||
com.perol.asdpl.pixivez
|
||||
com.pinterest
|
||||
com.popularapp.periodcalendar
|
||||
com.popularapp.videodownloaderforinstagram
|
||||
com.pushbullet.android
|
||||
com.quoord.tapatalkpro.activity
|
||||
com.quora.android
|
||||
com.rayark.cytus2
|
||||
com.rayark.implosion
|
||||
com.rayark.pluto
|
||||
com.reddit.frontpage
|
||||
com.resilio.sync
|
||||
com.rhmsoft.edit
|
||||
com.rubenmayayo.reddit
|
||||
com.sec.android.app.sbrowser
|
||||
com.sec.android.app.sbrowser.beta
|
||||
com.shanga.walli
|
||||
com.simplehabit.simplehabitapp
|
||||
com.slack
|
||||
com.snaptube.premium
|
||||
com.sololearn
|
||||
com.sonelli.juicessh
|
||||
com.sparkslab.dcardreader
|
||||
com.spotify.music
|
||||
com.tencent.huatuo
|
||||
com.termux
|
||||
com.teslacoilsw.launcher
|
||||
com.theinitium.news
|
||||
com.thomsonreuters.reuters
|
||||
com.thunkable.android.hritvik00.freenom
|
||||
com.topjohnwu.magisk
|
||||
com.tripadvisor.tripadvisor
|
||||
com.tumblr
|
||||
com.twitter.android
|
||||
com.u91porn
|
||||
com.u9porn
|
||||
com.ubisoft.dance.justdance2015companion
|
||||
com.udn.news
|
||||
com.utopia.pxview
|
||||
com.valvesoftware.android.steam.community
|
||||
com.vanced.manager
|
||||
com.vanced.android.youtube
|
||||
com.vanced.android.apps.youtube.music
|
||||
com.mgoogle.android.gms
|
||||
com.vimeo.android.videoapp
|
||||
com.vivaldi.browser
|
||||
com.vivaldi.browser.snapshot
|
||||
com.vkontakte.android
|
||||
com.whatsapp
|
||||
com.wire
|
||||
com.wuxiangai.refactor
|
||||
com.xda.labs
|
||||
com.xvideos.app
|
||||
com.yahoo.mobile.client.android.superapp
|
||||
com.yandex.browser
|
||||
com.yandex.browser.beta
|
||||
com.yandex.browser.alpha
|
||||
com.z28j.feel
|
||||
com.zhiliaoapp.musically
|
||||
con.medium.reader
|
||||
de.apkgrabber
|
||||
de.robv.android.xposed.installer
|
||||
dk.tacit.android.foldersync.full
|
||||
es.rafalense.telegram.themes
|
||||
es.rafalense.themes
|
||||
flipboard.app
|
||||
fm.moon.app
|
||||
fr.gouv.etalab.mastodon
|
||||
github.tornaco.xposedmoduletest
|
||||
idm.internet.download.manager
|
||||
idm.internet.download.manager.plus
|
||||
io.github.javiewer
|
||||
io.github.skyhacker2.magnetsearch
|
||||
io.va.exposed
|
||||
it.mvilla.android.fenix2
|
||||
jp.bokete.app.android
|
||||
jp.naver.line.android
|
||||
jp.pxv.android
|
||||
luo.speedometergpspro
|
||||
m.cna.com.tw.App
|
||||
mark.via.gp
|
||||
me.tshine.easymark
|
||||
net.teeha.android.url_shortener
|
||||
net.tsapps.appsales
|
||||
onion.fire
|
||||
org.fdroid.fdroid
|
||||
org.freedownloadmanager.fdm
|
||||
org.kustom.widget
|
||||
org.mozilla.fennec_aurora
|
||||
org.mozilla.fenix
|
||||
org.mozilla.fenix.nightly
|
||||
org.mozilla.firefox
|
||||
org.mozilla.firefox_beta
|
||||
org.mozilla.focus
|
||||
org.schabi.newpipe
|
||||
org.telegram.messenger
|
||||
org.telegram.multi
|
||||
org.telegram.plus
|
||||
org.thunderdog.challegram
|
||||
org.torproject.android
|
||||
org.torproject.torbrowser_alpha
|
||||
org.wikipedia
|
||||
org.xbmc.kodi
|
||||
pl.zdunex25.updater
|
||||
tv.twitch.android.app
|
||||
tw.com.gamer.android.activecenter
|
||||
videodownloader.downloadvideo.downloader
|
||||
uk.co.bbc.learningenglish
|
||||
com.ted.android
|
||||
de.danoeh.antennapod
|
||||
com.kiwibrowser.browser
|
||||
nekox.messenger
|
||||
com.nextcloud.client
|
||||
com.aurora.store
|
||||
com.aurora.adroid
|
||||
chat.simplex.app
|
||||
im.vector.app
|
||||
network.loki.messenger
|
||||
eu.siacs.conversations
|
||||
xyz.nextalone.nagram
|
||||
de.danoeh.antennapod
|
||||
net.programmierecke.radiodroid2
|
||||
im.fdx.v2ex
|
||||
ml.docilealligator.infinityforreddit
|
||||
com.bytemyth.ama
|
||||
app.vanadium.browser
|
||||
com.cakewallet.cake_wallet
|
||||
org.purplei2p.i2pd
|
||||
dk.tacit.android.foldersync.lite
|
||||
com.nononsenseapps.feeder
|
||||
com.m2049r.xmrwallet
|
||||
com.paypal.android.p2pmobile
|
||||
com.google.android.apps.googlevoice
|
||||
com.readdle.spark
|
||||
org.torproject.torbrowser
|
||||
com.deepl.mobiletranslator
|
||||
com.microsoft.bing
|
||||
com.keylesspalace.tusky
|
||||
com.ottplay.ottplay
|
||||
ru.iptvremote.android.iptv.pro
|
||||
jp.naver.line.android
|
||||
com.xmflsct.app.tooot
|
||||
com.forem.android
|
||||
app.revanced.android.youtube
|
||||
com.mgoogle.android.gms
|
||||
com.pionex.client
|
||||
vip.mytokenpocket
|
||||
im.token.app
|
||||
com.linekong.mars24
|
||||
com.feixiaohao
|
||||
com.aicoin.appandroid
|
||||
com.binance.dev
|
||||
com.kraken.trade
|
||||
com.okinc.okex.gp
|
||||
com.authy.authy
|
||||
air.com.rosettastone.mobile.CoursePlayer
|
||||
com.blizzard.bma
|
||||
com.amazon.kindle
|
||||
com.google.android.apps.fitness
|
||||
net.tsapps.appsales
|
||||
com.wemesh.android
|
||||
com.google.android.apps.googleassistant
|
||||
allen.town.focus.reader
|
||||
me.hyliu.fluent_reader_lite
|
||||
com.aljazeera.mobile
|
||||
com.ft.news
|
||||
de.marmaro.krt.ffupdater
|
||||
myradio.radio.fmradio.liveradio.radiostation
|
||||
com.google.earth
|
||||
eu.kanade.tachiyomi.j2k
|
||||
com.audials
|
||||
com.microsoft.skydrive
|
||||
com.mb.android.tg
|
||||
com.melodis.midomiMusicIdentifier.freemium
|
||||
com.foxnews.android
|
||||
ch.threema.app
|
||||
com.briarproject.briar.android
|
||||
foundation.e.apps
|
||||
com.valvesoftware.android.steam.friendsui
|
||||
com.imback.yeetalk
|
||||
so.onekey.app.wallet
|
||||
com.xc3fff0e.xmanager
|
||||
meditofoundation.medito
|
||||
com.picol.client
|
||||
com.streetwriters.notesnook
|
||||
shanghai.panewsApp.com
|
||||
org.coursera.android
|
||||
com.positron_it.zlib
|
||||
com.blizzard.messenger
|
||||
com.javdb.javrocket
|
||||
com.picacomic.fregata
|
||||
com.fxl.chacha
|
||||
me.proton.android.drive
|
||||
com.lastpass.lpandroid
|
||||
com.tradingview.tradingviewapp
|
||||
com.deviantart.android.damobile
|
||||
com.fusionmedia.investing
|
||||
com.ewa.ewaapp
|
||||
com.duolingo
|
||||
com.hellotalk
|
||||
io.github.huskydg.magisk
|
||||
com.jsy.xpgbox
|
||||
com.hostloc.app.hostloc
|
||||
com.dena.pokota
|
||||
com.vitorpamplona.amethyst
|
||||
com.zhiliaoapp.musically
|
||||
us.spotco.fennec_dos
|
||||
com.fongmi.android.tv
|
||||
com.pocketprep.android.itcybersecurity
|
||||
com.cloudtv
|
||||
com.glassdoor.app
|
||||
com.indeed.android.jobsearch
|
||||
com.linkedin.android
|
||||
com.github.tvbox.osc.bh
|
||||
com.example.douban
|
||||
com.sipnetic.app
|
||||
com.microsoft.rdc.androidx
|
||||
org.zwanoo.android.speedtest
|
||||
com.sonelli.juicessh
|
||||
com.scmp.newspulse
|
||||
org.lsposed.manager
|
||||
mnn.Android
|
||||
com.thomsonretuers.reuters
|
||||
com.guardian
|
||||
com.ttxapps.onesyncv2
|
||||
org.fcitx.fcitx5.android.updater
|
||||
@ -99,7 +99,7 @@ class AboutFragment : ToolbarFragment(R.layout.layout_about) {
|
||||
.subText(R.string.donate_info)
|
||||
.setOnClickAction {
|
||||
requireContext().launchCustomTab(
|
||||
"https://matsuridayo.github.io/#donate"
|
||||
"https://matsuridayo.github.io/index_docs/#donate"
|
||||
)
|
||||
}
|
||||
.build())
|
||||
|
||||
@ -3,15 +3,14 @@ package io.nekohasekai.sagernet.ui
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.util.SparseBooleanArray
|
||||
import android.view.*
|
||||
import android.widget.Filter
|
||||
import android.widget.Filterable
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.core.util.contains
|
||||
import androidx.core.util.set
|
||||
@ -30,8 +29,8 @@ import io.nekohasekai.sagernet.SagerNet
|
||||
import io.nekohasekai.sagernet.database.DataStore
|
||||
import io.nekohasekai.sagernet.databinding.LayoutAppsBinding
|
||||
import io.nekohasekai.sagernet.databinding.LayoutAppsItemBinding
|
||||
import io.nekohasekai.sagernet.databinding.LayoutLoadingBinding
|
||||
import io.nekohasekai.sagernet.ktx.Logs
|
||||
import io.nekohasekai.sagernet.ktx.app
|
||||
import io.nekohasekai.sagernet.ktx.crossFadeFrom
|
||||
import io.nekohasekai.sagernet.ktx.onMainDispatcher
|
||||
import io.nekohasekai.sagernet.ktx.runOnDefaultDispatcher
|
||||
@ -42,12 +41,7 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.ensureActive
|
||||
import kotlinx.coroutines.withContext
|
||||
import okhttp3.internal.closeQuietly
|
||||
import org.jf.dexlib2.dexbacked.DexBackedDexFile
|
||||
import org.jf.dexlib2.iface.DexFile
|
||||
import java.io.File
|
||||
import java.util.zip.ZipException
|
||||
import java.util.zip.ZipFile
|
||||
import moe.matsuri.nb4a.utils.NGUtil
|
||||
import kotlin.coroutines.coroutineContext
|
||||
|
||||
class AppManagerActivity : ThemedActivity() {
|
||||
@ -145,7 +139,8 @@ class AppManagerActivity : ThemedActivity() {
|
||||
}
|
||||
|
||||
override fun publishResults(constraint: CharSequence, results: FilterResults) {
|
||||
@Suppress("UNCHECKED_CAST") filteredApps = results.values as List<ProxiedApp>
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
filteredApps = results.values as List<ProxiedApp>
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
@ -212,10 +207,12 @@ class AppManagerActivity : ThemedActivity() {
|
||||
DataStore.proxyApps = false
|
||||
finish()
|
||||
}
|
||||
|
||||
R.id.appProxyModeOn -> DataStore.bypass = false
|
||||
R.id.appProxyModeBypass -> DataStore.bypass = true
|
||||
}
|
||||
}
|
||||
binding.autoSelectProxyApps.setOnClickListener { selectProxyApp() }
|
||||
|
||||
initProxiedUids()
|
||||
binding.list.layoutManager = LinearLayoutManager(this, RecyclerView.VERTICAL, false)
|
||||
@ -247,10 +244,6 @@ class AppManagerActivity : ThemedActivity() {
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_scan_china_apps -> {
|
||||
scanChinaApps()
|
||||
return true
|
||||
}
|
||||
R.id.action_invert_selections -> {
|
||||
runOnDefaultDispatcher {
|
||||
for (app in apps) {
|
||||
@ -270,6 +263,7 @@ class AppManagerActivity : ThemedActivity() {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
R.id.action_clear_selections -> {
|
||||
runOnDefaultDispatcher {
|
||||
proxiedUids.clear()
|
||||
@ -280,8 +274,10 @@ class AppManagerActivity : ThemedActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
R.id.action_export_clipboard -> {
|
||||
val success = SagerNet.trySetPrimaryClip("${DataStore.bypass}\n${DataStore.individual}")
|
||||
val success =
|
||||
SagerNet.trySetPrimaryClip("${DataStore.bypass}\n${DataStore.individual}")
|
||||
Snackbar.make(
|
||||
binding.list,
|
||||
if (success) R.string.action_export_msg else R.string.action_export_err,
|
||||
@ -289,8 +285,10 @@ class AppManagerActivity : ThemedActivity() {
|
||||
).show()
|
||||
return true
|
||||
}
|
||||
|
||||
R.id.action_import_clipboard -> {
|
||||
val proxiedAppString = SagerNet.clipboard.primaryClip?.getItemAt(0)?.text?.toString()
|
||||
val proxiedAppString =
|
||||
SagerNet.clipboard.primaryClip?.getItemAt(0)?.text?.toString()
|
||||
if (!proxiedAppString.isNullOrEmpty()) {
|
||||
val i = proxiedAppString.indexOf('\n')
|
||||
try {
|
||||
@ -316,150 +314,53 @@ class AppManagerActivity : ThemedActivity() {
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun scanChinaApps() {
|
||||
|
||||
val text: TextView
|
||||
|
||||
val dialog = MaterialAlertDialogBuilder(this).setView(
|
||||
LayoutLoadingBinding.inflate(layoutInflater).apply {
|
||||
text = loadingText
|
||||
}.root
|
||||
).setCancelable(false).show()
|
||||
|
||||
val txt = text.text.toString()
|
||||
|
||||
runOnDefaultDispatcher {
|
||||
val chinaApps = ArrayList<Pair<PackageInfo, String>>()
|
||||
val chinaRegex = ("(" + arrayOf(
|
||||
"com.tencent",
|
||||
"com.alibaba",
|
||||
"com.umeng",
|
||||
"com.qihoo",
|
||||
"com.ali",
|
||||
"com.alipay",
|
||||
"com.amap",
|
||||
"com.sina",
|
||||
"com.weibo",
|
||||
"com.vivo",
|
||||
"com.xiaomi",
|
||||
"com.huawei",
|
||||
"com.taobao",
|
||||
"com.secneo",
|
||||
"s.h.e.l.l",
|
||||
"com.stub",
|
||||
"com.kiwisec",
|
||||
"com.secshell",
|
||||
"com.wrapper",
|
||||
"cn.securitystack",
|
||||
"com.mogosec",
|
||||
"com.secoen",
|
||||
"com.netease",
|
||||
"com.mx",
|
||||
"com.qq.e",
|
||||
"com.baidu",
|
||||
"com.bytedance",
|
||||
"com.bugly",
|
||||
"com.miui",
|
||||
"com.oppo",
|
||||
"com.coloros",
|
||||
"com.iqoo",
|
||||
"com.meizu",
|
||||
"com.gionee",
|
||||
"cn.nubia"
|
||||
).joinToString("|") { "${it.replace(".", "\\.")}\\." } + ").*").toRegex()
|
||||
|
||||
val bypass = DataStore.bypass
|
||||
val cachedApps = cachedApps
|
||||
|
||||
apps = cachedApps.map { (packageName, packageInfo) ->
|
||||
kotlin.coroutines.coroutineContext[Job]!!.ensureActive()
|
||||
ProxiedApp(packageManager, packageInfo.applicationInfo, packageName)
|
||||
}.sortedWith(compareBy({ !isProxiedApp(it) }, { it.name.toString() }))
|
||||
|
||||
scan@ for ((pkg, app) in cachedApps.entries) {
|
||||
/*if (!sysApps && app.applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM != 0) {
|
||||
continue
|
||||
}*/
|
||||
|
||||
val index = appsAdapter.filteredApps.indexOfFirst { it.uid == app.applicationInfo.uid }
|
||||
var changed = false
|
||||
|
||||
onMainDispatcher {
|
||||
text.text = (txt + " " + app.packageName + "\n\n" + chinaApps.map { it.second }
|
||||
.reversed()
|
||||
.joinToString("\n", postfix = "\n")).trim()
|
||||
}
|
||||
|
||||
private fun selectProxyApp() {
|
||||
MaterialAlertDialogBuilder(this).setTitle(R.string.confirm)
|
||||
.setMessage(R.string.auto_select_proxy_apps_message)
|
||||
.setPositiveButton(R.string.yes) { _, _ ->
|
||||
try {
|
||||
|
||||
val dex = File(app.applicationInfo.publicSourceDir)
|
||||
val zipFile = ZipFile(dex)
|
||||
var dexFile: DexFile
|
||||
|
||||
for (entry in zipFile.entries()) {
|
||||
if (entry.name.startsWith("classes") && entry.name.endsWith(".dex")) {
|
||||
val input = zipFile.getInputStream(entry).readBytes()
|
||||
dexFile = try {
|
||||
DexBackedDexFile.fromInputStream(null, input.inputStream())
|
||||
} catch (e: Exception) {
|
||||
Logs.w(e)
|
||||
break
|
||||
val needProxyAppsList = getAutoProxyApps("")
|
||||
val bypass = DataStore.bypass
|
||||
proxiedUids.clear()
|
||||
for (app in cachedApps) {
|
||||
val needProxy =
|
||||
needProxyAppsList.contains(app.key) || app.value.applicationInfo.uid == 1000
|
||||
if (needProxy) {
|
||||
if (!bypass) {
|
||||
proxiedUids[app.value.applicationInfo.uid] = true
|
||||
}
|
||||
for (clazz in dexFile.classes) {
|
||||
val clazzName = clazz.type.substring(1, clazz.type.length - 1)
|
||||
.replace("/", ".")
|
||||
.replace("$", ".")
|
||||
|
||||
if (clazzName.matches(chinaRegex)) {
|
||||
chinaApps.add(
|
||||
app to app.applicationInfo.loadLabel(packageManager)
|
||||
.toString()
|
||||
)
|
||||
zipFile.closeQuietly()
|
||||
|
||||
if (bypass) {
|
||||
changed = !proxiedUids[app.applicationInfo.uid]
|
||||
proxiedUids[app.applicationInfo.uid] = true
|
||||
} else {
|
||||
proxiedUids.delete(app.applicationInfo.uid)
|
||||
}
|
||||
|
||||
continue@scan
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
zipFile.closeQuietly()
|
||||
|
||||
if (bypass) {
|
||||
proxiedUids.delete(app.applicationInfo.uid)
|
||||
} else {
|
||||
changed = !proxiedUids[index]
|
||||
proxiedUids[app.applicationInfo.uid] = true
|
||||
proxiedUids[app.value.applicationInfo.uid] = true
|
||||
}
|
||||
|
||||
} catch (e: ZipException) {
|
||||
Logs.w("Error in pkg ${app.packageName}:${app.versionName}", e)
|
||||
continue
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DataStore.individual = apps.filter { isProxiedApp(it) }
|
||||
.joinToString("\n") { it.packageName }
|
||||
|
||||
DataStore.individual =
|
||||
apps.filter { isProxiedApp(it) }.joinToString("\n") { it.packageName }
|
||||
apps = apps.sortedWith(compareBy({ !isProxiedApp(it) }, { it.name.toString() }))
|
||||
|
||||
onMainDispatcher {
|
||||
appsAdapter.filter.filter(binding.search.text?.toString() ?: "")
|
||||
|
||||
dialog.dismiss()
|
||||
} catch (e: Exception) {
|
||||
Logs.e(e)
|
||||
}
|
||||
}
|
||||
.setNegativeButton(R.string.no, null)
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun getAutoProxyApps(content: String): List<String> {
|
||||
var list = listOf<String>()
|
||||
try {
|
||||
val proxyApps = if (TextUtils.isEmpty(content)) {
|
||||
NGUtil.readTextFromAssets(app, "proxy_packagename.txt")
|
||||
} else {
|
||||
content
|
||||
}
|
||||
|
||||
|
||||
if (!TextUtils.isEmpty(proxyApps)) {
|
||||
list = proxyApps.split("\n")
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
override fun supportNavigateUpTo(upIntent: Intent) =
|
||||
|
||||
@ -77,14 +77,29 @@
|
||||
|
||||
</com.google.android.material.chip.ChipGroup>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/show_system_apps"
|
||||
style="@style/Widget.MaterialComponents.Chip.Filter"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:text="@string/show_system_apps" />
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/autoSelectProxyApps"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checkable="false"
|
||||
android:text="@string/auto_select_proxy_apps" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_scan_china_apps"
|
||||
android:title="@string/action_scan_china_apps"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_invert_selections"
|
||||
android:title="@string/invert_selections"
|
||||
|
||||
@ -478,4 +478,6 @@
|
||||
<string name="sniff_routing">探测结果用于路由判断</string>
|
||||
<string name="sniff_override">探测结果用于目标地址</string>
|
||||
<string name="resolve_server">根据 IPv6 策略解析服务器地址</string>
|
||||
<string name="auto_select_proxy_apps">自动选择需要代理的应用</string>
|
||||
<string name="auto_select_proxy_apps_message">自动选择需要代理的应用,这将清除您当前的选择。</string>
|
||||
</resources>
|
||||
@ -519,5 +519,7 @@ Anyone can write advanced plugins, which can control NekoBox. please download an
|
||||
<string name="sniff_routing">Sniff result for routing</string>
|
||||
<string name="sniff_override">Sniff result for destination</string>
|
||||
<string name="resolve_server">Resolve the server address according to the IPv6 policy</string>
|
||||
<string name="auto_select_proxy_apps">Auto select proxy apps</string>
|
||||
<string name="auto_select_proxy_apps_message">Auto select proxy apps, this will clear your current selection.</string>
|
||||
|
||||
</resources>
|
||||
Loading…
Reference in New Issue
Block a user