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

The screen/audio streaming permission flow of the yaacc server row: asks for the MediaProjection permission, applies the answer, and resets the streaming state when the projection stops. More...

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

Public Member Functions

 StreamingPermissionHelper (Context context, Runnable refreshAdapter)
 
boolean hasRecordAudioPermission ()
 
void onRecordAudioResult (boolean granted)
 Applies the answer to the RECORD_AUDIO question: a denial switches the streaming buttons off, exactly like a denied screen capture permission.
 
Intent createRequestIntent ()
 
void onPermissionResult (int requestCode, int resultCode, Intent data)
 Applies the answer to the request issued by createRequestIntent().
 
void registerStopCallback ()
 Refreshes the server row when the projection stops.
 
void unregisterStopCallback ()
 Call from onStop.
 

Static Public Attributes

static final int REQUEST_CODE_RECORD_AUDIO = 2002
 Request code of the runtime permission question for the audio capture (RECORD_AUDIO).
 

Detailed Description

The screen/audio streaming permission flow of the yaacc server row: asks for the MediaProjection permission, applies the answer, and resets the streaming state when the projection stops.

Shared by every fragment that hosts the BrowseDeviceAdapter.

Usage in the fragment: call createRequestIntent() from the adapter's permission callback and start it with startActivityForResult(intent,
MediaProjectionHelper.REQUEST_CODE_MEDIA_PROJECTION)
; pass the result of onActivityResult to onPermissionResult(int, int, Intent); call registerStopCallback() in onStart and unregisterStopCallback() in onStop.

Security: the permission result Intent is a capability to capture the screen. It is handed straight to MediaProjectionHelper, which keeps it in its static fields only. It is never put in a Bundle, preferences or another Intent, and its extras are never logged. A result is accepted only after this helper issued a request and only for that request code. Only the application context is kept. Main thread only.

Constructor & Destructor Documentation

◆ StreamingPermissionHelper()

de.yaacc.browser.StreamingPermissionHelper.StreamingPermissionHelper ( Context context,
Runnable refreshAdapter )
Parameters
contextany context; only the application context is kept
refreshAdapterrefreshes the server row after the streaming state changed; called on the main thread, between register and unregister of the stop callback and after a permission result

Member Function Documentation

◆ createRequestIntent()

Intent de.yaacc.browser.StreamingPermissionHelper.createRequestIntent ( )
Returns
the intent that asks the user for the screen capture permission, to be started with startActivityForResult and MediaProjectionHelper#REQUEST_CODE_MEDIA_PROJECTION. Returns null before Android 10.
Here is the call graph for this function:

◆ hasRecordAudioPermission()

boolean de.yaacc.browser.StreamingPermissionHelper.hasRecordAudioPermission ( )
Returns
true if the runtime permission the audio capture needs is granted (or not needed before Android 10, where the capture does not exist)

◆ onPermissionResult()

void de.yaacc.browser.StreamingPermissionHelper.onPermissionResult ( int requestCode,
int resultCode,
Intent data )

Applies the answer to the request issued by createRequestIntent().

Results for another request code, or without a pending request, are ignored.

Here is the call graph for this function:

◆ onRecordAudioResult()

void de.yaacc.browser.StreamingPermissionHelper.onRecordAudioResult ( boolean granted)

Applies the answer to the RECORD_AUDIO question: a denial switches the streaming buttons off, exactly like a denied screen capture permission.

A grant needs no action here; the caller goes on with the screen capture request.

◆ registerStopCallback()

void de.yaacc.browser.StreamingPermissionHelper.registerStopCallback ( )

Refreshes the server row when the projection stops.

Call from onStart.

Here is the call graph for this function:

◆ unregisterStopCallback()

void de.yaacc.browser.StreamingPermissionHelper.unregisterStopCallback ( )

Call from onStop.

Removes exactly the callback this helper added.

Here is the call graph for this function:

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