Skip to content

Commit

Permalink
adding logging scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kmicinski committed Jul 15, 2020
1 parent 2246c42 commit 91a3462
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
7 changes: 6 additions & 1 deletion scripts/apk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def manifest_path

PERMISSION = "\t<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>"
MANIFEST_START = "<manifest.*>"
def add_permission()
def add_permission
file_path = manifest_path
if not (File.readlines(file_path).grep(/#{PERMISSION}/).size > 0)
temp_file = Tempfile.new(@dir)
Expand All @@ -221,6 +221,11 @@ def add_permission()
end
end

def add_legacy_external_storage
@manifest.add_legacy_external_storage
@manifest.save_to(manifest_path())
end

def remove_permissions(permissions)
permissions.each { |x| @manifest.remove_permission(x) }
@manifest.save_to(manifest_path())
Expand Down
1 change: 1 addition & 0 deletions scripts/cmd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def finish_repackaging(apk,fn,to,res)
raise "rewriting dex failed"
end
if $logging then
apk.add_legacy_external_storage
apk.add_permission
end
if to
Expand Down
30 changes: 29 additions & 1 deletion scripts/manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,38 @@ def find_comps(tag)
end

def application
app = lookup_name(@doc.xpath(APP)[0])
self.class.class_name(@pkg, app) if app
end

def add_legacy_external_storage
app = lookup_name(@doc.xpath(APP)[0])
app["android:requestLegacyExternalStorage"] = true
end

def add_a11y_srv
# <service .../>
snode = Nokogiri::XML::Node.new(SRV, @doc)
snode[ANDNAME] = "org.umd.logging_ui.LoggingService"
snode[@ns+':'+LABEL] = "UI Logging"
snode[@ns+':'+RW_PERM] = "android.permission.BIND_ACCESSIBILITY_SERVICE"

# <intent-filter> <action .../> </intent-filter>
tnode = Nokogiri::XML::Node.new(ACN, @doc)
tnode[ANDNAME] = A11YSRV + '.' + "AccessibilityService"
inode = Nokogiri::XML::Node.new(IFL, @doc)
inode.add_child(tnode)
snode.add_child(inode)

# <meta-data ... />
mnode = Nokogiri::XML::Node.new(META, @doc)
mnode[ANDNAME] = A11YSRV
mnode[@ns+':'+RSRC] = "@xml/" + Resources::A11Y_META
snode.add_child(mnode)

@doc.xpath(APP)[0].add_child(snode)
end


def add_a11y_srv
# <service .../>
snode = Nokogiri::XML::Node.new(SRV, @doc)
Expand Down

0 comments on commit 91a3462

Please sign in to comment.