Skip to content

Commit

Permalink
Merge pull request #1745 from tryzealot/feat/native-codes-for-android
Browse files Browse the repository at this point in the history
Add native codes for Android
  • Loading branch information
icyleaf authored Nov 27, 2024
2 parents 7e4774a + 81dc776 commit 4d47980
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ gem 'webp-ffi', '~> 0.4.0'
# Helper
gem 'rake', '~> 13.0.4'
gem 'rails-settings-cached', '~> 2.9.5'
gem 'app-info', '~> 3.2.0'
gem 'app-info', '~> 3.3.0'
gem 'faraday', '~> 2.12.1'
gem 'rqrcode'

Expand Down
18 changes: 9 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ GEM
android_parser (2.7.0)
rexml (> 3.0)
rubyzip (>= 1.0, < 3.0)
app-info (3.2.0)
app-info (3.3.0)
CFPropertyList (>= 2.3.4, < 3.1.0)
android_parser (>= 2.7, < 3.0)
base64 (~> 0.2.0)
google-protobuf (>= 4.27.1, < 5.0.0)
google-protobuf (>= 4.27.5, < 5.0.0)
icns (~> 0.2.0)
image_size (>= 1.5, < 3.5)
nkf (~> 0.2.0)
Expand Down Expand Up @@ -205,19 +205,19 @@ GEM
fugit (>= 1.11.0)
railties (>= 6.1.0)
thor (>= 1.0.0)
google-protobuf (4.28.2)
google-protobuf (4.28.3)
bigdecimal
rake (>= 13)
google-protobuf (4.28.2-aarch64-linux)
google-protobuf (4.28.3-aarch64-linux)
bigdecimal
rake (>= 13)
google-protobuf (4.28.2-arm64-darwin)
google-protobuf (4.28.3-arm64-darwin)
bigdecimal
rake (>= 13)
google-protobuf (4.28.2-x86_64-darwin)
google-protobuf (4.28.3-x86_64-darwin)
bigdecimal
rake (>= 13)
google-protobuf (4.28.2-x86_64-linux)
google-protobuf (4.28.3-x86_64-linux)
bigdecimal
rake (>= 13)
graphiql-rails (1.10.1)
Expand All @@ -237,7 +237,7 @@ GEM
image_size (3.4.0)
interception (0.5)
io-console (0.7.2)
iostruct (0.1.3)
iostruct (0.2.0)
irb (1.14.1)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
Expand Down Expand Up @@ -639,7 +639,7 @@ PLATFORMS
DEPENDENCIES
active_model_serializers (~> 0.10.14)
activejob-status (~> 1.0.2)
app-info (~> 3.2.0)
app-info (~> 3.3.0)
awesome_print
better_errors
binding_of_caller
Expand Down
10 changes: 8 additions & 2 deletions app/helpers/apps_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ def app_icon(release, options = {})
image_tag(release.icon_url, **options)
end

def app_device(device)

def native_codes(release)
native_codes = release.native_codes
return if native_codes.blank?

count = native_codes.size
return t('releases.show.multi_native_codes') if count > 0

native_codes[0]
end

def logged_in_or_without_auth?(release)
Expand Down
19 changes: 18 additions & 1 deletion app/models/release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@ def app_name
"#{app.name} #{scheme.name} #{channel.name}"
end

def native_codes(original: true)
return unless native_codes = metadata&.native_codes
return native_codes if original

native_codes.each_with_object({}) do |code, obj|
key = nil
key = :x86 if code.include?('x86')
key = :arm if code.include?('arm')
key = :mips if code.include?('mips')
key = riscv if code.include?('riscv')
next unless key

obj[key] ||= []
obj[key] = code
end
end

def size
file&.size
end
Expand Down Expand Up @@ -266,7 +283,7 @@ def determine_file_exist
def determine_disk_space
upload_path = Sys::Filesystem.stat(Rails.root.join('public/uploads'))

# Combo Orginal file and unarchived files
# Combo original file and unarchived files
if upload_path.bytes_free < (self&.file&.size || 0) * 3
errors.add(:file, :not_enough_space)
end
Expand Down
13 changes: 7 additions & 6 deletions app/services/teardown_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ def process_android(parser, metadata)

metadata.bundle_id = parser.package_name
metadata.target_sdk_version = parser.target_sdk_version
metadata.activities = parser&.activities&.select(&:present?).map(&:name)
metadata.permissions = parser&.use_permissions&.select(&:present?) || []
metadata.features = parser&.use_features&.select(&:present?) || []
metadata.services = parser&.services&.sort_by(&:name)&.select(&:present?)&.map(&:name) || []
metadata.url_schemes = parser&.schemes&.sort
metadata.deep_links = parser&.deep_links&.sort
metadata.activities = parser.activities&.select(&:present?).map(&:name)
metadata.permissions = parser.use_permissions&.select(&:present?) || []
metadata.features = parser.use_features&.select(&:present?) || []
metadata.services = parser.services&.sort_by(&:name)&.select(&:present?)&.map(&:name) || []
metadata.url_schemes = parser.schemes&.sort
metadata.deep_links = parser.deep_links&.sort
metadata.native_codes = parser.native_codes

