Documentation
¶
Overview ¶
Package apk writes Android packages: the ZIP archive, the binary manifest and the v2 signature. Every NSGo build needs only Go, so the Android SDK's aapt2, d8 and apksigner stay out of it; the Java runtime comes prebuilt from platform/android/runtime.
Index ¶
- Constants
- func EncodeManifest(template []byte, m Manifest) ([]byte, error)
- func VersionCode(version string) int
- func Write(w io.Writer, template []byte, m Manifest, files []File, key *Key) error
- func WriteBundle(w io.Writer, template []byte, m Manifest, files []File, key *Key) error
- type File
- type Key
- type Manifest
Constants ¶
const ( RecordingService = "dev.oneo.nsgo.RecordingService" OverlayService = "dev.oneo.nsgo.OverlayService" OverlaySubtype = "Keeps a window the user opened over other apps showing" )
The runtime's foreground services: RecordingService is the one microphone.RecordWAV records in (Manifest.Recording), of the microphone type, OverlayService the one overlays over other apps take (Manifest.Overlay), of the specialUse type, and OverlaySubtype the subtype of its specialUse type, which stores read.
const BundletoolVersion = "1.18.3"
BundletoolVersion is the bundletool the bundle says it is made for.
const IconSize = 192
IconSize is the launcher icon's size in pixels: 48dp at xxxhdpi, the density the table declares it for. The system scales it for others.
Variables ¶
This section is empty.
Functions ¶
func EncodeManifest ¶
EncodeManifest turns the runtime's readable manifest into the binary XML an APK carries, with the app's package, version and label set.
func VersionCode ¶
VersionCode turns a version like 1.2.3 into Android's integer code. A version that is not dotted numbers codes as 1.
func Write ¶
Write writes a signed APK to w: template's manifest with m filled in, then files, and the resource table the system expects, which holds the launcher icon and the app's names when m has them.
func WriteBundle ¶
WriteBundle writes a signed Android App Bundle to w: template's manifest with m filled in, files as the base module's, by their paths in an APK, and the resource table, which holds the launcher icon and the app's names when m has them.
Types ¶
type File ¶
type File struct {
Name string
Data []byte
// Stored keeps Data uncompressed, for files the system maps instead
// of reading whole.
Stored bool
}
File is one entry of an APK.
type Key ¶
type Key struct {
Private *rsa.PrivateKey
Cert *x509.Certificate
}
Key is the identity an APK is signed with.
func ReadKeystore ¶
ReadKeystore reads the signing key alias from a keystore as keytool and Android Studio write them: PKCS#12 (keytool's default since JDK 9) or the older JKS. keyPassword, when empty, is storePassword; alias, when empty, picks the only private key.
type Manifest ¶
type Manifest struct {
Package string
Label string
// Names are the app's name in its languages, by BCP 47 tag, "" for
// the default, which the launcher lists it under in place of Label.
Names map[string]string
VersionName string
VersionCode int
// Icon is the launcher icon, an IconSize PNG; nil keeps the system's.
Icon []byte
// Theme replaces the application's theme, a framework style; empty
// keeps the runtime's.
Theme string
// Debuggable marks a test build, whose launch intent may name the test
// the runtime runs.
Debuggable bool
// Permissions are the permissions the app asks for beyond the
// runtime's, by their full names.
Permissions []string
// TargetSDK replaces the runtime's targetSdkVersion when it is set.
TargetSDK int
// Overlay declares the runtime's OverlayService, the specialUse foreground service an overlay over other apps takes, for an app that asks for SYSTEM_ALERT_WINDOW; Permissions name its FOREGROUND_SERVICE permissions.
Overlay bool
// Recording declares the runtime's RecordingService, the microphone foreground service microphone.RecordWAV records in, with the permissions it needs. An app without it declares no such service, as Google Play asks an app to justify each foreground-service type its manifest has.
Recording bool
// Libraries are the shared libraries of the device the app uses where it has them, by name, as uses-library elements that do not require them.
Libraries []string
}
Manifest is what packaging fills into the runtime's manifest template.