headdesk 0.11.3 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/Gemfile.lock +1 -1
- data/docs/activity_alias.md +46 -0
- data/docs/teak/api21_icon.md +3 -3
- data/lib/headdesk/apk.rb +10 -4
- data/lib/headdesk/checks/activity_alias.rb +47 -0
- data/lib/headdesk/checks/teak.rb +1 -1
- data/lib/headdesk/report.rb +1 -1
- data/lib/headdesk/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32bd2bbb779c1bf25077fcbe9680c62e66237ca200b0d37c8d38a637ee0a80a4
|
4
|
+
data.tar.gz: ba38100146dbaab98d4c355548980ca9133e5ba4fa1bc192b1ac6c2cfd7ea27a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8998523ae8fc26ed6717b871399b0810435efab9bf88d900af6b61746b9dc5f6563b04c4e299dc33e0204adee5c8788b8d7fdd2127297d9e5f94fc972aa0c74
|
7
|
+
data.tar.gz: fbd63dd5c57e087e658bfb487abbd7c690ee6c8aa137dd773b92c0e35a68f0c3fae23c59b85d834dd3b7035469ebe9b4bc4f0fda0e356506792bd2fc47595090
|
data/.rspec
ADDED
data/Gemfile.lock
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
# activity_alias
|
2
|
+
Ensures that each `<activity-alias>` declared in the `AndroidManifest.xml` is valid.
|
3
|
+
|
4
|
+
## Will Skip If
|
5
|
+
* `AndroidManifest.xml` does not contain any `<activity-alias>` nodes.
|
6
|
+
|
7
|
+
## Will Fail If
|
8
|
+
* An `<activity-alias>` has a `targetActivity` which does not exist in the `AndroidManifest.xml`.
|
9
|
+
* An `<activity-alias>` does not contain an `<intent-filter>` or...
|
10
|
+
* An `<intent-filter>` does not include `<action android:name="android.intent.action.MAIN" />`.
|
11
|
+
* An `<intent-filter>` does not include `<category android:name="android.intent.category.LAUNCHER" />`.
|
12
|
+
|
13
|
+
## Exports
|
14
|
+
The `<activity-alias>` nodes present.
|
15
|
+
|
16
|
+
### Example
|
17
|
+
```json
|
18
|
+
{
|
19
|
+
"aliases":[
|
20
|
+
{
|
21
|
+
"name":"com.unity3d.player.UnityPlayerActivity",
|
22
|
+
"targetActivity":"io.teak.sdk.wrapper.unity.TeakUnityPlayerActivity"
|
23
|
+
}
|
24
|
+
]
|
25
|
+
}
|
26
|
+
```
|
27
|
+
|
28
|
+
## Reason
|
29
|
+
When an app changes the class of its main `<activity>` any shortcut that the app, or the user, has created will be removed.
|
30
|
+
|
31
|
+
To avoid this, apps can use `<activity-alias>` to redirect any reference to the old activity to a new activity.
|
32
|
+
|
33
|
+
An `<activity-alias>` must point to a valid `<activity>` and must include intent filters which will redirect the `android.intent.action.MAIN` action and `android.intent.category.LAUNCHER` category, otherwise shortcuts will not be preserved.
|
34
|
+
|
35
|
+
## Resolution
|
36
|
+
Make sure your `<activity-alias>` has a `targetActivity` which points to an `<activity>` defined in `AndroidManifest.xml`
|
37
|
+
```xml
|
38
|
+
<activity-alias
|
39
|
+
android:name="your.old.activity.name"
|
40
|
+
android:targetActivity="your.new.activity.name" >
|
41
|
+
<intent-filter>
|
42
|
+
<action android:name="android.intent.action.MAIN" />
|
43
|
+
<category android:name="android.intent.category.LAUNCHER" />
|
44
|
+
</intent-filter>
|
45
|
+
</activity-alias>
|
46
|
+
```
|
data/docs/teak/api21_icon.md
CHANGED
@@ -13,10 +13,10 @@ Also verifies following files have the specified image dimensions:
|
|
13
13
|
|
14
14
|
## Will Fail If
|
15
15
|
* There is no drawable resource for `io_teak_small_notification_icon`.
|
16
|
-
* There is no v21 drawable resource for `io_teak_small_notification_icon
|
16
|
+
* There is no v21 drawable resource for `io_teak_small_notification_icon`.
|
17
17
|
* The drawable resources point to the same image.
|
18
|
-
* The v21 drawable resources do not exist, or are the incorrect size
|
19
|
-
* `drawable-mdpi/[icon_v21].png` does not exist, or is not
|
18
|
+
* The v21 drawable resources do not exist, or are the incorrect size...
|
19
|
+
* `drawable-mdpi/[icon_v21].png` does not exist, or is not 24x2
|
20
20
|
* `drawable-hdpi/[icon_v21].png` does not exist, or is not 36x36
|
21
21
|
* `drawable-xhdpi/[icon_v21].png` does not exist, or is not 48x48
|
22
22
|
* `drawable-xxhdpi/[icon_v21].png` does not exist, or is not 72x72
|
data/lib/headdesk/apk.rb
CHANGED
@@ -17,21 +17,27 @@ module Headdesk
|
|
17
17
|
attr_reader :yaml, :sdk_info, :android_manifest, :resources
|
18
18
|
|
19
19
|
# :reek:TooManyStatements
|
20
|
-
def initialize(path)
|
20
|
+
def initialize(path, manifest_contents = nil, yaml_contents = nil)
|
21
21
|
@path = path
|
22
22
|
|
23
23
|
android_manifest_xml = File.join(@path, 'AndroidManifest.xml').freeze
|
24
24
|
apktool_yml = File.join(@path, 'apktool.yml').freeze
|
25
25
|
|
26
|
-
throw CliError.new('Path did not contain AndroidManifest.xml
|
26
|
+
throw CliError.new('Path did not contain AndroidManifest.xml') unless File.exist?(android_manifest_xml) || manifest_contents
|
27
|
+
throw CliError.new('Path did not contain apktool.yml') unless File.exist?(apktool_yml) || yaml_contents
|
27
28
|
|
28
|
-
@yaml = YAML.load_file(apktool_yml)
|
29
|
+
@yaml = yaml_contents || YAML.load_file(apktool_yml)
|
29
30
|
@sdk_info = @yaml['sdkInfo']
|
30
31
|
@resources = Resources.new(@path)
|
31
32
|
|
32
|
-
|
33
|
+
manifest = Nokogiri::XML(manifest_contents) if manifest_contents
|
34
|
+
manifest ||= File.open(android_manifest_xml) do |file|
|
33
35
|
Nokogiri::XML(file)
|
34
36
|
end
|
37
|
+
|
38
|
+
@android_manifest = manifest.xpath('manifest')
|
39
|
+
throw CliError.new('Invalid Android manifest') if @android_manifest.empty?
|
40
|
+
@android_manifest = @android_manifest.first
|
35
41
|
end
|
36
42
|
|
37
43
|
def analyze
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Headdesk
|
4
|
+
module Checks
|
5
|
+
#
|
6
|
+
# An <activity-alias> is most commonly used to change the class of the MAIN
|
7
|
+
# activity, while preserving shortcuts.
|
8
|
+
#
|
9
|
+
# <intent-filter> must include both:
|
10
|
+
# <action android:name="android.intent.action.MAIN" />
|
11
|
+
# <category android:name="android.intent.category.LAUNCHER" />
|
12
|
+
#
|
13
|
+
# and must point to an <activity> that has been defined
|
14
|
+
#
|
15
|
+
class ActivityAlias
|
16
|
+
include Check::APK
|
17
|
+
|
18
|
+
check_name 'activity_alias'
|
19
|
+
describe "<activity-alias> is used to preserve app shortcuts"
|
20
|
+
def call
|
21
|
+
describe 'AndroidManifest.xml contains one or more <activity-alias>'
|
22
|
+
skip_check if: apk.android_manifest.xpath('application/activity-alias').empty?
|
23
|
+
|
24
|
+
aliases = []
|
25
|
+
apk.android_manifest.xpath('application/activity-alias').each do |activity_alias|
|
26
|
+
describe "AndroidManifest.xml contains <activity> '#{activity_alias.attributes['targetActivity']}'"
|
27
|
+
fail_check if: apk.android_manifest.xpath("application/activity[@android:name='#{activity_alias.attributes['targetActivity']}']").empty?
|
28
|
+
|
29
|
+
describe "<activity-alias> '#{activity_alias.attributes['name']}' -> '#{activity_alias.attributes['targetActivity']}' has '<intent-filter>'"
|
30
|
+
fail_check if: activity_alias.xpath("intent-filter").empty?
|
31
|
+
|
32
|
+
describe "<intent-filter> contains '<action android:name=\"android.intent.action.MAIN\" />'"
|
33
|
+
fail_check if: activity_alias.xpath("intent-filter/action[@android:name='android.intent.action.MAIN']").empty?
|
34
|
+
|
35
|
+
describe "<intent-filter> contains '<category android:name=\"android.intent.category.LAUNCHER\" />'"
|
36
|
+
fail_check if: activity_alias.xpath("intent-filter/category[@android:name='android.intent.category.LAUNCHER']").empty?
|
37
|
+
|
38
|
+
aliases << {
|
39
|
+
name: activity_alias.attributes['name'],
|
40
|
+
targetActivity: activity_alias.attributes['targetActivity']
|
41
|
+
}
|
42
|
+
end
|
43
|
+
export aliases: aliases
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/headdesk/checks/teak.rb
CHANGED
data/lib/headdesk/report.rb
CHANGED
@@ -73,7 +73,7 @@ module Headdesk
|
|
73
73
|
class APKReport < Report
|
74
74
|
def initialize(apk)
|
75
75
|
super()
|
76
|
-
@bundle_id = apk.android_manifest.
|
76
|
+
@bundle_id = apk.android_manifest.attributes['package']
|
77
77
|
@file_name = apk.yaml['apkFileName']
|
78
78
|
@android_sdk = apk.sdk_info
|
79
79
|
end
|
data/lib/headdesk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: headdesk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -180,6 +180,7 @@ extra_rdoc_files: []
|
|
180
180
|
files:
|
181
181
|
- ".gitignore"
|
182
182
|
- ".reek.yml"
|
183
|
+
- ".rspec"
|
183
184
|
- ".rubocop.yml"
|
184
185
|
- ".ruby-gemset"
|
185
186
|
- ".ruby-version"
|
@@ -191,6 +192,7 @@ files:
|
|
191
192
|
- bin/console
|
192
193
|
- bin/facebook_sdk_versions
|
193
194
|
- bin/setup
|
195
|
+
- docs/activity_alias.md
|
194
196
|
- docs/api26.md
|
195
197
|
- docs/facebook.md
|
196
198
|
- docs/receiver.md
|
@@ -209,6 +211,7 @@ files:
|
|
209
211
|
- lib/headdesk/apk/resources.rb
|
210
212
|
- lib/headdesk/apktool.rb
|
211
213
|
- lib/headdesk/check.rb
|
214
|
+
- lib/headdesk/checks/activity_alias.rb
|
212
215
|
- lib/headdesk/checks/api26.rb
|
213
216
|
- lib/headdesk/checks/facebook.rb
|
214
217
|
- lib/headdesk/checks/receiver.rb
|