mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-22 04:05:31 -04:00
universal7885: SamsungParts: Move to AIDL
This commit is contained in:
parent
453f0f5f48
commit
9030e2eb7b
16 changed files with 148 additions and 269 deletions
|
|
@ -5,8 +5,11 @@ android_app {
|
|||
],
|
||||
platform_apis: true,
|
||||
certificate: "platform",
|
||||
jni_libs: ["libsamsungparts_jni"],
|
||||
static_libs: ["androidx.preference_preference"],
|
||||
jni_libs: ["libSwapStorageHelper"],
|
||||
static_libs: [
|
||||
"androidx.preference_preference",
|
||||
"vendor.eureka.hardware.parts-java",
|
||||
],
|
||||
defaults: ["SettingsLibDefaults"],
|
||||
required: ["vendor.eureka.hardware.parts-service"],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
cc_library_shared {
|
||||
name: "libsamsungparts_jni",
|
||||
name: "libSwapStorageHelper",
|
||||
defaults: ["eureka_defaults"],
|
||||
cflags: [
|
||||
"-Wall",
|
||||
|
|
@ -10,10 +10,4 @@ cc_library_shared {
|
|||
srcs: ["*.cpp"],
|
||||
header_libs: ["jni_headers"],
|
||||
static_libs: ["libc++fs"],
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"vendor.eureka.hardware.parts@1.0",
|
||||
],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,88 +0,0 @@
|
|||
#include "jni.h"
|
||||
#include <hardware/hardware.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IBatteryStats.h>
|
||||
|
||||
using android::sp;
|
||||
using vendor::eureka::hardware::parts::V1_0::IBatteryStats;
|
||||
using vendor::eureka::hardware::parts::V1_0::Status;
|
||||
using vendor::eureka::hardware::parts::V1_0::BatterySys;
|
||||
|
||||
enum {
|
||||
BATTERY_CAPACITY_MAX = 1,
|
||||
BATTERY_CAPACITY_CURRENT,
|
||||
BATTERY_CAPACITY_CURRENT_MAH,
|
||||
CHARGING_STATE,
|
||||
BATTERY_TEMP,
|
||||
BATTERY_CURRENT = 6
|
||||
};
|
||||
|
||||
static android::sp<IBatteryStats> service = IBatteryStats::getService();
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_setChargeSysfs(
|
||||
JNIEnv /*env*/, __unused jclass obj, jint enable) {
|
||||
if (enable == 1) {
|
||||
service->setBatteryWritable(BatterySys::CHARGE, Status::ENABLE);
|
||||
} else {
|
||||
service->setBatteryWritable(BatterySys::CHARGE, Status::DISABLE);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_getChargeSysfs(
|
||||
JNIEnv /*env*/, __unused jclass obj) {
|
||||
int ret = service->getBatteryStats(BatterySys::CHARGE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_setFastCharge(
|
||||
JNIEnv /*env*/, __unused jobject obj, jint enable) {
|
||||
if (enable == 1) {
|
||||
service->setBatteryWritable(BatterySys::FASTCHARGE, Status::ENABLE);
|
||||
} else {
|
||||
service->setBatteryWritable(BatterySys::FASTCHARGE, Status::DISABLE);
|
||||
}
|
||||
}
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_getFastChargeSysfs(
|
||||
JNIEnv /*env*/, __unused jclass obj) {
|
||||
int ret = service->getBatteryStats(BatterySys::FASTCHARGE);
|
||||
return ret;
|
||||
}
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_getGeneralBatteryStats(
|
||||
JNIEnv /*env*/, __unused jobject obj, jint id) {
|
||||
int ret;
|
||||
switch (id) {
|
||||
case BATTERY_CAPACITY_MAX:
|
||||
ret = service->getBatteryStats(BatterySys::CAPACITY_MAX) / 1000;
|
||||
break;
|
||||
case BATTERY_CAPACITY_CURRENT:
|
||||
ret = service->getBatteryStats(BatterySys::CAPACITY_CURRENT);
|
||||
break;
|
||||
case BATTERY_CAPACITY_CURRENT_MAH:
|
||||
ret = (float)service->getBatteryStats(BatterySys::CAPACITY_CURRENT) *
|
||||
(float)service->getBatteryStats(BatterySys::CAPACITY_MAX) / 100000;
|
||||
break;
|
||||
case CHARGING_STATE:
|
||||
if (service->getBatteryStats(BatterySys::CURRENT) > 0) {
|
||||
ret = 1;
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
case BATTERY_TEMP:
|
||||
ret = service->getBatteryStats(BatterySys::TEMP) / 10;
|
||||
break;
|
||||
case BATTERY_CURRENT:
|
||||
ret = service->getBatteryStats(BatterySys::CURRENT);
|
||||
break;
|
||||
default:
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
#include "jni.h"
|
||||
#include <hardware/hardware.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IDisplayConfigs.h>
|
||||
|
||||
using android::sp;
|
||||
using vendor::eureka::hardware::parts::V1_0::DisplaySys;
|
||||
using vendor::eureka::hardware::parts::V1_0::IDisplayConfigs;
|
||||
using vendor::eureka::hardware::parts::V1_0::Status;
|
||||
|
||||
static android::sp<IDisplayConfigs> service = IDisplayConfigs::getService();
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Display_setDT2W(JNIEnv /*env*/,
|
||||
jclass /*clazz*/,
|
||||
jboolean enable) {
|
||||
if (enable) {
|
||||
service->writeDisplay(Status::ENABLE, DisplaySys::DOUBLE_TAP);
|
||||
} else {
|
||||
service->writeDisplay(Status::DISABLE, DisplaySys::DOUBLE_TAP);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Display_setGloveMode(
|
||||
JNIEnv /**env*/, jclass /*clazz*/, jboolean enable) {
|
||||
if (enable) {
|
||||
service->writeDisplay(Status::ENABLE, DisplaySys::GLOVE_MODE);
|
||||
} else {
|
||||
service->writeDisplay(Status::DISABLE, DisplaySys::GLOVE_MODE);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
#include "jni.h"
|
||||
#include <hardware/hardware.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IFlashBrightness.h>
|
||||
|
||||
using android::sp;
|
||||
|
||||
using vendor::eureka::hardware::parts::V1_0::IFlashBrightness;
|
||||
using vendor::eureka::hardware::parts::V1_0::Status;
|
||||
|
||||
static android::sp<IFlashBrightness> service = IFlashBrightness::getService();
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Flashlight_setEnabled(
|
||||
JNIEnv /*env*/, __unused jobject obj, jboolean enabled) {
|
||||
if (enabled) {
|
||||
service->setFlashlightEnable(Status::ENABLE);
|
||||
} else {
|
||||
service->setFlashlightEnable(Status::DISABLE);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Flashlight_setFlash(
|
||||
JNIEnv /*env*/, __unused jobject obj, jint value) {
|
||||
service->setFlashlightWritable(value);
|
||||
}
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Flashlight_getFlash(JNIEnv /*env*/,
|
||||
jobject /*clazz*/,
|
||||
jint isA10) {
|
||||
int ret;
|
||||
if (isA10 == 1) {
|
||||
ret = service->readFlashlightstats(false);
|
||||
} else {
|
||||
ret = service->readFlashlightstats(true);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
#include "jni.h"
|
||||
#include <hardware/hardware.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/ISwapOnData.h>
|
||||
|
||||
using android::sp;
|
||||
using vendor::eureka::hardware::parts::V1_0::ISwapOnData;
|
||||
|
||||
static sp<ISwapOnData> service = ISwapOnData::getService();
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Swap_setSize(JNIEnv /*env*/,
|
||||
jclass /*clazz*/,
|
||||
jint size) {
|
||||
service->setSwapSize(size);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Swap_setSwapOn(JNIEnv /*env*/,
|
||||
jclass /*clazz*/,
|
||||
jboolean enable) {
|
||||
if (enable) {
|
||||
service->setSwapOn();
|
||||
} else {
|
||||
service->setSwapOff();
|
||||
}
|
||||
}
|
||||
|
|
@ -20,16 +20,11 @@ class BootReceiver : BroadcastReceiver() {
|
|||
val mSharedPreferences = p0?.let { PreferenceManager.getDefaultSharedPreferences(it) }
|
||||
if (p1 != null && mSharedPreferences != null) {
|
||||
if (p1.action == Intent.ACTION_BOOT_COMPLETED) {
|
||||
System.loadLibrary("samsungparts_jni")
|
||||
System.loadLibrary("SwapStorageHelper")
|
||||
// Battery
|
||||
Battery.chargeSysfs = if (mSharedPreferences
|
||||
.getBoolean(BatteryFragment.PREF_CHARGE, true)
|
||||
) 0 else 1
|
||||
Battery.setFastCharge(
|
||||
if (mSharedPreferences
|
||||
.getBoolean(BatteryFragment.PREF_FASTCHARGE, true)
|
||||
) 0 else 1
|
||||
)
|
||||
val mBattery = Battery()
|
||||
mBattery.Charge = mSharedPreferences.getBoolean(BatteryFragment.PREF_CHARGE, true)
|
||||
mBattery.FastCharge = mSharedPreferences.getBoolean(BatteryFragment.PREF_FASTCHARGE, true)
|
||||
// Dolby
|
||||
DolbyCore.setEnabled(
|
||||
mSharedPreferences
|
||||
|
|
@ -41,14 +36,18 @@ class BootReceiver : BroadcastReceiver() {
|
|||
)
|
||||
|
||||
// FlashLight
|
||||
Flashlight.setFlash(mSharedPreferences.getInt(FlashLightFragment.PREF_FLASHLIGHT, 5))
|
||||
val mFlash = Flashlight()
|
||||
mFlash.setFlash(mSharedPreferences.getInt(FlashLightFragment.PREF_FLASHLIGHT, 5))
|
||||
|
||||
// ZRAM
|
||||
Swap.setSize(mSharedPreferences.getInt(SwapFragment.PREF_SWAP_SIZE, 50))
|
||||
Swap.setSwapOn(mSharedPreferences.getBoolean(SwapFragment.PREF_SWAP_ENABLE, false))
|
||||
val mSwap = Swap()
|
||||
mSwap.setSize(mSharedPreferences.getInt(SwapFragment.PREF_SWAP_SIZE, 50))
|
||||
mSwap.setSwapOn(mSharedPreferences.getBoolean(SwapFragment.PREF_SWAP_ENABLE, false))
|
||||
|
||||
// Display
|
||||
Display.DT2W = mSharedPreferences.getBoolean(DeviceSettings.PREF_DOUBLE_TAP, true)
|
||||
Display.GloveMode = mSharedPreferences.getBoolean(DeviceSettings.PREF_GLOVE_MODE, false)
|
||||
val mDisplay = Display()
|
||||
mDisplay.DT2W = mSharedPreferences.getBoolean(DeviceSettings.PREF_DOUBLE_TAP, true)
|
||||
mDisplay.GloveMode = mSharedPreferences.getBoolean(DeviceSettings.PREF_GLOVE_MODE, false)
|
||||
Log.i("SamsungParts", "Applied settings")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,15 +26,14 @@ import androidx.preference.SwitchPreference
|
|||
import com.eurekateam.samsungextras.battery.BatteryActivity
|
||||
import com.eurekateam.samsungextras.flashlight.FlashLightActivity
|
||||
import com.eurekateam.samsungextras.fps.FPSInfoService
|
||||
import com.eurekateam.samsungextras.interfaces.Display.DT2W
|
||||
import com.eurekateam.samsungextras.interfaces.Display.GloveMode
|
||||
import com.eurekateam.samsungextras.interfaces.Display
|
||||
import com.eurekateam.samsungextras.speaker.ClearSpeakerActivity
|
||||
|
||||
class DeviceSettings : PreferenceFragmentCompat(), Preference.OnPreferenceChangeListener {
|
||||
|
||||
private lateinit var mPrefs: SharedPreferences
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
System.loadLibrary("samsungparts_jni")
|
||||
System.loadLibrary("SwapStorageHelper")
|
||||
setPreferencesFromResource(R.xml.preferences_samsung_parts, rootKey)
|
||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
val mClearSpeakerPref = findPreference<Preference>(PREF_CLEAR_SPEAKER)!!
|
||||
|
|
@ -72,6 +71,7 @@ class DeviceSettings : PreferenceFragmentCompat(), Preference.OnPreferenceChange
|
|||
}
|
||||
|
||||
override fun onPreferenceChange(preference: Preference, value: Any): Boolean {
|
||||
val mDisplay = Display()
|
||||
when (preference.key) {
|
||||
PREF_KEY_FPS_INFO -> {
|
||||
val mEnabled = value as Boolean
|
||||
|
|
@ -84,11 +84,11 @@ class DeviceSettings : PreferenceFragmentCompat(), Preference.OnPreferenceChange
|
|||
mPrefs.edit().putBoolean(PREF_KEY_FPS_INFO, mEnabled).apply()
|
||||
}
|
||||
PREF_DOUBLE_TAP -> {
|
||||
DT2W = value as Boolean
|
||||
mDisplay.DT2W = value as Boolean
|
||||
mPrefs.edit().putBoolean(PREF_DOUBLE_TAP, value).apply()
|
||||
}
|
||||
PREF_GLOVE_MODE -> {
|
||||
GloveMode = value as Boolean
|
||||
mDisplay.GloveMode = value as Boolean
|
||||
mPrefs.edit().putBoolean(PREF_GLOVE_MODE, value).apply()
|
||||
}
|
||||
else -> {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.android.settingslib.widget.MainSwitchPreference
|
|||
import com.android.settingslib.widget.OnMainSwitchChangeListener
|
||||
import com.eurekateam.samsungextras.R
|
||||
import com.eurekateam.samsungextras.interfaces.Battery
|
||||
import com.eurekateam.samsungextras.interfaces.BatteryIds
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
|
|
@ -54,27 +55,30 @@ class BatteryFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChang
|
|||
}
|
||||
|
||||
override fun onPreferenceChange(preference: Preference, newValue: Any): Boolean {
|
||||
val mBattery = Battery()
|
||||
if (preference == mChargePref) {
|
||||
val value = newValue as Boolean
|
||||
Battery.chargeSysfs = if (value) 0 else 1
|
||||
mChargePref.isChecked = Battery.chargeSysfs == 0
|
||||
mSharedPreferences.edit().putBoolean(PREF_CHARGE, Battery.chargeSysfs == 0).apply()
|
||||
mBattery.Charge = value
|
||||
mChargePref.isChecked = mBattery.Charge
|
||||
mSharedPreferences.edit().putBoolean(PREF_CHARGE, mBattery.Charge).apply()
|
||||
return true
|
||||
} else if (preference == mFastChargePref) {
|
||||
Battery.setFastCharge(if (newValue as Boolean) 0 else 1)
|
||||
mFastChargePref.isChecked = Battery.fastChargeSysfs == 0
|
||||
mSharedPreferences.edit().putBoolean(PREF_FASTCHARGE, Battery.fastChargeSysfs == 0).apply()
|
||||
mBattery.FastCharge = newValue as Boolean
|
||||
mFastChargePref.isChecked = mBattery.FastCharge
|
||||
mSharedPreferences.edit().putBoolean(PREF_FASTCHARGE, mBattery.FastCharge).apply()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
private val mScheduler = Runnable {
|
||||
val mBattery = Battery()
|
||||
requireActivity().runOnUiThread {
|
||||
findPreference<Preference>(INFO_MAX_CAP)!!.summary = Battery.getGeneralBatteryStats(1).toString() + " mAh"
|
||||
findPreference<Preference>(INFO_CHARGED_UP_TO)!!.summary = Battery.getGeneralBatteryStats(2).toString() + " %"
|
||||
findPreference<Preference>(INFO_CHARGED_MAH)!!.summary = Battery.getGeneralBatteryStats(3).toString() + " mAh"
|
||||
findPreference<Preference>(INFO_CURRENT)!!.summary = Battery.getGeneralBatteryStats(6).toString() + " mA"
|
||||
findPreference<Preference>(INFO_STATUS)!!.summary = if (Battery.getGeneralBatteryStats(4) == 1) "Charging" else "Discharging"
|
||||
findPreference<Preference>(INFO_TEMP)!!.summary = Battery.getGeneralBatteryStats(5).toString() + " \u2103"
|
||||
findPreference<Preference>(INFO_MAX_CAP)!!.summary = mBattery.getGeneralBatteryStats(BatteryIds.BATTERY_CAPACITY_MAX).toString() + " mAh"
|
||||
findPreference<Preference>(INFO_CHARGED_UP_TO)!!.summary = mBattery.getGeneralBatteryStats(BatteryIds.BATTERY_CAPACITY_CURRENT).toString() + " %"
|
||||
findPreference<Preference>(INFO_CHARGED_MAH)!!.summary = mBattery.getGeneralBatteryStats(BatteryIds.BATTERY_CAPACITY_CURRENT_MAH).toString() + " mAh"
|
||||
findPreference<Preference>(INFO_CURRENT)!!.summary = mBattery.getGeneralBatteryStats(BatteryIds.BATTERY_CURRENT).toString() + " mA"
|
||||
findPreference<Preference>(INFO_STATUS)!!.summary = if (mBattery.getGeneralBatteryStats(BatteryIds.CHARGING_STATE) == 1) "Charging" else "Discharging"
|
||||
findPreference<Preference>(INFO_TEMP)!!.summary = mBattery.getGeneralBatteryStats(BatteryIds.BATTERY_TEMP).toString() + " \u2103"
|
||||
}
|
||||
}
|
||||
override fun onSwitchChanged(switchView: Switch, isChecked: Boolean) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ class FlashLightFragment : PreferenceFragmentCompat(), Preference.OnPreferenceCh
|
|||
mFlashLightPref.onPreferenceChangeListener = this
|
||||
mFlashLightPref.setMax(10)
|
||||
mFlashLightPref.setMin(1)
|
||||
mFlashLightPref.value = Flashlight.getFlash(if (Build.DEVICE.contains("a10")) 1 else 0)
|
||||
val mFlashLight = Flashlight()
|
||||
mFlashLightPref.value = mFlashLight.getFlash(Build.DEVICE.contains("a10"))
|
||||
mFlashLightEnable = findPreference(PREF_FLASHLIGHT_ENABLE)!!
|
||||
mFlashLightEnable.isChecked = mSharedPreferences.getBoolean(PREF_FLASHLIGHT_ENABLE, true)
|
||||
mFlashLightEnable.addOnSwitchChangeListener(this)
|
||||
|
|
@ -49,7 +50,8 @@ class FlashLightFragment : PreferenceFragmentCompat(), Preference.OnPreferenceCh
|
|||
override fun onPreferenceChange(preference: Preference, newValue: Any): Boolean {
|
||||
if (preference == mFlashLightPref) {
|
||||
val value = newValue as Int
|
||||
Flashlight.setFlash(value)
|
||||
val mFlash = Flashlight()
|
||||
mFlash.setFlash(value)
|
||||
mSharedPreferences.edit().putInt(PREF_FLASHLIGHT, value).apply()
|
||||
return true
|
||||
}
|
||||
|
|
@ -57,10 +59,13 @@ class FlashLightFragment : PreferenceFragmentCompat(), Preference.OnPreferenceCh
|
|||
}
|
||||
|
||||
override fun onSwitchChanged(switchView: Switch, isChecked: Boolean) {
|
||||
Flashlight.setEnabled(isChecked)
|
||||
val mFlash = Flashlight()
|
||||
mFlash.setEnabled(isChecked)
|
||||
mSharedPreferences.edit().putBoolean(PREF_FLASHLIGHT_ENABLE, isChecked)
|
||||
mFlashLightPref.isEnabled = isChecked
|
||||
} companion object {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val PREF_FLASHLIGHT = "flashlight_pref"
|
||||
const val PREF_FLASHLIGHT_ENABLE = "flashlight_enable"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,14 +15,40 @@
|
|||
*/
|
||||
package com.eurekateam.samsungextras.interfaces
|
||||
|
||||
object Battery {
|
||||
var chargeSysfs: Int
|
||||
external get
|
||||
external set
|
||||
import vendor.eureka.hardware.parts.IBatteryStats
|
||||
import vendor.eureka.hardware.parts.BatterySys
|
||||
|
||||
external fun setFastCharge(enable: Int)
|
||||
val fastChargeSysfs: Int
|
||||
external get
|
||||
import android.os.ServiceManager
|
||||
|
||||
external fun getGeneralBatteryStats(id: Int): Int
|
||||
class Battery {
|
||||
private val mBattery : IBatteryStats
|
||||
|
||||
init {
|
||||
mBattery = IBatteryStats.Stub.asInterface(ServiceManager.waitForDeclaredService("vendor.eureka.hardware.parts.IBatteryStats/default"))
|
||||
}
|
||||
|
||||
var Charge: Boolean
|
||||
get() {
|
||||
return mBattery.getBatteryStats(BatterySys.CHARGE) == 0
|
||||
}
|
||||
set(k) {
|
||||
mBattery.setBatteryWritable(BatterySys.CHARGE, k)
|
||||
}
|
||||
|
||||
var FastCharge: Boolean
|
||||
get() {
|
||||
return mBattery.getBatteryStats(BatterySys.FASTCHARGE) == 1
|
||||
}
|
||||
set(k) {
|
||||
mBattery.setBatteryWritable(BatterySys.FASTCHARGE, k)
|
||||
}
|
||||
|
||||
fun getGeneralBatteryStats(id: BatteryIds): Int = when (id) {
|
||||
BatteryIds.BATTERY_CAPACITY_MAX -> mBattery.getBatteryStats(BatterySys.CAPACITY_MAX) / 1000
|
||||
BatteryIds.BATTERY_CAPACITY_CURRENT -> mBattery.getBatteryStats(BatterySys.CAPACITY_CURRENT)
|
||||
BatteryIds.BATTERY_CAPACITY_CURRENT_MAH -> (mBattery.getBatteryStats(BatterySys.CAPACITY_CURRENT).toFloat() * mBattery.getBatteryStats(BatterySys.CAPACITY_MAX).toFloat() / 100000).toInt()
|
||||
BatteryIds.CHARGING_STATE -> if (mBattery.getBatteryStats(BatterySys.CURRENT) > 0) 1 else 0
|
||||
BatteryIds.BATTERY_TEMP -> mBattery.getBatteryStats(BatterySys.TEMP) / 10
|
||||
BatteryIds.BATTERY_CURRENT -> mBattery.getBatteryStats(BatterySys.CURRENT)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
package com.eurekateam.samsungextras.interfaces
|
||||
|
||||
enum class BatteryIds {
|
||||
BATTERY_CAPACITY_MAX,
|
||||
BATTERY_CAPACITY_CURRENT,
|
||||
BATTERY_CAPACITY_CURRENT_MAH,
|
||||
CHARGING_STATE,
|
||||
BATTERY_TEMP,
|
||||
BATTERY_CURRENT
|
||||
}
|
||||
|
|
@ -16,10 +16,21 @@
|
|||
|
||||
package com.eurekateam.samsungextras.interfaces
|
||||
|
||||
object Display {
|
||||
import vendor.eureka.hardware.parts.IDisplayConfigs
|
||||
import vendor.eureka.hardware.parts.DisplaySys
|
||||
|
||||
import android.os.ServiceManager
|
||||
|
||||
class Display {
|
||||
private val mDisplay : IDisplayConfigs
|
||||
|
||||
init {
|
||||
mDisplay = IDisplayConfigs.Stub.asInterface(ServiceManager.waitForDeclaredService("vendor.eureka.hardware.parts.IDisplayConfigs/default"))
|
||||
}
|
||||
|
||||
var DT2W: Boolean = false
|
||||
external set
|
||||
set(k) = mDisplay.writeDisplay(k, DisplaySys.DOUBLE_TAP)
|
||||
|
||||
var GloveMode: Boolean = false
|
||||
external set
|
||||
set(k) = mDisplay.writeDisplay(k, DisplaySys.GLOVE_MODE)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,19 @@
|
|||
|
||||
package com.eurekateam.samsungextras.interfaces
|
||||
|
||||
object Flashlight {
|
||||
external fun setFlash(value: Int)
|
||||
external fun getFlash(isA10: Int): Int
|
||||
external fun setEnabled(enable: Boolean)
|
||||
import vendor.eureka.hardware.parts.IFlashBrightness
|
||||
|
||||
import android.os.ServiceManager
|
||||
|
||||
class Flashlight {
|
||||
private val mFlash : IFlashBrightness
|
||||
|
||||
init {
|
||||
mFlash = IFlashBrightness.Stub.asInterface(ServiceManager.waitForDeclaredService("vendor.eureka.hardware.parts.IFlashBrightness/default"))
|
||||
}
|
||||
|
||||
fun setFlash(value: Int) = mFlash.setFlashlightWritable(value)
|
||||
|
||||
fun getFlash(a10: Boolean): Int = mFlash.readFlashlightstats(!a10)
|
||||
fun setEnabled(enable: Boolean) = mFlash.setFlashlightEnable(enable)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,18 @@
|
|||
|
||||
package com.eurekateam.samsungextras.interfaces
|
||||
|
||||
object Swap {
|
||||
external fun setSwapOn(mEnabled: Boolean)
|
||||
external fun setSize(mSize: Int)
|
||||
import vendor.eureka.hardware.parts.ISwapOnData
|
||||
|
||||
import android.os.ServiceManager
|
||||
|
||||
class Swap {
|
||||
private val mSwap : ISwapOnData
|
||||
init {
|
||||
mSwap = ISwapOnData.Stub.asInterface(ServiceManager.waitForDeclaredService("vendor.eureka.hardware.parts.ISwapOnData/default"))
|
||||
}
|
||||
|
||||
fun setSwapOn(mEnabled: Boolean) = if (mEnabled) mSwap.setSwapOn() else mSwap.setSwapOff()
|
||||
fun setSize(mSize: Int) = mSwap.setSwapSize(mSize)
|
||||
external fun getFreeSpace(): Double
|
||||
external fun getSwapSize(): Long
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ class SwapFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChangeLi
|
|||
private lateinit var mFreeSpace: Preference
|
||||
private lateinit var mSwapFileSize: Preference
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
val mSwap = Swap()
|
||||
addPreferencesFromResource(R.xml.swap_settings)
|
||||
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
mSwapSizePref = findPreference(PREF_SWAP_SIZE)!!
|
||||
|
|
@ -47,18 +48,19 @@ class SwapFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChangeLi
|
|||
mSwapEnable.addOnSwitchChangeListener(this)
|
||||
mSwapSizePref.isEnabled = !mSwapEnable.isChecked
|
||||
mFreeSpace = findPreference(INFO_FREE_SPACE)!!
|
||||
mFreeSpace.summary = "${Swap.getFreeSpace()} GB"
|
||||
mFreeSpace.summary = "${mSwap.getFreeSpace()} GB"
|
||||
mSwapFileSize = findPreference(INFO_SWAP_FILE_SIZE)!!
|
||||
mSwapFileSize.summary = "${Swap.getSwapSize()} MB"
|
||||
mSwapFileSize.summary = "${mSwap.getSwapSize()} MB"
|
||||
}
|
||||
|
||||
override fun onPreferenceChange(preference: Preference, newValue: Any): Boolean {
|
||||
val mSwap = Swap()
|
||||
if (preference == mSwapSizePref) {
|
||||
val value = newValue as Int
|
||||
Swap.setSize(value)
|
||||
mSwap.setSize(value)
|
||||
mSharedPreferences.edit().putInt(PREF_SWAP_SIZE, value).apply()
|
||||
mFreeSpace.summary = "${Swap.getFreeSpace()} GB"
|
||||
mSwapFileSize.summary = "${Swap.getSwapSize()} MB"
|
||||
mFreeSpace.summary = "${mSwap.getFreeSpace()} GB"
|
||||
mSwapFileSize.summary = "${mSwap.getSwapSize()} MB"
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
|
@ -66,16 +68,13 @@ class SwapFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChangeLi
|
|||
|
||||
override fun onSwitchChanged(switchView: Switch, isChecked: Boolean) {
|
||||
mSwapEnable.isEnabled = false
|
||||
Thread {
|
||||
Swap.setSwapOn(isChecked)
|
||||
requireActivity().runOnUiThread {
|
||||
mSwapEnable.isEnabled = true
|
||||
mSharedPreferences.edit().putBoolean(PREF_SWAP_ENABLE, isChecked).apply()
|
||||
mSwapSizePref.isEnabled = !isChecked
|
||||
mFreeSpace.summary = "${Swap.getFreeSpace()} GB"
|
||||
mSwapFileSize.summary = "${Swap.getSwapSize()} MB"
|
||||
}
|
||||
}.start()
|
||||
val mSwap = Swap()
|
||||
mSwap.setSwapOn(isChecked)
|
||||
mSwapEnable.isEnabled = true
|
||||
mSharedPreferences.edit().putBoolean(PREF_SWAP_ENABLE, isChecked).apply()
|
||||
mSwapSizePref.isEnabled = !isChecked
|
||||
mFreeSpace.summary = "${mSwap.getFreeSpace()} GB"
|
||||
mSwapFileSize.summary = "${mSwap.getSwapSize()} MB"
|
||||
}
|
||||
companion object {
|
||||
const val PREF_SWAP_SIZE = "swap_size"
|
||||
|
|
|
|||
Loading…
Reference in a new issue