Skip to content

AWARE-LIGHT crashes when enabling accessibility before starting a study #34

Description

@EcZww

Description

The app crashes with a java.lang.NumberFormatException when trying to enable accessibility services before starting a study. This issue occurs due to an empty string being passed to Long.parseLong() in the onAccessibilityEvent() method of the aware-core/src/main/java/com/aware/Applications.java class (line 196).

int criteria = (int) Long.parseLong(Aware.getSetting(getApplicationContext(), Aware_Preferences.PACKAGE_SPECIFICATION));

Steps to Reproduce

  • Reinstall and launch the app, and allow all the permissions.
  • Enable app accessibility services before starting a study.
  • Observe that the app crashes.

Device

  • Samsung S20+ with API level 33 (Android 13)
  • Android Virtual Emulator with level API 34
  • Android Virtual Emulator with level API 28

Error Message

FATAL EXCEPTION: main
                                                                                                    Process: com.aware.phone, PID: 7142
                                                                                                    java.lang.NumberFormatException: For input string: ""
                                                                                                    	at java.lang.Long.parseLong(Long.java:761)
                                                                                                    	at java.lang.Long.parseLong(Long.java:876)
                                                                                                    	at com.aware.Applications.onAccessibilityEvent(Applications.java:196)
                                                                                                    	at android.accessibilityservice.AccessibilityService$2.onAccessibilityEvent(AccessibilityService.java:2744)
                                                                                                    	at android.accessibilityservice.AccessibilityService$IAccessibilityServiceClientWrapper.lambda$onAccessibilityEvent$2(AccessibilityService.java:2930)
                                                                                                    	at android.accessibilityservice.AccessibilityService$IAccessibilityServiceClientWrapper.$r8$lambda$09cnCCQeC7txVafv5NeCrjYkmcY(Unknown Source:0)
                                                                                                    	at android.accessibilityservice.AccessibilityService$IAccessibilityServiceClientWrapper$$ExternalSyntheticLambda8.run(Unknown Source:6)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:958)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:205)
                                                                                                    	at android.os.Looper.loop(Looper.java:294)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8177)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

Possible Reason

Before importing the study config, Aware_Preferences.PACKAGE_SPECIFICATION will be the empty string. When onAccessibilityEvent() is called before starting a study, the app will crash with a java.lang.NumberFormatException

Possible Solution

  • Add a check to ensure that the string is not empty before parsing it as a long in the onAccessibilityEvent() method.
  • Add default value for criteria

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions