<commit_before>require File.join(pwd, 'lib/build/jake.rb')
require 'fileutils'

namespace 'device' do
  namespace 'android' do
    task :make_container, [:target_path] => 'device:android:production' do |t,args|

      target_path = args[:target_path]

      puts "Target path for prebuilt binaries: #{args}"

      FileUtils.mkdir_p target_path

      FileUtils.cp( File.join($bindir,'classes.dex'), target_path )

      FileUtils.mkdir_p File.join(target_path,'native','lib')

      Dir.glob(File.join($bindir,'tmp','**','lib*.so')) { |lib|
        arch = File.basename(File.dirname(lib))
        FileUtils::mkdir_p File.join(target_path,'native','lib',arch)
        FileUtils.cp(lib, File.join(target_path,'native','lib',arch))
      }

      FileUtils.cp( File.join($app_path,'build.yml'), target_path )
      
    end

  module AndroidPrebuild

    def self.determine_prebuild_path(config)
      require 'rhodes/containers'
      Rhodes::Containers::get_container_path_prefix('android', config)
    end

    def self.make_app_bundle
      $use_prebuild_data = true
      Rake::Task['build:android:rhobundle'].execute
      return $appassets
    end

    def self.generate_manifest(prebuilt_config,app_config)

      version = {'major' => 0, 'minor' => 0, 'patch' => 0, "build" => 0}
      if $app_config["version"]
        if $app_config["version"] =~ /^(\d+)$/
          version["major"] = $1.to_i
        elsif $app_config["version"] =~ /^(\d+)\.(\d+)$/
          version["major"] = $1.to_i
          version["minor"] = $2.to_i
        elsif $app_config["version"] =~ /^(\d+)\.(\d+)\.(\d+)$/
          version["major"] = $1.to_i
          version["minor"] = $2.to_i
          version["patch"] = $3.to_i
        elsif $app_config["version"] =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/
          version["major"] = $1.to_i
          version["minor"] = $2.to_i
          version["patch"] = $3.to_i
          version["build"] = $4.to_i
        else
          raise "Version number must be numeric and in one of these formats: major, major.minor, major.minor.patch, or major.minor.patch.build."
        end
      end

      version = version["major"]*1000000 + version["minor"]*10000 + version["patch"]*100 + version["build"]

      usesPermissions = ['android.permission.INTERNET', 'android.permission.PERSISTENT_ACTIVITY', 'android.permission.WAKE_LOCK']

      capabilities = []
      capabilities.concat(app_config['capabilities']) if app_config['capabilities']
      capabilities.concat(prebuilt_config['capabilities']) if prebuilt_config['capabilities']
      capabilities.uniq!

      capabilities.each do |cap|
        cap = ANDROID_PERMISSIONS[cap]
        next if cap.nil?
        cap = [cap] unless cap.is_a? Array

        cap.each do |cap_item|
          if cap_item.is_a? Proc
            #caps_proc << cap_item
            next
          end

          if cap_item.is_a? String
            usesPermissions << "android.permission.#{cap_item}"
            next
          end
        end
      end
      usesPermissions.uniq!

      hidden = get_boolean(prebuilt_config['hidden_app'])

      generator = ManifestGenerator.new JAVA_PACKAGE_NAME, $app_package_name, hidden, usesPermissions

      generator.versionName = prebuilt_config["version"]
      generator.versionCode = version
      generator.installLocation = 'auto'
      generator.minSdkVer = $min_sdk_level
      generator.maxSdkVer = $max_sdk_level<commit_msg>use only app' capabilities for prebuilt app<commit_after>require File.join(pwd, 'lib/build/jake.rb')
require 'fileutils'

namespace 'device' do
  namespace 'android' do
    task :make_container, [:target_path] => 'device:android:production' do |t,args|

      target_path = args[:target_path]

      puts "Target path for prebuilt binaries: #{args}"

      FileUtils.mkdir_p target_path

      FileUtils.cp( File.join($bindir,'classes.dex'), target_path )

      FileUtils.mkdir_p File.join(target_path,'native','lib')

      Dir.glob(File.join($bindir,'tmp','**','lib*.so')) { |lib|
        arch = File.basename(File.dirname(lib))
        FileUtils::mkdir_p File.join(target_path,'native','lib',arch)
        FileUtils.cp(lib, File.join(target_path,'native','lib',arch))
      }

      FileUtils.cp( File.join($app_path,'build.yml'), target_path )
      
    end

  module AndroidPrebuild

    def self.determine_prebuild_path(config)
      require 'rhodes/containers'
      Rhodes::Containers::get_container_path_prefix('android', config)
    end

    def self.make_app_bundle
      $use_prebuild_data = true
      Rake::Task['build:android:rhobundle'].execute
      return $appassets
    end

    def self.generate_manifest(prebuilt_config,app_config)

      version = {'major' => 0, 'minor' => 0, 'patch' => 0, "build" => 0}
      if $app_config["version"]
        if $app_config["version"] =~ /^(\d+)$/
          version["major"] = $1.to_i
        elsif $app_config["version"] =~ /^(\d+)\.(\d+)$/
          version["major"] = $1.to_i
          version["minor"] = $2.to_i
        elsif $app_config["version"] =~ /^(\d+)\.(\d+)\.(\d+)$/
          version["major"] = $1.to_i
          version["minor"] = $2.to_i
          version["patch"] = $3.to_i
        elsif $app_config["version"] =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/
          version["major"] = $1.to_i
          version["minor"] = $2.to_i
          version["patch"] = $3.to_i
          version["build"] = $4.to_i
        else
          raise "Version number must be numeric and in one of these formats: major, major.minor, major.minor.patch, or major.minor.patch.build."
        end
      end

      version = version["major"]*1000000 + version["minor"]*10000 + version["patch"]*100 + version["build"]

      usesPermissions = ['android.permission.INTERNET', 'android.permission.PERSISTENT_ACTIVITY', 'android.permission.WAKE_LOCK']

      capabilities = []
      capabilities.concat(app_config['capabilities']) if app_config['capabilities']
      capabilities.uniq!

      capabilities.each do |cap|
        cap = ANDROID_PERMISSIONS[cap]
        next if cap.nil?
        cap = [cap] unless cap.is_a? Array

        cap.each do |cap_item|
          if cap_item.is_a? Proc
            #caps_proc << cap_item
            next
          end

          if cap_item.is_a? String
            usesPermissions << "android.permission.#{cap_item}"
            next
          end
        end
      end
      usesPermissions.uniq!

      hidden = get_boolean(prebuilt_config['hidden_app'])

      generator = ManifestGenerator.new JAVA_PACKAGE_NAME, $app_package_name, hidden, usesPermissions

      generator.versionName = prebuilt_config["version"]
      generator.versionCode = version
      generator.installLocation = 'auto'
      generator.minSdkVer = $min_sdk_level
      generator.maxSdkVer = $max_sdk_level
{'fraction_non_alphanumeric': 0.1470674918950781, 'fraction_numerical': 0.008547008547008548, 'mean_word_length': 2.781058495821727, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2482395', 'n_tokens_mistral': 2240, 'n_tokens_neox': 2150, 'n_words': 392}