JavaScript Restrictor
Browser extension that improves privacy and security
Loading...
Searching...
No Matches
wrappingS-SENSOR-ACCEL.js File Reference

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

Classes

class  DataGenerator
 

Functions

function shake (axis)
 
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). Accelerometer readings can also be used for determining human walking patterns (See https://www.researchgate.net/publication/322835708_Classifying_Human_ Walking_Patterns_using_Accelerometer_Data_from_Smartphone).

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 can be possibly rotated. The rotation of the device is represented by the fake rotation matrix "orient.rotMat".

The GravitySensor should provide readings of gravity acceleration applied to the device. This is represented by a vector made of x, y, z portions. To get this faked gravity vector for the device, the reference vector [0, 0, 9.8] is multipled with the rotation matrix. Wrappers for the GravitySensor's getters return x, y, z portions of the fake gravity vector.

Next, the LinearAccelerationSensor should return acceleration values without the contribution of gravity. For a stationary device, it should be all zeroes. Yet, there could be vibrations that may change values a little bit, e.g., spin around -0.1 to +0.1, as seen on the examined devices. 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.

Finally, the Accelerometer sensor combines the previous two. Our wrappers thus return tha values from the LinearAccelerationSensor with the fake gravity vector portions added.

POSSIBLE IMPROVEMENTS Support for simulation of a non-stationary device where the rotation can change. Currently, the calculation of the gravity vector is done only once by the initDataGenerator() where the reference vector is multiplied with the rotation matrix. If orient.rotMat could change, the dataGen would have to be updated periodically. Moreover, such a change should also be taken into account in wrappers for other movement-related sensors (Gyroscope, etc.).

Function Documentation

◆ shake()

function shake (   axis)
Here is the call 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 || new DataGenerator()
Definition wrappingS-SENSOR-ACCEL.js:135

◆ hc

var hc = init_data + orig_getters + helping_functions + generators

◆ helping_functions

var helping_functions
Initial value:
var device_orientation_functions
Definition wrappingL-SENSOR.js:117
var sensorapi_prng_functions
Definition wrappingL-SENSOR.js:35
function shake(axis)
Definition wrappingS-SENSOR-ACCEL.js:113
function updateReadings(sensorObject)
Definition wrappingS-SENSOR-ACCEL.js:303

◆ 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, gVector: null}
var previousReading
Definition wrappingS-SENSOR-ACCEL.js:90

◆ TWOPI

const TWOPI = 2 * Math.PI

◆ wrappers

var wrappers