Android 5 support and aarch64-related fixes for Android Manager.

This commit is contained in:
Alexander Smorkalov 2015-02-17 16:54:05 +03:00
parent 6a3a6416d7
commit 352485fc54
13 changed files with 62 additions and 23 deletions

View File

@ -10,6 +10,8 @@ if(NOT ANDROID_PACKAGE_PLATFORM)
else()
set(ANDROID_PACKAGE_PLATFORM armv7a)
endif()
elseif(ARM64_V8A)
set(ANDROID_PACKAGE_PLATFORM aarch64)
elseif(ARMEABI_V6)
set(ANDROID_PACKAGE_PLATFORM armv6)
elseif(ARMEABI)

View File

@ -12,14 +12,16 @@ if(ARMEABI_V7A)
else()
set(ANDROID_PLATFORM_VERSION_CODE "3")
endif()
elseif(ARM64_V8A)
set(ANDROID_PLATFORM_VERSION_CODE "4")
elseif(ARMEABI_V6)
set(ANDROID_PLATFORM_VERSION_CODE "1")
elseif(ARMEABI)
set(ANDROID_PLATFORM_VERSION_CODE "1")
elseif(X86)
set(ANDROID_PLATFORM_VERSION_CODE "4")
elseif(MIPS)
set(ANDROID_PLATFORM_VERSION_CODE "5")
elseif(MIPS)
set(ANDROID_PLATFORM_VERSION_CODE "6")
else()
message(WARNING "Can not automatically determine the value for ANDROID_PLATFORM_VERSION_CODE")
endif()

View File

@ -39,6 +39,12 @@ int GetCpuID()
#else
result = ARCH_UNKNOWN;
#endif
#elif defined(__aarch64__)
#ifdef __SUPPORT_AARCH64
result |= ARCH_AARCH64;
#else
result = ARCH_UNKNOWN;
#endif
#elif defined(__arm__)
LOGD("Using ARM HW detector");
it = cpu_info.find("Processor");

View File

@ -9,7 +9,7 @@
#define ARCH_ARMv5 67108864L
#define ARCH_ARMv6 134217728L
#define ARCH_ARMv7 268435456L
#define ARCH_ARMv8 536870912L
#define ARCH_AARCH64 536870912L
#define ARCH_MIPS 1073741824L
#define FEATURES_HAS_VFPv3d16 1L

View File

@ -208,6 +208,11 @@ std::vector<std::pair<int, int> > CommonPackageManager::InitArmRating()
result.push_back(std::pair<int, int>(PLATFORM_TEGRA4, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_VFPv4 | FEATURES_HAS_NEON));
result.push_back(std::pair<int, int>(PLATFORM_TEGRA5, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_VFPv4 | FEATURES_HAS_NEON));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_AARCH64));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_AARCH64 | FEATURES_HAS_VFPv3));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_AARCH64 | FEATURES_HAS_VFPv3 | FEATURES_HAS_VFPv4));
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_AARCH64 | FEATURES_HAS_VFPv3 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON));
return result;
}

View File

