Open ijdoc opened 11 years ago
The steps to reproduce the error:
1) The app must already be installed on the device 2) The AccessibilityServices must be enabled and Tecla Next is set to on 3) While the Tecla Next Accessibility Service was on, the app was reinstalled 4) When app starts up again it produces the bug
Remember:
The app will always be reinstalled if debug is pressed in eclipse
The app will not be reinstalled if run is pressed in eclipse.
The reason why this bug occurred is because of the nature of AccessibilityServices. Remember that these services are not started by the package containing the service through the traditional startService and bindService methods. Instead these services are started by the AccessbilityManager, when the On button is clicked in the settings. When the app is reinstalled, the AccessibilityService in our case com.android.tecla.ServiceAccessibility is removed from the device before it is put back on again. The result of reinstalling was that the service was destroyed. The problem is that the AccessibilityManager does not know that the service was reinstalled and therefore it does not start up the service again and the setting values are not updated to reflect that the service is not running. The actual test used to determine if the service’s running in the background is correct. If you dump the ResolverServiceInfo values from the isAccessibilityServiceRunning(), you see that you will not find the com.android.tecla.ServiceAccessibility which makes sense.
The Solution:
This is a bug with the android system and others have had the same problem. No one has been able to find a proper solution.
I have tried the following:
I have tried to overwrite the Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES; however, that requires the WRITE_SECURE_SETTINGS permission which is only available for system apps.
I have also tried to modify the database using the ContentURI of Content://Settings/Secure with a ContentResolver but even that requires the signature level permission which is only given to system apps
Lastly I tried to see if there was a way to force start the service through the AccessiblityManager but the API for the AccessiblityManager does not expose those functions, which makes sense since this would be very similar to being able to modify secure settings. Android does not allow you to have access to these functions for security reasons.
It seems that the only thing possible is to inform the user when this occurs. I have written the function which checks if the service is enabled. This is only called if and only if the test to check if the com.android.tecla.ServiceAccessibility is running does not return true. If the service is enabled and the AccessiblityService is not running a message should be shown to the user. I will leave the message creation up to you but I have indicated in the code where it should be created.
Cheers :)
This may have been due to an earlier crash as described in #390, however, this likely means that the test for whether Tecla Next is enabled and/or running is not working properly.