Skip to content

Commit 8addbb9

Browse files
darkobasGenkzsz11
authored andcommitted
SystemUI: FPS Info Overlay & Tile
-- Also update bootreceiver Signed-off-by: Pranav Vashi <[email protected]>
1 parent 4bf6221 commit 8addbb9

File tree

10 files changed

+502
-7
lines changed

10 files changed

+502
-7
lines changed

core/java/android/provider/Settings.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6024,6 +6024,11 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
60246024
*/
60256025
public static final String USE_OLD_MOBILETYPE = "use_old_mobiletype";
60266026

6027+
/**
6028+
* @hide
6029+
*/
6030+
public static final String SHOW_FPS_OVERLAY = "show_fps_overlay";
6031+
60276032
/**
60286033
* Keys we no longer back up under the current schema, but want to continue to
60296034
* process when restoring historical backup datasets.

packages/SystemUI/AndroidManifest.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,15 @@
383383
</intent-filter>
384384
</receiver>
385385

386+
<service android:name="com.android.systemui.FPSInfoService"
387+
android:exported="false" />
388+
389+
<receiver android:name=".BootReceiver" androidprv:systemUserOnly="true">
390+
<intent-filter>
391+
<action android:name="android.intent.action.BOOT_COMPLETED" />
392+
</intent-filter>
393+
</receiver>
394+
386395
<service android:name=".ImageWallpaper"
387396
android:permission="android.permission.BIND_WALLPAPER"
388397
android:exported="true" />
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:height="24dp"
3+
android:width="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:fillColor="#ffffff"
8+
android:pathData="M1 5h2v14H1zm4 0h2v14H5zm17 0H10c-0.55 0-1 0.45-1 1v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V6c0-0.55-0.45-1-1-1zm-1 12H11V7h10v10zm-3.57-4.38l-2 2.57L14 13.47l-2 2.52h8z" />
9+
</vector>

packages/SystemUI/res/values/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114

115115
<!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
116116
<string name="quick_settings_tiles_stock" translatable="false">
117-
wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,location,dataswitch,hotspot,inversion,saver,gaming,screenshot,dark,work,cast,night,screenrecord,reverse,reboot,nfc,heads_up,usb_tether,cpuinfo,caffeine
117+
wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,location,dataswitch,hotspot,inversion,saver,gaming,screenshot,dark,work,cast,night,screenrecord,reverse,reboot,nfc,heads_up,usb_tether,cpuinfo,caffeine,fpsinfo
118118
</string>
119119

120120
<!-- The tiles to display in QuickSettings -->

packages/SystemUI/res/values/nad_config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,8 @@
5252
<!-- Color of the FOD view -->
5353
<color name="config_fodColor">#00ff00</color>
5454
<color name="config_fodColorBackground">#20000000</color>
55+
56+
<!-- FPSInfoService FPS node file path -->
57+
<string name="config_fpsInfoSysNode" translatable="false"></string>
5558
</resources>
5659

packages/SystemUI/res/values/nad_strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,7 @@
166166
<!-- Indication on the keyguard that is shown when the device is charging with a VOOC charger. Should match keyguard_plugged_in_vooc_charging [CHAR LIMIT=40]-->
167167
<string name="keyguard_indication_vooc_charging_time"><xliff:g id="percentage">%2$s</xliff:g> • VOOC Charging (<xliff:g id="charging_time_left" example="4 hours and 2 minutes">%1$s</xliff:g> until full)</string>
168168
<string name="keyguard_plugged_in_vooc_charging"><xliff:g id="percentage">%s</xliff:g> • VOOC Charging</string>
169+
170+
<!-- FPS Info tile -->
171+
<string name="quick_settings_fpsinfo_label">FPS Info</string>
169172
</resources>

packages/SystemUI/src/com/android/systemui/BootReceiver.java

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import android.content.ContentResolver;
2121
import android.content.Context;
2222
import android.content.Intent;
23+
import android.database.ContentObserver;
24+
import android.os.Handler;
2325
import android.provider.Settings;
2426
import android.util.Log;
2527

@@ -29,19 +31,69 @@
2931
*/
3032
public class BootReceiver extends BroadcastReceiver {
3133
private static final String TAG = "SystemUIBootReceiver";
34+
private Handler mHandler = new Handler();
35+
private SettingsObserver mSettingsObserver;
36+
private Context mContext;
37+
38+
private class SettingsObserver extends ContentObserver {
39+
SettingsObserver(Handler handler) {
40+
super(handler);
41+
}
42+
43+
void observe() {
44+
mContext.getContentResolver().registerContentObserver(Settings.Global.getUriFor(
45+
Settings.Global.SHOW_CPU_OVERLAY),
46+
false, this);
47+
mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(
48+
Settings.System.SHOW_FPS_OVERLAY),
49+
false, this);
50+
update();
51+
}
52+
53+
@Override
54+
public void onChange(boolean selfChange) {
55+
update();
56+
}
57+
58+
public void update() {
59+
Intent cpuinfo = new Intent(mContext, com.android.systemui.CPUInfoService.class);
60+
Intent fpsinfo = new Intent(mContext, com.android.systemui.FPSInfoService.class);
61+
if (Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.SHOW_CPU_OVERLAY, 0) != 0) {
62+
mContext.startService(cpuinfo);
63+
} else {
64+
mContext.stopService(cpuinfo);
65+
}
66+
if (Settings.System.getInt(mContext.getContentResolver(), Settings.System.SHOW_FPS_OVERLAY, 0) != 0) {
67+
mContext.startService(fpsinfo);
68+
} else {
69+
mContext.stopService(fpsinfo);
70+
}
71+
}
72+
}
3273

3374
@Override
3475
public void onReceive(final Context context, Intent intent) {
3576
try {
77+
mContext = context;
78+
if (mSettingsObserver == null) {
79+
mSettingsObserver = new SettingsObserver(mHandler);
80+
mSettingsObserver.observe();
81+
}
82+
3683
// Start the cpu info overlay, if activated
37-
ContentResolver res = context.getContentResolver();
38-
if (Settings.Global.getInt(res, Settings.Global.SHOW_CPU_OVERLAY, 0) != 0) {
39-
Intent cpuinfo = new Intent(context, com.android.systemui.CPUInfoService.class);
40-
context.startService(cpuinfo);
84+
if (Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.SHOW_CPU_OVERLAY, 0) != 0) {
85+
Intent cpuinfo = new Intent(mContext, com.android.systemui.CPUInfoService.class);
86+
mContext.startService(cpuinfo);
4187
}
4288

89+
// Start the fps info overlay, if activated
90+
if (Settings.System.getInt(mContext.getContentResolver(), Settings.System.SHOW_FPS_OVERLAY, 0) != 0) {
91+
Intent fpsinfo = new Intent(mContext, com.android.systemui.FPSInfoService.class);
92+
mContext.startService(fpsinfo);
93+
}
94+
4395
} catch (Exception e) {
44-
Log.e(TAG, "Can't start cpuinfo service", e);
96+
Log.e(TAG, "Can't start load average service", e);
4597
}
4698
}
4799
}

0 commit comments

Comments
 (0)