% SPDX-License-Identifier: GPL-3.0-or-later OR CC-BY-SA-4.0
\section{Interceptor Page}\label{sec:interceptor-page} %%##$section-title>>
%%!!intro<<
Interceptor can be used to intercept communication between applications using \texttt{Intent}.
It works as a man-in-the-middle between the source and the destination applications.
It offers a feature-complete user interface for editing \texttt{Intent}s.

\begin{warning}{Warning}
    Interceptor only works for \textit{implicit} intents where the \hyperref[subsec:faq:what-are-app-components]{app component} isn't specified.
\end{warning}

\begin{amseealso}
    \item \href{https://developer.android.com/guide/components/intents-common}{Common Intents}
    \item \href{https://developer.android.com/guide/components/intents-filters}{Intents and Intent Filters}
\end{amseealso}
%%!!>>

\subsection{Intent Filters}\label{subsec:intent-filters} %%##$intent-filters-title>>
%%!!intent-filters<<
Intent filters are used by the applications to specify the tasks they are able to perform or the tasks they are going to perform using other applications.
For example, when you're opening a PDF file using a file manager, the file manager will try to find the applications to open the PDF with.
To find the right applications, the file manager will create an Intent with filters such as the MIME type and ask the system to retrieve the applications capable of opening this filter.
The system will search through the Manifest of the installed applications to match the filter and list the application components that are able to open this filter (in our case the PDF).
At this, either the file manager will open the desired application component all by itself or use a system provided option to open it.
If multiple application components are able to open it and no default is set, you may get a prompt where you have to choose the right application component.
%%!!>>

\subsubsection{Action}\label{subsubsec:action} %%##$action-title>>
%%!!action<<
Action specifies the generic action to perform such as \texttt{android.intent.action.VIEW}. Applications often declare
the relevant actions in the Manifest file to catch the desired Intents. The action is particularly useful for broadcast
Intent where it plays a vital rule. In other cases, it works as an initial way to filter out the relevant application components.
Generic actions such as \texttt{android.intent.action.VIEW} and \texttt{android.intent.action.SEND} are widely used by applications.
Hence, setting this alone may match many application components.
%%!!>>

\subsubsection{Data}\label{subsubsec:data} %%##$data-title>>
%%!!data<<
Data is originally known as URI (Uniform Resource Identifier) defined in \href{http://www.faqs.org/rfcs/rfc2396.html}{RFC 2396}.
It can be web links, file location, or a special feature called \textit{content}. Contents are an Android feature managed by the \hyperref[subsubsec:providers]{content providers}.
Data are often associated with a \hyperref[subsubsec:mime-type]{MIME type}.

Examples:
%%!!>>
\begin{Verbatim}
http://search.disroot.org/?q=URI%20in%20Android%20scheme&categories=general&language=en-US
https://developer.android.com/reference/android/net/Uri
file:///sdcard/AppManager.apk
mailto:email@example.com
content://io.github.muntashirakon.AppManager.provider/23485af89b08d87e898a90c7e/AppManager.apk
\end{Verbatim}

\subsubsection{MIME Type}\label{subsubsec:mime-type} %%##$mime-type-title>>
%%!!mime-type<<
MIME type of the \hyperref[subsubsec:data]{data}. For example, if the data field is set to \texttt{file:///sdcard/AppManager.apk},
the associated MIME type can be \texttt{application/vnd.android.package-archive}.
%%!!>>

\subsubsection{Categories} %%##$categories-title>>
%%!!categories<<
This is similar to \hyperref[subsubsec:action]{action} in the sense that it is also used by the system to filter application components.
This has no further benefits. Unlike \textit{action}, there can be more than one category. Clicking on the \textit{plus} button next to the title allows adding more categories.
%%!!>>

\subsubsection{Flags} %%##$flags-title>>
%%!!flags<<
Flags are useful in determining how system should behave during the launch or after the launch of an activity.
This should not be touched as it requires some technical background. The \textit{plus} button next to the title can be used to add one or more flags.
%%!!>>

\subsubsection{Extras} %%##$extras-title>>
%%!!extras<<
Extras are the key-value pairs used for supplying additional information to the destination component. More extras can be added using the \textit{plus} button next to the title.
%%!!>>

\subsubsection{URI} %%##$uri-title>>
%%!!uri<<
Represents the entire Intent as a URI (e.g. \texttt{intent://\dots}). Some data cannot be converted to string,
and as a result, they might not appear here.
%%!!>>

\subsection{Matching Activities}\label{subsec:matching-activities} %%##$matching-activities-title>>
%%!!matching-activities<<
List all the activity components that matches the Intent. This is internally determined by the system (rather than App Manager).
The launch button next to each component can be used to launch them directly from App Manager.
%%!!>>

\subsection{Reset to Default}\label{subsec:interceptor-reset-to-default} %%##$reset-to-default-title>>
%%!!reset-to-default<<
Reset the Intent to its initial state.
%%!!>>

\subsection{Send Edited Intent}\label{subsec:interceptor-send-edited-intent} %%##$send-edited-intent-title>>
%%!!send-edited-intent<<
Resend the edited Intent to the destination application. This may open a list of applications where the desired application is needed to be selected.
The result received from the target application will be sent to the source application. As a result, the source application will not know if there was a man-in-the-middle.
%%!!>>
