JavaScript Restrictor
Browser extension that improves privacy and security
wrappingS-SENSOR-ACCELEROMETER.js File Reference

Wrappers for the Accelerometer Sensor, LinearAccelerationSensor, and GravitySensor. More...

Functions

function shake (axis)
 
function initDataGenerator ()
 
function updateReadings (sensorObject)
 

Variables

var previousReading
 
var emulateStationaryDevice = (typeof args === 'undefined') ? true : args[0]
 
var debugMode = false
 
const TWOPI = 2 * Math.PI
 
var orig_getters
 
var origGetY = Object.getOwnPropertyDescriptor(Accelerometer.prototype, "y").get
 
var origGetZ = Object.getOwnPropertyDescriptor(Accelerometer.prototype, "z").get
 
var origGetTimestamp = Object.getOwnPropertyDescriptor(Sensor.prototype, "timestamp").get
 
var generators
 
var helping_functions
 
var hc = init_data + orig_getters + helping_functions + generators
 
var wrappers
 

Detailed Description

Wrappers for the Accelerometer Sensor, LinearAccelerationSensor, and GravitySensor.

See also
https://www.w3.org/TR/accelerometer/
https://www.w3.org/TR/accelerometer/#linearaccelerationsensor
https://www.w3.org/TR/accelerometer/#gravitysensor
Author
Copyright (C) 2021 Radek Hranicky
License:
SPDX-License-Identifier: GPL-3.0-or-later

MOTIVATION Readings from the Accelerometer, LinearAccelerationSensor, and GravitySensor of the Generic Sensor API should be secured as they provide a potentially valuable data for creating fingerprints. There are multiple options. A unique fingerprint can be obtained by describing the device's vibrations (See https://link.springer.com/chapter/10.1007/978-3-319-30806-7_7). Using trajectory inference and matching of the model to map data, one may use the readings from the Accelerometer to determing the device's position (See https://www.researchgate.net/publication/220990763_ACComplice_Location_ inference_using_accelerometers_on_smartphones).

WRAPPING The wrapper replaces the "XYZ" getters of the Accelerometer sensor, LinearAccelerationSensor, and GravitySensor. The wrapping's goal is to simulate a stationary device that is lying bottom down on a flat surface, e.g., a cell phone on the table. In such a case, only the z axis is affected by gravity. The x and y axes values should be set to zero. Yet, there could be vibrations that may change values a little bit, e.g., to spin around -0.1 to +0.1. This usually does not happed with every reading but only in intervals of seconds. And thus, after a few seconds we pseudo-randomly change these values. For the LinearAccelerationSensor, the returned values should represent the acceleration without the conribution of gravity. For stationary devices, the x and y are zeroes, while the 'z' portion fluctuates between 0 and 0.1 on the examined devices. The wrapper simulates the same behavior. Lastly, the GravitySensor's readings are calculated as the difference between the previous two.

POSSIBLE IMPROVEMENTS Currently, we assume te device is lying on a flat surface bottom down, and thus only the z is affected by gravity. As improvement, we can also assume the device is in an oblique position. In this case, the gravitational acceleration would affect two or three axes. Those will have to be updated properly to create a realistic behavior.

Function Documentation

◆ initDataGenerator()

function initDataGenerator ( )
Here is the call graph for this function:

◆ shake()

function shake (   axis)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateReadings()

function updateReadings (   sensorObject)

Variable Documentation

◆ debugMode

var debugMode = false

◆ emulateStationaryDevice

var emulateStationaryDevice = (typeof args === 'undefined') ? true : args[0]

◆ generators

var generators
Initial value:
= `
var dataGenerator = dataGenerator || initDataGenerator()
function initDataGenerator()
Definition: wrappingS-SENSOR-ACCELEROMETER.js:112

◆ hc

var hc = init_data + orig_getters + helping_functions + generators

◆ helping_functions

var helping_functions
Initial value:
var sensorapi_prng_functions
Definition: wrappingL-SENSOR.js:30
function shake(axis)
Definition: wrappingS-SENSOR-ACCELEROMETER.js:101
function updateReadings(sensorObject)
Definition: wrappingS-SENSOR-ACCELEROMETER.js:241

◆ orig_getters

var orig_getters
Initial value:
= `
var origGetX = Object.getOwnPropertyDescriptor(Accelerometer.prototype, "x").get

◆ origGetTimestamp

var origGetTimestamp = Object.getOwnPropertyDescriptor(Sensor.prototype, "timestamp").get

◆ origGetY

var origGetY = Object.getOwnPropertyDescriptor(Accelerometer.prototype, "y").get

◆ origGetZ

var origGetZ = Object.getOwnPropertyDescriptor(Accelerometer.prototype, "z").get

◆ previousReading

var previousReading
Initial value:
= previousReading || {orig_x: null, orig_y: null, orig_z: null, timestamp: null,
fake_x: null, fake_y: null, fake_z: null}
var previousReading
Definition: wrappingS-SENSOR-ACCELEROMETER.js:78

◆ TWOPI

const TWOPI = 2 * Math.PI

◆ wrappers

var wrappers