Android Open Source - trust Log Entry Maker






From Project

Back to project page trust.

License

The source code is released under:

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCT...

If you think the Android project trust listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package eu.thedarken.trust.logentries;
/*from  w  w  w. j av a 2 s.  co  m*/
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import eu.thedarken.trust.db.TrustDB;

public class LogEntryMaker {
    private Context mContext;
    private final static String TAG = "eu.thedarken.trust.logentries.LogEntryMaker";
    private IDMaker mIDMaker;
    private TrustDB mDB;
    private String mVersionTag;

    public LogEntryMaker(Context c) {
        mContext = c;
        mIDMaker = IDMaker.getInstance(mContext);
        mDB = TrustDB.getInstance(mContext);
        try {
            mVersionTag = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionName + "("
                    + mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionCode + ")";
        } catch (NameNotFoundException e) {
            mVersionTag = "";
        }
    }

    public void makeEntry(Intent i) {
        int type = IntentHelper.getType(i);
        if (type == LogEntry.NO_TYPE)
            return;

        LogEntry event = new LogEntry();
        event.setType(type);
        event.setID(mIDMaker.makeID());
        event.setExtra(IntentHelper.retrieve(mContext, i, event.getType()));
        mDB.addEntry(event);
        notifyList(event);
    }


    public boolean createStartEventIfNecessary() {
        if (mIDMaker.getID() == 0) {
            LogEntry event = new LogEntry();
            event.setType(LogEntry.LOG_START);
            event.setID(mIDMaker.makeID());
            event.setExtra(mVersionTag);
            mDB.addEntry(event);
            notifyList(event);
            return true;
        }
        return false;
    }

    public void makeBootCompleteEntry() {
        LogEntry event = new LogEntry();
        event.setType(LogEntry.BOOT_COMPLETED);
        event.setID(mIDMaker.makeID());
        mDB.addEntry(event);
        notifyList(event);
    }

    public void makeSystemResumeEntry() {
        LogEntry event = new LogEntry();
        event.setType(LogEntry.LOG_SYSTEM_RESUME);
        event.setID(mIDMaker.makeID());
        event.setExtra(mVersionTag);
        mDB.addEntry(event);
        notifyList(event);
    }

    public void makeResumeEntry() {
        LogEntry event = new LogEntry();
        event.setType(LogEntry.LOG_RESUME);
        event.setID(mIDMaker.makeID());
        event.setExtra(mVersionTag);
        mDB.addEntry(event);
        notifyList(event);
    }

    public void makeKilledEntry() {
        LogEntry event = new LogEntry();
        event.setType(LogEntry.LOG_SYSTEM_KILLED);
        event.setID(mIDMaker.makeID());
        event.setExtra(mVersionTag);
        mDB.addEntry(event);
        notifyList(event);
    }

    public void makePauseEntry() {
        LogEntry event = new LogEntry();
        event.setType(LogEntry.LOG_PAUSE);
        event.setID(mIDMaker.makeID());
        event.setExtra(mVersionTag);
        mDB.addEntry(event);
        notifyList(event);
    }

    public void makeResetEntry() {
        LogEntry event = new LogEntry();
        event.setType(LogEntry.LOG_RESET);
        event.setID(mIDMaker.makeID());
        event.setExtra(mVersionTag);
        mDB.addEntry(event);
        notifyList(event);
    }

    public void makeAppEntry(String currentForegroundAppPkg) {
        LogEntry event = new LogEntry();
        event.setType(LogEntry.APP_ACTIVITY);
        event.setID(mIDMaker.makeID());
        event.setExtra("package:" + currentForegroundAppPkg);
        mDB.addEntry(event);
        notifyList(event);
    }

    private void notifyList(LogEntry event) {
        Intent i = new Intent();
        i.setAction(TrustDB.NEW_EVENT_INTENT);
        i.putExtra("id", event.getID());
        mContext.sendBroadcast(i);
    }

}




Java Source Code List

eu.thedarken.trust.AppWatcher.java
eu.thedarken.trust.ApplicationTest.java
eu.thedarken.trust.TestGenerator.java
eu.thedarken.trust.TrustActivity.java
eu.thedarken.trust.TrustAutostart.java
eu.thedarken.trust.TrustListAdapter.java
eu.thedarken.trust.TrustListFragment.java
eu.thedarken.trust.TrustPreferences.java
eu.thedarken.trust.TrustReceivers.java
eu.thedarken.trust.TrustService.java
eu.thedarken.trust.db.TrustDB.java
eu.thedarken.trust.dialogs.AboutDialogFragment.java
eu.thedarken.trust.dialogs.DetailsDialogFragment.java
eu.thedarken.trust.dialogs.ExportDialogFragment.java
eu.thedarken.trust.dialogs.FilterDialogFragment.java
eu.thedarken.trust.dialogs.FollowMeDialog.java
eu.thedarken.trust.dialogs.NewsDialogFragment.java
eu.thedarken.trust.lockpattern.Lists.java
eu.thedarken.trust.lockpattern.LockPatternActivity.java
eu.thedarken.trust.lockpattern.LockPatternUtils.java
eu.thedarken.trust.lockpattern.LockPatternView.java
eu.thedarken.trust.logentries.Descriptions.java
eu.thedarken.trust.logentries.IDMaker.java
eu.thedarken.trust.logentries.IntentHelper.java
eu.thedarken.trust.logentries.LogEntryMaker.java
eu.thedarken.trust.logentries.LogEntry.java
eu.thedarken.trust.pro.TrustPro.java