Skip to content

Commit

Permalink
Merge remote-tracking branch 'phh/android-9.0' into pie
Browse files Browse the repository at this point in the history
* phh/android-9.0:
  Remove global libeffects sed. Breaks many devices, and is actually needed only on moto
  Add few debug commands
  Samsung pie vendors arent happy with my edits. Disable them until it is fixed
  Remove mtk/ussd fix from vndk-detect. It is plain wrong (property doesnt exist)
  Set ussd fix on mtk-ril
  • Loading branch information
akhilnarang committed Apr 9, 2019
2 parents 07b24dc + eaacc3a commit 7f685d2
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 21 deletions.
36 changes: 36 additions & 0 deletions cmds/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,39 @@ cc_binary {
"mtk-sms-fwk-ready.rc"
],
}

cc_binary {
name: "xiaomi-display-feature",
srcs: [
"xiaomi-display-feature.cpp",
],
shared_libs: [
"[email protected]",
"libutils",
"libhidlbase",
],
}

cc_binary {
name: "xiaomi-fp",
srcs: [
"xiaomi-fp.cpp",
],
shared_libs: [
"[email protected]",
"libutils",
"libhidlbase",
],
}

cc_binary {
name: "lightsctl-sec",
srcs: [
"lightsctl-sec.cpp",
],
shared_libs: [
"[email protected]",
"libutils",
"libhidlbase",
],
}
59 changes: 59 additions & 0 deletions cmds/lightsctl-sec.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include <iostream>
#include <vendor/samsung/hardware/light/2.0/ISecLight.h>
#include <vendor/samsung/hardware/light/2.0/types.h>

using ::vendor::samsung::hardware::light::V2_0::ISecLight;
using ::android::sp;

int main(int argc, char **argv) {
auto svc = ISecLight::getService();
svc->getSupportedTypes([](auto types) {
for(const auto& type: types) {
std::cout << "Got type " << toString(type) << std::endl;
}
});
if(argc <= 1) return 0;
if(argc != 3 && argc != 6) return 1;

std::string typeArg(argv[1]);
vendor::samsung::hardware::light::V2_0::SecType type;
if(typeArg == "BACKLIGHT")
type = vendor::samsung::hardware::light::V2_0::SecType::BACKLIGHT;
if(typeArg == "KEYBOARD")
type = vendor::samsung::hardware::light::V2_0::SecType::KEYBOARD;
if(typeArg == "BUTTONS")
type = vendor::samsung::hardware::light::V2_0::SecType::BUTTONS;
if(typeArg == "BATTERY")
type = vendor::samsung::hardware::light::V2_0::SecType::BATTERY;
if(typeArg == "NOTIFICATIONS")
type = vendor::samsung::hardware::light::V2_0::SecType::NOTIFICATIONS;
if(typeArg == "ATTENTION")
type = vendor::samsung::hardware::light::V2_0::SecType::ATTENTION;
if(typeArg == "BLUETOOTH")
type = vendor::samsung::hardware::light::V2_0::SecType::BLUETOOTH;
if(typeArg == "WIFI")
type = vendor::samsung::hardware::light::V2_0::SecType::WIFI;
std::cout << "Set request type " << toString(type) << std::endl;

android::hardware::light::V2_0::LightState state;
state.color = (uint32_t)strtoll(argv[2], NULL, 16);
state.flashMode = android::hardware::light::V2_0::Flash::NONE;
state.brightnessMode = android::hardware::light::V2_0::Brightness::USER;

if(argc == 6) {
std::string flashArg(argv[3]);
if(flashArg == "NONE")
state.flashMode = android::hardware::light::V2_0::Flash::NONE;
if(flashArg == "TIMED")
state.flashMode = android::hardware::light::V2_0::Flash::TIMED;
if(flashArg == "HARDWARE")
state.flashMode = android::hardware::light::V2_0::Flash::HARDWARE;

state.flashOnMs = atoi(argv[4]);
state.flashOffMs = atoi(argv[5]);
}
std::cout << "Set flash type to " << toString(state.flashMode) << std::endl;

auto ret = svc->setLightSec(type, state);
std::cout << "Set light returned " << toString(ret) << std::endl;
}
38 changes: 38 additions & 0 deletions cmds/xiaomi-display-feature.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <iostream>
#include <unistd.h>
#include <vendor/xiaomi/hardware/displayfeature/1.0/IDisplayFeature.h>

using ::vendor::xiaomi::hardware::displayfeature::V1_0::IDisplayFeature;
using ::android::sp;

