blob: 1a5eab4ec87eed459e78a01c85a394f4726538fb [file] [log] [blame]
// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package android
import (
"fmt"
"strings"
)
// Action represents an Android action that can be sent as an intent.
type Action struct {
Name string // Example: android.intent.action.MAIN
Package *InstalledPackage
Activity string // Example: FooBarActivity
}
// Component returns the component name with package name prefix. For example:
// "com.example.app/.ExampleActivity" or "com.example.app/com.foo.ExampleActivity"
func (a *Action) Component() string {
if strings.ContainsRune(a.Activity, '.') {
return fmt.Sprintf("%s/%s", a.Package.Name, a.Activity)
}
return fmt.Sprintf("%s/.%s", a.Package.Name, a.Activity)
}
func (a *Action) String() string {
return a.Name + ":" + a.Component()
}