mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-21 19:55:33 -04:00
universal7885: SamsungParts: Inital HAL test
This commit is contained in:
parent
588ef40ab6
commit
e04e91f54f
15 changed files with 318 additions and 150 deletions
13
universal7885-common/SamsungParts/Android.bp
Normal file
13
universal7885-common/SamsungParts/Android.bp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
android_app {
|
||||
name: "SamsungParts",
|
||||
srcs: [
|
||||
"src/*/*/*/*/*.java",
|
||||
"src/*/*/*/*.java",
|
||||
],
|
||||
platform_apis: true,
|
||||
privileged: true,
|
||||
certificate: "platform",
|
||||
jni_libs: ["libsamsungparts_jni"],
|
||||
static_libs: ["androidx.preference_preference"],
|
||||
defaults: ["SettingsLibDefaults"],
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_STATIC_ANDROID_LIBRARIES := \
|
||||
androidx.preference_preference
|
||||
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||
LOCAL_PACKAGE_NAME := SamsungParts
|
||||
LOCAL_CERTIFICATE := platform
|
||||
LOCAL_PRIVILEGED_MODULE := true
|
||||
LOCAL_PRIVATE_PLATFORM_APIS := true
|
||||
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
|
||||
LOCAL_USE_AAPT2 := true
|
||||
|
||||
LOCAL_RESOURCE_DIR := \
|
||||
$(LOCAL_PATH)/res \
|
||||
$(TOP)/packages/resources/devicesettings/res
|
||||
|
||||
LOCAL_PROGUARD_ENABLED := disabled
|
||||
LOCAL_DEX_PREOPT := false
|
||||
|
||||
include frameworks/base/packages/SettingsLib/common.mk
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
|
||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := SamsungParts.rc
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_CLASS := ETC
|
||||
LOCAL_SRC_FILES := $(LOCAL_MODULE)
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/init
|
||||
include $(BUILD_PREBUILT)
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
on property:sys.boot_completed=1
|
||||
chmod 664 /sys/devices/platform/11500000.mali/tmu
|
||||
chown system system /sys/devices/platform/11500000.mali/tmu
|
||||
chmod 664 /sys/class/camera/flash/torch_brightness_lvl
|
||||
chown system system /sys/class/camera/flash/torch_brightness_lvl
|
||||
chmod 664 /sys/class/camera/flash/torch_brightness_lvl_enable
|
||||
chown system system /sys/class/camera/flash/torch_brightness_lvl_enable
|
||||
chmod 664 /sys/devices/platform/battery/power_supply/battery/batt_slate_mode
|
||||
chown system system /sys/devices/platform/battery/power_supply/battery/batt_slate_mode
|
||||
chmod 644 /sys/class/sec/switch/afc_disable
|
||||
chown system system /sys/class/sec/switch/afc_disable
|
||||
chmod 644 /sys/fs/selinux/enforce
|
||||
chown system system /sys/fs/selinux/enforce
|
||||
21
universal7885-common/SamsungParts/jni/Android.bp
Normal file
21
universal7885-common/SamsungParts/jni/Android.bp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
cc_library_shared {
|
||||
name: "libsamsungparts_jni",
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Wno-unused-parameter",
|
||||
"-Werror",
|
||||
],
|
||||
srcs: ["*.cpp"],
|
||||
header_libs: ["jni_headers"],
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"vendor.eureka.hardware.battery@1.0",
|
||||
"vendor.eureka.hardware.flashlight@1.0",
|
||||
"vendor.eureka.hardware.gpu@1.0",
|
||||
"vendor.eureka.security.selinux@1.0",
|
||||
]
|
||||
}
|
||||
|
||||
93
universal7885-common/SamsungParts/jni/BatteryBridge.cpp
Normal file
93
universal7885-common/SamsungParts/jni/BatteryBridge.cpp
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
#include <vendor/eureka/hardware/battery/1.0/IBattery.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include "jni.h"
|
||||
|
||||
using vendor::eureka::hardware::battery::V1_0::IBattery;
|
||||
using vendor::eureka::hardware::battery::V1_0::SysfsType;
|
||||
using vendor::eureka::hardware::battery::V1_0::Number;
|
||||
using android::sp;
|
||||
|
||||
extern "C" JNIEXPORT void
|
||||
JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_setChargeSysfs
|
||||
(JNIEnv *env , __unused jclass obj, jint enable) {
|
||||
android::sp<IBattery> service = IBattery::getService();
|
||||
if (enable == 1){
|
||||
service->setBatteryWritable(SysfsType::CHARGE, Number::ENABLE);
|
||||
}else{
|
||||
service->setBatteryWritable(SysfsType::CHARGE, Number::DISABLE);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint
|
||||
JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_getChargeSysfs
|
||||
(JNIEnv *env , __unused jclass obj) {
|
||||
android::sp<IBattery> service = IBattery::getService();
|
||||
int ret = service->getBatteryStats(SysfsType::CHARGE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_setFastCharge(JNIEnv *env, __unused jclass obj,
|
||||
jint enable) {
|
||||
android::sp<IBattery> service = IBattery::getService();
|
||||
if (enable == 1){
|
||||
service->setBatteryWritable(SysfsType::FASTCHARGE, Number::ENABLE);
|
||||
}else{
|
||||
service->setBatteryWritable(SysfsType::FASTCHARGE, Number::DISABLE);
|
||||
}
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_getFastChargeSysfs(JNIEnv *env, __unused
|
||||
jclass obj) {
|
||||
android::sp<IBattery> service = IBattery::getService();
|
||||
int ret = service->getBatteryStats(SysfsType::FASTCHARGE);
|
||||
return ret;
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_getGeneralBatteryStats(JNIEnv *env,
|
||||
__unused
|
||||
jclass obj, jint id) {
|
||||
/**
|
||||
* id:
|
||||
* 1 = BATTERY_CAPACITY_MAX
|
||||
* 2 = BATTERY_CAPACITY_CURRENT (%)
|
||||
* 3 = BATTERY_CAPACITY_CURRENT (mAh)
|
||||
* 4 = CHARGING_STATE
|
||||
* 5 = BATTERY_TEMP
|
||||
* 6 = BATTERY_CURRENT
|
||||
*/
|
||||
android::sp<IBattery> service = IBattery::getService();
|
||||
int ret;
|
||||
switch (id) {
|
||||
case 1:
|
||||
ret = service->getBatteryStats(SysfsType::CAPACITY_MAX) / 1000;
|
||||
case 2:
|
||||
ret = service->getBatteryStats(SysfsType::CAPACITY_CURRENT);
|
||||
case 3:
|
||||
ret = (float) service->getBatteryStats(SysfsType::CAPACITY_CURRENT) *
|
||||
(float) service->getBatteryStats(SysfsType::CAPACITY_MAX) / 100000;
|
||||
case 4:
|
||||
if (service->getBatteryStats(SysfsType::CURRENT) > 0){
|
||||
ret = 1;
|
||||
}else{
|
||||
ret = 0;
|
||||
}
|
||||
case 5:
|
||||
ret = service->getBatteryStats(SysfsType::TEMP) / 10;
|
||||
case 6:
|
||||
ret = service->getBatteryStats(SysfsType::CURRENT);
|
||||
default:
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
|
||||
|
||||
}
|
||||
56
universal7885-common/SamsungParts/jni/FlashlightBridge.cpp
Normal file
56
universal7885-common/SamsungParts/jni/FlashlightBridge.cpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#include <vendor/eureka/hardware/flashlight/1.0/IFlashlight.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include "jni.h"
|
||||
|
||||
using vendor::eureka::hardware::battery::V1_0::IFlashlight;
|
||||
using vendor::eureka::hardware::battery::V1_0::Device;
|
||||
using vendor::eureka::hardware::battery::V1_0::Enable;
|
||||
using vendor::eureka::hardware::battery::V1_0::Number;
|
||||
using android::sp;
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Flashlight_setFlash(JNIEnv *env, __unused jclass obj,
|
||||
jint value) {
|
||||
android::sp<IFlashlight> service = IFlashlight::getService();
|
||||
service->setFlashlightEnable(Enable::ENABLE);
|
||||
switch (value) {
|
||||
case 1:
|
||||
service->setFlashlightWritable(Number::ONEUI);
|
||||
case 2:
|
||||
service->setFlashlightWritable(Number::TWOUI);
|
||||
case 3:
|
||||
service->setFlashlightWritable(Number::THREEUI);
|
||||
case 4:
|
||||
service->setFlashlightWritable(Number::FOURUI);
|
||||
case 5:
|
||||
service->setFlashlightWritable(Number::FIVEUI);
|
||||
case 6:
|
||||
service->setFlashlightWritable(Number::SIXUI);
|
||||
case 7:
|
||||
service->setFlashlightWritable(Number::SEVENUI);
|
||||
case 8:
|
||||
service->setFlashlightWritable(Number::EIGHTUI);
|
||||
case 9:
|
||||
service->setFlashlightWritable(Number::NINEUI);
|
||||
case 10:
|
||||
service->setFlashlightWritable(Number::TENUI);
|
||||
|
||||
}
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Flashlight_getFlash(JNIEnv *env, jclass clazz,
|
||||
jint isA10) {
|
||||
android::sp<IFlashlight> service = IFlashlight::getService();
|
||||
int ret;
|
||||
if(isA10 == 1) {
|
||||
ret = service->readFlashlightstats(Device::A10);
|
||||
}else{
|
||||
ret = service->readFlashlightstats(Device::NOTA10);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
40
universal7885-common/SamsungParts/jni/GPUBridge.cpp
Normal file
40
universal7885-common/SamsungParts/jni/GPUBridge.cpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#include <vendor/eureka/hardware/gpu/1.0/IGpu.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include "jni.h"
|
||||
|
||||
using vendor::eureka::hardware::gpu::V1_0::IGpu;
|
||||
using vendor::eureka::hardware::gpu::V1_0::Enable;
|
||||
using android::sp;
|
||||
|
||||
extern "C" JNIEXPORT void
|
||||
JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_Battery_setChargeSysfs
|
||||
(JNIEnv *env , __unused jclass obj, jint enable) {
|
||||
android::sp<IBattery> service = IBattery::getService();
|
||||
if (enable == 1){
|
||||
service->setBatteryWritable(SysfsType::CHARGE, Number::ENABLE);
|
||||
}else{
|
||||
service->setBatteryWritable(SysfsType::CHARGE, Number::DISABLE);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_GPU_setGPU(JNIEnv *env, jclass clazz, jint enable) {
|
||||
android::sp<IGpu> service = IGpu::getService();
|
||||
if (enable == 1){
|
||||
service->setGpuWritable(Enable::ENABLE);
|
||||
}else{
|
||||
service->setGpuWritable(Enable::DISABLE);
|
||||
}
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_GPU_getGPU(JNIEnv *env, jclass clazz) {
|
||||
android::sp<IGpu> service = IGpu::getService();
|
||||
int ret = service->readGpustats();
|
||||
return ret;
|
||||
}
|
||||
29
universal7885-common/SamsungParts/jni/SELinuxBridge.cpp
Normal file
29
universal7885-common/SamsungParts/jni/SELinuxBridge.cpp
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include <vendor/eureka/security/selinux/1.0/ISELinux.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include "jni.h"
|
||||
|
||||
using vendor::eureka::security::selinux::V1_0::ISELinux;
|
||||
using vendor::eureka::security::selinux::V1_0::Enable;
|
||||
using android::sp;
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_SELinux_getSELinux(JNIEnv *env, jclass clazz) {
|
||||
android::sp<ISELinux> service = ISELinux::getService();
|
||||
int ret = service->readSELinuxstats();
|
||||
return ret;
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_eurekateam_samsungextras_interfaces_SELinux_setSELinux(JNIEnv *env, jclass clazz,
|
||||
jint enable) {
|
||||
android::sp<ISELinux> service = ISELinux::getService();
|
||||
if (enable == 1){
|
||||
service->setSELinuxWritable(Enable::ENABLE);
|
||||
}else{
|
||||
service->setSELinuxWritable(Enable::DISABLE);
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,6 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
|
@ -30,9 +29,9 @@ import androidx.preference.SwitchPreference;
|
|||
|
||||
import com.eurekateam.samsungextras.battery.BatteryActivity;
|
||||
import com.eurekateam.samsungextras.flashlight.FlashLightActivity;
|
||||
import com.eurekateam.samsungextras.interfaces.GPU;
|
||||
import com.eurekateam.samsungextras.interfaces.SELinux;
|
||||
import com.eurekateam.samsungextras.speaker.ClearSpeakerActivity;
|
||||
import com.eurekateam.samsungextras.utils.FileUtilsWrapper;
|
||||
import com.eurekateam.samsungextras.utils.SystemProperties;
|
||||
|
||||
public class DeviceSettings extends PreferenceFragment implements
|
||||
Preference.OnPreferenceChangeListener {
|
||||
|
|
@ -48,6 +47,7 @@ public class DeviceSettings extends PreferenceFragment implements
|
|||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
System.loadLibrary("samsungparts_jni");
|
||||
setPreferencesFromResource(R.xml.preferences_samsung_parts, rootKey);
|
||||
Context mContext = this.getContext();
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
|
|
@ -66,30 +66,16 @@ public class DeviceSettings extends PreferenceFragment implements
|
|||
|
||||
SwitchPreference mGPUExynos = findPreference(PREF_GPUEXYNOS);
|
||||
assert mGPUExynos != null;
|
||||
if (FileUtilsWrapper.isFileReadable(GlobalConstants.TMU_SYSFS)) {
|
||||
Log.d(GlobalConstants.TAG, "onCreatePreferences: "
|
||||
+ (GlobalConstants.TMU_SYSFS) + " readable, value " +
|
||||
FileUtilsWrapper.readOneLine(GlobalConstants.TMU_SYSFS));
|
||||
mGPUExynos.setChecked(
|
||||
FileUtilsWrapper.readOneLine(GlobalConstants.TMU_SYSFS).equals("1"));
|
||||
}else {
|
||||
Log.w(GlobalConstants.TAG, "onCreatePreferences: "
|
||||
+ (GlobalConstants.TMU_SYSFS) + " not readable");
|
||||
mGPUExynos.setEnabled(false);
|
||||
}
|
||||
mGPUExynos.setChecked(GPU.getGPU() == 1);
|
||||
mGPUExynos.setOnPreferenceChangeListener(this);
|
||||
|
||||
Preference mSELinux = findPreference(PREF_SELINUX);
|
||||
SwitchPreference mSELinux = findPreference(PREF_SELINUX);
|
||||
assert mSELinux != null;
|
||||
mSELinux.setOnPreferenceClickListener(preference -> {
|
||||
boolean selinux_enforcing = SystemProperties.getenforce();
|
||||
Toast.makeText(getContext(), selinux_enforcing ?
|
||||
"SELinux is in enforcing state." :
|
||||
"SELinux is in permissive state.",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
});
|
||||
mSELinux.setOnPreferenceChangeListener(this);
|
||||
mSELinux.setEnabled(SELinux.getSELinux() != 0);
|
||||
|
||||
Preference mFlashLight = findPreference(PREF_FLASHLIGHT);
|
||||
assert mFlashLight != null;
|
||||
mFlashLight.setOnPreferenceClickListener(preference -> {
|
||||
Intent intent = new Intent(getActivity().getApplicationContext(), FlashLightActivity.class);
|
||||
startActivity(intent);
|
||||
|
|
@ -119,12 +105,16 @@ public class DeviceSettings extends PreferenceFragment implements
|
|||
break;
|
||||
case PREF_GPUEXYNOS:
|
||||
boolean gpu_enabled = (Boolean) value;
|
||||
Log.d(GlobalConstants.TAG, "onPreferenceChange: Writing " +
|
||||
gpu_enabled + " to " + GlobalConstants.TMU_SYSFS);
|
||||
FileUtilsWrapper.writeLine(GlobalConstants.TMU_SYSFS, gpu_enabled ? "1" : "0");
|
||||
GPU.setGPU(gpu_enabled ? 1 : 0);
|
||||
Toast.makeText(getContext(), gpu_enabled ? "GPU Throttling is now enabled."
|
||||
: "GPU Throttling is now disabled.",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
case PREF_SELINUX:
|
||||
boolean selinux_enabled = (Boolean) value;
|
||||
SELinux.setSELinux(selinux_enabled ? 1 : 0);
|
||||
Toast.makeText(getContext(), selinux_enabled ? "SELinux is now in enforcing state."
|
||||
: "SELinux is now in permissive state.",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
package com.eurekateam.samsungextras.battery;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.preference.ListPreference;
|
||||
|
|
@ -26,9 +24,8 @@ import androidx.preference.Preference;
|
|||
import androidx.preference.PreferenceFragment;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.eurekateam.samsungextras.GlobalConstants;
|
||||
import com.eurekateam.samsungextras.R;
|
||||
import com.eurekateam.samsungextras.utils.FileUtilsWrapper;
|
||||
import com.eurekateam.samsungextras.interfaces.Battery;
|
||||
|
||||
public class BatteryFragment extends PreferenceFragment implements
|
||||
Preference.OnPreferenceChangeListener {
|
||||
|
|
@ -44,45 +41,20 @@ public class BatteryFragment extends PreferenceFragment implements
|
|||
mFastChargePref = findPreference(PREF_FASTCHARGE);
|
||||
assert mFastChargePref != null;
|
||||
mFastChargePref.setOnPreferenceChangeListener(this);
|
||||
mFastChargePref.setEnabled(FileUtilsWrapper.
|
||||
fileExists(GlobalConstants.FASTCHARGE_SYSFS));
|
||||
if (FileUtilsWrapper.isFileReadable(GlobalConstants.FLASHLIGHT_SYSFS)){
|
||||
Log.d(GlobalConstants.TAG, "onCreatePreferences: " +
|
||||
GlobalConstants.FASTCHARGE_SYSFS + " readable, value " +
|
||||
FileUtilsWrapper.readOneLine(GlobalConstants.FASTCHARGE_SYSFS));
|
||||
mFastChargePref.setChecked(FileUtilsWrapper.readOneLine
|
||||
(GlobalConstants.FASTCHARGE_SYSFS).equals("0"));
|
||||
}else{
|
||||
Log.w(GlobalConstants.TAG, "onCreatePreferences: " +
|
||||
GlobalConstants.FLASHLIGHT_SYSFS + " not readable");
|
||||
mFastChargePref.setEnabled(false);
|
||||
}
|
||||
mFastChargePref.setChecked(Battery.getChargeSysfs() == 0);
|
||||
mChargePref = findPreference(PREF_CHARGE);
|
||||
assert mChargePref != null;
|
||||
mChargePref.setOnPreferenceChangeListener(this);
|
||||
mChargePref.setEnabled(FileUtilsWrapper.
|
||||
fileExists(GlobalConstants.CHARGE_DISABLE_SYSFS));
|
||||
if (FileUtilsWrapper.isFileReadable(GlobalConstants.CHARGE_DISABLE_SYSFS)){
|
||||
Log.d(GlobalConstants.TAG, "onCreatePreferences: " +
|
||||
GlobalConstants.CHARGE_DISABLE_SYSFS + " readable, value " +
|
||||
FileUtilsWrapper.readOneLine(GlobalConstants.CHARGE_DISABLE_SYSFS));
|
||||
mChargePref.setChecked(FileUtilsWrapper.readOneLine
|
||||
(GlobalConstants.CHARGE_DISABLE_SYSFS).equals("0"));
|
||||
}else{
|
||||
Log.w(GlobalConstants.TAG, "onCreatePreferences: " +
|
||||
GlobalConstants.FLASHLIGHT_SYSFS + " not readable");
|
||||
mFastChargePref.setEnabled(false);
|
||||
}
|
||||
mChargePref.setChecked(Battery.getFastChargeSysfs() == 0);
|
||||
ListPreference mBatteryInfo = findPreference(BATTERY_INFO);
|
||||
CharSequence[] items = {
|
||||
Integer.parseInt(FileUtilsWrapper.readOneLine(GlobalConstants.BATTERY_CAPACITY_MAX_SYSFS)) / 1000 + " mAh",
|
||||
FileUtilsWrapper.readOneLine(GlobalConstants.BATTERY_CAPACITY_CURRENT_SYSFS) + " %",
|
||||
Float.parseFloat(FileUtilsWrapper.readOneLine(GlobalConstants.BATTERY_CAPACITY_MAX_SYSFS)) *
|
||||
Float.parseFloat(FileUtilsWrapper.readOneLine(GlobalConstants.BATTERY_CAPACITY_CURRENT_SYSFS)) / 100000 + " mAh" ,
|
||||
FileUtilsWrapper.readOneLine(GlobalConstants.BATTERY_CURRENT_SYSFS) + " mAh",
|
||||
Integer.parseInt(FileUtilsWrapper.readOneLine(GlobalConstants.BATTERY_CURRENT_SYSFS)) >= 0
|
||||
Battery.getGeneralBatteryStats(1) + " mAh",
|
||||
Battery.getGeneralBatteryStats(2) + " %",
|
||||
Battery.getGeneralBatteryStats(3) + " mAh" ,
|
||||
Battery.getGeneralBatteryStats(6) + " mAh",
|
||||
Battery.getGeneralBatteryStats(4) == 1
|
||||
? "Charging" : "Discharging",
|
||||
Float.parseFloat(FileUtilsWrapper.readOneLine(GlobalConstants.BATTERY_TEMP_SYSFS)) / 10 + " \u2103",
|
||||
Battery.getGeneralBatteryStats(5) + " \u2103",
|
||||
};
|
||||
assert mBatteryInfo != null;
|
||||
mBatteryInfo.setEntryValues(items);
|
||||
|
|
@ -94,21 +66,15 @@ public class BatteryFragment extends PreferenceFragment implements
|
|||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (preference == mFastChargePref) {
|
||||
if (preference == mChargePref) {
|
||||
Boolean value = (Boolean) newValue;
|
||||
Log.d(GlobalConstants.TAG, "onPreferenceChange: writing " + value + " to " +
|
||||
GlobalConstants.FASTCHARGE_SYSFS);
|
||||
FileUtilsWrapper.writeLine(GlobalConstants.FASTCHARGE_SYSFS, value ? "0" : "1");
|
||||
mFastChargePref.setChecked(FileUtilsWrapper.readOneLine
|
||||
(GlobalConstants.FASTCHARGE_SYSFS).equals("0"));
|
||||
Battery.setChargeSysfs(value ? 0 : 1 );
|
||||
mFastChargePref.setChecked(Battery.getChargeSysfs() == 0);
|
||||
return true;
|
||||
}else if (preference == mChargePref){
|
||||
}else if (preference == mFastChargePref){
|
||||
Boolean value = (Boolean) newValue;
|
||||
Log.d(GlobalConstants.TAG, "onPreferenceChange: writing " + value
|
||||
+ " to " + GlobalConstants.CHARGE_DISABLE_SYSFS);
|
||||
FileUtilsWrapper.writeLine(GlobalConstants.CHARGE_DISABLE_SYSFS, value ? "0" : "1");
|
||||
mChargePref.setChecked(FileUtilsWrapper.readOneLine
|
||||
(GlobalConstants.CHARGE_DISABLE_SYSFS).equals("0"));
|
||||
Battery.setFastCharge(value ? 0 : 1 );
|
||||
mChargePref.setChecked(Battery.getFastChargeSysfs() == 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -17,61 +17,42 @@
|
|||
package com.eurekateam.samsungextras.flashlight;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragment;
|
||||
|
||||
import com.eurekateam.samsungextras.GlobalConstants;
|
||||
import com.eurekateam.samsungextras.R;
|
||||
import com.eurekateam.samsungextras.interfaces.Flashlight;
|
||||
import com.eurekateam.samsungextras.preferences.CustomSeekBarPreference;
|
||||
import com.eurekateam.samsungextras.utils.FileUtilsWrapper;
|
||||
import com.eurekateam.samsungextras.utils.SystemProperties;
|
||||
|
||||
public class FlashLightFragment extends PreferenceFragment implements
|
||||
Preference.OnPreferenceChangeListener {
|
||||
private static int divideprefix = 21;
|
||||
private static final String PREF_FLASHLIGHT = "flashlight_pref";
|
||||
private CustomSeekBarPreference mFlashLightPref;
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.flashlight_settings);
|
||||
if (SystemProperties.read("ro.product.device").contains("a10")){
|
||||
divideprefix = 1;
|
||||
}
|
||||
mFlashLightPref = findPreference(PREF_FLASHLIGHT);
|
||||
assert mFlashLightPref != null;
|
||||
mFlashLightPref.setOnPreferenceChangeListener(this);
|
||||
mFlashLightPref.setMax(10);
|
||||
mFlashLightPref.setMin(0);
|
||||
mFlashLightPref.setEnabled(FileUtilsWrapper.
|
||||
fileExists(GlobalConstants.FLASHLIGHT_SYSFS));
|
||||
if (FileUtilsWrapper.isFileReadable(GlobalConstants.FLASHLIGHT_SYSFS)){
|
||||
Log.d(GlobalConstants.TAG, "onCreatePreferences: " +
|
||||
GlobalConstants.FLASHLIGHT_SYSFS + " readable, value " +
|
||||
Integer.parseInt(
|
||||
FileUtilsWrapper.readOneLine(GlobalConstants.FLASHLIGHT_SYSFS)));
|
||||
mFlashLightPref.setValue(Integer.parseInt(
|
||||
FileUtilsWrapper.readOneLine(GlobalConstants.FLASHLIGHT_SYSFS))
|
||||
/ divideprefix);
|
||||
}else{
|
||||
Log.w(GlobalConstants.TAG, "onCreatePreferences: " +
|
||||
GlobalConstants.FLASHLIGHT_SYSFS + " not readable");
|
||||
if (!FileUtilsWrapper.fileExists(GlobalConstants.FLASHLIGHT_SYSFS)){
|
||||
mFlashLightPref.setEnabled(false);
|
||||
}
|
||||
|
||||
mFlashLightPref.setMax(10);
|
||||
mFlashLightPref.setMin(0);
|
||||
boolean isa10 = SystemProperties.read("ro.product.device").equals("a10");
|
||||
mFlashLightPref.setValue(Flashlight.getFlash(isa10 ? 1 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (preference == mFlashLightPref) {
|
||||
Integer value = (Integer) newValue;
|
||||
Log.d(GlobalConstants.TAG, "onPreferenceChange: writing 1 to " +
|
||||
GlobalConstants.FLASHLIGHT_SYSFS_ENABLE);
|
||||
FileUtilsWrapper.writeLine(GlobalConstants.FLASHLIGHT_SYSFS_ENABLE, "1");
|
||||
Log.d(GlobalConstants.TAG, "onPreferenceChange: writing " + value
|
||||
+ " to " + GlobalConstants.FLASHLIGHT_SYSFS);
|
||||
FileUtilsWrapper.writeLine(GlobalConstants.FLASHLIGHT_SYSFS, String.valueOf(value));
|
||||
Flashlight.setFlash(value);
|
||||
mFlashLightPref.setValue(value, true);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package com.eurekateam.samsungextras.interfaces;
|
||||
|
||||
public class Battery {
|
||||
public static native void setChargeSysfs(int enable);
|
||||
public static native int getChargeSysfs();
|
||||
public static native void setFastCharge(int enable);
|
||||
public static native int getFastChargeSysfs();
|
||||
public static native int getGeneralBatteryStats(int id);
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.eurekateam.samsungextras.interfaces;
|
||||
|
||||
public class Flashlight {
|
||||
public static native void setFlash(int value);
|
||||
public static native int getFlash(int isA10);
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.eurekateam.samsungextras.interfaces;
|
||||
|
||||
public class GPU {
|
||||
public static native void setGPU(int enable);
|
||||
public static native int getGPU();
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.eurekateam.samsungextras.interfaces;
|
||||
|
||||
public class SELinux {
|
||||
public static native void setSELinux(int enable);
|
||||
public static native int getSELinux();
|
||||
}
|
||||
Loading…
Reference in a new issue