Skip to content

Commit

Permalink
Move test version tango call in binding function
Browse files Browse the repository at this point in the history
  • Loading branch information
Perrine Aguiar committed Mar 29, 2017
1 parent 9ee47dc commit d374a40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,6 @@ protected void init(NodeMainExecutor nodeMainExecutor) {
!= TangoInitializationHelper.ARCH_ERROR) {
mTangoRosNode = new TangoRosNode();
mTangoRosNode.attachCallbackListener(this);

TangoInitializationHelper.checkTangoVersionOk(this);
TangoInitializationHelper.bindTangoService(this, mTangoServiceConnection);
if (TangoInitializationHelper.isTangoVersionOk()) {
nodeMainExecutor.execute(mTangoRosNode, nodeConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,20 @@ public static boolean isTangoVersionOk() {
* @return returns false if the device doesn't have the Tango running as Android Service.
* Otherwise ture.
*/
public static final boolean bindTangoService(final Context context,
public static final boolean bindTangoService(final Activity activity,
ServiceConnection connection) {
testTangoVersionOk(activity);

Intent intent = new Intent();
intent.setClassName("com.google.tango", "com.google.atap.tango.TangoService");

boolean hasJavaService = (context.getPackageManager().resolveService(intent, 0) != null);
boolean hasJavaService = (activity.getPackageManager().resolveService(intent, 0) != null);

// User doesn't have the latest packagename for TangoCore, fallback to the previous name.
if (!hasJavaService) {
intent = new Intent();
intent.setClassName("com.projecttango.tango", "com.google.atap.tango.TangoService");
hasJavaService = (context.getPackageManager().resolveService(intent, 0) != null);
hasJavaService = (activity.getPackageManager().resolveService(intent, 0) != null);
}

// User doesn't have a Java-fied TangoCore at all; fallback to the deprecated approach
Expand All @@ -95,7 +97,7 @@ public static final boolean bindTangoService(final Context context,
return false;
}

return context.bindService(intent, connection, Context.BIND_AUTO_CREATE);
return activity.bindService(intent, connection, Context.BIND_AUTO_CREATE);
}

/**
Expand Down Expand Up @@ -207,11 +209,11 @@ public static ServiceConnection NewDefaultServiceConnection(
}

/**
* Checks if Tango Version is ok using native functions, and sets status variable.
* Tests if Tango Version is ok using native functions, and sets status variable.
* @param activity Caller activity.
* @return True if Tango Version is Ok.
*/
public static boolean checkTangoVersionOk(Activity activity) {
private static boolean testTangoVersionOk(Activity activity) {
mIsTangoVersionOk = isTangoVersionOk(activity);
return mIsTangoVersionOk;
}
Expand Down

0 comments on commit d374a40

Please sign in to comment.