Skip to content

AndroidAppInspector

Jordan Samhi edited this page Aug 22, 2023 · 1 revision

AndroidAppInspector 🔍

AndroidAppInspector is an abstract class designed to inspect Android classes, methods, and statements. You can define custom actions for inspection and control the inspection process through settings and filters.

Table of Contents

Overview

AndroidAppInspector allows you to selectively inspect classes, methods, and statements within Android applications. It utilizes the Soot framework.

Abstract Methods

examineClass(SootClass sc)

Examines the specified SootClass. Implementation required.

examineMethod(SootMethod sm)

Examines the specified SootMethod. Implementation required.

examineStatement(Unit u)

Examines the specified statement (Unit). Implementation required.

Examination Criteria

setExaminationCriteria(boolean examineClasses, boolean examineMethods, boolean examineStatements)

Sets criteria to decide whether to examine classes, methods, and/or statements.

Inspection Process

run()

Starts the inspection process, examining elements based on criteria and optional filters.

Optional Filters

shouldExamineClass(SootClass sc)

Optional filter for classes. Default is true.

shouldExamineMethod(SootMethod sm)

Optional filter for methods. Default is true.

shouldExamineStatement(Unit u)

Optional filter for statements. Default is true.

Examples

Example 1: Custom Implementation

public class MyInspector extends AndroidAppInspector {
    @Override
    public void examineClass(SootClass sc) {
        // Custom code here
    }

    @Override
    public void examineMethod(SootMethod sm) {
        // Custom code here
    }

    @Override
    public void examineStatement(Unit u) {
        // Custom code here
    }
}

MyInspector inspector = new MyInspector();
inspector.run();

Example 2: Setting Examination Criteria

MyInspector inspector = new MyInspector();
inspector.setExaminationCriteria(true, false, true); // Only examine classes and statements
inspector.run();

Example 3: Utilizing Filters

public class FilteredInspector extends AndroidAppInspector {
    @Override
    protected boolean shouldExamineClass(SootClass sc) {
        return sc.isPublic(); // Only examine public classes
    }

    // Implement other abstract methods as needed
}

FilteredInspector inspector = new FilteredInspector();
inspector.run();

These examples showcase how to use AndroidAppInspector to create customized inspection behaviors.