File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
services/java/com/android/server Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -134,14 +134,17 @@ public UsbService(Context context) {
134134 mContext = context ;
135135 init (); // set initial status
136136
137- mUEventObserver .startObserving (USB_CONNECTED_MATCH );
138- mUEventObserver .startObserving (USB_CONFIGURATION_MATCH );
139- mUEventObserver .startObserving (USB_FUNCTIONS_MATCH );
137+ if (mConfiguration >= 0 ) {
138+ mUEventObserver .startObserving (USB_CONNECTED_MATCH );
139+ mUEventObserver .startObserving (USB_CONFIGURATION_MATCH );
140+ mUEventObserver .startObserving (USB_FUNCTIONS_MATCH );
141+ }
140142 }
141143
142144 private final void init () {
143145 char [] buffer = new char [1024 ];
144146
147+ mConfiguration = -1 ;
145148 try {
146149 FileReader file = new FileReader (USB_CONNECTED_PATH );
147150 int len = file .read (buffer , 0 , 1024 );
@@ -153,10 +156,12 @@ private final void init() {
153156 file .close ();
154157 mConfiguration = Integer .valueOf ((new String (buffer , 0 , len )).trim ());
155158 } catch (FileNotFoundException e ) {
156- Slog .w (TAG , "This kernel does not have USB configuration switch support" );
159+ Slog .i (TAG , "This kernel does not have USB configuration switch support" );
157160 } catch (Exception e ) {
158161 Slog .e (TAG , "" , e );
159162 }
163+ if (mConfiguration < 0 )
164+ return ;
160165
161166 try {
162167 File [] files = new File (USB_COMPOSITE_CLASS_PATH ).listFiles ();
You can’t perform that action at this time.
0 commit comments