YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.browser.LauncherForwardPolicy Class Reference

Decides what the exported launcher activity hands on to the browser. More...

Collaboration diagram for de.yaacc.browser.LauncherForwardPolicy:
Collaboration graph

Classes

class  Decision
 Either a plain launch (no text) or a SEND text/plain with a capped text.
 
class  StreamDecision
 What to forward for a shared file: either nothing (no stream forward; the launch stays a plain one, or the text path decides), or exactly ONE content: URI to hand on as the only item of a new ClipData together with FLAG_GRANT_READ_URI_PERMISSION.
 

Static Public Member Functions

static Decision decide (String action, String type, String text)
 
static StreamDecision decideStream (String action, String type, String streamUri, String clipItemUri, int incomingFlags, String ownAuthority)
 Decides whether the launcher forwards a shared file.
 
static String rejectionReason (String action, String type, String streamUri, String clipItemUri, int incomingFlags, String ownAuthority)
 Why decideStream does not forward, as a short fixed code for the log (it names no URI, no type and no other payload), or null if it forwards.
 
static boolean isFileShareAttempt (String action, boolean hasExtraStream, boolean hasClipUri)
 Whether the incoming intent is an attempt to share a file (a stream or a clip URI).
 
static boolean isStreamType (String type)
 Whether a declared type selects the shared-file path (instead of the text path): an audio, video or image type, concrete or the sender's wildcard, exact lower case.
 

Static Public Attributes

static final int FLAG_GRANT_READ_URI_PERMISSION = 0x1
 Intent.FLAG_GRANT_READ_URI_PERMISSION, repeated here as a number so this class stays free of android.* (the value is part of the platform API and does not change).
 

Detailed Description

Decides what the exported launcher activity hands on to the browser.

Plain Java so it can be unit tested on the JVM; the Android Intent handling stays in the activity.

The launcher can be started by any app with any intent, so the forward is an allowlist: a plain launch for everything (MAIN, VIEW, no action, unknown actions), except an ACTION_SEND of exactly text/plain with a non-empty text of at most ShareUriPolicy#MAX_TEXT_LENGTH characters, which is forwarded as that text and nothing else. A text over the cap is dropped, not truncated, and the launch becomes a plain one.

Action and type are compared exactly, case-sensitively: the manifest filter and the share handler use the lower-case spelling, so another spelling is not forwarded.

Member Function Documentation

◆ decide()

static Decision de.yaacc.browser.LauncherForwardPolicy.decide ( String action,
String type,
String text )
static
Parameters
actionthe incoming action, may be null
typethe incoming MIME type, may be null
textthe incoming text (EXTRA_TEXT or clip text), may be null

◆ decideStream()

static StreamDecision de.yaacc.browser.LauncherForwardPolicy.decideStream ( String action,
String type,
String streamUri,
String clipItemUri,
int incomingFlags,
String ownAuthority )
static

Decides whether the launcher forwards a shared file.

Forwarded only if ALL hold:

  • action is exactly android.intent.action.SEND;
  • type is an audio, video or image type, concrete (image/png) or a sender's wildcard (audio/*): exact lower-case match, no parameters, no other spelling. The real type is checked later via SharedContentPolicy#chooseMimeType; text/plain (the text path, see decide(String, String, String)), application/*, a bare */* and null are not forwarded;
  • streamUri (EXTRA_STREAM as text) equals clipItemUri (ClipData item 0 as text) exactly: the system checks only data and ClipData for the grant, never EXTRA_STREAM, so a mismatch could name a URI the sender holds no grant for;
  • incomingFlags contain FLAG_GRANT_READ_URI_PERMISSION: the sender really passed a read grant on;
  • SharedContentPolicy.isAcceptableUri(streamUri, ownAuthority) (only content: URIs of other apps).

Otherwise the answer is "no stream forward". Never throws.

Parameters
actionthe incoming action, may be null
typethe incoming MIME type, may be null
streamUrithe incoming EXTRA_STREAM URI as text, may be null
clipItemUrithe URI of ClipData item 0 as text, may be null
incomingFlagsthe incoming intent flags
ownAuthoritythe authority of yaacc's own file provider
Here is the call graph for this function:

◆ isFileShareAttempt()

static boolean de.yaacc.browser.LauncherForwardPolicy.isFileShareAttempt ( String action,
boolean hasExtraStream,
boolean hasClipUri )
static

Whether the incoming intent is an attempt to share a file (a stream or a clip URI).

When such an attempt is not forwarded, the user is told once, with a fixed text, that only audio, video, images and links are accepted; a text share never counts.

◆ isStreamType()

static boolean de.yaacc.browser.LauncherForwardPolicy.isStreamType ( String type)
static

Whether a declared type selects the shared-file path (instead of the text path): an audio, video or image type, concrete or the sender's wildcard, exact lower case.

The browser side uses the same test as the launcher so the two cannot disagree about which path an intent takes.

Referenced by de.yaacc.browser.ShareIntentHandler.handle().

Here is the caller graph for this function:

◆ rejectionReason()

static String de.yaacc.browser.LauncherForwardPolicy.rejectionReason ( String action,
String type,
String streamUri,
String clipItemUri,
int incomingFlags,
String ownAuthority )
static

Why decideStream does not forward, as a short fixed code for the log (it names no URI, no type and no other payload), or null if it forwards.

Same checks in the same order.

Here is the call graph for this function:

The documentation for this class was generated from the following file: