mirror of
https://github.com/Evolution-X-Devices/device_xiaomi_sky
synced 2026-02-01 09:40:11 +00:00
sky: Add LCD features
This commit is contained in:
@@ -234,8 +234,8 @@ BOARD_VENDOR_SEPOLICY_DIRS += $(DEVICE_PATH)/sepolicy/vendor
|
||||
SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS += \
|
||||
$(DEVICE_PATH)/sepolicy/private/xiaomi/devicesettings
|
||||
|
||||
SYSTEM_EXT_PUBLIC_SEPOLICY_DIRS += \
|
||||
$(DEVICE_PATH)/sepolicy/public/xiaomi/devicesettings
|
||||
#SYSTEM_EXT_PUBLIC_SEPOLICY_DIRS += \
|
||||
# $(DEVICE_PATH)/sepolicy/public/xiaomi/devicesettings
|
||||
|
||||
# Vendor Boot
|
||||
PRODUCT_COPY_FILES += \
|
||||
|
||||
@@ -159,6 +159,12 @@ PRODUCT_PROPERTY_OVERRIDES += \
|
||||
PRODUCT_PACKAGES += \
|
||||
XiaomiParts
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
$(LOCAL_PATH)/parts/init.xiaomiparts.rc:$(TARGET_COPY_OUT_PRODUCT)/etc/init/init.xiaomiparts.rc
|
||||
|
||||
PRODUCT_SYSTEM_EXT_PROPERTIES += \
|
||||
persist.lcd.cabc_mode=1
|
||||
|
||||
# Display
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.graphics.mapper@4.0-impl-qti-display \
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
android_app {
|
||||
name: "XiaomiParts",
|
||||
|
||||
init_rc: ["init.xiaomiparts.rc"],
|
||||
srcs: ["src/**/*.java"],
|
||||
resource_dirs: ["res"],
|
||||
certificate: "platform",
|
||||
|
||||
@@ -47,6 +47,48 @@
|
||||
android:permission="ThermalService">
|
||||
</service>
|
||||
|
||||
<activity
|
||||
android:name=".display.LcdFeaturesPreferenceActivity"
|
||||
android:label="@string/lcd_features_title"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.SubSettingsBase">
|
||||
<intent-filter>
|
||||
<action android:name="com.android.settings.action.IA_SETTINGS" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="com.android.settings.category"
|
||||
android:value="com.android.settings.category.ia.display" />
|
||||
<meta-data
|
||||
android:name="com.android.settings.summary"
|
||||
android:resource="@string/lcd_features_summary" />
|
||||
</activity>
|
||||
<service
|
||||
android:name=".display.HbmTileService"
|
||||
android:exported="true"
|
||||
android:icon="@drawable/ic_hbm"
|
||||
android:label="@string/lcd_hbm_tile_title"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".display.CabcTileService"
|
||||
android:exported="true"
|
||||
android:icon="@drawable/ic_cabc"
|
||||
android:label="@string/lcd_cabc_title"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".display.LcdFeaturesService"
|
||||
android:exported="true"
|
||||
android:permission="LcdFeaturesService">
|
||||
</service>
|
||||
|
||||
<activity
|
||||
android:name=".thermal.ThermalActivity"
|
||||
android:label="@string/thermal_title"
|
||||
|
||||
40
parts/init.xiaomiparts.rc
Normal file
40
parts/init.xiaomiparts.rc
Normal file
@@ -0,0 +1,40 @@
|
||||
# Copyright (C) 2021 Paranoid Android
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# 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
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
on boot
|
||||
chown system system /sys/devices/virtual/display/disp_param/disp_param
|
||||
chmod 0660 /sys/devices/virtual/display/disp_param/disp_param
|
||||
|
||||
on property:persist.lcd.hbm_mode=0
|
||||
write /sys/devices/virtual/display/disp_param/disp_param "0xa0000"
|
||||
|
||||
on property:persist.lcd.hbm_mode=1
|
||||
write /sys/devices/virtual/display/disp_param/disp_param "0xb0000"
|
||||
|
||||
on property:persist.lcd.hbm_mode=2
|
||||
write /sys/devices/virtual/display/disp_param/disp_param "0xc0000"
|
||||
|
||||
on property:persist.lcd.hbm_mode=3
|
||||
write /sys/devices/virtual/display/disp_param/disp_param "0xd0000"
|
||||
|
||||
on property:persist.lcd.cabc_mode=0
|
||||
write /sys/devices/virtual/display/disp_param/disp_param "0x400"
|
||||
|
||||
on property:persist.lcd.cabc_mode=1
|
||||
write /sys/devices/virtual/display/disp_param/disp_param "0x100"
|
||||
|
||||
on property:persist.lcd.cabc_mode=2
|
||||
write /sys/devices/virtual/display/disp_param/disp_param "0x200"
|
||||
|
||||
on property:persist.lcd.cabc_mode=3
|
||||
write /sys/devices/virtual/display/disp_param/disp_param "0x300"
|
||||
19
parts/res/drawable/ic_cabc.xml
Normal file
19
parts/res/drawable/ic_cabc.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?android:attr/textColorSecondary">
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M19.5 19h-4c-0.276 0-0.5-0.224-0.5-0.5s0.224-0.5 0.5 -0.5h4c0.827 0 1.5-0.673 1.5-1.5v-1c0-0.276 0.224 -0.5 0.5 -0.5h0.991c0.276 0 0.5-0.224 0.5 -0.5v-6c0-0.276-0.224-0.5-0.5-0.5h-0.991c-0.276 0-0.5-0.224-0.5-0.5v-1c0-0.827-0.673-1.5-1.5-1.5h-4c-0.276 0-0.5-0.224-0.5-0.5s0.224-0.5 0.5 -0.5h4c1.378 0 2.5 1.122 2.5 2.5v0.5h0.491c0.827 0 1.5 0.673 1.5 1.5v6c0 0.827-0.673 1.5-1.5 1.5h-0.491v0.5c0 1.378-1.122 2.5-2.5 2.5z" />
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M6.75 19h-4.25c-1.378 0-2.5-1.122-2.5-2.5v-10c0-1.378 1.122-2.5 2.5-2.5h6c0.276 0 0.5 0.224 0.5 0.5 s-0.224 0.5 -0.5 0.5 h-6c-0.827 0-1.5 0.673 -1.5 1.5v10c0 0.827 0.673 1.5 1.5 1.5h4.25c0.276 0 0.5 0.224 0.5 0.5 s-0.224 0.5 -0.5 0.5 z" />
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M11.804 18c-3.053 0-4.804-2.032-4.804-5.574 0-1.637 0.769 -2.897 1.583-4.23 0.954 -1.563 1.939-3.178 1.939-5.696 0-0.198 0.116 -0.376 0.297 -0.457 0.181 -0.079 0.391 -0.046 0.538 0.086l0.136 0.122 c2.453 2.212 5.507 4.965 5.507 9.734 0 2.897-1.626 6.015-5.196 6.015zm-0.339-14.424c-0.238 2.207-1.183 3.754-2.029 5.141-0.77 1.262-1.436 2.353-1.436 3.709 0 2.087 0.66 4.574 3.804 4.574 2.883 0 4.196-2.6 4.196-5.015 0-3.946-2.291-6.356-4.535-8.409z" />
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M6.555 23c-0.226 0-0.43-0.153-0.485-0.382-0.065-0.269 0.1 -0.539 0.368 -0.604 5.912-1.432 5.309-9.891 5.302-9.976-0.022-0.275 0.184 -0.516 0.458 -0.538 0.278 -0.03 0.516 0.183 0.539 0.458 0.007 0.094 0.679 9.395-6.063 11.028-0.041 0.01 -0.08 0.014 -0.119 0.014 z" />
|
||||
</vector>
|
||||
8
parts/res/drawable/ic_hbm.xml
Normal file
8
parts/res/drawable/ic_hbm.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?android:attr/colorControlNormal" >
|
||||
<path android:fillColor="#000" android:pathData="M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0 c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2 c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1 C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06 c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41 l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41 c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36 c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z" />
|
||||
</vector>
|
||||
@@ -126,4 +126,32 @@
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="lcd_hbm_modes" translatable="false">
|
||||
<item>"Off"</item>
|
||||
<item>"Low"</item>
|
||||
<item>"Medium"</item>
|
||||
<item>"High"</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="lcd_hbm_values" translatable="false">
|
||||
<item>"0"</item>
|
||||
<item>"1"</item>
|
||||
<item>"2"</item>
|
||||
<item>"3"</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="lcd_cabc_modes" translatable="false">
|
||||
<item>"Off"</item>
|
||||
<item>"Low (UI)"</item>
|
||||
<item>"Medium (Videos)"</item>
|
||||
<item>"High (Images)"</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="lcd_cabc_values" translatable="false">
|
||||
<item>"0"</item>
|
||||
<item>"1"</item>
|
||||
<item>"3"</item>
|
||||
<item>"2"</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -84,4 +84,13 @@
|
||||
<string name="music_headset_scenario_select">Select Scene</string>
|
||||
<string name="music_headset_scenario_video">Video</string>
|
||||
<string name="music_headset_scenario_vocal">Voice</string>
|
||||
|
||||
<!-- LCD Features -->
|
||||
<string name="lcd_features_title">LCD features</string>
|
||||
<string name="lcd_features_summary">High Brightness Mode, CABC</string>
|
||||
<string name="lcd_hbm_title">High Brightness Mode (HBM)</string>
|
||||
<string name="lcd_hbm_tile_title">HBM</string>
|
||||
<string name="lcd_cabc_title">CABC Mode</string>
|
||||
<string name="lcd_features_info">High Brightness Mode (HBM) increases the maximum brightness of the display to improve visibility under sunlight. Increases power consumption.\n\nCABC (Content Adaptive Backlight Control) adjusts display and backlight brightness based on currently shown content, to reduce power consumption without degradation.</string>
|
||||
|
||||
</resources>
|
||||
|
||||
36
parts/res/xml/lcd_features_settings.xml
Normal file
36
parts/res/xml/lcd_features_settings.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2021 Paranoid Android
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"
|
||||
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
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/lcd_features_title" >
|
||||
<ListPreference
|
||||
android:key="pref_hbm"
|
||||
android:title="@string/lcd_hbm_title"
|
||||
android:entries="@array/lcd_hbm_modes"
|
||||
android:entryValues="@array/lcd_hbm_values"
|
||||
android:defaultValue="0" />
|
||||
<ListPreference
|
||||
android:key="pref_cabc"
|
||||
android:title="@string/lcd_cabc_title"
|
||||
android:entries="@array/lcd_cabc_modes"
|
||||
android:entryValues="@array/lcd_cabc_values"
|
||||
android:defaultValue="0" />
|
||||
<com.android.settingslib.widget.FooterPreference
|
||||
android:key="lcd_features_footer"
|
||||
android:title="@string/lcd_features_info"
|
||||
android:selectable="false" />
|
||||
</PreferenceScreen>
|
||||
@@ -23,6 +23,7 @@ import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import org.lineageos.settings.dirac.DiracUtils;
|
||||
import org.lineageos.settings.display.LcdFeaturesService;
|
||||
import org.lineageos.settings.thermal.ThermalUtils;
|
||||
|
||||
public class BootCompletedReceiver extends BroadcastReceiver {
|
||||
@@ -35,5 +36,6 @@ public class BootCompletedReceiver extends BroadcastReceiver {
|
||||
if (DEBUG) Log.d(TAG, "Received boot completed intent");
|
||||
ThermalUtils.startService(context);
|
||||
new DiracUtils(context).onBootCompleted();
|
||||
context.startService(new Intent(context, LcdFeaturesService.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Paranoid Android
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.lineageos.settings.display;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
import android.service.quicksettings.Tile;
|
||||
import android.service.quicksettings.TileService;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.lineageos.settings.R;
|
||||
|
||||
public class CabcTileService extends TileService {
|
||||
|
||||
private Context context;
|
||||
private Tile tile;
|
||||
|
||||
private String[] CabcModes;
|
||||
private String[] CabcValues;
|
||||
private int currentCabcMode;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
context = getApplicationContext();
|
||||
CabcModes = context.getResources().getStringArray(R.array.lcd_cabc_modes);
|
||||
CabcValues = context.getResources().getStringArray(R.array.lcd_cabc_values);
|
||||
}
|
||||
|
||||
private void updateCurrentCabcMode() {
|
||||
currentCabcMode = Arrays.asList(CabcValues).indexOf(SystemProperties.get(LcdFeaturesPreferenceFragment.CABC_PROP, "0"));
|
||||
}
|
||||
|
||||
private void updateCabcTile() {
|
||||
tile.setState(currentCabcMode > 0 ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
|
||||
tile.setContentDescription(CabcModes[currentCabcMode]);
|
||||
tile.setSubtitle(CabcModes[currentCabcMode]);
|
||||
tile.updateTile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartListening() {
|
||||
super.onStartListening();
|
||||
tile = getQsTile();
|
||||
updateCurrentCabcMode();
|
||||
updateCabcTile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick() {
|
||||
super.onClick();
|
||||
updateCurrentCabcMode();
|
||||
if (currentCabcMode == CabcModes.length - 1) {
|
||||
currentCabcMode = 0;
|
||||
} else {
|
||||
currentCabcMode++;
|
||||
}
|
||||
SystemProperties.set(LcdFeaturesPreferenceFragment.CABC_PROP, CabcValues[currentCabcMode]);
|
||||
updateCabcTile();
|
||||
}
|
||||
}
|
||||
74
parts/src/org/lineageos/settings/display/HbmTileService.java
Normal file
74
parts/src/org/lineageos/settings/display/HbmTileService.java
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Paranoid Android
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.lineageos.settings.display;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
import android.service.quicksettings.Tile;
|
||||
import android.service.quicksettings.TileService;
|
||||
|
||||
import org.lineageos.settings.R;
|
||||
|
||||
public class HbmTileService extends TileService {
|
||||
|
||||
private Context context;
|
||||
private Tile tile;
|
||||
|
||||
private String[] HbmModes;
|
||||
private String[] HbmValues;
|
||||
private int currentHbmMode;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
context = getApplicationContext();
|
||||
HbmModes = context.getResources().getStringArray(R.array.lcd_hbm_modes);
|
||||
HbmValues = context.getResources().getStringArray(R.array.lcd_hbm_values);
|
||||
}
|
||||
|
||||
private void updateCurrentHbmMode() {
|
||||
currentHbmMode = SystemProperties.getInt(LcdFeaturesPreferenceFragment.HBM_PROP, 0);
|
||||
}
|
||||
|
||||
private void updateHbmTile() {
|
||||
tile.setState(currentHbmMode > 0 ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
|
||||
tile.setContentDescription(HbmModes[currentHbmMode]);
|
||||
tile.setSubtitle(HbmModes[currentHbmMode]);
|
||||
tile.updateTile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartListening() {
|
||||
super.onStartListening();
|
||||
tile = getQsTile();
|
||||
updateCurrentHbmMode();
|
||||
updateHbmTile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick() {
|
||||
super.onClick();
|
||||
updateCurrentHbmMode();
|
||||
if (currentHbmMode == HbmModes.length - 1) {
|
||||
currentHbmMode = 0;
|
||||
} else {
|
||||
currentHbmMode++;
|
||||
}
|
||||
SystemProperties.set(LcdFeaturesPreferenceFragment.HBM_PROP, Integer.toString(currentHbmMode));
|
||||
updateHbmTile();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Paranoid Android
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.lineageos.settings.display;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;
|
||||
|
||||
public class LcdFeaturesPreferenceActivity extends CollapsingToolbarBaseActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getFragmentManager().beginTransaction()
|
||||
.replace(com.android.settingslib.collapsingtoolbar.R.id.content_frame, new LcdFeaturesPreferenceFragment())
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Paranoid Android
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.lineageos.settings.display;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemProperties;
|
||||
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragment;
|
||||
|
||||
import org.lineageos.settings.R;
|
||||
|
||||
public class LcdFeaturesPreferenceFragment extends PreferenceFragment
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
public static final String HBM_PROP = "persist.lcd.hbm_mode";
|
||||
public static final String CABC_PROP = "persist.lcd.cabc_mode";
|
||||
|
||||
private static final String KEY_HBM = "pref_hbm";
|
||||
private static final String KEY_CABC = "pref_cabc";
|
||||
|
||||
private ListPreference mHbmPref;
|
||||
private ListPreference mCabcPref;
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.lcd_features_settings);
|
||||
mHbmPref = (ListPreference) findPreference(KEY_HBM);
|
||||
mHbmPref.setOnPreferenceChangeListener(this);
|
||||
mCabcPref = (ListPreference) findPreference(KEY_CABC);
|
||||
mCabcPref.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mHbmPref.setValue(SystemProperties.get(HBM_PROP, "0"));
|
||||
mHbmPref.setSummary(mHbmPref.getEntry());
|
||||
mCabcPref.setValue(SystemProperties.get(CABC_PROP, "0"));
|
||||
mCabcPref.setSummary(mCabcPref.getEntry());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
final String key = preference.getKey();
|
||||
|
||||
if (key.equals(KEY_HBM)) {
|
||||
mHbmPref.setValue((String) newValue);
|
||||
mHbmPref.setSummary(mHbmPref.getEntry());
|
||||
SystemProperties.set(HBM_PROP, (String) newValue);
|
||||
} else if (key.equals(KEY_CABC)) {
|
||||
mCabcPref.setValue((String) newValue);
|
||||
mCabcPref.setSummary(mCabcPref.getEntry());
|
||||
SystemProperties.set(CABC_PROP, (String) newValue);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The CyanogenMod Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.lineageos.settings.display;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.IBinder;
|
||||
import android.os.SystemProperties;
|
||||
import android.util.Log;
|
||||
|
||||
public class LcdFeaturesService extends Service {
|
||||
private static final String TAG = "LcdFeaturesService";
|
||||
private static final boolean DEBUG = false;
|
||||
private String lastCABC;
|
||||
private String lastHBM;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
if (DEBUG) Log.d(TAG, "Creating service");
|
||||
IntentFilter screenStateFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
|
||||
screenStateFilter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||
registerReceiver(mScreenStateReceiver, screenStateFilter);
|
||||
lastHBM = SystemProperties.get(LcdFeaturesPreferenceFragment.HBM_PROP, "0");
|
||||
lastCABC = SystemProperties.get(LcdFeaturesPreferenceFragment.CABC_PROP, "0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
if (DEBUG) Log.d(TAG, "Starting service");
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (DEBUG) Log.d(TAG, "Destroying service");
|
||||
super.onDestroy();
|
||||
this.unregisterReceiver(mScreenStateReceiver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void onDisplayOn() {
|
||||
if (DEBUG) Log.d(TAG, "Display on");
|
||||
SystemProperties.set(LcdFeaturesPreferenceFragment.HBM_PROP, lastHBM);
|
||||
SystemProperties.set(LcdFeaturesPreferenceFragment.CABC_PROP, lastCABC);
|
||||
}
|
||||
|
||||
private void onDisplayOff() {
|
||||
if (DEBUG) Log.d(TAG, "Display off");
|
||||
lastHBM = SystemProperties.get(LcdFeaturesPreferenceFragment.HBM_PROP, "0");
|
||||
lastCABC = SystemProperties.get(LcdFeaturesPreferenceFragment.CABC_PROP, "0");
|
||||
}
|
||||
|
||||
private BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
|
||||
onDisplayOn();
|
||||
} else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
|
||||
onDisplayOff();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
app_domain(devicesettings_app)
|
||||
|
||||
# Allow devicesettings_app to find *_service
|
||||
allow devicesettings_app {
|
||||
app_api_service
|
||||
audio_service
|
||||
audioserver_service
|
||||
cameraserver_service
|
||||
drmserver_service
|
||||
mediaextractor_service
|
||||
mediametrics_service
|
||||
mediaserver_service
|
||||
}:service_manager find;
|
||||
|
||||
# Allow devicesettings_app read and write /data/data subdirectory
|
||||
allow devicesettings_app system_app_data_file:dir create_dir_perms;
|
||||
allow devicesettings_app system_app_data_file:{ file lnk_file } create_file_perms;
|
||||
|
||||
# Allow binder communication with gpuservice
|
||||
binder_call(devicesettings_app, gpuservice)
|
||||
|
||||
# Allow devicesettings_app to read and write to cgroup/sysfs_leds/sysfs_thermal
|
||||
allow devicesettings_app sysfs_leds:dir search;
|
||||
#allow devicesettings_app vendor_sysfs_graphics:dir search;
|
||||
allow devicesettings_app {
|
||||
cgroup
|
||||
sysfs_leds
|
||||
sysfs_thermal
|
||||
}:{ file lnk_file } rw_file_perms;
|
||||
1
sepolicy/private/xiaomi/devicesettings/file.te
Normal file
1
sepolicy/private/xiaomi/devicesettings/file.te
Normal file
@@ -0,0 +1 @@
|
||||
type sysfs_lcd_feature, sysfs_type, fs_type;
|
||||
1
sepolicy/private/xiaomi/devicesettings/genfs_contexts
Normal file
1
sepolicy/private/xiaomi/devicesettings/genfs_contexts
Normal file
@@ -0,0 +1 @@
|
||||
genfscon sysfs /devices/virtual/display/disp_param/disp_param u:object_r:sysfs_lcd_feature:s0
|
||||
2
sepolicy/private/xiaomi/devicesettings/init.te
Normal file
2
sepolicy/private/xiaomi/devicesettings/init.te
Normal file
@@ -0,0 +1,2 @@
|
||||
allow init sysfs_lcd_feature:{ file lnk_file } rw_file_perms;
|
||||
|
||||
1
sepolicy/private/xiaomi/devicesettings/property.te
Normal file
1
sepolicy/private/xiaomi/devicesettings/property.te
Normal file
@@ -0,0 +1 @@
|
||||
type persist_lcd_prop, property_type, system_property_type;
|
||||
1
sepolicy/private/xiaomi/devicesettings/property_contexts
Normal file
1
sepolicy/private/xiaomi/devicesettings/property_contexts
Normal file
@@ -0,0 +1 @@
|
||||
persist.lcd. u:object_r:persist_lcd_prop:s0
|
||||
@@ -1,2 +0,0 @@
|
||||
user=system seinfo=platform name=org.lineageos.settings domain=devicesettings_app type=system_app_data_file
|
||||
user=system seinfo=platform name=org.lineageos.devicesettings domain=devicesettings_app type=system_app_data_file
|
||||
30
sepolicy/private/xiaomi/devicesettings/system_app.te
Normal file
30
sepolicy/private/xiaomi/devicesettings/system_app.te
Normal file
@@ -0,0 +1,30 @@
|
||||
get_prop(system_app, persist_lcd_prop)
|
||||
set_prop(system_app, persist_lcd_prop)
|
||||
|
||||
# Allow system_app to find *_service
|
||||
allow system_app {
|
||||
app_api_service
|
||||
audio_service
|
||||
audioserver_service
|
||||
cameraserver_service
|
||||
drmserver_service
|
||||
mediaextractor_service
|
||||
mediametrics_service
|
||||
mediaserver_service
|
||||
}:service_manager find;
|
||||
|
||||
# Allow system_app read and write /data/data subdirectory
|
||||
allow system_app system_app_data_file:dir create_dir_perms;
|
||||
allow system_app system_app_data_file:{ file lnk_file } create_file_perms;
|
||||
|
||||
# Allow binder communication with gpuservice
|
||||
binder_call(system_app, gpuservice)
|
||||
|
||||
# Allow system_app to read and write to cgroup/sysfs_leds/sysfs_thermal
|
||||
allow system_app sysfs_leds:dir search;
|
||||
#allow system_app vendor_sysfs_graphics:dir search;
|
||||
allow system_app {
|
||||
cgroup
|
||||
sysfs_leds
|
||||
sysfs_thermal
|
||||
}:{ file lnk_file } rw_file_perms;
|
||||
@@ -1,2 +0,0 @@
|
||||
type devicesettings_app, domain;
|
||||
typeattribute devicesettings_app mlstrustedsubject;
|
||||
Reference in New Issue
Block a user