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
VersCode int
VersName string
IsSystem bool
}
var (
packageRegex = regexp.MustCompile(`^ Package \[([^\s]+)\]`)
verCodeRegex = regexp.MustCompile(`^ versionCode=([0-9]+)`)
verNameRegex = regexp.MustCompile(`^ versionName=(.+)`)
systemRegex = regexp.MustCompile(`^ pkgFlags=\[.*\bSYSTEM\b.*\]`)
)
func (d *Device) Installed() (map[string]Package, error) {
@ -253,6 +255,7 @@ func (d *Device) Installed() (map[string]Package, error) {
} else {
packages[cur.ID] = cur
cur = Package{}
cur.IsSystem = false
}
cur.ID = m[1]
} else if m := verCodeRegex.FindStringSubmatch(l); m != nil {
@ -263,6 +266,8 @@ func (d *Device) Installed() (map[string]Package, error) {
cur.VersCode = n
} else if m := verNameRegex.FindStringSubmatch(l); m != nil {
cur.VersName = m[1]
} else if systemRegex.MatchString(l) {
cur.IsSystem = true
}
}
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 {
var result []fdroid.App
for _, app := range apps {
if _, e := inst[app.PackageName]; !e {
if p, e := inst[app.PackageName]; !e || p.IsSystem {
continue
}
result = append(result, app)
@ -170,7 +170,7 @@ func filterAppsUpdates(apps []fdroid.App, inst map[string]adb.Package, device *a
var result []fdroid.App
for _, app := range apps {
p, e := inst[app.PackageName]
if !e {
if !e || p.IsSystem {
continue
}
suggested := app.SuggestedApk(device)

Loading…
Cancel
Save