process_signature_certs(parser, metadata)
end
Expand Down
4 changes: 4 additions & 0 deletions app/views/releases/body/_metadata.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
li title="#{t('releases.show.release_type')}" data-bs-toggle="tooltip" data-bs-custom-class="default-tooltip"
i.fas.fa-cubes
= release_type_url_builder(release)
- if release.native_codes.present?
li title="#{t('releases.show.native_codes')} #{release.native_codes.join(', ')}" data-bs-toggle="tooltip" data-bs-custom-class="default-tooltip"
i.fas.fa-microchip
= native_codes(release)
- if release.file.present?
li title="#{t('releases.show.filesize')}" data-bs-toggle="tooltip" data-bs-custom-class="default-tooltip"
i.fas.fa-weight
Expand Down
7 changes: 6 additions & 1 deletion app/views/teardowns/_android.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ruby:
begin
app_name = @metadata.name
rescue Android::NotFoundError
app_name = t('teardowns.show.unknow_app_name')
app_name = t('teardowns.show.unkonwn')
end

.col-md-6
Expand All @@ -26,6 +26,11 @@ ruby:
dt = t('teardowns.show.package_name')
dd
pre = @metadata.packet_name
dt
= t('teardowns.show.native_codes')
dd
pre
= @metadata.native_codes.join(', ')
dt
= t('teardowns.show.supported_device')
dd
Expand Down
2 changes: 1 addition & 1 deletion app/views/teardowns/_harmonyos.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ruby:
begin
app_name = @metadata.name
rescue Android::NotFoundError
app_name = t('teardowns.show.unknow_app_name')
app_name = t('teardowns.show.unkonwn')
end

.col-md-6
Expand Down
5 changes: 4 additions & 1 deletion config/locales/zealot/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ en:
device_type: Device
release_version: Release version (build version)
release_type: Release type
native_codes: Native codes
multi_native_codes: Universal
filesize: File size
uploaded_at: Uploaded time %{date}
git_branch: Git branch
Expand Down Expand Up @@ -639,11 +641,12 @@ en:
expired: Expired now!
related_app: Release related
related_body: This teardown was relates with %{link}
unknow_app_name: Unknown
unkonwn: Unknown
metadata: Metadata
app_name: App name
version: Version
package_name: Bundle id (package name)
native_codes: Native codes
supported_device: Supported device
android_min_sdk: Minimum SDK
android_target_sdk: Target SDK
Expand Down
5 changes: 4 additions & 1 deletion config/locales/zealot/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ zh-CN:
device_type: 平台
release_version: 构建版本
release_type: 打包类型
native_codes: 原生架构
multi_native_codes: 多架构
filesize: 文件体积
uploaded_at: 上传时间 %{date}
git_branch: Git 分支
Expand Down Expand Up @@ -629,11 +631,12 @@ zh-CN:
expired: 刚好过期
related_app: 关联提醒
related_body: 当前解包关联的应用是%{link}
unknow_app_name: 未知
unkonwn: 未知
metadata: 应用信息
app_name: 名称
version: 版本
package_name: 包名
native_codes: 原生架构
supported_device: 支持设备
android_min_sdk: 最低支持版本
android_target_sdk: 编译构建版本
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20241127060125_add_native_codes_to_metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddNativeCodesToMetadata < ActiveRecord::Migration[7.2]
def change
add_column :metadata, :native_codes, :jsonb, default: [], null: false
end
end
5 changes: 3 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.2].define(version: 2024_07_07_040749) do
ActiveRecord::Schema[7.2].define(version: 2024_11_27_060125) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Expand Down Expand Up @@ -258,6 +258,7 @@
t.datetime "updated_at", null: false
t.string "platform"
t.jsonb "deep_links", default: [], null: false
t.jsonb "native_codes", default: [], null: false
t.index ["checksum"], name: "index_metadata_on_checksum"
t.index ["release_id"], name: "index_metadata_on_release_id"
t.index ["user_id"], name: "index_metadata_on_user_id"
Expand Down Expand Up @@ -356,7 +357,7 @@
t.datetime "locked_at", precision: nil
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "locale", default: "zh-CN", null: false
t.string "locale", default: "en", null: false
t.string "appearance", default: "light", null: false
t.string "timezone", default: "Asia/Shanghai", null: false
end
Expand Down

0 comments on commit 4d47980

Please sign in to comment.