From 25dadea83beebefb949e050c9a97dd62f91bfe98 Mon Sep 17 00:00:00 2001 From: Stylogey Date: Thu, 12 Dec 2019 17:46:42 +0100 Subject: [PATCH] sdm660-common: XiaomiParts: Start folio_daemon only if a prop is set --- .../org/lineageos/settings/device/BootReceiver.java | 4 +++- .../lineageos/settings/device/DeviceSettings.java | 4 +++- .../src/org/lineageos/settings/device/FileUtils.java | 12 +++++++++++- rootdir/etc/init.target.rc | 8 ++++---- sepolicy/vendor/property.te | 3 +++ sepolicy/vendor/property_contexts | 3 +++ sepolicy/vendor/system_app.te | 2 ++ 7 files changed, 29 insertions(+), 7 deletions(-) diff --git a/XiaomiParts/src/org/lineageos/settings/device/BootReceiver.java b/XiaomiParts/src/org/lineageos/settings/device/BootReceiver.java index 0b803641..5092ab1a 100644 --- a/XiaomiParts/src/org/lineageos/settings/device/BootReceiver.java +++ b/XiaomiParts/src/org/lineageos/settings/device/BootReceiver.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 The Xiaomi-SDM660 Project + * Copyright (C) 2018-2019 The Xiaomi-SDM660 Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,6 +59,8 @@ public class BootReceiver extends BroadcastReceiver implements Utils { context.getContentResolver(), DeviceSettings.PREF_THERMAL)); FileUtils.setValue(DeviceSettings.HALL_WAKEUP_PATH, Settings.Secure.getInt( context.getContentResolver(), DeviceSettings.PREF_HALL_WAKEUP, 1) == 1 ? "Y" : "N"); + FileUtils.setProp(DeviceSettings.HALL_WAKEUP_PROP, Settings.Secure.getInt( + context.getContentResolver(), DeviceSettings.PREF_HALL_WAKEUP, 1) == 1); context.startService(new Intent(context, DiracService.class)); } } diff --git a/XiaomiParts/src/org/lineageos/settings/device/DeviceSettings.java b/XiaomiParts/src/org/lineageos/settings/device/DeviceSettings.java index 576c15c1..440ad878 100644 --- a/XiaomiParts/src/org/lineageos/settings/device/DeviceSettings.java +++ b/XiaomiParts/src/org/lineageos/settings/device/DeviceSettings.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 The Xiaomi-SDM660 Project + * Copyright (C) 2018-2019 The Xiaomi-SDM660 Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,6 +52,7 @@ public class DeviceSettings extends PreferenceFragment implements private static final String CATEGORY_HALL_WAKEUP = "hall_wakeup"; public static final String PREF_HALL_WAKEUP = "hall"; public static final String HALL_WAKEUP_PATH = "/sys/module/hall/parameters/hall_toggle"; + public static final String HALL_WAKEUP_PROP = "vendor.persist.hall_wakeup"; private static final String DEVICE_DOZE_PACKAGE_NAME = "org.lineageos.settings.doze"; @@ -160,6 +161,7 @@ public class DeviceSettings extends PreferenceFragment implements case PREF_HALL_WAKEUP: FileUtils.setValue(HALL_WAKEUP_PATH, (boolean) value ? "Y" : "N"); + FileUtils.setProp(HALL_WAKEUP_PROP, (boolean) value); break; default: diff --git a/XiaomiParts/src/org/lineageos/settings/device/FileUtils.java b/XiaomiParts/src/org/lineageos/settings/device/FileUtils.java index 72005f32..4190a5ac 100644 --- a/XiaomiParts/src/org/lineageos/settings/device/FileUtils.java +++ b/XiaomiParts/src/org/lineageos/settings/device/FileUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 The Xiaomi-SDM660 Project + * Copyright (C) 2018-2019 The Xiaomi-SDM660 Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ package org.lineageos.settings.device; +import android.os.SystemProperties; + import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; @@ -112,4 +114,12 @@ public class FileUtils { // ignore return line; } + + static void setProp(String prop, boolean value) { + if (value) { + SystemProperties.set(prop, "1"); + } else { + SystemProperties.set(prop, "0"); + } + } } diff --git a/rootdir/etc/init.target.rc b/rootdir/etc/init.target.rc index a26b5c87..f78d4d42 100755 --- a/rootdir/etc/init.target.rc +++ b/rootdir/etc/init.target.rc @@ -158,12 +158,12 @@ service folio_daemon /system/bin/folio_daemon group system uhid disabled -on property:init.svc.zygote=running - start folio_daemon - -on property:init.svc.zygote=stopped +on property:vendor.persist.hall_wakeup=0 stop folio_daemon +on property:vendor.persist.hall_wakeup=1 + start folio_daemon + #Peripheral manager service vendor.per_mgr /system/vendor/bin/pm-service class core diff --git a/sepolicy/vendor/property.te b/sepolicy/vendor/property.te index 354c0a16..31e4a884 100644 --- a/sepolicy/vendor/property.te +++ b/sepolicy/vendor/property.te @@ -9,3 +9,6 @@ type thermal_engine_prop, property_type; # Dirac type dirac_prop, property_type; + +# Hall wakeup +type hall_wakeup_prop, property_type; diff --git a/sepolicy/vendor/property_contexts b/sepolicy/vendor/property_contexts index 6589089c..dc27c9aa 100644 --- a/sepolicy/vendor/property_contexts +++ b/sepolicy/vendor/property_contexts @@ -37,3 +37,6 @@ persist.audio.dirac. u:object_r:dirac_prop:s0 # MPCTL sys.post_boot.parsed u:object_r:vendor_mpctl_prop:s0 + +# Hall wakeup +vendor.persist.hall_wakeup u:object_r:hall_wakeup_prop:s0 diff --git a/sepolicy/vendor/system_app.te b/sepolicy/vendor/system_app.te index ede860b4..f55b8216 100644 --- a/sepolicy/vendor/system_app.te +++ b/sepolicy/vendor/system_app.te @@ -9,3 +9,5 @@ allow system_app sysfs_thermal:file rw_file_perms; allow system_app sysfs_thermal:dir search; allow system_app sysfs_vibrator:file rw_file_perms; allow system_app sysfs_vibrator:dir search; + +set_prop(system_app, hall_wakeup_prop);