Merge "Added 1st atom for Tuner Metrics" into rvc-dev
This commit is contained in:
@@ -440,6 +440,7 @@ message Atom {
|
||||
273 [(module) = "permissioncontroller"];
|
||||
EvsUsageStatsReported evs_usage_stats_reported = 274 [(module) = "evs"];
|
||||
AudioPowerUsageDataReported audio_power_usage_data_reported = 275;
|
||||
TvTunerStateChanged tv_tuner_state_changed = 276 [(module) = "framework"];
|
||||
SdkExtensionStatus sdk_extension_status = 354;
|
||||
|
||||
// StatsdStats tracks platform atoms with ids upto 500.
|
||||
@@ -9169,6 +9170,28 @@ message SdkExtensionStatus {
|
||||
optional int32 failed_call_symbol = 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs when a tune occurs through device's Frontend.
|
||||
* This is atom ID 276.
|
||||
*
|
||||
* Logged from:
|
||||
* frameworks/base/media/java/android/media/tv/tuner/Tuner.java
|
||||
*/
|
||||
message TvTunerStateChanged {
|
||||
enum State {
|
||||
UNKNOWN = 0;
|
||||
TUNING = 1; // Signal is tuned
|
||||
LOCKED = 2; // the signal is locked
|
||||
NOT_LOCKED = 3; // the signal isn’t locked.
|
||||
SIGNAL_LOST = 4; // the signal was locked, but is lost now.
|
||||
SCANNING = 5; // the signal is scanned
|
||||
SCAN_STOPPED = 6; // the scan is stopped.
|
||||
}
|
||||
// The uid of the application that sent this custom atom.
|
||||
optional int32 uid = 1 [(is_uid) = true];
|
||||
// new state
|
||||
optional State state = 2;
|
||||
}
|
||||
/**
|
||||
* Logs when an app is frozen or unfrozen.
|
||||
*
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.annotation.SystemApi;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.hardware.tv.tuner.V1_0.Constants;
|
||||
import android.media.tv.TvInputService;
|
||||
@@ -55,6 +56,8 @@ import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.util.FrameworkStatsLog;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
@@ -208,7 +211,7 @@ public class Tuner implements AutoCloseable {
|
||||
private FrontendInfo mFrontendInfo;
|
||||
private Integer mFrontendHandle;
|
||||
private int mFrontendType = FrontendSettings.TYPE_UNDEFINED;
|
||||
|
||||
private int mUserId;
|
||||
private Lnb mLnb;
|
||||
private Integer mLnbHandle;
|
||||
@Nullable
|
||||
@@ -232,6 +235,11 @@ public class Tuner implements AutoCloseable {
|
||||
new TunerResourceManager.ResourcesReclaimListener() {
|
||||
@Override
|
||||
public void onReclaimResources() {
|
||||
if (mFrontend != null) {
|
||||
FrameworkStatsLog
|
||||
.write(FrameworkStatsLog.TV_TUNER_STATE_CHANGED, mUserId,
|
||||
FrameworkStatsLog.TV_TUNER_STATE_CHANGED__STATE__UNKNOWN);
|
||||
}
|
||||
mHandler.sendMessage(mHandler.obtainMessage(MSG_RESOURCE_LOST));
|
||||
}
|
||||
};
|
||||
@@ -261,6 +269,8 @@ public class Tuner implements AutoCloseable {
|
||||
profile, new HandlerExecutor(mHandler), mResourceListener, clientId);
|
||||
mClientId = clientId[0];
|
||||
|
||||
mUserId = ActivityManager.getCurrentUser();
|
||||
|
||||
setFrontendInfoList();
|
||||
setLnbIds();
|
||||
}
|
||||
@@ -358,6 +368,9 @@ public class Tuner implements AutoCloseable {
|
||||
TunerUtils.throwExceptionForResult(res, "failed to close frontend");
|
||||
}
|
||||
mTunerResourceManager.releaseFrontend(mFrontendHandle, mClientId);
|
||||
FrameworkStatsLog
|
||||
.write(FrameworkStatsLog.TV_TUNER_STATE_CHANGED, mUserId,
|
||||
FrameworkStatsLog.TV_TUNER_STATE_CHANGED__STATE__UNKNOWN);
|
||||
mFrontendHandle = null;
|
||||
mFrontend = null;
|
||||
}
|
||||
@@ -557,9 +570,14 @@ public class Tuner implements AutoCloseable {
|
||||
*/
|
||||
@Result
|
||||
public int tune(@NonNull FrontendSettings settings) {
|
||||
Log.d(TAG, "Tune to " + settings.getFrequency());
|
||||
mFrontendType = settings.getType();
|
||||
if (checkResource(TunerResourceManager.TUNER_RESOURCE_TYPE_FRONTEND)) {
|
||||
mFrontendInfo = null;
|
||||
Log.d(TAG, "Write Stats Log for tuning.");
|
||||
FrameworkStatsLog
|
||||
.write(FrameworkStatsLog.TV_TUNER_STATE_CHANGED, mUserId,
|
||||
FrameworkStatsLog.TV_TUNER_STATE_CHANGED__STATE__TUNING);
|
||||
return nativeTune(settings.getType(), settings);
|
||||
}
|
||||
return RESULT_UNAVAILABLE;
|
||||
@@ -602,6 +620,9 @@ public class Tuner implements AutoCloseable {
|
||||
mScanCallback = scanCallback;
|
||||
mScanCallbackExecutor = executor;
|
||||
mFrontendInfo = null;
|
||||
FrameworkStatsLog
|
||||
.write(FrameworkStatsLog.TV_TUNER_STATE_CHANGED, mUserId,
|
||||
FrameworkStatsLog.TV_TUNER_STATE_CHANGED__STATE__SCANNING);
|
||||
return nativeScan(settings.getType(), settings, scanType);
|
||||
}
|
||||
return RESULT_UNAVAILABLE;
|
||||
@@ -620,6 +641,10 @@ public class Tuner implements AutoCloseable {
|
||||
*/
|
||||
@Result
|
||||
public int cancelScanning() {
|
||||
FrameworkStatsLog
|
||||
.write(FrameworkStatsLog.TV_TUNER_STATE_CHANGED, mUserId,
|
||||
FrameworkStatsLog.TV_TUNER_STATE_CHANGED__STATE__SCAN_STOPPED);
|
||||
|
||||
int retVal = nativeStopScan();
|
||||
mScanCallback = null;
|
||||
mScanCallbackExecutor = null;
|
||||
@@ -779,12 +804,33 @@ public class Tuner implements AutoCloseable {
|
||||
}
|
||||
|
||||
private void onFrontendEvent(int eventType) {
|
||||
Log.d(TAG, "Got event from tuning. Event type: " + eventType);
|
||||
if (mOnTunerEventExecutor != null && mOnTuneEventListener != null) {
|
||||
mOnTunerEventExecutor.execute(() -> mOnTuneEventListener.onTuneEvent(eventType));
|
||||
}
|
||||
|
||||
Log.d(TAG, "Wrote Stats Log for the events from tuning.");
|
||||
if (eventType == OnTuneEventListener.SIGNAL_LOCKED) {
|
||||
FrameworkStatsLog
|
||||
.write(FrameworkStatsLog.TV_TUNER_STATE_CHANGED, mUserId,
|
||||
FrameworkStatsLog.TV_TUNER_STATE_CHANGED__STATE__LOCKED);
|
||||
} else if (eventType == OnTuneEventListener.SIGNAL_NO_SIGNAL) {
|
||||
FrameworkStatsLog
|
||||
.write(FrameworkStatsLog.TV_TUNER_STATE_CHANGED, mUserId,
|
||||
FrameworkStatsLog.TV_TUNER_STATE_CHANGED__STATE__NOT_LOCKED);
|
||||
} else if (eventType == OnTuneEventListener.SIGNAL_LOST_LOCK) {
|
||||
FrameworkStatsLog
|
||||
.write(FrameworkStatsLog.TV_TUNER_STATE_CHANGED, mUserId,
|
||||
FrameworkStatsLog.TV_TUNER_STATE_CHANGED__STATE__SIGNAL_LOST);
|
||||
}
|
||||
}
|
||||
|
||||
private void onLocked() {
|
||||
Log.d(TAG, "Wrote Stats Log for locked event from scanning.");
|
||||
FrameworkStatsLog
|
||||
.write(FrameworkStatsLog.TV_TUNER_STATE_CHANGED, mUserId,
|
||||
FrameworkStatsLog.TV_TUNER_STATE_CHANGED__STATE__LOCKED);
|
||||
|
||||
if (mScanCallbackExecutor != null && mScanCallback != null) {
|
||||
mScanCallbackExecutor.execute(() -> mScanCallback.onLocked());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user