Adds check/exception handling for logging stats to external storage in Cts Sensor Tests

- Checks if external storage is available and writable before making
directory structure, logs a warning message if not writable.
- Handle IOException with warning message to avoid test crash for
directory/file write fails.

Note:
This change was previously submitted in aosp/921013.
Change did not make it in rvc.
Currently resulting in not so helpful stack trace messages for failures in android auto emulator.

Bug: 158244451
Test: atest CtsSensorTestCases
Change-Id: I1b72bb31dcb86b755dfc493fe6f1f01b03b278a2
1 file changed