Repository: nvaccess/nvda

Issue:
Unsigned builds (such as PRs) fail to start on touchscreen devices
### Steps to reproduce:

Create a PR build and install it, and run it

### Actual behavior:

Touch handler fails to initialise with the following log.

```python
DEBUG - core.main (10:19:34.062) - MainThread (10856):
Initializing touchHandler
DEBUG - touchHandler.initialize (10:19:34.063) - MainThread (10856):
Touchscreen detected, maximum touch inputs: 10
CRITICAL - __main__ (10:19:34.066) - MainThread (10856):
core failure
Traceback (most recent call last):
  File "nvda.pyw", line 266, in <module>
  File "core.pyc", line 555, in main
  File "touchHandler.pyc", line 342, in initialize
  File "touchHandler.pyc", line 322, in setTouchSupport
  File "touchHandler.pyc", line 217, in __init__
  File "touchHandler.pyc", line 232, in run
  File "_ctypes/callproc.c", line 935, in GetResult
PermissionError: [WinError -2147024891] Access is denied
IO - inputCore.InputManager.executeGesture (10:19:36.378) - winInputHook (30428):
Input: kb(laptop):windows+u
IO - inputCore.InputManager.executeGesture (10:19:46.708) - winInputHook (30428):
Input: kb(laptop):shift+5
```

### Expected behavior:

NVDA starts properly

### System configuration
#### NVDA installed/portable/running from source:

PR builds

#### NVDA version:

alpha and 2021.1 beta

#### Windows version:

10

#### Name and version of other software in use when reproducing the issue:

N/a

#### Other information about your system:

n/a

### Other questions
#### Does the issue still occur after restarting your computer?

yes

#### Have you tried any other versions of NVDA? If so, please report their behaviors.

n/a

#### If add-ons are disabled, is your problem still occurring?

yes

#### Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?

n/a



Discussion:
this is due to NVDA not having the UIAccess permission without being a signed copy. touchHandler.touchSupported should return false at the bottom if systemUtils.hasUIAccess returns false
Hi, this is the first time I’m seeing this traceback (note that touch support requires UI access privilege). Besides that, whenever I test touch support, I experiment with Enhanced Touch Gestures add-on first before submitting PR’s dealing with touch handler. CC @MichaelDCurrand others using touchscreens.


On non-touch enabled systems, I've been getting the same permission denied 
error, but for audio ducking initialization, for such builds. I assumed it 
had something to due with signing.

Hi, yes, UI access privilege is also required to use audio ducking functionality (this is why the user guide states that you must be running an installed copy of NVDA in order to use audio ducking feature). As far as internals are concerned, PR builds are seen as portable NVDA because it lacks privileges (no signing as folks pointed out).



Resolving patch:
diff --git a/source/touchHandler.py b/source/touchHandler.py
--- a/source/touchHandler.py
+++ b/source/touchHandler.py
@@ -1,7 +1,7 @@
 # A part of NonVisual Desktop Access (NVDA)
 # This file is covered by the GNU General Public License.
 # See the file COPYING for more details.
-# Copyright (C) 2012-2020 NV Access Limited, Joseph Lee, Babbage B.V.
+# Copyright (C) 2012-2021 NV Access Limited, Joseph Lee, Babbage B.V.
 
 """handles touchscreen interaction (Windows 8 and later).
 Used to provide input gestures for touchscreens, touch modes and other support facilities.
@@ -14,18 +14,15 @@
 import re
 import gui
 import winVersion
-import globalPluginHandler
 import config
 import winUser
-import speech
-import api
-import ui
 import inputCore
 import screenExplorer
 from logHandler import log
 import touchTracker
-import gui
 import core
+import systemUtils
+
 
 availableTouchModes=['text','object']
 
@@ -311,6 +308,10 @@ def touchSupported(debugLog: bool = False):
 		if debugLog:
 			log.debugWarning("No touch devices found")
 		return False
+	if not systemUtils.hasUiAccess():
+		if debugLog:
+			log.debugWarning("NVDA doesn't have UI Access so touch isn't supported.")
+		return False
 	return True
 
 


Test patch: