mirror of
https://git.sr.ht/~eliasnaur/gio-cmd
synced 2026-07-01 07:35:37 +00:00
gogio: [Android] add support for querying apps
Previously, it was impossible to identify if a specific app was installed on the user device. It was also impossible to launch a external app from Gio using Intent. Now, you can use `-queries` with a comma separed package names, like `com.another.app`. That allows you to launch Intent to `com.another.app`. Signed-off-by: inkeliz <inkeliz@inkeliz.com>
This commit is contained in:
+27
-18
@@ -40,15 +40,16 @@ type errWriter struct {
|
|||||||
var exeSuffix string
|
var exeSuffix string
|
||||||
|
|
||||||
type manifestData struct {
|
type manifestData struct {
|
||||||
AppID string
|
AppID string
|
||||||
Version Semver
|
Version Semver
|
||||||
MinSDK int
|
MinSDK int
|
||||||
TargetSDK int
|
TargetSDK int
|
||||||
Permissions []string
|
Permissions []string
|
||||||
Features []string
|
Features []string
|
||||||
IconSnip string
|
IconSnip string
|
||||||
AppName string
|
AppName string
|
||||||
Schemes []string
|
Schemes []string
|
||||||
|
PackageQueries []string
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -435,15 +436,16 @@ func exeAndroid(tmpDir string, tools *androidTools, bi *buildInfo, extraJars, pe
|
|||||||
permissions, features := getPermissions(perms)
|
permissions, features := getPermissions(perms)
|
||||||
appName := UppercaseName(bi.name)
|
appName := UppercaseName(bi.name)
|
||||||
manifestSrc := manifestData{
|
manifestSrc := manifestData{
|
||||||
AppID: bi.appID,
|
AppID: bi.appID,
|
||||||
Version: bi.version,
|
Version: bi.version,
|
||||||
MinSDK: minSDK,
|
MinSDK: minSDK,
|
||||||
TargetSDK: targetSDK,
|
TargetSDK: targetSDK,
|
||||||
Permissions: permissions,
|
Permissions: permissions,
|
||||||
Features: features,
|
Features: features,
|
||||||
IconSnip: iconSnip,
|
IconSnip: iconSnip,
|
||||||
AppName: appName,
|
AppName: appName,
|
||||||
Schemes: bi.schemes,
|
Schemes: bi.schemes,
|
||||||
|
PackageQueries: bi.packageQueries,
|
||||||
}
|
}
|
||||||
tmpl, err := template.New("test").Parse(
|
tmpl, err := template.New("test").Parse(
|
||||||
`<?xml version="1.0" encoding="utf-8"?>
|
`<?xml version="1.0" encoding="utf-8"?>
|
||||||
@@ -451,6 +453,13 @@ func exeAndroid(tmpDir string, tools *androidTools, bi *buildInfo, extraJars, pe
|
|||||||
package="{{.AppID}}"
|
package="{{.AppID}}"
|
||||||
android:versionCode="{{.Version.VersionCode}}"
|
android:versionCode="{{.Version.VersionCode}}"
|
||||||
android:versionName="{{.Version}}">
|
android:versionName="{{.Version}}">
|
||||||
|
{{if .PackageQueries}}
|
||||||
|
<queries>
|
||||||
|
{{range .PackageQueries}}
|
||||||
|
<package android:name="{{.}}" />
|
||||||
|
{{end}}
|
||||||
|
</queries>
|
||||||
|
{{end}}
|
||||||
<uses-sdk android:minSdkVersion="{{.MinSDK}}" android:targetSdkVersion="{{.TargetSDK}}" />
|
<uses-sdk android:minSdkVersion="{{.MinSDK}}" android:targetSdkVersion="{{.TargetSDK}}" />
|
||||||
{{range .Permissions}} <uses-permission android:name="{{.}}"/>
|
{{range .Permissions}} <uses-permission android:name="{{.}}"/>
|
||||||
{{end}}{{range .Features}} <uses-feature android:{{.}} android:required="false"/>
|
{{end}}{{range .Features}} <uses-feature android:{{.}} android:required="false"/>
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ type buildInfo struct {
|
|||||||
notaryPassword string
|
notaryPassword string
|
||||||
notaryTeamID string
|
notaryTeamID string
|
||||||
schemes []string
|
schemes []string
|
||||||
|
packageQueries []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Semver struct {
|
type Semver struct {
|
||||||
@@ -80,6 +81,7 @@ func newBuildInfo(pkgPath string) (*buildInfo, error) {
|
|||||||
notaryPassword: *notaryPass,
|
notaryPassword: *notaryPass,
|
||||||
notaryTeamID: *notaryTeamID,
|
notaryTeamID: *notaryTeamID,
|
||||||
schemes: getCommaList(*schemes),
|
schemes: getCommaList(*schemes),
|
||||||
|
packageQueries: getCommaList(*pkgQueries),
|
||||||
}
|
}
|
||||||
return bi, nil
|
return bi, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,4 +88,8 @@ The -schemes flag specifies a list of comma separated URI schemes that the progr
|
|||||||
handle. For example, use -schemes yourAppName to receive a app.URLEvent for URIs
|
handle. For example, use -schemes yourAppName to receive a app.URLEvent for URIs
|
||||||
starting with yourAppName://. It is only supported on Android, iOS, macOS and Windows.
|
starting with yourAppName://. It is only supported on Android, iOS, macOS and Windows.
|
||||||
On Windows, it will restrict the program to a single instance.
|
On Windows, it will restrict the program to a single instance.
|
||||||
|
|
||||||
|
The -queries flag specifies a list of comma separated package names used to query other apps,
|
||||||
|
that is useful to launch other apps and verify their presence. For example, use -queries
|
||||||
|
com.example.otherapp to query the app with that package name. It is only necessary on Android.
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ var (
|
|||||||
notaryPass = flag.String("notarypass", "", "specify app-specific password of the Apple ID to be used for notarization.")
|
notaryPass = flag.String("notarypass", "", "specify app-specific password of the Apple ID to be used for notarization.")
|
||||||
notaryTeamID = flag.String("notaryteamid", "", "specify the team id to use for notarization.")
|
notaryTeamID = flag.String("notaryteamid", "", "specify the team id to use for notarization.")
|
||||||
schemes = flag.String("schemes", "", "specify a list of comma separated URL schemes that the program accepts")
|
schemes = flag.String("schemes", "", "specify a list of comma separated URL schemes that the program accepts")
|
||||||
|
pkgQueries = flag.String("queries", "", "specify a list of comma separated package names used to query other apps on Android.")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
Reference in New Issue
Block a user