diff options
author | Dianne Hackborn <hackbod@google.com> | 2014-11-04 10:31:54 -0800 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2014-11-11 00:42:18 +0000 |
commit | 85d558cd486d195aabfc4b43cff8f338126f60a5 (patch) | |
tree | 0a228ca6ffb9079635434a740abeeece370f055d /cmds | |
parent | 993e3d2d40cbd95d78cd3d2a76c77af2f4ab0e88 (diff) | |
download | frameworks_base-85d558cd486d195aabfc4b43cff8f338126f60a5.zip frameworks_base-85d558cd486d195aabfc4b43cff8f338126f60a5.tar.gz frameworks_base-85d558cd486d195aabfc4b43cff8f338126f60a5.tar.bz2 |
Add Activity API to get referrer information.
This expands the use of EXTRA_REFERRER to be relevant anywhere,
allowing apps to supply referrer information if they want. However,
if they don't explicitly supply it, then the platform now keeps
track of package names that go with Intents when delivering them
to apps, which it can be returned as the default value.
The new method Activity.getReferrer() is used to retrieve this
referrer information. It knows about EXTRA_REFERRER, it can return
the default package name tracked internally, and it also can return
a new EXTRA_REFERRER_NAME if that exists. The latter is needed
because we can't use EXTRA_REFERRER in some cases since it is a Uri,
and things like #Intent; URI extras can only generate primitive type
extras. We really need to support this syntax for referrers, so we
need to have this additional extra field as an option.
When a referrer is to a native app, we are adopting the android-app
scheme. Since we are doing this, Intent's URI creation and parsing
now supports this scheme, and we improve its syntax to be able to build
intents with custom actions and stuff, instead of being all hung up
on custom schemes.
While doing this, fixed a problem when parsing both intent: and new
android-app: schemes with a selector portion, where we were not
respecting any scheme that was specified.
Change-Id: I06e55221e21a8156c1d6ac755a254fea386917a2
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/am/src/com/android/commands/am/Am.java | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index bc57030..0cad17d 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -127,6 +127,7 @@ public class Am extends BaseCommand { " am screen-compat [on|off] <PACKAGE>\n" + " am to-uri [INTENT]\n" + " am to-intent-uri [INTENT]\n" + + " am to-app-uri [INTENT]\n" + " am switch-user <USER_ID>\n" + " am start-user <USER_ID>\n" + " am stop-user <USER_ID>\n" + @@ -229,6 +230,8 @@ public class Am extends BaseCommand { "\n" + "am to-intent-uri: print the given Intent specification as an intent: URI.\n" + "\n" + + "am to-app-uri: print the given Intent specification as an android-app: URI.\n" + + "\n" + "am switch-user: switch to put USER_ID in the foreground, starting\n" + " execution of that user if it is currently stopped.\n" + "\n" + @@ -270,7 +273,7 @@ public class Am extends BaseCommand { " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]\n" + " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]\n" + " (to embed a comma into a string escape it using \"\\,\")\n" + - " [-n <COMPONENT>] [-f <FLAGS>]\n" + + " [-n <COMPONENT>] [-p <PACKAGE>] [-f <FLAGS>]\n" + " [--grant-read-uri-permission] [--grant-write-uri-permission]\n" + " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]\n" + " [--debug-log-resolution] [--exclude-stopped-packages]\n" + @@ -337,9 +340,11 @@ public class Am extends BaseCommand { } else if (op.equals("screen-compat")) { runScreenCompat(); } else if (op.equals("to-uri")) { - runToUri(false); + runToUri(0); } else if (op.equals("to-intent-uri")) { - runToUri(true); + runToUri(Intent.URI_INTENT_SCHEME); + } else if (op.equals("to-app-uri")) { + runToUri(Intent.URI_ANDROID_APP_SCHEME); } else if (op.equals("switch-user")) { runSwitchUser(); } else if (op.equals("start-user")) { @@ -502,6 +507,12 @@ public class Am extends BaseCommand { if (intent == baseIntent) { hasIntentInfo = true; } + } else if (opt.equals("-p")) { + String str = nextArgRequired(); + intent.setPackage(str); + if (intent == baseIntent) { + hasIntentInfo = true; + } } else if (opt.equals("-f")) { String str = nextArgRequired(); intent.setFlags(Integer.decode(str).intValue()); @@ -607,7 +618,8 @@ public class Am extends BaseCommand { } else if (arg.indexOf(':') >= 0) { // The argument is a URI. Fully parse it, and use that result // to fill in any data not specified so far. - baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME); + baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME + | Intent.URI_ANDROID_APP_SCHEME); } else if (arg.indexOf('/') >= 0) { // The argument is a component name. Build an Intent to launch // it. @@ -1549,9 +1561,9 @@ public class Am extends BaseCommand { } while (packageName != null); } - private void runToUri(boolean intentScheme) throws Exception { + private void runToUri(int flags) throws Exception { Intent intent = makeIntent(UserHandle.USER_CURRENT); - System.out.println(intent.toUri(intentScheme ? Intent.URI_INTENT_SCHEME : 0)); + System.out.println(intent.toUri(flags)); } private class IntentReceiver extends IIntentReceiver.Stub { |