Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix StorageManager.getStorageVolumes signature - it returns a List, not an array. #22

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/List.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "LinkAddress.h"
#include "RouteInfo.h"
#include "InetAddress.h"
#include "StorageVolume.h"

#include "jutils-details.hpp"

Expand Down Expand Up @@ -55,3 +56,4 @@ template class CJNIList<CJNIURIPermission>;
template class CJNIList<CJNILinkAddress>;
template class CJNIList<CJNIRouteInfo>;
template class CJNIList<CJNIInetAddress>;
template class CJNIList<CJNIStorageVolume>;
30 changes: 2 additions & 28 deletions src/StorageManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,12 @@
*/

#include "StorageManager.h"
#include "ClassLoader.h"

#include "jutils-details.hpp"

using namespace jni;


// Not in public API

std::vector<CJNIStorageVolume> CJNIStorageManager::getStorageVolumes()
{
jmethodID mid = get_method_id(m_object, "getStorageVolumes", "()[Landroid/os/storage/StorageVolume;");
if (mid != NULL)
return jcast<CJNIStorageVolumes>(call_method<jhobjectArray>(m_object, mid));
else
return std::vector<CJNIStorageVolume>();
}

std::vector<std::string> CJNIStorageManager::getVolumePaths()
{
jmethodID mid = get_method_id(m_object, "getVolumePaths", "()[Ljava/lang/String;");
if (mid != NULL)
return jcast<std::vector<std::string>>(call_method<jhobjectArray>(m_object, mid));
else
return std::vector<std::string>();
}

std::string CJNIStorageManager::getVolumeState(const std::string& mountPoint)
CJNIList<CJNIStorageVolume> CJNIStorageManager::getStorageVolumes()
{
jmethodID mid = get_method_id(m_object, "getVolumeState", "(Ljava/lang/String;)Ljava/lang/String;");
if (mid != NULL)
return jcast<std::string>(call_method<jhstring>(m_object, mid, jcast<jhstring>(mountPoint)));
else
return "";
return call_method<jhobject>(m_object, "getStorageVolumes", "()Ljava/util/List;");
}
10 changes: 4 additions & 6 deletions src/StorageManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,18 @@

#include "JNIBase.h"

#include "StorageVolume.h"
#include "List.h"

class CJNIStorageVolume;

class CJNIStorageManager : public CJNIBase
{
public:
CJNIStorageManager(const jni::jhobject &object) : CJNIBase(object) {};
~CJNIStorageManager() {};

std::vector<CJNIStorageVolume> getStorageVolumes();
std::vector<std::string> getVolumePaths();
std::string getVolumeState(const std::string& mountPoint);
CJNIList<CJNIStorageVolume> getStorageVolumes();

private:
CJNIStorageManager();
};

typedef std::vector<CJNIStorageVolume> CJNIStorageVolumes;
3 changes: 2 additions & 1 deletion src/StorageVolume.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "JNIBase.h"

#include "Context.h"
#include "List.h"

class CJNIStorageVolume : public CJNIBase
{
Expand All @@ -48,4 +49,4 @@ class CJNIStorageVolume : public CJNIBase
CJNIStorageVolume();
};

typedef std::vector<CJNIStorageVolume> CJNIStorageVolumes;
typedef CJNIList<CJNIStorageVolume> CJNIStorageVolumes;