+ \r
+ // Before we close the RAF, we have to wind the current search down.\r
+ if (currentSearchOperation != null) {\r
+ Log.d(LOG, "Interrupting search to shut down.");\r
+ final SearchOperation searchOperation = currentSearchOperation;\r
+ currentSearchOperation = null;\r
+ searchOperation.interrupted.set(true);\r
+ synchronized (searchOperation) {\r
+ while (!searchOperation.done) {\r
+ try {\r
+ searchOperation.wait();\r
+ } catch (InterruptedException e) {\r
+ Log.d(LOG, "Interrupted.", e);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ \r