Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 package com.introlab.rtabmap;
00020
00021 import android.content.Context;
00022 import android.content.Intent;
00023 import android.content.ServiceConnection;
00024 import android.os.Build;
00025 import android.os.IBinder;
00026 import android.util.Log;
00027
00028 import java.io.File;
00029
00034 public class TangoInitializationHelper {
00035 public static final int ARCH_ERROR = -2;
00036 public static final int ARCH_FALLBACK = -1;
00037 public static final int ARCH_DEFAULT = 0;
00038 public static final int ARCH_ARM64 = 1;
00039 public static final int ARCH_ARM32 = 2;
00040 public static final int ARCH_X86_64 = 3;
00041 public static final int ARCH_X86 = 4;
00042
00050 public static final boolean bindTangoService(final Context context,
00051 ServiceConnection connection) {
00052 Intent intent = new Intent();
00053 intent.setClassName("com.google.tango", "com.google.atap.tango.TangoService");
00054
00055 boolean hasJavaService = (context.getPackageManager().resolveService(intent, 0) != null);
00056
00057
00058 if (!hasJavaService) {
00059 intent = new Intent();
00060 intent.setClassName("com.projecttango.tango", "com.google.atap.tango.TangoService");
00061 hasJavaService = (context.getPackageManager().resolveService(intent, 0) != null);
00062 }
00063
00064
00065
00066
00067 if (!hasJavaService) {
00068 return false;
00069 }
00070
00071 return context.bindService(intent, connection, Context.BIND_AUTO_CREATE);
00072 }
00073
00074
00080 public static final int loadTangoSharedLibrary() {
00081 int loadedSoId = ARCH_ERROR;
00082 String basePath = "/data/data/com.google.tango/libfiles/";
00083 if (!(new File(basePath).exists())) {
00084 basePath = "/data/data/com.projecttango.tango/libfiles/";
00085 }
00086 Log.i("TangoInitializationHelper", "basePath: " + basePath);
00087
00088 try {
00089 System.load(basePath + "arm64-v8a/libtango_client_api.so");
00090 loadedSoId = ARCH_ARM64;
00091 Log.i("TangoInitializationHelper", "Success! Using arm64-v8a/libtango_client_api.");
00092 } catch (UnsatisfiedLinkError e) {
00093 }
00094 if (loadedSoId < ARCH_DEFAULT) {
00095 try {
00096 System.load(basePath + "armeabi-v7a/libtango_client_api.so");
00097 loadedSoId = ARCH_ARM32;
00098 Log.i("TangoInitializationHelper", "Success! Using armeabi-v7a/libtango_client_api.");
00099 } catch (UnsatisfiedLinkError e) {
00100 }
00101 }
00102 if (loadedSoId < ARCH_DEFAULT) {
00103 try {
00104 System.load(basePath + "x86_64/libtango_client_api.so");
00105 loadedSoId = ARCH_X86_64;
00106 Log.i("TangoInitializationHelper", "Success! Using x86_64/libtango_client_api.");
00107 } catch (UnsatisfiedLinkError e) {
00108 }
00109 }
00110 if (loadedSoId < ARCH_DEFAULT) {
00111 try {
00112 System.load(basePath + "x86/libtango_client_api.so");
00113 loadedSoId = ARCH_X86;
00114 Log.i("TangoInitializationHelper", "Success! Using x86/libtango_client_api.");
00115 } catch (UnsatisfiedLinkError e) {
00116 }
00117 }
00118 if (loadedSoId < ARCH_DEFAULT) {
00119 try {
00120 System.load(basePath + "default/libtango_client_api.so");
00121 loadedSoId = ARCH_DEFAULT;
00122 Log.i("TangoInitializationHelper", "Success! Using default/libtango_client_api.");
00123 } catch (UnsatisfiedLinkError e) {
00124 }
00125 }
00126 if (loadedSoId < ARCH_DEFAULT) {
00127 try {
00128 System.loadLibrary("tango_client_api");
00129 loadedSoId = ARCH_FALLBACK;
00130 Log.i("TangoInitializationHelper", "Falling back to libtango_client_api.so symlink.");
00131 } catch (UnsatisfiedLinkError e) {
00132 }
00133 }
00134 return loadedSoId;
00135 }
00136 }