@ -302,20 +302,13 @@ PackageInfo::PackageInfo(int version, int platform, int cpu_id, std::string inst
}
#endif
}
else if (ARCH_ARMv8 & CpuID)
#ifdef __SUPPORT_AARCH64
else if (ARCH_AARCH64 & CpuID)
{
LOGD("PackageInfo::PackageInfo: package arch ARMv8");
#ifdef __SUPPORT_ARMEABI_V8
FullName += string("_") + ARCH_ARMv8_NAME;
#else
FullName += string("_") + ARCH_ARMv7_NAME;
#endif
//string features = JoinARMFeatures(CpuID);
//if (!features.empty())
//{
// FullName += string("_") + features;
//}
LOGD("PackageInfo::PackageInfo: package arch AARCH64");
FullName += string("_") + ARCH_AARCH64_NAME;
}
#endif
#ifdef __SUPPORT_MIPS
else if (ARCH_MIPS & CpuID)
{
@ -460,14 +453,22 @@ InstallPath(install_path)
{
CpuID = ARCH_ARMv7 | SplitARMFeatures(features);
}
#ifdef __SUPPORT_AARCH64
else if (ARCH_AARCH64_NAME == features[2])
{
CpuID = ARCH_AARCH64 | SplitARMFeatures(features);
}
#endif
else if (ARCH_X86_NAME == features[2])
{
CpuID = ARCH_X86 | SplitIntelFeatures(features);
}
#ifdef __SUPPORT_INTEL_x64
else if (ARCH_X64_NAME == features[2])
{
CpuID = ARCH_X64 | SplitIntelFeatures(features);
}
#endif
#ifdef __SUPPORT_MIPS
else if (ARCH_MIPS_NAME == features[2])
{

View File

@ -10,7 +10,7 @@
#define ARCH_ARMv5_NAME "armv5"
#define ARCH_ARMv6_NAME "armv6"
#define ARCH_ARMv7_NAME "armv7a"
#define ARCH_ARMv8_NAME "armv8"
#define ARCH_AARCH64_NAME "aarch64"
#define FEATURES_HAS_VFPv3d16_NAME "vfpv3d16"
#define FEATURES_HAS_VFPv3_NAME "vfpv3"

View File

@ -146,6 +146,12 @@ TEST(CpuID, CheckMips)
EXPECT_TRUE(cpu_id & ARCH_MIPS);
}
#endif
#elif defined(__aarch64__)
TEST(CpuID, CheckAarch64)
{
int cpu_id = GetCpuID();
EXPECT_TRUE(cpu_id & ARCH_AARCH64);
}
#else
TEST(TegraDetector, Detect)
{

View File

@ -52,6 +52,13 @@ TEST(PackageInfo, FullNameArmv7VFPv3Neon)
#endif
}
TEST(PackageInfo, FullNameAarch64)
{
PackageInfo info(2041000, PLATFORM_UNKNOWN, ARCH_AARCH64);
string name = info.GetFullName();
EXPECT_STREQ("org.opencv.lib_v24_aarch64", name.c_str());
}
TEST(PackageInfo, FullNameArmv5)
{
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv5);

View File

@ -54,6 +54,14 @@ TEST(PackageManager, GetPackagePathForArmv7)
EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a/lib", path.c_str());
}
TEST(PackageManager, GetPackagePathForAarch64)
{
PackageManagerStub pm;
EXPECT_TRUE(pm.InstallVersion(2041100, PLATFORM_UNKNOWN, ARCH_AARCH64));
string path = pm.GetPackagePathByVersion(2041100, PLATFORM_UNKNOWN, ARCH_AARCH64);
EXPECT_STREQ("/data/data/org.opencv.lib_v24_aarch64/lib", path.c_str());
}
TEST(PackageManager, GetPackagePathForArmv7Neon)
{
PackageManagerStub pm;

View File

@ -10,7 +10,7 @@ public class HardwareDetector
public static final int ARCH_ARMv5 = 0x04000000;
public static final int ARCH_ARMv6 = 0x08000000;
public static final int ARCH_ARMv7 = 0x10000000;
public static final int ARCH_ARMv8 = 0x20000000;
public static final int ARCH_AARCH64 = 0x20000000;
public static final int ARCH_MIPS = 0x40000000;
// Platform specific features

View File

@ -7,6 +7,7 @@ import java.util.StringTokenizer;
import org.opencv.engine.HardwareDetector;
import org.opencv.engine.MarketConnector;
import org.opencv.engine.OpenCVEngineInterface;
import org.opencv.engine.OpenCVEngineService;
import org.opencv.engine.OpenCVLibraryInfo;
import org.opencv.engine.R;
import android.annotation.TargetApi;
@ -140,11 +141,11 @@ public class ManagerActivity extends Activity
}
else if ((CpuId & HardwareDetector.ARCH_ARMv7) == HardwareDetector.ARCH_ARMv7)
{
HardwarePlatformView.setText("ARM v7 " + JoinArmFeatures(CpuId));
HardwarePlatformView.setText("ARM v7a " + JoinArmFeatures(CpuId));
}
else if ((CpuId & HardwareDetector.ARCH_ARMv8) == HardwareDetector.ARCH_ARMv8)
else if ((CpuId & HardwareDetector.ARCH_AARCH64) == HardwareDetector.ARCH_AARCH64)
{
HardwarePlatformView.setText("ARM v8 " + JoinArmFeatures(CpuId));
HardwarePlatformView.setText("AARCH64 (ARM64 v8a) " + JoinArmFeatures(CpuId));
}
else if ((CpuId & HardwareDetector.ARCH_MIPS) == HardwareDetector.ARCH_MIPS)
{
@ -220,7 +221,8 @@ public class ManagerActivity extends Activity
public void onReceive(Context context, Intent intent) {
Log.d("OpenCVManager/Receiver", "Broadcast message " + intent.getAction() + " receiver");
Log.d("OpenCVManager/Receiver", "Filling package list on broadcast message");
if (!bindService(new Intent("org.opencv.engine.BIND"), new OpenCVEngineServiceConnection(), Context.BIND_AUTO_CREATE))
if (!bindService(new Intent("org.opencv.engine.BIND"),
new OpenCVEngineServiceConnection(), Context.BIND_AUTO_CREATE))
{
TextView EngineVersionView = (TextView)findViewById(R.id.EngineVersionValue);
EngineVersionView.setText("not avaliable");
@ -251,7 +253,7 @@ public class ManagerActivity extends Activity
if (HardwareDetector.mIsReady) {
Log.d(TAG, "Filling package list on resume");
OpenCVEngineServiceConnection connection = new OpenCVEngineServiceConnection();
if (!bindService(new Intent("org.opencv.engine.BIND"), connection, Context.BIND_AUTO_CREATE)) {
if (!bindService(new Intent(this, OpenCVEngineService.class), connection, Context.BIND_AUTO_CREATE)) {
Log.e(TAG, "Cannot bind to OpenCV Manager service!");
TextView EngineVersionView = (TextView)findViewById(R.id.EngineVersionValue);
if (EngineVersionView != null)

View File

@ -4,4 +4,4 @@ cd `dirname $0`/..
mkdir -p build_android_service
cd build_android_service
cmake -DCMAKE_TOOLCHAIN_FILE=../android/android.toolchain.cmake -DANDROID_TOOLCHAIN_NAME="arm-linux-androideabi-4.4.3" -DANDROID_STL=stlport_static -DANDROID_STL_FORCE_FEATURES=OFF -DBUILD_ANDROID_SERVICE=ON -DANDROID_SOURCE_TREE=~/Projects/AndroidSource/ServiceStub/ $@ ../..
cmake -DCMAKE_TOOLCHAIN_FILE=../android/android.toolchain.cmake -DANDROID_TOOLCHAIN_NAME="arm-linux-androideabi-4.6" -DANDROID_STL=stlport_static -DANDROID_STL_FORCE_FEATURES=OFF -DBUILD_ANDROID_SERVICE=ON -DANDROID_SOURCE_TREE=~/Projects/AndroidSource/ServiceStub/ $@ ../..