diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java index 4a2b48e974d5d..f2b52573cd37a 100644 --- a/core/java/android/os/Process.java +++ b/core/java/android/os/Process.java @@ -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)}, not 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. */ diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp index 3cf5d5fdde24b..d9d65dd16f957 100644 --- a/core/jni/android_media_AudioTrack.cpp +++ b/core/jni/android_media_AudioTrack.cpp @@ -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}, - {"native_write_native_bytes", "(Ljava/nio/ByteBuffer;IIIZ)I", + {"native_write_byte", "!([BIIIZ)I", (void *)android_media_AudioTrack_writeArray}, + {"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}, - {"native_write_float", "([FIIIZ)I", + {"native_write_float", "!([FIIIZ)I", (void *)android_media_AudioTrack_writeArray}, {"native_setVolume", "(FF)V", (void *)android_media_AudioTrack_set_volume}, {"native_get_buffer_size_frames", "()I", diff --git a/packages/SystemUI/res/values/lunaris_config.xml b/packages/SystemUI/res/values/lunaris_config.xml index bb9ca52e8766a..ebe1d97cea84f 100644 --- a/packages/SystemUI/res/values/lunaris_config.xml +++ b/packages/SystemUI/res/values/lunaris_config.xml @@ -6,7 +6,7 @@ 1000 - + @@ -17,6 +17,8 @@ /sys/class/thermal/thermal_zone0/temp + /sys/class/kgsl/kgsl-3d0/temp + /sys/class/power_supply/battery/temp 1 @@ -25,7 +27,7 @@ - /sys/class/drm/sde-crtc-0/measured_fps + /sys/class/drm/card0-sde-crtc-0/measured_fps 1000 @@ -35,7 +37,7 @@ 999 - + true diff --git a/packages/SystemUI/src/com/android/systemui/CPUInfoService.java b/packages/SystemUI/src/com/android/systemui/CPUInfoService.java index 05dfc1f1eadfb..f94871136ab48 100644 --- a/packages/SystemUI/src/com/android/systemui/CPUInfoService.java +++ b/packages/SystemUI/src/com/android/systemui/CPUInfoService.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -25,12 +25,10 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.PixelFormat; -import android.graphics.Rect; import android.graphics.Typeface; import android.os.Handler; import android.os.IBinder; import android.os.Message; -import android.os.RemoteException; import android.view.Gravity; import android.view.View; import android.view.WindowManager; @@ -40,14 +38,8 @@ import com.android.systemui.res.R; import java.io.BufferedReader; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileReader; -import java.io.IOException; import java.lang.StringBuffer; -import java.util.Arrays; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; public class CPUInfoService extends Service { private View mView; @@ -57,17 +49,25 @@ public class CPUInfoService extends Service { private String[] mCpu = null; private String[] mCurrFreq = null; private String[] mCurrGov = null; + private String[] mCurrLoad = null; private int CPU_TEMP_DIVIDER = 1; private String CPU_TEMP_SENSOR = ""; + private String GPU_TEMP_SENSOR = ""; + private String BATTERY_TEMP_SENSOR = ""; + private String FPS_SENSOR = ""; private String DISPLAY_CPUS = ""; private boolean mCpuTempAvail; + private boolean mGpuTempAvail; + private boolean mBatTempAvail; + private boolean mFpsAvail; 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/clock_mhz"; + private static final String GPU_LOAD_PATH = "/sys/class/kgsl/kgsl-3d0/gpu_busy_percentage"; private class CPUView extends View { private Paint mOnlinePaint; @@ -78,7 +78,12 @@ public class CPUInfoService extends Service { private int mNeededWidth; private int mNeededHeight; + private String mFps; private String mCpuTemp; + private String mGpuTemp; + private String mBatTemp; + private String mGpuFreq; + private String mGpuLoad; private boolean mDataAvail; @@ -91,18 +96,25 @@ public class CPUInfoService extends Service { String msgData = (String) msg.obj; try { String[] parts=msgData.split(";"); - mCpuTemp=parts[0]; + mFps = parts[0]; + mCpuTemp = parts[1]; + mGpuTemp = parts[2]; + mBatTemp = parts[3]; + mGpuFreq = parts[4]; + mGpuLoad = parts[5]; - String[] cpuParts=parts[1].split("\\|"); + String[] cpuParts=parts[6].split("\\|"); for(int i=0; i 1) { - return String.format("%s", - Integer.parseInt(cpuTemp) / CPU_TEMP_DIVIDER); - } else { - return cpuTemp; + private String getCPUInfoString(int i) { + return "Core " + mCpu[i] + ": " + String.format("%3s", mCurrLoad[i]) + " " + mCurrGov[i] + " " + String.format("%8s", toMHz(mCurrFreq[i])); + } + + private String getTemp(String rawTemp) { + try { + float temp = Float.parseFloat(rawTemp); + if (temp > 10000) { + return String.format("%.2f", temp / 1000.0f); + } + if (CPU_TEMP_DIVIDER > 1) { + return String.format("%.2f", temp / CPU_TEMP_DIVIDER); + } else { + return rawTemp; + } + } catch (NumberFormatException e) { + return "0"; } } @@ -188,33 +204,50 @@ public class CPUInfoService extends Service { return; } - final int W = mNeededWidth; final int RIGHT = getWidth()-1; - - int x = RIGHT - mPaddingRight; - int top = mPaddingTop + 2; - int bottom = mPaddingTop + mFH - 2; - int y = mPaddingTop - (int)mAscent; + if(mFpsAvail) { + canvas.drawText("FPS: " + mFps, + RIGHT-mPaddingRight-mMaxWidth, y-1, mOnlinePaint); + y += mFH; + } + 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")) { + canvas.drawText("GPU: " + getTemp(mGpuTemp) + " °C", + 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; } for(int i=0; i= 2) { + try { + float fpsFloat = Float.parseFloat(parts[1]); + fpsVal = String.format("%.1f", fpsFloat); + } catch (NumberFormatException e) { + // ignore + } + } + } + } + } + sb.append(fpsVal).append(";"); + 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(";"); + + String gpuLoadStr = "0%"; + String gpuBusy = CPUInfoService.readOneLine(GPU_LOAD_PATH); + if (gpuBusy != null) { + gpuLoadStr = gpuBusy.replaceAll("[^0-9]", "") + "%"; + } + sb.append(gpuLoadStr).append(";"); + + String[] cpuLoads = getCpuLoad(); for(int i=0; i= mNumCpus) continue; + + long idle = Long.parseLong(tokens[4]); + long total = 0; + for (int k=1; k 0) { + load = (int)((diffTotal - diffIdle) * 100 / diffTotal); + } + + mLastIdle[cpuId] = idle; + mLastTotal[cpuId] = total; + results[cpuId] = load + "%"; + } + reader.close(); + } catch (Exception e) { + for(int j=0; j