public class Nanny extends Object
PermissionRequest.
WifiRequest.getConnectionInfo() - is
considered a one-shot request.
Clients start the flow by broadcasting an Intent to Permission Nanny's ClientRequestReceiver, a BroadcastReceiver
that validates incoming Intents. The Intent must contain a PROTOCOL_VERSION String and an ENTITY_BODY Bundle containing valid request metadata. Request metadata must contain a SENDER_IDENTITY so that Permission Nanny knows who sent the request, REQUEST_PARAMS to know what resource
to access. Request metadata may contain a REQUEST_REASON String to explain to the user why the client
needs access to the resource. The request may also contain a CLIENT_ADDRESS String to tell Permission
Nanny where to deliver the response. If CLIENT_ADDRESS is empty, Permission Nanny will not return a response
and you will not know the status of your request, nor be able to retrieve the requested resources.
{
PROTOCOL_VERSION*
CLIENT_ADDRESS
ENTITY_BODY* = {
SENDER_IDENTITY*
REQUEST_PARAMS*
REQUEST_REASON
}
}
Permission Nanny will return an authorization response. The response Intent must contain a PROTOCOL_VERSION String, a STATUS_CODE integer similar to HTTP, a CONNECTION String fixed to
CLOSE and a SERVER String fixed to AUTHORIZATION_SERVICE. If STATUS_CODE
indicates success, the response must contain an ENTITY_BODY Bundle containing the requested resource;
otherwise, the response must contain an ENTITY_ERROR.
{
PROTOCOL_VERSION*
STATUS_CODE*
CONNECTION* = CLOSE
SERVER* = AUTHORIZATION_SERVICE
ENTITY_BODY
ENTITY_ERROR
}
CLIENT_ADDRESS that the client's response receiver is listening on and is packaged in the request so that
Permission Nanny knows where to send responses to.
LocationRequest.requestLocationUpdates(long, float, Criteria, LocationListener, Looper) is considered an ongoing
request.
The requirements for an ongoing request is exactly the same as one-shot requests.
Permission Nanny will return one authorization response followed by a series of resource responses.
PROTOCOL_VERSION, STATUS_CODE and SERVER. But it's CONNECTION String must not be set to CLOSE. In
addition, it must not contain an ENTITY_BODY; resources are packaged in the subsequent resource
responses. It may contain an ENTITY_ERROR if the request failed.
{
PROTOCOL_VERSION*
STATUS_CODE*
SERVER = AUTHORIZATION_SERVICE*
ENTITY_ERROR
}
PROTOCOL_VERSION, STATUS_CODE, SERVER and ENTITY_BODY. SERVER must not be set to AUTHORIZATION_SERVICE. ENTITY_BODY
must contain the requested resource and an ACK_SERVER_ADDRESS, which is used by the client the send
acknowledgements for resource responses.
{
PROTOCOL_VERSION*
STATUS_CODE*
SERVER*
ENTITY_BODY* = {
ACK_SERVER_ADDRESS*
}
ENTITY_ERROR
}
PROTOCOL_VERSION and CLIENT_ADDRESS.
{
PROTOCOL_VERSION*
CLIENT_ADDRESS*
}
ContentProviders is considered a content query.
Requests that insert, update and delete resources in ContentProviders are one-shot
requests, not content queries.
The requirements for a content query is exactly the same as one-shot requests. Clients start the flow by sending a
content query to Permission Nanny. If the user authorizes the query, Permission Nanny will return a content response.
The content response must contain an ENTITY_BODY Bundle, which must only contain a ContentRequest.SELECT URI. The client must then make a 2nd request to Permission Nanny's content provider
with the URI appended to PROVIDER_AUTHORITY. The 2nd request will be handled by Permission Nanny's
ProxyContentProvider which will execute the content query and return results.
{
PROTOCOL_VERSION*
STATUS_CODE*
CONNECTION* = CLOSE
SERVER* = AUTHORIZATION_SERVICE
ENTITY_BODY = {
ContentRequest.SELECT*
}
ENTITY_ERROR
}
CrossProcessCursorWrapper, which facilitated sending Cursor data
between processes. Permission Nanny uses this mechanism to deliver content resources to the client. After the 1st
handshake, Permission Nanny uses SecureRandom to generate a key to cache the query parameters; the key is returned to
the client as the ContentRequest.SELECT URI. The client then appends the key to the PROVIDER_AUTHORITY and starts the 2nd handshake with ProxyContentProvider.
If you would like to know how to make requests and listen for responses using the SDK or integrating your
application with Permission Nanny, please proceed to PermissionRequest.| Modifier and Type | Field and Description |
|---|---|
static String |
ACK_SERVER_ADDRESS
Entity field:
|
static String |
ACTION_GET_PERMISSION_MANIFEST
Broadcast Action: Sent when Permission Nanny wants to know which permissions clients are using.
|
static String |
AUTHORIZATION_SERVICE
Response value: Service that authorizes requests.
|
static String |
CLIENT_ADDRESS
Request field: Address client is listening on.
|
static String |
CLIENT_PERMISSION_MANIFEST_RECEIVER
Server Component that listens for client permission usages.
|
static String |
CLIENT_REQUEST_RECEIVER
Server Component that handles client requests.
|
static String |
CLOSE
Response value: Client shall receive no further responses from the server; it is safe to unregister receivers or
unbind services.*
|
static String |
CONNECTION
Response field: Connection options.
|
static android.net.Uri |
DEBUG_PROVIDER |
static String |
ENTITY_BODY
Request/Response field: Resource payload.
|
static String |
ENTITY_ERROR
Response field: Error payload.
|
static String |
GPS_STATUS_SERVICE
Response value: Service that delivers GPS status updates.
|
static String |
LOCATION_SERVICE
Response value: Service that delivers location updates.
|
static String |
NMEA_SERVICE
Response value: Service that delivers NMEA updates.
|
static String |
PERMISSION_MANIFEST
Entity field:
|
static String |
PPP_0_1
Request/Response value: Permission Police Protocol v0.1
|
static String |
PROTOCOL_VERSION
Request/Response field: Protocol version of the request the client is using.
|
static android.net.Uri |
PROVIDER |
static String |
PROVIDER_AUTHORITY
Authority that resolves to Permission Nanny's proxy content provider.
|
static String |
REQUEST_PARAMS
Entity field:
|
static String |
REQUEST_REASON
Entity field:
|
static int |
SC_BAD_REQUEST
Response value: Server could not process request due to incorrect request parameters.
|
static int |
SC_FORBIDDEN
Response value: User denied your request.
|
static int |
SC_OK
Response value: Request succeeded.
|
static int |
SC_UNAUTHORIZED
Response value: Client is not authorized to make a request.
|
static String |
SENDER_IDENTITY
Entity field:
|
static String |
SERVER
Response field: Service that handled the request.
|
static String |
SERVER_APP_ID
Permission Nanny's Release build application ID.
|
static String |
SERVER_DEBUG_APP_ID
Permission Nanny's Debug build application ID.
|
static String |
SERVER_PACKAGE_NAME
Permission Nanny's root package name.
|
static String |
STATUS_CODE
Response field: Result status code.
|
static String |
TYPE
Entity field:
|
| Constructor and Description |
|---|
Nanny() |
| Modifier and Type | Method and Description |
|---|---|
static void |
configureServer(boolean targetDebugBuild)
Configure the SDK to communicate with Permission Nanny's Debug or Release build variant.
|
static android.net.Uri |
getProxyContentProvider()
Return Permission Nanny's proxy content provider's URI, which changes depending on the build variant to avoid
conflict with each other.
|
static String |
getServerAppId()
Return Permission Nanny's app ID, which changes depending on the build variant to avoid conflict with each
other.
|
static boolean |
isPermissionNannyInstalled(android.content.Context context)
Checks if Permission Nanny is installed.
|
public static final String PROTOCOL_VERSION
Stringpublic static final String PPP_0_1
public static final String STATUS_CODE
public static final int SC_OK
public static final int SC_BAD_REQUEST
public static final int SC_UNAUTHORIZED
public static final int SC_FORBIDDEN
public static final String CLIENT_ADDRESS
public static final String CONNECTION
Stringpublic static final String CLOSE
public static final String SERVER
Stringpublic static final String AUTHORIZATION_SERVICE
public static final String LOCATION_SERVICE
public static final String GPS_STATUS_SERVICE
public static final String NMEA_SERVICE
public static final String ENTITY_BODY
Bundle.public static final String ENTITY_ERROR
NannyException.public static final String TYPE
public static final String REQUEST_PARAMS
public static final String REQUEST_REASON
public static final String SENDER_IDENTITY
public static final String PERMISSION_MANIFEST
public static final String ACK_SERVER_ADDRESS
public static final String SERVER_PACKAGE_NAME
public static final String SERVER_APP_ID
public static final String SERVER_DEBUG_APP_ID
public static final String CLIENT_REQUEST_RECEIVER
public static final String CLIENT_PERMISSION_MANIFEST_RECEIVER
public static final String ACTION_GET_PERMISSION_MANIFEST
public static final String PROVIDER_AUTHORITY
public static final android.net.Uri PROVIDER
public static final android.net.Uri DEBUG_PROVIDER
public static void configureServer(boolean targetDebugBuild)
targetDebugBuild - true to issue requests to a Debug build, false to target a Release buildpublic static String getServerAppId()
public static android.net.Uri getProxyContentProvider()
public static boolean isPermissionNannyInstalled(android.content.Context context)
context - Activity, Service, etc.true if Permission Nanny is installed