From 6c5da520d2590eb3d1732510aa04a8a8aafc380a Mon Sep 17 00:00:00 2001 From: Lostark13 Date: Sun, 22 Sep 2024 05:48:06 +0000 Subject: [PATCH] sky: Add LCD features --- BoardConfig.mk | 4 +- device.mk | 6 ++ parts/Android.bp | 1 + parts/AndroidManifest.xml | 42 ++++++++++ parts/init.xiaomiparts.rc | 40 +++++++++ parts/res/drawable/ic_cabc.xml | 19 +++++ parts/res/drawable/ic_hbm.xml | 8 ++ parts/res/values/arrays.xml | 28 +++++++ parts/res/values/strings.xml | 9 ++ parts/res/xml/lcd_features_settings.xml | 36 ++++++++ .../settings/BootCompletedReceiver.java | 2 + .../settings/display/CabcTileService.java | 76 +++++++++++++++++ .../settings/display/HbmTileService.java | 74 ++++++++++++++++ .../LcdFeaturesPreferenceActivity.java | 31 +++++++ .../LcdFeaturesPreferenceFragment.java | 80 ++++++++++++++++++ .../settings/display/LcdFeaturesService.java | 84 +++++++++++++++++++ .../devicesettings/devicesettings_app.te | 29 ------- .../private/xiaomi/devicesettings/file.te | 1 + .../xiaomi/devicesettings/genfs_contexts | 1 + .../private/xiaomi/devicesettings/init.te | 2 + .../private/xiaomi/devicesettings/property.te | 1 + .../xiaomi/devicesettings/property_contexts | 1 + .../xiaomi/devicesettings/seapp_contexts | 2 - .../xiaomi/devicesettings/system_app.te | 30 +++++++ .../devicesettings/devicesettings_app.te | 2 - 25 files changed, 574 insertions(+), 35 deletions(-) create mode 100644 parts/init.xiaomiparts.rc create mode 100644 parts/res/drawable/ic_cabc.xml create mode 100644 parts/res/drawable/ic_hbm.xml create mode 100644 parts/res/xml/lcd_features_settings.xml create mode 100644 parts/src/org/lineageos/settings/display/CabcTileService.java create mode 100644 parts/src/org/lineageos/settings/display/HbmTileService.java create mode 100644 parts/src/org/lineageos/settings/display/LcdFeaturesPreferenceActivity.java create mode 100644 parts/src/org/lineageos/settings/display/LcdFeaturesPreferenceFragment.java create mode 100644 parts/src/org/lineageos/settings/display/LcdFeaturesService.java delete mode 100644 sepolicy/private/xiaomi/devicesettings/devicesettings_app.te create mode 100644 sepolicy/private/xiaomi/devicesettings/file.te create mode 100644 sepolicy/private/xiaomi/devicesettings/genfs_contexts create mode 100644 sepolicy/private/xiaomi/devicesettings/init.te create mode 100644 sepolicy/private/xiaomi/devicesettings/property.te create mode 100644 sepolicy/private/xiaomi/devicesettings/property_contexts delete mode 100644 sepolicy/private/xiaomi/devicesettings/seapp_contexts create mode 100644 sepolicy/private/xiaomi/devicesettings/system_app.te delete mode 100644 sepolicy/public/xiaomi/devicesettings/devicesettings_app.te diff --git a/BoardConfig.mk b/BoardConfig.mk index 65b3fe9..bdffa0f 100644 --- a/BoardConfig.mk +++ b/BoardConfig.mk @@ -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 += \ diff --git a/device.mk b/device.mk index a0118cf..511ffb9 100644 --- a/device.mk +++ b/device.mk @@ -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 \ diff --git a/parts/Android.bp b/parts/Android.bp index faa4349..8d7adc2 100644 --- a/parts/Android.bp +++ b/parts/Android.bp @@ -7,6 +7,7 @@ android_app { name: "XiaomiParts", + init_rc: ["init.xiaomiparts.rc"], srcs: ["src/**/*.java"], resource_dirs: ["res"], certificate: "platform", diff --git a/parts/AndroidManifest.xml b/parts/AndroidManifest.xml index ffab526..38a8365 100644 --- a/parts/AndroidManifest.xml +++ b/parts/AndroidManifest.xml @@ -47,6 +47,48 @@ android:permission="ThermalService"> + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/parts/res/drawable/ic_hbm.xml b/parts/res/drawable/ic_hbm.xml new file mode 100644 index 0000000..a280bdf --- /dev/null +++ b/parts/res/drawable/ic_hbm.xml @@ -0,0 +1,8 @@ + + + diff --git a/parts/res/values/arrays.xml b/parts/res/values/arrays.xml index b977678..abc6d4d 100644 --- a/parts/res/values/arrays.xml +++ b/parts/res/values/arrays.xml @@ -126,4 +126,32 @@ 2 3 + + + "Off" + "Low" + "Medium" + "High" + + + + "0" + "1" + "2" + "3" + + + + "Off" + "Low (UI)" + "Medium (Videos)" + "High (Images)" + + + + "0" + "1" + "3" + "2" + diff --git a/parts/res/values/strings.xml b/parts/res/values/strings.xml index 36c3b21..950e4c9 100644 --- a/parts/res/values/strings.xml +++ b/parts/res/values/strings.xml @@ -84,4 +84,13 @@ Select Scene Video Voice + + + LCD features + High Brightness Mode, CABC + High Brightness Mode (HBM) + HBM + CABC Mode + 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. + diff --git a/parts/res/xml/lcd_features_settings.xml b/parts/res/xml/lcd_features_settings.xml new file mode 100644 index 0000000..0e2be5e --- /dev/null +++ b/parts/res/xml/lcd_features_settings.xml @@ -0,0 +1,36 @@ + + + + + + + diff --git a/parts/src/org/lineageos/settings/BootCompletedReceiver.java b/parts/src/org/lineageos/settings/BootCompletedReceiver.java index d02bfa2..31d4360 100644 --- a/parts/src/org/lineageos/settings/BootCompletedReceiver.java +++ b/parts/src/org/lineageos/settings/BootCompletedReceiver.java @@ -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)); } } diff --git a/parts/src/org/lineageos/settings/display/CabcTileService.java b/parts/src/org/lineageos/settings/display/CabcTileService.java new file mode 100644 index 0000000..7a582ed --- /dev/null +++ b/parts/src/org/lineageos/settings/display/CabcTileService.java @@ -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(); + } +} diff --git a/parts/src/org/lineageos/settings/display/HbmTileService.java b/parts/src/org/lineageos/settings/display/HbmTileService.java new file mode 100644 index 0000000..4b3915c --- /dev/null +++ b/parts/src/org/lineageos/settings/display/HbmTileService.java @@ -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(); + } +} diff --git a/parts/src/org/lineageos/settings/display/LcdFeaturesPreferenceActivity.java b/parts/src/org/lineageos/settings/display/LcdFeaturesPreferenceActivity.java new file mode 100644 index 0000000..8e42e3b --- /dev/null +++ b/parts/src/org/lineageos/settings/display/LcdFeaturesPreferenceActivity.java @@ -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(); + } +} diff --git a/parts/src/org/lineageos/settings/display/LcdFeaturesPreferenceFragment.java b/parts/src/org/lineageos/settings/display/LcdFeaturesPreferenceFragment.java new file mode 100644 index 0000000..5830202 --- /dev/null +++ b/parts/src/org/lineageos/settings/display/LcdFeaturesPreferenceFragment.java @@ -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; + } +} diff --git a/parts/src/org/lineageos/settings/display/LcdFeaturesService.java b/parts/src/org/lineageos/settings/display/LcdFeaturesService.java new file mode 100644 index 0000000..2ad11b2 --- /dev/null +++ b/parts/src/org/lineageos/settings/display/LcdFeaturesService.java @@ -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(); + } + } + }; +} diff --git a/sepolicy/private/xiaomi/devicesettings/devicesettings_app.te b/sepolicy/private/xiaomi/devicesettings/devicesettings_app.te deleted file mode 100644 index a082294..0000000 --- a/sepolicy/private/xiaomi/devicesettings/devicesettings_app.te +++ /dev/null @@ -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; diff --git a/sepolicy/private/xiaomi/devicesettings/file.te b/sepolicy/private/xiaomi/devicesettings/file.te new file mode 100644 index 0000000..0ed7f25 --- /dev/null +++ b/sepolicy/private/xiaomi/devicesettings/file.te @@ -0,0 +1 @@ +type sysfs_lcd_feature, sysfs_type, fs_type; diff --git a/sepolicy/private/xiaomi/devicesettings/genfs_contexts b/sepolicy/private/xiaomi/devicesettings/genfs_contexts new file mode 100644 index 0000000..5b3e6d3 --- /dev/null +++ b/sepolicy/private/xiaomi/devicesettings/genfs_contexts @@ -0,0 +1 @@ +genfscon sysfs /devices/virtual/display/disp_param/disp_param u:object_r:sysfs_lcd_feature:s0 diff --git a/sepolicy/private/xiaomi/devicesettings/init.te b/sepolicy/private/xiaomi/devicesettings/init.te new file mode 100644 index 0000000..86d9d78 --- /dev/null +++ b/sepolicy/private/xiaomi/devicesettings/init.te @@ -0,0 +1,2 @@ +allow init sysfs_lcd_feature:{ file lnk_file } rw_file_perms; + diff --git a/sepolicy/private/xiaomi/devicesettings/property.te b/sepolicy/private/xiaomi/devicesettings/property.te new file mode 100644 index 0000000..7a2f7c4 --- /dev/null +++ b/sepolicy/private/xiaomi/devicesettings/property.te @@ -0,0 +1 @@ +type persist_lcd_prop, property_type, system_property_type; diff --git a/sepolicy/private/xiaomi/devicesettings/property_contexts b/sepolicy/private/xiaomi/devicesettings/property_contexts new file mode 100644 index 0000000..6f663e7 --- /dev/null +++ b/sepolicy/private/xiaomi/devicesettings/property_contexts @@ -0,0 +1 @@ +persist.lcd. u:object_r:persist_lcd_prop:s0 diff --git a/sepolicy/private/xiaomi/devicesettings/seapp_contexts b/sepolicy/private/xiaomi/devicesettings/seapp_contexts deleted file mode 100644 index 5a0ad21..0000000 --- a/sepolicy/private/xiaomi/devicesettings/seapp_contexts +++ /dev/null @@ -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 diff --git a/sepolicy/private/xiaomi/devicesettings/system_app.te b/sepolicy/private/xiaomi/devicesettings/system_app.te new file mode 100644 index 0000000..8827b00 --- /dev/null +++ b/sepolicy/private/xiaomi/devicesettings/system_app.te @@ -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; diff --git a/sepolicy/public/xiaomi/devicesettings/devicesettings_app.te b/sepolicy/public/xiaomi/devicesettings/devicesettings_app.te deleted file mode 100644 index 9c05e95..0000000 --- a/sepolicy/public/xiaomi/devicesettings/devicesettings_app.te +++ /dev/null @@ -1,2 +0,0 @@ -type devicesettings_app, domain; -typeattribute devicesettings_app mlstrustedsubject;