A portable electronic device (10,100,200,300) suitable for thwarting malicious attacks designed to deduce user input through the analysis of hardware sensor output, comprising: a processor; a hardware sensor (60,62,64,66) integrated in the portable electronic device, the hardware sensor operable to produce hardware sensor output indicative of orientation or motion or both of the portable electronic device within its environment; a hardware user-input component (22,32,42,102,202,302,306) integrated in the portable electronic device, the hardware user-input component having multiple elements (24,34,44,104,204,304) operable to accept user input through touch; a memory coupled to the processor, the memory storing: an operating system; a sensor driver (61,63,65,67) for use by the operating system to interface with the hardware sensor; a user-input driver (26,36,46) for use by the operating system to interface with the hardware user-input component, the user-input driver and operating system jointly operable to detect touch events involving the elements; and a software application, wherein, while the software application is executed by the processor as a process, the sensor driver or the operating system or both are configured to control what hardware sensor output, if any, is available to the process as follows: any hardware sensor output sampled during those time periods throughout which the process is running in foreground is available to the process and any hardware sensor output sampled during those time periods throughout which the processing is running in background is not available to the process. a processor; a hardware sensor (60,62,64,66) integrated in the portable electronic device, the hardware sensor operable to produce hardware sensor output indicative of orientation or motion or both of the portable electronic device within its environment; a hardware user-input component (22,32,42,102,202,302,306) integrated in the portable electronic device, the hardware user-input component having multiple elements (24,34,44,104,204,304) operable to accept user input through touch; a memory coupled to the processor, the memory storing: an operating system; a sensor driver (61,63,65,67) for use by the operating system to interface with the hardware sensor; a user-input driver (26,36,46) for use by the operating system to interface with the hardware user-input component, the user-input driver and operating system jointly operable to detect touch events involving the elements; and a software application, an operating system; a sensor driver (61,63,65,67) for use by the operating system to interface with the hardware sensor; a user-input driver (26,36,46) for use by the operating system to interface with the hardware user-input component, the user-input driver and operating system jointly operable to detect touch events involving the elements; and a software application, wherein, while the software application is executed by the processor as a process, the sensor driver or the operating system or both are configured to control what hardware sensor output, if any, is available to the process as follows: any hardware sensor output sampled during those time periods throughout which the process is running in foreground is available to the process and any hardware sensor output sampled during those time periods throughout which the processing is running in background is not available to the process.