diff options
author | Jeff Sharkey <jsharkey@android.com> | 2015-02-25 11:27:55 -0800 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2015-02-25 12:06:40 -0800 |
commit | 047d7f0c6ded6fb6b01a708070955647b7ff4ae7 (patch) | |
tree | 345411d75a0d4c2ef1d1430995d5b874dea350c6 /tools | |
parent | a18a2e3428d73369be7ab1663792f0a080e037ca (diff) | |
download | frameworks_base-047d7f0c6ded6fb6b01a708070955647b7ff4ae7.zip frameworks_base-047d7f0c6ded6fb6b01a708070955647b7ff4ae7.tar.gz frameworks_base-047d7f0c6ded6fb6b01a708070955647b7ff4ae7.tar.bz2 |
Relax Handler lint check slightly.
This way we avoid yelling at support library APIs.
Change-Id: I20bab887fe8b1c7f4d197273ddedbcda48c5a429
Diffstat (limited to 'tools')
-rw-r--r-- | tools/apilint/apilint.py | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/tools/apilint/apilint.py b/tools/apilint/apilint.py index 8af4f50..5c6d870 100644 --- a/tools/apilint/apilint.py +++ b/tools/apilint/apilint.py @@ -132,10 +132,14 @@ class Class(): if "extends" in raw: self.extends = raw[raw.index("extends")+1] + self.extends_path = self.extends.split(".") else: self.extends = None + self.extends_path = [] self.fullname = self.pkg.name + "." + self.fullname + self.fullname_path = self.fullname.split(".") + self.name = self.fullname[self.fullname.rindex(".")+1:] def __repr__(self): @@ -150,6 +154,7 @@ class Package(): raw = raw.split() self.name = raw[raw.index("package")+1] + self.name_path = self.name.split(".") def __repr__(self): return self.raw @@ -760,7 +765,7 @@ def verify_manager(clazz): if not clazz.name.endswith("Manager"): return for c in clazz.ctors: - error(clazz, c, None, "Managers must always be obtained from Context") + error(clazz, c, None, "Managers must always be obtained from Context; no direct constructors") def verify_boxed(clazz): @@ -846,35 +851,26 @@ def verify_callback_handlers(clazz): """Verifies that methods adding listener/callback have overload for specifying delivery thread.""" - # Ignore UI components which deliver things on main thread - skip = [ - "android.animation", - "android.view", - "android.graphics", - "android.transition", - "android.widget", - "android.webkit", - ] - for s in skip: - if clazz.fullname.startswith(s): return - if clazz.extends and clazz.extends.startswith(s): return - + # Ignore UI packages which assume main thread skip = [ - "android.app.ActionBar", - "android.app.AlertDialog", - "android.app.AlertDialog.Builder", - "android.app.Application", - "android.app.Activity", - "android.app.Dialog", - "android.app.Fragment", - "android.app.FragmentManager", - "android.app.LoaderManager", - "android.app.ListActivity", - "android.app.AlertDialog.Builder" - "android.content.Loader", + "animation", + "view", + "graphics", + "transition", + "widget", + "webkit", ] for s in skip: - if clazz.fullname == s or clazz.extends == s: return + if s in clazz.pkg.name_path: return + if s in clazz.extends_path: return + + # Ignore UI classes which assume main thread + if "app" in clazz.pkg.name_path or "app" in clazz.extends_path: + for s in ["ActionBar","Dialog","Application","Activity","Fragment","Loader"]: + if s in clazz.fullname: return + if "content" in clazz.pkg.name_path or "content" in clazz.extends_path: + for s in ["Loader"]: + if s in clazz.fullname: return found = {} by_name = collections.defaultdict(list) |