CPU Info Overlay Tweaks + Perf. Tweaks
Change-Id: I20c87526f30124d9b059b46dc71d2388cf8d19ce Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
@@ -480,6 +480,17 @@ public class Process {
|
||||
*/
|
||||
public static final int THREAD_PRIORITY_URGENT_AUDIO = -19;
|
||||
|
||||
/**
|
||||
* Real-time priority used for critical UI tasks
|
||||
* This gets converted to be lined into the SCHED_RR queue.
|
||||
* Applications can not normally change to this priority.
|
||||
* Use with {@link #setThreadPriority(int)} and
|
||||
* {@link #setThreadPriority(int, int)}, <b>not</b> with the normal
|
||||
* {@link java.lang.Thread} class.
|
||||
* @hide
|
||||
*/
|
||||
public static final int THREAD_PRIORITY_REALTIME = -21;
|
||||
|
||||
/**
|
||||
* Minimum increment to make a priority more favorable.
|
||||
*/
|
||||
|
||||
@@ -1462,19 +1462,19 @@ static const JNINativeMethod gMethods[] = {
|
||||
{"native_start", "()V", (void *)android_media_AudioTrack_start},
|
||||
{"native_stop", "()V", (void *)android_media_AudioTrack_stop},
|
||||
{"native_pause", "()V", (void *)android_media_AudioTrack_pause},
|
||||
{"native_flush", "()V", (void *)android_media_AudioTrack_flush},
|
||||
{"native_flush", "!()V", (void *)android_media_AudioTrack_flush},
|
||||
{"native_setup",
|
||||
"(Ljava/lang/Object;Ljava/lang/Object;[IIIIII[ILandroid/os/Parcel;"
|
||||
"JZILjava/lang/Object;Ljava/lang/String;)I",
|
||||
(void *)android_media_AudioTrack_setup},
|
||||
{"native_finalize", "()V", (void *)android_media_AudioTrack_finalize},
|
||||
{"native_release", "()V", (void *)android_media_AudioTrack_release},
|
||||
{"native_write_byte", "([BIIIZ)I", (void *)android_media_AudioTrack_writeArray<jbyteArray>},
|
||||
{"native_write_native_bytes", "(Ljava/nio/ByteBuffer;IIIZ)I",
|
||||
{"native_write_byte", "!([BIIIZ)I", (void *)android_media_AudioTrack_writeArray<jbyteArray>},
|
||||
{"native_write_native_bytes", "!(Ljava/nio/ByteBuffer;IIIZ)I",
|
||||
(void *)android_media_AudioTrack_write_native_bytes},
|
||||
{"native_write_short", "([SIIIZ)I",
|
||||
{"native_write_short", "!([SIIIZ)I",
|
||||
(void *)android_media_AudioTrack_writeArray<jshortArray>},
|
||||
{"native_write_float", "([FIIIZ)I",
|
||||
{"native_write_float", "!([FIIIZ)I",
|
||||
(void *)android_media_AudioTrack_writeArray<jfloatArray>},
|
||||
{"native_setVolume", "(FF)V", (void *)android_media_AudioTrack_set_volume},
|
||||
{"native_get_buffer_size_frames", "()I",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<resources>
|
||||
<!-- Charging info current divider, if needed -->
|
||||
<integer name="config_currentInfoDivider" translatable="false">1000</integer>
|
||||
|
||||
|
||||
<!-- The location of the devices physical tri state switch
|
||||
0: Left side
|
||||
1: Right side -->
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
<!-- The CPU temperature sensor path, defaults to empty -->
|
||||
<string name="config_cpuTempSensor" translatable="false">/sys/class/thermal/thermal_zone0/temp</string>
|
||||
<string name="config_gpuTempSensor" translatable="false">/sys/class/thermal/thermal_zone24/temp</string>
|
||||
<string name="config_batteryTempSensor" translatable="false">/sys/class/thermal/thermal_zone65/temp</string>
|
||||
|
||||
<!-- The CPU temperature divider, if needed -->
|
||||
<integer name="config_cpuTempDivider" translatable="false">1</integer>
|
||||
@@ -25,7 +27,7 @@
|
||||
<string name="config_displayCpus" translatable="false"></string>
|
||||
|
||||
<!-- FPSInfoService FPS node file path -->
|
||||
<string name="config_fpsInfoSysNode" translatable="false">/sys/class/drm/sde-crtc-0/measured_fps</string>
|
||||
<string name="config_fpsInfoSysNode" translatable="false">/sys/class/drm/card0-sde-crtc-0/measured_fps</string>
|
||||
|
||||
<!-- FPS measure interval in milliseconds, default 1000 -->
|
||||
<integer name="config_fpsReadInterval">1000</integer>
|
||||
@@ -35,7 +37,7 @@
|
||||
|
||||
<!-- Notification counter -->
|
||||
<integer name="status_bar_notification_info_maxnum">999</integer>
|
||||
|
||||
|
||||
<!-- Show 5G toggle in internet dialog when available -->
|
||||
<bool name="config_supportsVONR">true</bool>
|
||||
</resources>
|
||||
|
||||
@@ -60,14 +60,19 @@ public class CPUInfoService extends Service {
|
||||
|
||||
private int CPU_TEMP_DIVIDER = 1;
|
||||
private String CPU_TEMP_SENSOR = "";
|
||||
private String GPU_TEMP_SENSOR = "";
|
||||
private String BATTERY_TEMP_SENSOR = "";
|
||||
private String DISPLAY_CPUS = "";
|
||||
private boolean mCpuTempAvail;
|
||||
private boolean mGpuTempAvail;
|
||||
private boolean mBatTempAvail;
|
||||
|
||||
private static final String NUM_OF_CPUS_PATH = "/sys/devices/system/cpu/present";
|
||||
private static final String CURRENT_CPU = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq";
|
||||
private static final String CPU_ROOT = "/sys/devices/system/cpu/cpu";
|
||||
private static final String CPU_CUR_TAIL = "/cpufreq/scaling_cur_freq";
|
||||
private static final String CPU_GOV_TAIL = "/cpufreq/scaling_governor";
|
||||
private static final String GPU_FREQ_PATH = "/sys/class/kgsl/kgsl-3d0/gpuclk";
|
||||
|
||||
private class CPUView extends View {
|
||||
private Paint mOnlinePaint;
|
||||
@@ -79,6 +84,9 @@ public class CPUInfoService extends Service {
|
||||
private int mNeededWidth;
|
||||
private int mNeededHeight;
|
||||
private String mCpuTemp;
|
||||
private String mGpuTemp;
|
||||
private String mBatTemp;
|
||||
private String mGpuFreq;
|
||||
|
||||
private boolean mDataAvail;
|
||||
|
||||
@@ -91,9 +99,12 @@ public class CPUInfoService extends Service {
|
||||
String msgData = (String) msg.obj;
|
||||
try {
|
||||
String[] parts=msgData.split(";");
|
||||
mCpuTemp=parts[0];
|
||||
mCpuTemp = parts[0];
|
||||
mGpuTemp = parts[1];
|
||||
mBatTemp = parts[2];
|
||||
mGpuFreq = parts[3];
|
||||
|
||||
String[] cpuParts=parts[1].split("\\|");
|
||||
String[] cpuParts=parts[4].split("\\|");
|
||||
for(int i=0; i<cpuParts.length; i++){
|
||||
String cpuInfo=cpuParts[i];
|
||||
String cpuInfoParts[]=cpuInfo.split(":");
|
||||
@@ -172,12 +183,16 @@ public class CPUInfoService extends Service {
|
||||
return "cpu" + cpu + ": " + gov + " " + String.format("%8s", toMHz(freq));
|
||||
}
|
||||
|
||||
private String getCpuTemp(String cpuTemp) {
|
||||
if (CPU_TEMP_DIVIDER > 1) {
|
||||
return String.format("%s",
|
||||
Integer.parseInt(cpuTemp) / CPU_TEMP_DIVIDER);
|
||||
} else {
|
||||
return cpuTemp;
|
||||
private String getTemp(String rawTemp) {
|
||||
try {
|
||||
float temp = Float.parseFloat(rawTemp);
|
||||
if (CPU_TEMP_DIVIDER > 1) {
|
||||
return String.format("%.2f", temp / CPU_TEMP_DIVIDER);
|
||||
} else {
|
||||
return rawTemp;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +213,23 @@ public class CPUInfoService extends Service {
|
||||
int y = mPaddingTop - (int)mAscent;
|
||||
|
||||
if(!mCpuTemp.equals("0")) {
|
||||
canvas.drawText("Temp: " + getCpuTemp(mCpuTemp) + "°C",
|
||||
canvas.drawText("CPU: " + getTemp(mCpuTemp) + "°C",
|
||||
RIGHT-mPaddingRight-mMaxWidth, y-1, mOnlinePaint);
|
||||
y += mFH;
|
||||
}
|
||||
|
||||
if(!mGpuTemp.equals("0")) {
|
||||
String gpuText = "GPU: " + getTemp(mGpuTemp) + "°C";
|
||||
if(!mGpuFreq.equals("0")) {
|
||||
gpuText += " " + toMHzGPU(mGpuFreq);
|
||||
}
|
||||
canvas.drawText(gpuText,
|
||||
RIGHT-mPaddingRight-mMaxWidth, y-1, mOnlinePaint);
|
||||
y += mFH;
|
||||
}
|
||||
|
||||
if(!mBatTemp.equals("0")) {
|
||||
canvas.drawText("BAT: " + getTemp(mBatTemp) + "°C",
|
||||
RIGHT-mPaddingRight-mMaxWidth, y-1, mOnlinePaint);
|
||||
y += mFH;
|
||||
}
|
||||
@@ -224,7 +255,8 @@ public class CPUInfoService extends Service {
|
||||
final int NW = mNumCpus;
|
||||
|
||||
int neededWidth = mPaddingLeft + mPaddingRight + mMaxWidth;
|
||||
int neededHeight = mPaddingTop + mPaddingBottom + (mFH*((mCpuTempAvail?1:0)+NW));
|
||||
int numExtraLines = (mCpuTempAvail?1:0) + (mGpuTempAvail?1:0) + (mBatTempAvail?1:0);
|
||||
int neededHeight = mPaddingTop + mPaddingBottom + (mFH*(numExtraLines+NW));
|
||||
if (neededWidth != mNeededWidth || neededHeight != mNeededHeight) {
|
||||
mNeededWidth = neededWidth;
|
||||
mNeededHeight = neededHeight;
|
||||
@@ -235,7 +267,23 @@ public class CPUInfoService extends Service {
|
||||
}
|
||||
|
||||
private String toMHz(String mhzString) {
|
||||
return new StringBuilder().append(Integer.valueOf(mhzString) / 1000).append(" MHz").toString();
|
||||
try {
|
||||
return new StringBuilder().append(Integer.valueOf(mhzString) / 1000).append(" MHz").toString();
|
||||
} catch (Exception e) {
|
||||
return "0 MHz";
|
||||
}
|
||||
}
|
||||
|
||||
private String toMHzGPU(String hzString) {
|
||||
try {
|
||||
long val = Long.parseLong(hzString);
|
||||
if (val > 10000000) {
|
||||
return (val / 1000000) + " MHz";
|
||||
}
|
||||
return (val / 1000) + " MHz";
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public Handler getHandler(){
|
||||
@@ -262,9 +310,18 @@ public class CPUInfoService extends Service {
|
||||
while (!mInterrupt) {
|
||||
sleep(500);
|
||||
StringBuffer sb=new StringBuffer();
|
||||
|
||||
String cpuTemp = CPUInfoService.readOneLine(CPU_TEMP_SENSOR);
|
||||
sb.append(cpuTemp == null ? "0" : cpuTemp);
|
||||
sb.append(";");
|
||||
sb.append(cpuTemp == null ? "0" : cpuTemp).append(";");
|
||||
|
||||
String gpuTemp = CPUInfoService.readOneLine(GPU_TEMP_SENSOR);
|
||||
sb.append(gpuTemp == null ? "0" : gpuTemp).append(";");
|
||||
|
||||
String batTemp = CPUInfoService.readOneLine(BATTERY_TEMP_SENSOR);
|
||||
sb.append(batTemp == null ? "0" : batTemp).append(";");
|
||||
|
||||
String gpuFreq = CPUInfoService.readOneLine(GPU_FREQ_PATH);
|
||||
sb.append(gpuFreq == null ? "0" : gpuFreq).append(";");
|
||||
|
||||
for(int i=0; i<mNumCpus; i++) {
|
||||
final String currCpu = mCpu[i];
|
||||
@@ -295,6 +352,8 @@ public class CPUInfoService extends Service {
|
||||
|
||||
CPU_TEMP_DIVIDER = getResources().getInteger(R.integer.config_cpuTempDivider);
|
||||
CPU_TEMP_SENSOR = getResources().getString(R.string.config_cpuTempSensor);
|
||||
GPU_TEMP_SENSOR = getResources().getString(R.string.config_gpuTempSensor);
|
||||
BATTERY_TEMP_SENSOR = getResources().getString(R.string.config_batteryTempSensor);
|
||||
DISPLAY_CPUS = getResources().getString(R.string.config_displayCpus);
|
||||
|
||||
mNumCpus = getCpus(DISPLAY_CPUS);
|
||||
@@ -302,6 +361,8 @@ public class CPUInfoService extends Service {
|
||||
mCurrGov = new String[mNumCpus];
|
||||
|
||||
mCpuTempAvail = readOneLine(CPU_TEMP_SENSOR) != null;
|
||||
mGpuTempAvail = readOneLine(GPU_TEMP_SENSOR) != null;
|
||||
mBatTempAvail = readOneLine(BATTERY_TEMP_SENSOR) != null;
|
||||
|
||||
mView = new CPUView(this);
|
||||
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
|
||||
|
||||
@@ -24,9 +24,9 @@ import android.os.Trace;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
|
||||
/**
|
||||
* Shared singleton thread for showing UI. This is a foreground thread, and in
|
||||
* Shared singleton thread for showing UI. This is a realtime thread, and in
|
||||
* additional should not have operations that can take more than a few ms scheduled
|
||||
* on it to avoid UI jank.
|
||||
* on it to avoid impacting the runtime of other non-realtime processes.
|
||||
*/
|
||||
public final class UiThread extends ServiceThread {
|
||||
private static final long SLOW_DISPATCH_THRESHOLD_MS = 100;
|
||||
@@ -35,7 +35,7 @@ public final class UiThread extends ServiceThread {
|
||||
private static Handler sHandler;
|
||||
|
||||
private UiThread() {
|
||||
super("android.ui", Process.THREAD_PRIORITY_URGENT_DISPLAY, false /*allowIo*/);
|
||||
super("android.ui", android.os.Process.THREAD_PRIORITY_REALTIME, false /*allowIo*/);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -254,7 +254,7 @@ static jint nativeCloseHal(JNIEnv* env, jobject clazz) {
|
||||
|
||||
// TODO: clean up void methods
|
||||
static const JNINativeMethod g_methods[] = {
|
||||
{ "nativeAuthenticate", "(JI)I", (void*)nativeAuthenticate },
|
||||
{ "nativeAuthenticate", "!(JI)I", (void*)nativeAuthenticate },
|
||||
{ "nativeStopAuthentication", "()I", (void*)nativeStopAuthentication },
|
||||
{ "nativeEnroll", "([BII)I", (void*)nativeEnroll },
|
||||
{ "nativeSetActiveGroup", "(I[B)I", (void*)nativeSetActiveGroup },
|
||||
|
||||
Reference in New Issue
Block a user