Browse Source

do not show system apps

related issue: #62
pull/70/head
Linus789 3 years ago
parent
commit
ea74ed88a8
  1. 5
      adb/device.go
  2. 4
      search.go

5
adb/device.go

@ -224,12 +224,14 @@ type Package struct {
ID string ID string
VersCode int VersCode int
VersName string VersName string
IsSystem bool
} }
var ( var (
packageRegex = regexp.MustCompile(`^ Package \[([^\s]+)\]`) packageRegex = regexp.MustCompile(`^ Package \[([^\s]+)\]`)
verCodeRegex = regexp.MustCompile(`^ versionCode=([0-9]+)`) verCodeRegex = regexp.MustCompile(`^ versionCode=([0-9]+)`)
verNameRegex = regexp.MustCompile(`^ versionName=(.+)`) verNameRegex = regexp.MustCompile(`^ versionName=(.+)`)
systemRegex = regexp.MustCompile(`^ pkgFlags=\[.*\bSYSTEM\b.*\]`)
) )
func (d *Device) Installed() (map[string]Package, error) { func (d *Device) Installed() (map[string]Package, error) {
@ -253,6 +255,7 @@ func (d *Device) Installed() (map[string]Package, error) {
} else { } else {
packages[cur.ID] = cur packages[cur.ID] = cur
cur = Package{} cur = Package{}
cur.IsSystem = false
} }
cur.ID = m[1] cur.ID = m[1]
} else if m := verCodeRegex.FindStringSubmatch(l); m != nil { } else if m := verCodeRegex.FindStringSubmatch(l); m != nil {
@ -263,6 +266,8 @@ func (d *Device) Installed() (map[string]Package, error) {
cur.VersCode = n cur.VersCode = n
} else if m := verNameRegex.FindStringSubmatch(l); m != nil { } else if m := verNameRegex.FindStringSubmatch(l); m != nil {
cur.VersName = m[1] cur.VersName = m[1]
} else if systemRegex.MatchString(l) {
cur.IsSystem = true
} }
} }
if !first { if !first {

4
search.go

@ -158,7 +158,7 @@ func printApp(app fdroid.App, IDLen int, inst *adb.Package, device *adb.Device)
func filterAppsInstalled(apps []fdroid.App, inst map[string]adb.Package) []fdroid.App { func filterAppsInstalled(apps []fdroid.App, inst map[string]adb.Package) []fdroid.App {
var result []fdroid.App var result []fdroid.App
for _, app := range apps { for _, app := range apps {
if _, e := inst[app.PackageName]; !e { if p, e := inst[app.PackageName]; !e || p.IsSystem {
continue continue
} }
result = append(result, app) result = append(result, app)
@ -170,7 +170,7 @@ func filterAppsUpdates(apps []fdroid.App, inst map[string]adb.Package, device *a
var result []fdroid.App var result []fdroid.App
for _, app := range apps { for _, app := range apps {
p, e := inst[app.PackageName] p, e := inst[app.PackageName]
if !e { if !e || p.IsSystem {
continue continue
} }
suggested := app.SuggestedApk(device) suggested := app.SuggestedApk(device)

Loading…
Cancel
Save