int main(int argc, char **argv) {
auto svc = IDisplayFeature::getService();
if(svc == nullptr) {
std::cerr << "Failed getting IDisplayFeature" << std::endl;
return -1;
}
if(argc != 3) {
fprintf(stderr, "Usage: %s <ADAPT|ENHANCE|STANDARD|EYECARE|MONOCHROME|SUNLIGHT|NIGHTLIGHT|HIGHLIGHT> <value>\n", argv[0]);
return -2;
}
int mode = -1;
std::string modeArg(argv[1]);
if(modeArg == "ADAPT")
mode = 0;
if(modeArg == "ENHANCE")
mode = 1;
if(modeArg == "STANDARD")
mode = 2;
if(modeArg == "EYECARE")
mode = 3;
if(modeArg == "MONOCHROME")
mode = 4;
if(modeArg == "SUNLIGHT")
mode = 8;
if(modeArg == "NIGHTLIGHT")
mode = 9;
if(modeArg == "HIGHLIGHT")
mode = 11;

svc->setFeature(0, mode, atoi(argv[2]), 255);
}
21 changes: 21 additions & 0 deletions cmds/xiaomi-fp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <iostream>
#include <unistd.h>
#include <vendor/xiaomi/hardware/fingerprintextension/1.0/IXiaomiFingerprint.h>

using ::vendor::xiaomi::hardware::fingerprintextension::V1_0::IXiaomiFingerprint;
using ::android::sp;

int main(int argc, char **argv) {
auto svc = IXiaomiFingerprint::getService();
if(svc == nullptr) {
std::cerr << "Failed getting IDisplayFeature" << std::endl;
return -1;
}
if(argc != 3) {
fprintf(stderr, "Usage: %s <command> <value>\n", argv[0]);
return -2;
}
uint32_t cmd = (uint32_t)strtoll(argv[1], NULL, 16);
uint32_t value = (uint32_t)strtoll(argv[2], NULL, 16);
svc->extCmd(cmd, value);
}
20 changes: 3 additions & 17 deletions rw-system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,6 @@ if [ "$(getprop ro.vendor.product.manufacturer)" = "motorola" ] || [ "$(getprop
fi
fi

for f in /vendor/lib/libeffects.so /vendor/lib64/libeffects.so; do
[ ! -f $f ] && continue
f="/vendor/lib/libeffects.so"
# shellcheck disable=SC2010
ctxt="$(ls -lZ "$f" | grep -oE 'u:object_r:[^:]*:s0')"
b="$(echo "$f" | tr / _)"

cp -a "$f" "/mnt/phh/$b"
sed -i \
's/%zu errors during loading of configuration: %s/%zu errors during loading of configuration: ss/g' \
"/mnt/phh/$b"
chcon "$ctxt" "/mnt/phh/$b"
mount -o bind "/mnt/phh/$b" "$f"
done

if getprop ro.vendor.build.fingerprint | grep -q -i -e xiaomi/wayne -e xiaomi/jasmine; then
setprop persist.imx376_sunny.low.lux 310
setprop persist.imx376_sunny.light.lux 280
Expand All @@ -234,6 +219,7 @@ for f in /vendor/lib/mtk-ril.so /vendor/lib64/mtk-ril.so /vendor/lib/libmtk-ril.
mount -o bind "/mnt/phh/$b" "$f"

setprop persist.sys.phh.radio.force_cognitive true
setprop persist.sys.radio.ussd.fix true
done

mount -o bind /system/phh/empty /vendor/overlay/SysuiDarkTheme/SysuiDarkTheme.apk || true
Expand All @@ -247,7 +233,7 @@ if grep -qF 'PowerVR Rogue GE8100' /vendor/lib/egl/GLESv1_CM_mtk.so ||
fi

#If we have both Samsung and AOSP power hal, take Samsung's
if [ -f /vendor/bin/hw/[email protected] ]; then
if [ -f /vendor/bin/hw/[email protected] ] && [ "$vndk" -lt 28 ]; then
mount -o bind /system/phh/empty /vendor/bin/hw/[email protected]
fi

Expand Down Expand Up @@ -279,7 +265,7 @@ if getprop ro.vendor.build.fingerprint | grep -iq -E -e 'huawei|honor' || getpro
mount -o bind /system/phh/libnfc-nci-huawei.conf /system/etc/libnfc-nci.conf
fi

if getprop ro.vendor.build.fingerprint | grep -qE -e ".*(crown|star)[q2]*lte.*" -e ".*(SC-0[23]K|SCV3[89]).*"; then
if getprop ro.vendor.build.fingerprint | grep -qE -e ".*(crown|star)[q2]*lte.*" -e ".*(SC-0[23]K|SCV3[89]).*" && [ "$vndk" -lt 28 ]; then
for f in /vendor/lib/libfloatingfeature.so /vendor/lib64/libfloatingfeature.so; do
[ ! -f "$f" ] && continue
# shellcheck disable=SC2010
Expand Down
4 changes: 0 additions & 4 deletions vndk-detect
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,3 @@ if getprop ro.hardware |grep -qiE -e qcom -e judyln -e judypn;then
setprop persist.sys.overlay.devinputjack true
fi
fi

if getprop Build.BRAND | grep -qiE -e MTK;then
setprop persist.sys.radio.ussd.fix true
fi

0 comments on commit 7f685d2

Please sign in to comment.