If you think the Android project SensorDataCollector 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
/*
* Copyright (c) 2014, the SenSee authors. Please see the AUTHORS file
* for details. //fromwww.java2s.com
*
* Licensed under the GNU Public License, Version 3.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.gnu.org/copyleft/gpl.html
*
* 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 sysnetlab.android.sdc.datacollector;
import android.annotation.SuppressLint;
import android.os.Build;
import android.os.SystemClock;
publicclass ExperimentTime {
privatelong mThreadTimeMillis; /*
* Returns milliseconds running in the
* current thread. Added in API level 1.
*/privatelong mElapsedRealtime; /*
* Returns milliseconds since boot, including
* time spent in sleep. Added in API level 1.
*/privatelong mElapsedRealtimeNanos; /*
* Returns nanoseconds since boot,
* including time spent in sleep. Added
* in API level 17.
*/
@SuppressLint("NewApi")
public ExperimentTime() {
mThreadTimeMillis = SystemClock.currentThreadTimeMillis();
mElapsedRealtime = SystemClock.elapsedRealtime();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
mElapsedRealtimeNanos = SystemClock.elapsedRealtimeNanos();
} else {
mElapsedRealtimeNanos = -1l;
}
}
public ExperimentTime(long threadTimeMillis, long elapsedRealtime, long elapsedRealtimeNanos) {
mThreadTimeMillis = threadTimeMillis;
mElapsedRealtime = elapsedRealtime;
mElapsedRealtimeNanos = elapsedRealtimeNanos;
}
public ExperimentTime(long threadTimeMillis, long elapsedRealtime) {
this(threadTimeMillis, elapsedRealtime, -1);
}
publiclong getThreadTimeMillis() {
return mThreadTimeMillis;
}
publicvoid setThreadTimeMillis(long threadTimeMillis) {
mThreadTimeMillis = threadTimeMillis;
}
publiclong getElapsedRealtime() {
return mElapsedRealtime;
}
publicvoid setElapsedRealtime(long elapsedRealtime) {
mElapsedRealtime = elapsedRealtime;
}
publiclong getElapsedRealtimeNanos() {
return mElapsedRealtimeNanos;
}
publicvoid setmElapsedRealtimeNanos(long mElapsedRealtimeNanos) {
this.mElapsedRealtimeNanos = mElapsedRealtimeNanos;
}
public String toString() {
return Long.toString(mThreadTimeMillis) + "\n" + Long.toString(mElapsedRealtime) + "\n"
+ mElapsedRealtimeNanos;
}
publicboolean equals(Object rhs) {
if (rhs == this) {
return true;
}
if (!(rhs instanceof ExperimentTime)) {
return false;
}
ExperimentTime t = (ExperimentTime) rhs;
if (mThreadTimeMillis != t.mThreadTimeMillis) {
return false;
}
if (mElapsedRealtime != t.mElapsedRealtime) {
return false;
}
if (mElapsedRealtimeNanos != t.mElapsedRealtimeNanos) {
return false;
}
return true;
}
}