Skip to content

Commit

Permalink
Merge pull request marshall#25 from wheniwork/android5.1-regex
Browse files Browse the repository at this point in the history
Android 5.1 regex
  • Loading branch information
marshall authored Mar 14, 2017
2 parents b0035ce + 1ea8afe commit 4109ad3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions logcatcolor/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ def init_packages(self, packages):

self.pid_map = {}
self.package_search = {}

if packages:
for package in packages:
search_string = 'Start proc ' + package
regex = re.compile(search_string + ".*?pid=(\\d+)", re.IGNORECASE|re.DOTALL)
self.package_search[package] = (search_string, regex)
regex51 = re.compile(r'Start proc (\d+):' + package)

self.package_search[package] = (search_string, regex, regex51)

def init_tags(self, tags):
self.tags = None
Expand Down Expand Up @@ -89,6 +91,9 @@ def process_new_pid(self, data):
match = self.package_search[package][1].search(string)
if match:
self.pid_map[package] = match.group(1)
match51 = self.package_search[package][2].search(string)
if match51:
self.pid_map[package] = match51.group(1)

def include(self, data):
if not data:
Expand Down
6 changes: 5 additions & 1 deletion test/profile_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ def test_package_name_filter(self):
self.assertFalse(profile.include({'message' : 'Start proc com.example.test for activity tw.com.xxxx.android.yyyy/.333Activity: pid=123456 uid=10105 gids={3003}'}))
self.assertTrue(profile.include({'pid' : '123456', 'message' : 'foo bar'}))

def test_package_name_filter_android_51(self):
profile = Profile(name = 'package_filt', packages = ['com.example.test'])
self.assertFalse(profile.include({'message' : 'Start proc 26360:com.example.test/u0a208 for activity tw.com.xxxx.android.yyyy/com.example.test.ui.MainActivity'}))
self.assertTrue(profile.include({'pid' : '26360', 'message' : 'foo bar'}))

def test_empty_package_will_still_work(self):
profile = Profile(name = 'package_filt')
self.assertTrue(profile.include({'message' : 'Start proc com.example.test for activity tw.com.xxxx.android.yyyy/.333Activity: pid=123456 uid=10105 gids={3003}'}))

0 comments on commit 4109ad3

Please sign in to comment.