forked from joejulian/gio-cmd
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:
@@ -49,6 +49,7 @@ type manifestData struct {
|
||||
IconSnip string
|
||||
AppName string
|
||||
Schemes []string
|
||||
PackageQueries []string
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -444,6 +445,7 @@ func exeAndroid(tmpDir string, tools *androidTools, bi *buildInfo, extraJars, pe
|
||||
IconSnip: iconSnip,
|
||||
AppName: appName,
|
||||
Schemes: bi.schemes,
|
||||
PackageQueries: bi.packageQueries,
|
||||
}
|
||||
tmpl, err := template.New("test").Parse(
|
||||
`<?xml version="1.0" encoding="utf-8"?>
|
||||
@@ -451,6 +453,13 @@ func exeAndroid(tmpDir string, tools *androidTools, bi *buildInfo, extraJars, pe
|
||||
package="{{.AppID}}"
|
||||
android:versionCode="{{.Version.VersionCode}}"
|
||||
android:versionName="{{.Version}}">
|
||||
{{if .PackageQueries}}
|
||||
<queries>
|
||||
{{range .PackageQueries}}
|
||||
<package android:name="{{.}}" />
|
||||
{{end}}
|
||||
</queries>
|
||||
{{end}}
|
||||
<uses-sdk android:minSdkVersion="{{.MinSDK}}" android:targetSdkVersion="{{.TargetSDK}}" />
|
||||
{{range .Permissions}} <uses-permission android:name="{{.}}"/>
|
||||
{{end}}{{range .Features}} <uses-feature android:{{.}} android:required="false"/>
|
||||
|
||||
@@ -32,6 +32,7 @@ type buildInfo struct {
|
||||
notaryPassword string
|
||||
notaryTeamID string
|
||||
schemes []string
|
||||
packageQueries []string
|
||||
}
|
||||
|
||||
type Semver struct {
|
||||
@@ -80,6 +81,7 @@ func newBuildInfo(pkgPath string) (*buildInfo, error) {
|
||||
notaryPassword: *notaryPass,
|
||||
notaryTeamID: *notaryTeamID,
|
||||
schemes: getCommaList(*schemes),
|
||||
packageQueries: getCommaList(*pkgQueries),
|
||||
}
|
||||
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
|
||||
starting with yourAppName://. It is only supported on Android, iOS, macOS and Windows.
|
||||
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.")
|
||||
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")
|
||||
pkgQueries = flag.String("queries", "", "specify a list of comma separated package names used to query other apps on Android.")
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
Reference in New Issue
Block a user