Skip to content

Commit

Permalink
Watch out for VehicleManager going away before a thread starts.
Browse files Browse the repository at this point in the history
  • Loading branch information
peplin committed Aug 30, 2015
1 parent 202827c commit eb357df
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions enabler/src/main/java/com/openxc/enabler/StatusFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,17 @@ public void onServiceConnected(ComponentName className,
new Thread(new Runnable() {
public void run() {
try {
mVehicleManager.waitUntilBound();
if(getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
public void run() {
mServiceNotRunningWarningView.setVisibility(View.GONE);
}
});
// It's possible that between starting the thread and
// this running, the manager has gone away.
if(mVehicleManager != null) {
mVehicleManager.waitUntilBound();
if(getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
public void run() {
mServiceNotRunningWarningView.setVisibility(View.GONE);
}
});
}
}
} catch(VehicleServiceException e) {
Log.w(TAG, "Unable to connect to VehicleService");
Expand Down

0 comments on commit eb357df

Please sign in to comment.