private int mSleepDelay;
private boolean mLogVerbose;
- private final String TAG = "Filter";
+ private static final String TAG = "Filter";
public Filter(String name) {
mName = name;
private static FilterFactory mSharedFactory;
private HashSet<String> mPackages = new HashSet<String>();
+ private boolean mLogVerbose;
+ private static final String TAG = "FilterFactory";
+
public static FilterFactory sharedFactory() {
if (mSharedFactory == null) {
mSharedFactory = new FilterFactory();
+ mSharedFactory.mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
}
return mSharedFactory;
}
public void addPackage(String packageName) {
- Log.i("FilterFactory", "Adding package " + packageName);
+ if (mLogVerbose) Log.v(TAG, "Adding package " + packageName);
/*
Package pkg = Package.getPackage(packageName);
if (pkg == null) {
}
public Filter createFilterByClassName(String className, String filterName) {
- Log.i("FilterFactory", "Looking up class " + className);
+ if (mLogVerbose) Log.v(TAG, "Looking up class " + className);
Class filterClass = null;
// Get context's classloader; otherwise cannot load non-framework filters
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
// Look for the class in the imported packages
for (String packageName : mPackages) {
try {
- Log.i("FilterFactory", "Trying "+packageName + "." + className);
+ if (mLogVerbose) Log.v(TAG, "Trying "+packageName + "." + className);
filterClass = contextClassLoader.loadClass(packageName + "." + className);
} catch (ClassNotFoundException e) {
continue;
+++ /dev/null
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package android.filterfw.core;
-
-import android.util.Log;
-
-/**
- * Settings for MCA-specific logging.
- *
- * @hide
- */
-public class LogMCA {
-
- // Set this to true to enable per-frame logging.
- public static final boolean LOG_EVERY_FRAME = false;
-
- public static final String TAG = "MCA";
-
- public static final void perFrame(String message) {
- if (LOG_EVERY_FRAME) {
- Log.v(TAG, message);
- }
- }
-
-}
* @hide
*/
public class OneShotScheduler extends RoundRobinScheduler {
- private HashMap <String, Integer> scheduled;
+ private HashMap <String, Integer> scheduled = new HashMap<String, Integer>();
public OneShotScheduler(FilterGraph graph) {
super(graph);
package android.filterfw.core;
import android.os.ConditionVariable;
+import android.util.Log;
import java.lang.reflect.Constructor;
import java.util.concurrent.ScheduledThreadPoolExecutor;
private StopWatchMap mTimer = null;
+ private final boolean mLogVerbose;
+ private final static String TAG = "SyncRunner";
// TODO: Provide factory based constructor?
public SyncRunner(FilterContext context, FilterGraph graph, Class schedulerClass) {
super(context);
+ mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
+
+ if (mLogVerbose) Log.v(TAG, "Initializing SyncRunner");
+
// Create the scheduler
if (Scheduler.class.isAssignableFrom(schedulerClass)) {
try {
mTimer = new StopWatchMap();
+ if (mLogVerbose) Log.v(TAG, "Setting up filters");
+
// Setup graph filters
graph.setupFilters();
}
public void close() {
// Close filters
+ if (mLogVerbose) Log.v(TAG, "Closing graph.");
getGraph().closeFilters(mFilterContext);
}
@Override
public void run() {
+ if (mLogVerbose) Log.v(TAG, "Beginning run.");
+
// Preparation
beginProcessing();
assertReadyToStep();
// Call completion callback if set
if (mDoneListener != null) {
+ if (mLogVerbose) Log.v(TAG, "Calling completion listener.");
mDoneListener.onRunnerDone(determinePostRunState());
}
+ if (mLogVerbose) Log.v(TAG, "Run complete");
}
@Override
}
protected void processFilterNode(Filter filter) {
- LogMCA.perFrame("Processing " + filter);
+ if (mLogVerbose) Log.v(TAG, "Processing filter node");
filter.performProcess(mFilterContext);
if (filter.getStatus() == Filter.STATUS_ERROR) {
throw new RuntimeException("There was an error executing " + filter + "!");
} else if (filter.getStatus() == Filter.STATUS_SLEEPING) {
+ if (mLogVerbose) Log.v(TAG, "Scheduling filter wakeup");
scheduleFilterWake(filter, filter.getSleepDelay());
}
}
// Core internal methods ///////////////////////////////////////////////////////////////////////
boolean performStep() {
+ if (mLogVerbose) Log.v(TAG, "Performing one step.");
Filter filter = mScheduler.scheduleNextNode();
if (filter != null) {
mTimer.start(filter.getName());