com.android.tools.lint.checks
Class WakelockDetector

java.lang.Object
  extended by com.android.tools.lint.detector.api.Detector
      extended by com.android.tools.lint.checks.WakelockDetector
All Implemented Interfaces:
com.android.tools.lint.detector.api.Detector.ClassScanner

public class WakelockDetector
extends com.android.tools.lint.detector.api.Detector
implements com.android.tools.lint.detector.api.Detector.ClassScanner

Checks for problems with wakelocks (such as failing to release them) which can lead to unnecessary battery usage.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.android.tools.lint.detector.api.Detector
com.android.tools.lint.detector.api.Detector.ClassScanner, com.android.tools.lint.detector.api.Detector.GradleScanner, com.android.tools.lint.detector.api.Detector.JavaScanner, com.android.tools.lint.detector.api.Detector.OtherFileScanner, com.android.tools.lint.detector.api.Detector.XmlScanner
 
Field Summary
static com.android.tools.lint.detector.api.Issue ISSUE
          Problems using wakelocks
 
Constructor Summary
WakelockDetector()
          Constructs a new WakelockDetector
 
Method Summary
 void afterCheckProject(com.android.tools.lint.detector.api.Context context)
           
 void checkCall(com.android.tools.lint.detector.api.ClassContext context, org.objectweb.asm.tree.ClassNode classNode, org.objectweb.asm.tree.MethodNode method, org.objectweb.asm.tree.MethodInsnNode call)
           
protected static int dfs(ControlFlowGraph.Node node)
          Search from the given node towards the target; return false if we reach an exit point such as a return or a call on the way there that is not within a try/catch clause.
 java.util.List<java.lang.String> getApplicableCallNames()
           
 
Methods inherited from class com.android.tools.lint.detector.api.Detector
afterCheckFile, afterCheckLibraryProject, appliesTo, appliesToFolder, appliesToResourceRefs, beforeCheckFile, beforeCheckLibraryProject, beforeCheckProject, checkClass, checkInstruction, createJavaVisitor, getApplicableAsmNodeTypes, getApplicableAttributes, getApplicableCallOwners, getApplicableElements, getApplicableFiles, getApplicableMethodNames, getApplicableNodeTypes, getSpeed, run, visitAttribute, visitBuildScript, visitDocument, visitElement, visitElementAfter, visitMethod, visitResourceReference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.android.tools.lint.detector.api.Detector.ClassScanner
checkClass, checkInstruction, getApplicableAsmNodeTypes, getApplicableCallOwners
 

Field Detail

ISSUE

public static final com.android.tools.lint.detector.api.Issue ISSUE
Problems using wakelocks

Constructor Detail

WakelockDetector

public WakelockDetector()
Constructs a new WakelockDetector

Method Detail

afterCheckProject

public void afterCheckProject(@NonNull
                              com.android.tools.lint.detector.api.Context context)
Overrides:
afterCheckProject in class com.android.tools.lint.detector.api.Detector

getApplicableCallNames

@Nullable
public java.util.List<java.lang.String> getApplicableCallNames()
Specified by:
getApplicableCallNames in interface com.android.tools.lint.detector.api.Detector.ClassScanner
Overrides:
getApplicableCallNames in class com.android.tools.lint.detector.api.Detector

checkCall

public void checkCall(@NonNull
                      com.android.tools.lint.detector.api.ClassContext context,
                      @NonNull
                      org.objectweb.asm.tree.ClassNode classNode,
                      @NonNull
                      org.objectweb.asm.tree.MethodNode method,
                      @NonNull
                      org.objectweb.asm.tree.MethodInsnNode call)
Specified by:
checkCall in interface com.android.tools.lint.detector.api.Detector.ClassScanner
Overrides:
checkCall in class com.android.tools.lint.detector.api.Detector

dfs

protected static int dfs(ControlFlowGraph.Node node)
Search from the given node towards the target; return false if we reach an exit point such as a return or a call on the way there that is not within a try/catch clause.

Parameters:
node - the current node
Returns:
true if the target was reached XXX RETURN VALUES ARE WRONG AS OF RIGHT NOW