Sync up to v119
This commit is contained in:
parent
04c4a9e1b3
commit
81616af6df
@ -1,25 +1,25 @@
|
|||||||
From e3f08c02ab7d0bc5d0efcc9eb3ad98d9a3a98e32 Mon Sep 17 00:00:00 2001
|
From 7369d2c37720cc88bbb28c6487b0209732ac52fa Mon Sep 17 00:00:00 2001
|
||||||
From: Pierre-Hugues Husson <phh@phh.me>
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
Date: Sat, 24 Mar 2018 08:01:48 +0100
|
Date: Sat, 24 Mar 2018 08:01:48 +0100
|
||||||
Subject: [PATCH 01/31] Fix backlight control on Galaxy S9(+)
|
Subject: [PATCH] Fix backlight control on Galaxy S9(+)
|
||||||
|
|
||||||
---
|
---
|
||||||
.../core/java/com/android/server/lights/LightsService.java | 7 +++++++
|
.../core/java/com/android/server/lights/LightsService.java | 7 +++++++
|
||||||
1 file changed, 7 insertions(+)
|
1 file changed, 7 insertions(+)
|
||||||
|
|
||||||
diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java
|
diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java
|
||||||
index a94ed608b9c..762b0ae4037 100644
|
index 9dee0171683..378e7c367b1 100644
|
||||||
--- a/services/core/java/com/android/server/lights/LightsService.java
|
--- a/services/core/java/com/android/server/lights/LightsService.java
|
||||||
+++ b/services/core/java/com/android/server/lights/LightsService.java
|
+++ b/services/core/java/com/android/server/lights/LightsService.java
|
||||||
@@ -21,6 +21,7 @@ import android.app.ActivityManager;
|
@@ -23,6 +23,7 @@ import android.content.Context;
|
||||||
import android.content.Context;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
+import android.os.SystemProperties;
|
+import android.os.SystemProperties;
|
||||||
import android.os.Trace;
|
import android.os.Trace;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
@@ -52,6 +53,12 @@ public class LightsService extends SystemService {
|
@@ -54,6 +55,12 @@ public class LightsService extends SystemService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
From 2dcdcc26c6f48915fc9b036f7c72adc29b110901 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
|
Date: Sun, 11 Aug 2019 10:30:37 +0200
|
||||||
|
Subject: [PATCH 36/40] Add property to use linear brightness slider
|
||||||
|
|
||||||
|
---
|
||||||
|
.../com/android/settingslib/display/BrightnessUtils.java | 6 ++++++
|
||||||
|
1 file changed, 6 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java b/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
|
||||||
|
index 55723f9d8ed..da8ce4a67e9 100644
|
||||||
|
--- a/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
|
||||||
|
+++ b/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
|
||||||
|
@@ -50,7 +50,12 @@ public class BrightnessUtils {
|
||||||
|
* @param max The maximum acceptable value for the setting.
|
||||||
|
* @return The corresponding setting value.
|
||||||
|
*/
|
||||||
|
+ private static final boolean useLinearBrightness = android.os.SystemProperties.getBoolean("persist.sys.phh.linear_brightness", false);
|
||||||
|
public static final int convertGammaToLinear(int val, int min, int max) {
|
||||||
|
+ if(useLinearBrightness) {
|
||||||
|
+ if(val < 4) return 1;
|
||||||
|
+ return val/4;
|
||||||
|
+ }
|
||||||
|
final float normalizedVal = MathUtils.norm(0, GAMMA_SPACE_MAX, val);
|
||||||
|
final float ret;
|
||||||
|
if (normalizedVal <= R) {
|
||||||
|
@@ -87,6 +92,7 @@ public class BrightnessUtils {
|
||||||
|
* @return The corresponding slider value
|
||||||
|
*/
|
||||||
|
public static final int convertLinearToGamma(int val, int min, int max) {
|
||||||
|
+ if(useLinearBrightness) return val*4;
|
||||||
|
// For some reason, HLG normalizes to the range [0, 12] rather than [0, 1]
|
||||||
|
final float normalizedVal = MathUtils.norm(min, max, val) * 12;
|
||||||
|
final float ret;
|
||||||
|
--
|
||||||
|
2.17.1
|
||||||
|
|
@ -0,0 +1,53 @@
|
|||||||
|
From 2b3f995ecdc7c8c8c066d698f66d2ea4f9f6cb56 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
|
Date: Mon, 12 Aug 2019 23:08:26 +0200
|
||||||
|
Subject: [PATCH 37/40] Add support for samsung touch proximity sensor as
|
||||||
|
fallback to real proximity sensor
|
||||||
|
|
||||||
|
---
|
||||||
|
.../server/display/DisplayPowerController.java | 15 +++++++++++++++
|
||||||
|
1 file changed, 15 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
|
||||||
|
index 6f0a51bf107..32cece6f893 100644
|
||||||
|
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
|
||||||
|
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
|
||||||
|
@@ -62,6 +62,7 @@ import com.android.server.am.BatteryStatsService;
|
||||||
|
import com.android.server.policy.WindowManagerPolicy;
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
+import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls the power state of the display.
|
||||||
|
@@ -501,6 +502,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||||
|
|
||||||
|
if (!DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT) {
|
||||||
|
mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
||||||
|
+ if(mProximitySensor == null) {
|
||||||
|
+ List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
|
||||||
|
+ for(Sensor sensor: sensors) {
|
||||||
|
+ if("com.samsung.sensor.touch_proximity".equals(sensor.getStringType()))
|
||||||
|
+ mProximitySensor = sensor;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
if (mProximitySensor != null) {
|
||||||
|
mProximityThreshold = Math.min(mProximitySensor.getMaximumRange(),
|
||||||
|
TYPICAL_PROXIMITY_THRESHOLD);
|
||||||
|
@@ -1816,6 +1824,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||||
|
public void onSensorChanged(SensorEvent event) {
|
||||||
|
if (mProximitySensorEnabled) {
|
||||||
|
final long time = SystemClock.uptimeMillis();
|
||||||
|
+ if("com.samsung.sensor.touch_proximity".equals(mProximitySensor.getStringType())) {
|
||||||
|
+ int v = (int)event.values[0];
|
||||||
|
+ boolean positive = (v <= 4);
|
||||||
|
+ android.util.Log.d("PHH", "Samsung sensor changed " + positive + ":" + v);
|
||||||
|
+ handleProximitySensorEvent(time, positive);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
final float distance = event.values[0];
|
||||||
|
boolean positive = distance >= 0.0f && distance < mProximityThreshold;
|
||||||
|
handleProximitySensorEvent(time, positive);
|
||||||
|
--
|
||||||
|
2.17.1
|
||||||
|
|
@ -0,0 +1,107 @@
|
|||||||
|
From 400520d763e99653b8ebf81ed38e178bea2443b5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
|
Date: Mon, 12 Aug 2019 23:10:21 +0200
|
||||||
|
Subject: [PATCH 38/40] Add Samsung `fod_enable` for under-display fingerprint.
|
||||||
|
For the moment only ultra-sonic works
|
||||||
|
|
||||||
|
---
|
||||||
|
.../server/fingerprint/FacolaView.java | 54 +++++++++++++++++++
|
||||||
|
1 file changed, 54 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/services/core/java/com/android/server/fingerprint/FacolaView.java b/services/core/java/com/android/server/fingerprint/FacolaView.java
|
||||||
|
index 86f03360ad0..254c1f99b44 100644
|
||||||
|
--- a/services/core/java/com/android/server/fingerprint/FacolaView.java
|
||||||
|
+++ b/services/core/java/com/android/server/fingerprint/FacolaView.java
|
||||||
|
@@ -32,6 +32,9 @@ import android.view.Gravity;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
|
||||||
|
+import java.io.BufferedReader;
|
||||||
|
+import java.io.File;
|
||||||
|
+import java.io.FileReader;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
|
import vendor.xiaomi.hardware.fingerprintextension.V1_0.IXiaomiFingerprint;
|
||||||
|
@@ -53,9 +56,12 @@ public class FacolaView extends ImageView implements OnTouchListener {
|
||||||
|
private boolean visible = false;
|
||||||
|
|
||||||
|
private final WindowManager mWM;
|
||||||
|
+ private final boolean samsungFod = samsungHasCmd("fod_enable");
|
||||||
|
FacolaView(Context context) {
|
||||||
|
super(context);
|
||||||
|
|
||||||
|
+ android.util.Log.d("PHH", "Samsung FOD " + samsungFod);
|
||||||
|
+
|
||||||
|
mMainHandler = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
|
String[] location = android.os.SystemProperties.get("persist.vendor.sys.fp.fod.location.X_Y", "").split(",");
|
||||||
|
@@ -157,6 +163,9 @@ public class FacolaView extends ImageView implements OnTouchListener {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show() {
|
||||||
|
+ if(samsungFod) {
|
||||||
|
+ samsungCmd("fod_enable,1,1");
|
||||||
|
+ }
|
||||||
|
if(mX == -1 || mY == -1 || mW == -1 || mH == -1) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
@@ -191,6 +200,9 @@ public class FacolaView extends ImageView implements OnTouchListener {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hide() {
|
||||||
|
+ if(samsungFod) {
|
||||||
|
+ samsungCmd("fod_enable,0");
|
||||||
|
+ }
|
||||||
|
if(mX == -1 || mY == -1 || mW == -1 || mH == -1) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
@@ -211,4 +223,46 @@ public class FacolaView extends ImageView implements OnTouchListener {
|
||||||
|
mWM.removeView(this);
|
||||||
|
visible = false;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ private static boolean samsungHasCmd(String cmd) {
|
||||||
|
+ try {
|
||||||
|
+ File f = new File("/sys/devices/virtual/sec/tsp/cmd_list");
|
||||||
|
+ if(!f.exists()) return false;
|
||||||
|
+
|
||||||
|
+ BufferedReader b = new BufferedReader(new FileReader(f));
|
||||||
|
+ String line = null;
|
||||||
|
+ while( (line = b.readLine()) != null) {
|
||||||
|
+ if(line.equals(cmd)) return true;
|
||||||
|
+ }
|
||||||
|
+ return false;
|
||||||
|
+ } catch(Exception e) {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static String readFile(String path) {
|
||||||
|
+ try {
|
||||||
|
+ File f = new File(path);
|
||||||
|
+
|
||||||
|
+ BufferedReader b = new BufferedReader(new FileReader(f));
|
||||||
|
+ return b.readLine();
|
||||||
|
+ } catch(Exception e) {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void samsungCmd(String cmd) {
|
||||||
|
+ try {
|
||||||
|
+ PrintWriter writer = new PrintWriter("/sys/devices/virtual/sec/tsp/cmd", "UTF-8");
|
||||||
|
+ writer.println(cmd);
|
||||||
|
+ writer.close();
|
||||||
|
+
|
||||||
|
+ String status = readFile("/sys/devices/virtual/sec/tsp/cmd_status");
|
||||||
|
+ String ret = readFile("/sys/devices/virtual/sec/tsp/cmd_result");
|
||||||
|
+
|
||||||
|
+ android.util.Log.d("PHH", "Sending command " + cmd + " returned " + ret + ":" + status);
|
||||||
|
+ } catch(Exception e) {
|
||||||
|
+ android.util.Log.d("PHH", "Failed sending command " + cmd, e);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.17.1
|
||||||
|
|
@ -0,0 +1,30 @@
|
|||||||
|
From 2699dc1cb20a07e8bccf60b47d556d10289bb3b3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
|
Date: Wed, 14 Aug 2019 08:50:47 +0200
|
||||||
|
Subject: [PATCH 39/40] Use Samsung power HAL
|
||||||
|
|
||||||
|
Samsung likes to have two android.hardware.power@1.0 implementation
|
||||||
|
side-by-side, one that works, one that doesn't.
|
||||||
|
Pick the one that works.
|
||||||
|
---
|
||||||
|
.../core/jni/com_android_server_power_PowerManagerService.cpp | 4 +++-
|
||||||
|
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp
|
||||||
|
index b2d35d4153a..3cac85139c5 100644
|
||||||
|
--- a/services/core/jni/com_android_server_power_PowerManagerService.cpp
|
||||||
|
+++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp
|
||||||
|
@@ -84,7 +84,9 @@ static bool checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodNa
|
||||||
|
// The caller must be holding gPowerHalMutex.
|
||||||
|
static void connectPowerHalLocked() {
|
||||||
|
if (gPowerHalExists && gPowerHalV1_0_ == nullptr) {
|
||||||
|
- gPowerHalV1_0_ = IPowerV1_0::getService();
|
||||||
|
+ gPowerHalV1_0_ = IPowerV1_0::getService("miscpower");
|
||||||
|
+ if(gPowerHalV1_0_ == nullptr)
|
||||||
|
+ gPowerHalV1_0_ = IPowerV1_0::getService();
|
||||||
|
if (gPowerHalV1_0_ != nullptr) {
|
||||||
|
ALOGI("Loaded power HAL 1.0 service");
|
||||||
|
// Try cast to powerHAL V1_1
|
||||||
|
--
|
||||||
|
2.17.1
|
||||||
|
|
@ -0,0 +1,31 @@
|
|||||||
|
From ad4d27e4be4048fa178d4755be4e2063e3204246 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
|
Date: Wed, 14 Aug 2019 23:36:45 +0200
|
||||||
|
Subject: [PATCH 40/40] Also add com.samsung.sensor.physical_proximity (if
|
||||||
|
available, it is more a true proximity sensor than touch proximity sensor)
|
||||||
|
|
||||||
|
---
|
||||||
|
.../com/android/server/display/DisplayPowerController.java | 7 +++++++
|
||||||
|
1 file changed, 7 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
|
||||||
|
index 32cece6f893..9ffc8a817e2 100644
|
||||||
|
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
|
||||||
|
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
|
||||||
|
@@ -502,6 +502,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||||
|
|
||||||
|
if (!DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT) {
|
||||||
|
mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
||||||
|
+ if(mProximitySensor == null) {
|
||||||
|
+ List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
|
||||||
|
+ for(Sensor sensor: sensors) {
|
||||||
|
+ if("com.samsung.sensor.physical_proximity".equals(sensor.getStringType()))
|
||||||
|
+ mProximitySensor = sensor;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
if(mProximitySensor == null) {
|
||||||
|
List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
|
||||||
|
for(Sensor sensor: sensors) {
|
||||||
|
--
|
||||||
|
2.17.1
|
||||||
|
|
@ -0,0 +1,31 @@
|
|||||||
|
From 725b2c6c7b45072c96531656711b89bf9b6b502a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
|
Date: Mon, 12 Aug 2019 23:48:37 +0200
|
||||||
|
Subject: [PATCH 5/6] Some Samsung devices requires lying colorspace
|
||||||
|
|
||||||
|
---
|
||||||
|
opengl/libs/EGL/eglApi.cpp | 6 ++++++
|
||||||
|
1 file changed, 6 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
|
||||||
|
index c65bddfbb..3cde19af1 100644
|
||||||
|
--- a/opengl/libs/EGL/eglApi.cpp
|
||||||
|
+++ b/opengl/libs/EGL/eglApi.cpp
|
||||||
|
@@ -454,8 +454,14 @@ EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Translates EGL color spaces to Android data spaces.
|
||||||
|
+static int samsungColorspace = -1;
|
||||||
|
static android_dataspace dataSpaceFromEGLColorSpace(EGLint colorspace) {
|
||||||
|
+ if(samsungColorspace == -1) {
|
||||||
|
+ samsungColorspace = property_get_bool("persist.sys.phh.samsung_colorspace", false);
|
||||||
|
+ }
|
||||||
|
if (colorspace == EGL_GL_COLORSPACE_LINEAR_KHR) {
|
||||||
|
+ if(samsungColorspace)
|
||||||
|
+ return HAL_DATASPACE_UNKNOWN;
|
||||||
|
return HAL_DATASPACE_SRGB_LINEAR;
|
||||||
|
} else if (colorspace == EGL_GL_COLORSPACE_SRGB_KHR) {
|
||||||
|
return HAL_DATASPACE_SRGB;
|
||||||
|
--
|
||||||
|
2.17.1
|
||||||
|
|
@ -0,0 +1,35 @@
|
|||||||
|
From 663f83cdb9628315a8501a24d85eee6df707e1ae Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
|
Date: Wed, 14 Aug 2019 23:37:10 +0200
|
||||||
|
Subject: [PATCH 6/6] On Samsung, we need to send a hack-message to HAL to get
|
||||||
|
all Sensors
|
||||||
|
|
||||||
|
---
|
||||||
|
services/sensorservice/SensorDevice.cpp | 4 ++++
|
||||||
|
1 file changed, 4 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp
|
||||||
|
index 115a983bc..7fe05190e 100644
|
||||||
|
--- a/services/sensorservice/SensorDevice.cpp
|
||||||
|
+++ b/services/sensorservice/SensorDevice.cpp
|
||||||
|
@@ -26,6 +26,8 @@
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
+#include <android-base/properties.h>
|
||||||
|
+
|
||||||
|
using namespace android::hardware::sensors::V1_0;
|
||||||
|
using namespace android::hardware::sensors::V1_0::implementation;
|
||||||
|
using android::hardware::hidl_vec;
|
||||||
|
@@ -59,6 +61,8 @@ SensorDevice::SensorDevice()
|
||||||
|
|
||||||
|
float minPowerMa = 0.001; // 1 microAmp
|
||||||
|
|
||||||
|
+ if(::android::base::GetBoolProperty("persist.sys.phh.samsung_sensors", false))
|
||||||
|
+ setMode(5555);
|
||||||
|
checkReturn(mSensors->getSensorsList(
|
||||||
|
[&](const auto &list) {
|
||||||
|
const size_t count = list.size();
|
||||||
|
--
|
||||||
|
2.17.1
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,76 @@
|
|||||||
|
From 544b54a5a560262561b41bfce9735138d3aac7a8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
|
Date: Wed, 7 Aug 2019 16:45:03 +0200
|
||||||
|
Subject: [PATCH 09/10] Add a Samsung safeplace remover. It will reboot to
|
||||||
|
recovery when it does so, just reboot normally
|
||||||
|
|
||||||
|
Change-Id: Iaee40b23c4041ef8e89b9a3217c693ab02a1def4
|
||||||
|
---
|
||||||
|
init/init.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
1 file changed, 44 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/init/init.cpp b/init/init.cpp
|
||||||
|
index 168e68042..93836fdbd 100644
|
||||||
|
--- a/init/init.cpp
|
||||||
|
+++ b/init/init.cpp
|
||||||
|
@@ -543,6 +543,48 @@ static void InstallSigtermHandler() {
|
||||||
|
register_epoll_handler(sigterm_signal_fd, HandleSigtermSignal);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void DisableSamsungSafeplace() {
|
||||||
|
+ static const char before[] = {
|
||||||
|
+ 0x82, 0x1B, 0x80, 0x12
|
||||||
|
+ };
|
||||||
|
+ static const char after[] = {
|
||||||
|
+ 0xE2, 0xFF, 0x8F, 0x12
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ int fd = open("/dev/block/by-name/boot", O_RDWR);
|
||||||
|
+ LOG(INFO) << "opened boot! " << fd;
|
||||||
|
+ if(fd < 0) return;
|
||||||
|
+
|
||||||
|
+ off_t end = lseek(fd, 0, SEEK_END);
|
||||||
|
+ LOG(INFO) << "Found size! " << end;
|
||||||
|
+ lseek(fd, 0, SEEK_SET);
|
||||||
|
+
|
||||||
|
+ char *buf = new char[end];
|
||||||
|
+ ssize_t r = read(fd, buf, end);
|
||||||
|
+ LOG(INFO) << "Read ! " << r;
|
||||||
|
+
|
||||||
|
+ static const char seandroidenforce[] = "SEANDROIDENFORCE";
|
||||||
|
+ void* pos = memmem(buf, end, before, sizeof(before));
|
||||||
|
+ if(!memmem(buf, end, seandroidenforce, strlen(seandroidenforce))) {
|
||||||
|
+ LOG(INFO) << "Not a samsung kernel + " << pos;
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ if(pos) {
|
||||||
|
+ LOG(INFO) << "bfore ! " << pos;
|
||||||
|
+ memcpy(pos, after, sizeof(after));
|
||||||
|
+ lseek(fd, 0, SEEK_SET);
|
||||||
|
+ ssize_t w = write(fd, buf, end);
|
||||||
|
+ printf("%d__: %zd\n", __LINE__, w);
|
||||||
|
+ RebootSystem(ANDROID_RB_RESTART2, "recovery");
|
||||||
|
+ close(fd);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ close(fd);
|
||||||
|
+ LOG(INFO) << "After ! " << memmem(buf, end, after, sizeof(after));
|
||||||
|
+
|
||||||
|
+ return;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
if (!strcmp(basename(argv[0]), "ueventd")) {
|
||||||
|
return ueventd_main(argc, argv);
|
||||||
|
@@ -616,6 +658,8 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
|
SetInitAvbVersionInRecovery();
|
||||||
|
|
||||||
|
+ DisableSamsungSafeplace();
|
||||||
|
+
|
||||||
|
// Enable seccomp if global boot option was passed (otherwise it is enabled in zygote).
|
||||||
|
global_seccomp();
|
||||||
|
|
||||||
|
--
|
||||||
|
2.17.1
|
||||||
|
|
@ -0,0 +1,70 @@
|
|||||||
|
From e6db829c4c05539b585c125ecf9f10265ce650c4 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pierre-Hugues Husson <phh@phh.me>
|
||||||
|
Date: Thu, 22 Aug 2019 20:27:54 +0200
|
||||||
|
Subject: [PATCH 10/10] Always close boot file descriptor. This lead to zygote
|
||||||
|
not starting. Should probably add cloexec later
|
||||||
|
|
||||||
|
Change-Id: Ia58f953c0edc7c85705dc75c3b4e3478f1eb00a7
|
||||||
|
---
|
||||||
|
init/init.cpp | 24 +++++++++++++++---------
|
||||||
|
1 file changed, 15 insertions(+), 9 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/init/init.cpp b/init/init.cpp
|
||||||
|
index 93836fdbd..5843974a9 100644
|
||||||
|
--- a/init/init.cpp
|
||||||
|
+++ b/init/init.cpp
|
||||||
|
@@ -551,36 +551,42 @@ static void DisableSamsungSafeplace() {
|
||||||
|
0xE2, 0xFF, 0x8F, 0x12
|
||||||
|
};
|
||||||
|
|
||||||
|
+ char *buf;
|
||||||
|
+ off_t end;
|
||||||
|
+ ssize_t r, w;
|
||||||
|
+ void *pos;
|
||||||
|
+ static const char seandroidenforce[] = "SEANDROIDENFORCE";
|
||||||
|
+
|
||||||
|
int fd = open("/dev/block/by-name/boot", O_RDWR);
|
||||||
|
LOG(INFO) << "opened boot! " << fd;
|
||||||
|
- if(fd < 0) return;
|
||||||
|
+ if(fd < 0) goto end;
|
||||||
|
|
||||||
|
- off_t end = lseek(fd, 0, SEEK_END);
|
||||||
|
+ end = lseek(fd, 0, SEEK_END);
|
||||||
|
LOG(INFO) << "Found size! " << end;
|
||||||
|
lseek(fd, 0, SEEK_SET);
|
||||||
|
|
||||||
|
- char *buf = new char[end];
|
||||||
|
- ssize_t r = read(fd, buf, end);
|
||||||
|
+ buf = new char[end];
|
||||||
|
+ r = read(fd, buf, end);
|
||||||
|
LOG(INFO) << "Read ! " << r;
|
||||||
|
|
||||||
|
- static const char seandroidenforce[] = "SEANDROIDENFORCE";
|
||||||
|
- void* pos = memmem(buf, end, before, sizeof(before));
|
||||||
|
+ pos = memmem(buf, end, before, sizeof(before));
|
||||||
|
if(!memmem(buf, end, seandroidenforce, strlen(seandroidenforce))) {
|
||||||
|
LOG(INFO) << "Not a samsung kernel + " << pos;
|
||||||
|
- return;
|
||||||
|
+ goto end;
|
||||||
|
}
|
||||||
|
if(pos) {
|
||||||
|
LOG(INFO) << "bfore ! " << pos;
|
||||||
|
memcpy(pos, after, sizeof(after));
|
||||||
|
lseek(fd, 0, SEEK_SET);
|
||||||
|
- ssize_t w = write(fd, buf, end);
|
||||||
|
+ w = write(fd, buf, end);
|
||||||
|
printf("%d__: %zd\n", __LINE__, w);
|
||||||
|
RebootSystem(ANDROID_RB_RESTART2, "recovery");
|
||||||
|
close(fd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
- close(fd);
|
||||||
|
LOG(INFO) << "After ! " << memmem(buf, end, after, sizeof(after));
|
||||||
|
+end:
|
||||||
|
+ close(fd);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.17.1
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user