Enum TapjackingPolicy
- All Implemented Interfaces:
Comparable<TapjackingPolicy>
What the framework should do about a touch that arrives while another application's window is
drawn over this app. See DeviceIntegrity.setTapjackingProtection(TapjackingPolicy).
The distinction that matters here is between fully and partially obscured. Android reports them as two different flags, and they carry very different signal-to-noise:
- Fully obscured means another window sits directly over the point that was touched. That is the tapjacking attack itself, and it is rare enough in normal use that blocking on it is safe.
- Partially obscured means some other window covers part of this app's window, anywhere. Benign system UI sets it routinely, so treating it as an attack will drop legitimate taps.
That is why BLOCK stops at the first and STRICT is a deliberate opt-in to the second.
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionReport, and drop any gesture that begins on a fully obscured window.No detection and no reporting.Observe and report, but never change event delivery.AsBLOCK, and additionally drop gestures that arrive while the window is only partially obscured. -
Method Summary
Modifier and TypeMethodDescriptionbooleanblocks(boolean obscured, boolean partiallyObscured) Whether a gesture carrying these obscured flags should be dropped rather than delivered.booleanWhether this policy wants the platform to look at the obscured flags at all.static TapjackingPolicyReturns the enum constant of this type with the specified name.static TapjackingPolicy[]values()Returns an array containing the constants of this enum type, in the order they are declared.Methods inherited from class Enum
clone, compareTo, equals, getDeclaringClass, getEnumValues, hashCode, name, ordinal, setEnumValues, toString, valueOf
-
Enum Constant Details
-
OFF
No detection and no reporting. This is the default: the check costs nothing but an app that never asked for it should not start seeing signals, and blocking touches is not a behaviour to switch on behind a developer's back. -
REPORT
Observe and report, but never change event delivery. Touches are dispatched exactly as they would be with
OFF, whileDeviceIntegrity.isScreenObscured(), the tapjacking listeners and theShieldSignal.TAPJACKsignal all become live.Use this to measure how often obscuring actually happens in your user base before you commit to dropping input.
-
BLOCK
Report, and drop any gesture that begins on a fully obscured window. The recommended setting for a sensitive app.
The whole gesture is dropped, not the individual event: swallowing a press while letting the matching release through would leave the framework holding half a gesture.
-
STRICT
As
BLOCK, and additionally drop gestures that arrive while the window is only partially obscured.Understand the cost before choosing this. The partial flag is set by ordinary system UI, so on some devices this will discard taps the user meant, and the app will read as unresponsive with nothing in the logs to explain it. Reach for it only where a missed tap is clearly preferable to a hijacked one.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
isDetecting
public boolean isDetecting()Whether this policy wants the platform to look at the obscured flags at all. False only forOFF, which is what lets a port skip the check entirely on the hot input path. -
blocks
public boolean blocks(boolean obscured, boolean partiallyObscured) Whether a gesture carrying these obscured flags should be dropped rather than delivered.
This is the whole blocking decision, kept here as pure logic so it is identical on every port and can be tested without a device.
Parameters
obscured: another window sits directly over the touched pointpartiallyObscured: another window covers some part of this app's window
Returns
true if the gesture must not be delivered to the application
-