Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: LGPL 

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;

public class Main {
    private final static String keyBaseName = "taintinfo";
    public static Map<Integer, Set<String>> sourceSinkConnection = new HashMap<Integer, Set<String>>();

    public static void registerNewSourceSinkConnection(int counter, String taintInfoOfSource) {
        Log.i("PEP", "in registerNewSourceSinkConnection(int counter, String taintInfoOfSource)");
        Set<String> taintInfos = new HashSet<String>();
        taintInfos.add(taintInfoOfSource);
        sourceSinkConnection.put(counter, taintInfos);
    }

    public static void registerNewSourceSinkConnection(int counter, Bundle bundle) {
        Log.i("PEP", "in registerNewSourceSinkConnection(int counter, Bundle bundle)");
        int taintInfoKeyCounter = 0;

        if (bundle != null) {
            for (String intentKey : bundle.keySet()) {
                if (intentKey.startsWith(keyBaseName)) {
                    String possibleNumber = intentKey.substring(keyBaseName.length());
                    if (possibleNumber.length() > 0 && TextUtils.isDigitsOnly(possibleNumber)) {
                        int currentCounter = Integer.parseInt(possibleNumber);
                        if (taintInfoKeyCounter < currentCounter)
                            taintInfoKeyCounter = currentCounter;
                    }
                }
            }

            if (taintInfoKeyCounter == 0) {
                Log.i("PEP", "bundle:" + bundle.toString());
                if (bundle.containsKey(keyBaseName)) {
                    String taintSourceCats = bundle.getString(keyBaseName);
                    String[] allCats = taintSourceCats.split(",");
                    sourceSinkConnection.put(counter, new HashSet<String>(Arrays.asList(allCats)));
                }
            } else {
                if (bundle.containsKey(keyBaseName + taintInfoKeyCounter)) {
                    String taintSourceCats = bundle.getString(keyBaseName + taintInfoKeyCounter);
                    String[] allCats = taintSourceCats.split(",");
                    sourceSinkConnection.put(counter, new HashSet<String>(Arrays.asList(allCats)));
                }
            }
        }
    }
}