Methods Summary |
---|
void | cancelTimer()
if (DBG) log("cancelTimer()...");
removeCallbacks(mTimerCallback);
mTimerRunning = false;
|
static long | getCallDuration(com.android.internal.telephony.Call call)Returns a "call duration" value for the specified Call, in msec,
suitable for display in the UI.
long duration = 0;
List connections = call.getConnections();
int count = connections.size();
Connection c;
if (count == 1) {
c = (Connection) connections.get(0);
//duration = (state == Call.State.ACTIVE
// ? c.getDurationMillis() : c.getHoldDurationMillis());
duration = c.getDurationMillis();
} else {
for (int i = 0; i < count; i++) {
c = (Connection) connections.get(i);
//long t = (state == Call.State.ACTIVE
// ? c.getDurationMillis() : c.getHoldDurationMillis());
long t = c.getDurationMillis();
if (t > duration) {
duration = t;
}
}
}
if (DBG) log("updateElapsedTime, count=" + count + ", duration=" + duration);
return duration;
|
boolean | isTraceReady()
return sProfileState == PROFILE_STATE_READY;
|
boolean | isTraceRunning()
return sProfileState == PROFILE_STATE_RUNNING;
|
private static void | log(java.lang.String msg)
Log.d(LOG_TAG, "[CallTime] " + msg);
|
void | periodicUpdateTimer()
if (!mTimerRunning) {
mTimerRunning = true;
long now = SystemClock.uptimeMillis();
long nextReport = mLastReportedTime + mInterval;
while (now >= nextReport) {
nextReport += mInterval;
}
if (DBG) log("periodicUpdateTimer() @ " + nextReport);
postAtTime(mTimerCallback, nextReport);
mLastReportedTime = nextReport;
if (mCall != null) {
Call.State state = mCall.getState();
if (state == Call.State.ACTIVE) {
updateElapsedTime(mCall);
}
}
if (PROFILE && isTraceReady()) {
startTrace();
}
} else {
if (DBG) log("periodicUpdateTimer: timer already running, bail");
}
|
void | reset()
if (DBG) log("reset()...");
mLastReportedTime = SystemClock.uptimeMillis() - mInterval;
|
void | setActiveCallMode(com.android.internal.telephony.Call call)Sets the call timer to "active call" mode, where the timer will
periodically update the UI to show how long the specified call
has been active.
After calling this you should also call reset() and
periodicUpdateTimer() to get the timer started.
if (DBG) log("setActiveCallMode(" + call + ")...");
mCall = call;
// How frequently should we update the UI?
mInterval = 1000; // once per second
|
static void | setTraceReady()
if (sProfileState == PROFILE_STATE_NONE) {
sProfileState = PROFILE_STATE_READY;
log("trace ready...");
} else {
log("current trace state = " + sProfileState);
}
|
void | startTrace()
if (PROFILE & sProfileState == PROFILE_STATE_READY) {
// For now, we move away from temp directory in favor of
// the application's data directory to store the trace
// information (/data/data/com.android.phone).
File file = PhoneApp.getInstance().getDir ("phoneTrace", Context.MODE_PRIVATE);
if (file.exists() == false) {
file.mkdirs();
}
String baseName = file.getPath() + File.separator + "callstate";
String dataFile = baseName + ".data";
String keyFile = baseName + ".key";
file = new File(dataFile);
if (file.exists() == true) {
file.delete();
}
file = new File(keyFile);
if (file.exists() == true) {
file.delete();
}
sProfileState = PROFILE_STATE_RUNNING;
log("startTrace");
Debug.startMethodTracing(baseName, 8 * 1024 * 1024);
}
|
void | stopTrace()
if (PROFILE) {
if (sProfileState == PROFILE_STATE_RUNNING) {
sProfileState = PROFILE_STATE_NONE;
log("stopTrace");
Debug.stopMethodTracing();
}
}
|
private void | updateElapsedTime(com.android.internal.telephony.Call call)
if (mListener != null) {
long duration = getCallDuration(call);
mListener.onTickForCallTimeElapsed(duration / 1000);
}
|