contents.push_back(inst->get_real_target());
AndroidManifestFile *manifest = new AndroidManifestFile(builder, *this);
+ for(set<string>::const_iterator i=permissions.begin(); i!=permissions.end(); ++i)
+ manifest->add_permission(*i);
list<Target *> resource_sources;
resource_sources.push_back(manifest);
Target *apk = apk_builder.create_target(apk_sources);
builder.get_build_graph().add_primary_target(*apk);
}
+
+
+AndroidApplicationComponent::Loader::Loader(AndroidApplicationComponent &c):
+ DataFile::DerivedObjectLoader<AndroidApplicationComponent, Component::Loader>(c)
+{
+ add("permission", &Loader::permission);
+}
+
+void AndroidApplicationComponent::Loader::permission(const string &perm)
+{
+ obj.permissions.insert(perm);
+}
#ifndef ANDROIDAPPLICATIONCOMPONENT_H_
#define ANDROIDAPPLICATIONCOMPONENT_H_
+#include <set>
#include "component.h"
class AndroidApplicationComponent: public Component
{
+public:
+ class Loader: public Msp::DataFile::DerivedObjectLoader<AndroidApplicationComponent, Component::Loader>
+ {
+ public:
+ Loader(AndroidApplicationComponent &);
+
+ private:
+ void permission(const std::string &);
+ };
+
+private:
+ std::set<std::string> permissions;
+
public:
AndroidApplicationComponent(SourcePackage &, const std::string &);
#include "builder.h"
#include "sourcepackage.h"
+using namespace std;
+
AndroidManifestFile::AndroidManifestFile(Builder &b, const AndroidApplicationComponent &a):
FileTarget(b, a.get_package(), a.get_package().get_temp_directory()/a.get_name()/"AndroidManifest.xml"),
native_lib(0)
{
native_lib = lib;
}
+
+void AndroidManifestFile::add_permission(const string &perm)
+{
+ permissions.insert(perm);
+}
#ifndef ANDROIDMANIFESTFILE_H_
#define ANDROIDMANIFESTFILE_H_
+#include <set>
#include "filetarget.h"
class AndroidApplicationComponent;
{
private:
SharedLibrary *native_lib;
+ std::set<std::string> permissions;
public:
AndroidManifestFile(Builder &, const AndroidApplicationComponent &);
void set_native_library(SharedLibrary *);
SharedLibrary *get_native_library() const { return native_lib; }
+
+ void add_permission(const std::string &);
+ const std::set<std::string> &get_permissions() const { return permissions; }
};
#endif
out.write("\t\t</activity>\n");
}
out.write("\t</application>\n");
+ const set<string> &permissions = manifest.get_permissions();
+ for(set<string>::const_iterator i=permissions.begin(); i!=permissions.end(); ++i)
+ IO::print(out, "\t<uses-permission android:name=\"%s\" />\n", *i);
out.write("</manifest>\n");
status = Task::SUCCESS;