UsbService: Remove stack-trace message during boot. DO NOT MERGE
This removes a stack trace message during the boot under emulation. The observers tried to access a null reference when no USB configuration is supported by the emulated device. So do not start them in this case. + Change a Slog.w into a Slog.i since this is an acceptable condition. Change-Id: I801f352574716d7868f182bb6e5ee49e5b12e4f1
This commit is contained in:
committed by
Mike Lockwood
parent
f13ec7a3ac
commit
1a7408cd64
@@ -134,14 +134,17 @@ class UsbService {
|
||||
mContext = context;
|
||||
init(); // set initial status
|
||||
|
||||
mUEventObserver.startObserving(USB_CONNECTED_MATCH);
|
||||
mUEventObserver.startObserving(USB_CONFIGURATION_MATCH);
|
||||
mUEventObserver.startObserving(USB_FUNCTIONS_MATCH);
|
||||
if (mConfiguration >= 0) {
|
||||
mUEventObserver.startObserving(USB_CONNECTED_MATCH);
|
||||
mUEventObserver.startObserving(USB_CONFIGURATION_MATCH);
|
||||
mUEventObserver.startObserving(USB_FUNCTIONS_MATCH);
|
||||
}
|
||||
}
|
||||
|
||||
private final void init() {
|
||||
char[] buffer = new char[1024];
|
||||
|
||||
mConfiguration = -1;
|
||||
try {
|
||||
FileReader file = new FileReader(USB_CONNECTED_PATH);
|
||||
int len = file.read(buffer, 0, 1024);
|
||||
@@ -153,10 +156,12 @@ class UsbService {
|
||||
file.close();
|
||||
mConfiguration = Integer.valueOf((new String(buffer, 0, len)).trim());
|
||||
} catch (FileNotFoundException e) {
|
||||
Slog.w(TAG, "This kernel does not have USB configuration switch support");
|
||||
Slog.i(TAG, "This kernel does not have USB configuration switch support");
|
||||
} catch (Exception e) {
|
||||
Slog.e(TAG, "" , e);
|
||||
}
|
||||
if (mConfiguration < 0)
|
||||
return;
|
||||
|
||||
try {
|
||||
File[] files = new File(USB_COMPOSITE_CLASS_PATH).listFiles();
|
||||
|
||||
Reference in New Issue
Block a user