Sync up to v300.i

This commit is contained in:
Andy CrossGate Yan 2020-12-13 01:56:05 +00:00
parent 1bc6933877
commit 4048bfed3a
11 changed files with 887 additions and 0 deletions

View File

@ -0,0 +1,39 @@
From 709393961b2c65d2e9c50fdb5c2db3370811da5c Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 26 Oct 2020 23:23:24 +0100
Subject: [PATCH 3/3] Ignore vndk lite when looking for ld.config
Change-Id: I6927ba11dcb8435fab1866985c177a1852488414
---
linker/linker.cpp | 8 --------
1 file changed, 8 deletions(-)
diff --git a/linker/linker.cpp b/linker/linker.cpp
index ae2c00c21..ea504c91e 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -93,7 +93,6 @@ static uint64_t g_module_unload_counter = 0;
static const char* const kLdConfigArchFilePath = "/system/etc/ld.config." ABI_STRING ".txt";
static const char* const kLdConfigFilePath = "/system/etc/ld.config.txt";
-static const char* const kLdConfigVndkLiteFilePath = "/system/etc/ld.config.vndk_lite.txt";
static const char* const kLdGeneratedConfigFilePath = "/linkerconfig/ld.config.txt";
@@ -3372,13 +3371,6 @@ static std::string get_ld_config_file_apex_path(const char* executable_path) {
}
static std::string get_ld_config_file_vndk_path() {
- bool same_version_system_vendor = false;
- if(std::to_string(__ANDROID_API__) == Config::get_vndk_version_string('.'))
- same_version_system_vendor = true;
- if (android::base::GetBoolProperty("ro.vndk.lite", false) && same_version_system_vendor) {
- return kLdConfigVndkLiteFilePath;
- }
-
std::string ld_config_file_vndk = kLdConfigFilePath;
size_t insert_pos = ld_config_file_vndk.find_last_of('.');
if (insert_pos == std::string::npos) {
--
2.17.1

View File

@ -0,0 +1,37 @@
From cbe557557ea73ea8fef866f362c869daf4c3be51 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 25 Oct 2020 23:57:26 +0100
Subject: [PATCH 26/26] Re-implement fnmatch-like behaviour for RRO java-side
Change-Id: Id38292a9a1453aa87b8401c1fdb390fa4e63c7d1
---
core/java/android/content/pm/PackageParser.java | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 70e4e6cbf62..a4d8941d1e5 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -2476,8 +2476,17 @@ public class PackageParser {
for (int i = 0; i < propNames.length; i++) {
// Check property value: make sure it is both set and equal to expected value
final String currValue = SystemProperties.get(propNames[i]);
- if (!TextUtils.equals(currValue, propValues[i])) {
- return false;
+ final String value = propValues[i];
+ if(value.startsWith("+")) {
+ final java.util.regex.Pattern regex = java.util.regex.Pattern.compile(value.substring(1, value.length()).replace("*", ".*"));
+ java.util.regex.Matcher matcher = regex.matcher(currValue);
+ if (!matcher.find()) {
+ return false;
+ }
+ } else {
+ if(!value.equals(currValue)) {
+ return false;
+ }
}
}
return true;
--
2.17.1

View File

@ -0,0 +1,157 @@
From 772f3c12ec0676d9e22eea8a005ddf302ad09940 Mon Sep 17 00:00:00 2001
From: Danny Lin <danny@kdrag0n.dev>
Date: Mon, 5 Oct 2020 12:36:35 -0700
Subject: [PATCH 27/27] Add support for app signature spoofing
This is needed by microG GmsCore to pretend to be the official Google
Play Services package, because client apps check the package signature
to make sure it matches Google's official certificate.
This was forward-ported from the Android 10 patch by gudenau:
https://github.com/microg/android_packages_apps_GmsCore/pull/957
Changes made for Android 11:
- Updated PackageInfo calls
- Added new permission to public API surface, needed for
PermissionController which is now an updatable APEX on 11
- Added a dummy permission group to allow users to manage the
permission through the PermissionController UI
(by Vachounet <vachounet@live.fr>)
- Updated location provider comment for conciseness
Change made by PHH:
- Permission is exposed as "privileged" rather than "dangerous", so that
apps need to be in system;product's priv-app
Change-Id: Ied7d6ce0b83a2d2345c3abba0429998d86494a88
---
api/current.txt | 1 +
core/res/AndroidManifest.xml | 7 ++++++
core/res/res/values/config.xml | 2 ++
core/res/res/values/strings.xml | 12 ++++++++++
non-updatable-api/current.txt | 1 +
.../server/pm/PackageManagerService.java | 23 +++++++++++++++++--
6 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/api/current.txt b/api/current.txt
index 952ccdad992..73fb59fedab 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -79,6 +79,7 @@ package android {
field public static final String DUMP = "android.permission.DUMP";
field public static final String EXPAND_STATUS_BAR = "android.permission.EXPAND_STATUS_BAR";
field public static final String FACTORY_TEST = "android.permission.FACTORY_TEST";
+ field public static final String FAKE_PACKAGE_SIGNATURE = "android.permission.FAKE_PACKAGE_SIGNATURE";
field public static final String FOREGROUND_SERVICE = "android.permission.FOREGROUND_SERVICE";
field public static final String GET_ACCOUNTS = "android.permission.GET_ACCOUNTS";
field public static final String GET_ACCOUNTS_PRIVILEGED = "android.permission.GET_ACCOUNTS_PRIVILEGED";
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 9945057f0e9..e1adee20ccf 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2829,6 +2829,13 @@
android:description="@string/permdesc_getPackageSize"
android:protectionLevel="normal" />
+ <!-- Allows an application to change the package signature as
+ seen by applications -->
+ <permission android:name="android.permission.FAKE_PACKAGE_SIGNATURE"
+ android:protectionLevel="signature|privileged"
+ android:label="@string/permlab_fakePackageSignature"
+ android:description="@string/permdesc_fakePackageSignature" />
+
<!-- @deprecated No longer useful, see
{@link android.content.pm.PackageManager#addPackageToPreferred}
for details. -->
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index d21930f31df..372319ed32b 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -1646,6 +1646,8 @@
<string-array name="config_locationProviderPackageNames" translatable="false">
<!-- The standard AOSP fused location provider -->
<item>com.android.location.fused</item>
+ <!-- Google Play Services or microG (free reimplementation) location provider -->
+ <item>com.google.android.gms</item>
</string-array>
<!-- This string array can be overriden to enable test location providers initially. -->
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 4f9911fbe38..32f2dbf33d3 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -847,6 +847,18 @@
<!-- Permissions -->
+ <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permlab_fakePackageSignature">Spoof package signature</string>
+ <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permdesc_fakePackageSignature">Allows the app to pretend to be a different app. Malicious applications might be able to use this to access private application data. Legitimate uses include an emulator pretending to be what it emulates. Grant this permission with caution only!</string>
+ <!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permgrouplab_fake_package_signature">Spoof package signature</string>
+ <!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permgroupdesc_fake_package_signature">allow to spoof package signature</string>
+ <!-- Message shown to the user when the apps requests permission from this group. If ever possible this should stay below 80 characters (assuming the parameters takes 20 characters). Don't abbreviate until the message reaches 120 characters though. [CHAR LIMIT=120] -->
+ <string name="permgrouprequest_fake_package_signature">Allow
+ &lt;b><xliff:g id="app_name" example="Gmail">%1$s</xliff:g>&lt;/b> to spoof package signature?</string>
+
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_statusBar">disable or modify status bar</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
diff --git a/non-updatable-api/current.txt b/non-updatable-api/current.txt
index 5f15216e840..c29feb9cd7b 100644
--- a/non-updatable-api/current.txt
+++ b/non-updatable-api/current.txt
@@ -79,6 +79,7 @@ package android {
field public static final String DUMP = "android.permission.DUMP";
field public static final String EXPAND_STATUS_BAR = "android.permission.EXPAND_STATUS_BAR";
field public static final String FACTORY_TEST = "android.permission.FACTORY_TEST";
+ field public static final String FAKE_PACKAGE_SIGNATURE = "android.permission.FAKE_PACKAGE_SIGNATURE";
field public static final String FOREGROUND_SERVICE = "android.permission.FOREGROUND_SERVICE";
field public static final String GET_ACCOUNTS = "android.permission.GET_ACCOUNTS";
field public static final String GET_ACCOUNTS_PRIVILEGED = "android.permission.GET_ACCOUNTS_PRIVILEGED";
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index c3c655d632e..f7faf418fb4 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -4395,8 +4395,9 @@ public class PackageManagerService extends IPackageManager.Stub
});
}
- PackageInfo packageInfo = PackageInfoUtils.generate(p, gids, flags,
- ps.firstInstallTime, ps.lastUpdateTime, permissions, state, userId, ps);
+ PackageInfo packageInfo = mayFakeSignature(p, PackageInfoUtils.generate(p, gids, flags,
+ ps.firstInstallTime, ps.lastUpdateTime, permissions, state, userId, ps),
+ permissions);
if (packageInfo == null) {
return null;
@@ -4432,6 +4433,24 @@ public class PackageManagerService extends IPackageManager.Stub
}
}
+ private PackageInfo mayFakeSignature(AndroidPackage p, PackageInfo pi,
+ Set<String> permissions) {
+ try {
+ if (permissions.contains("android.permission.FAKE_PACKAGE_SIGNATURE")
+ && p.getTargetSdkVersion() > Build.VERSION_CODES.LOLLIPOP_MR1
+ && p.getMetaData() != null) {
+ String sig = p.getMetaData().getString("fake-signature");
+ if (sig != null) {
+ pi.signatures = new Signature[] {new Signature(sig)};
+ }
+ }
+ } catch (Throwable t) {
+ // We should never die because of any failures, this is system code!
+ Log.w("PackageManagerService.FAKE_PACKAGE_SIGNATURE", t);
+ }
+ return pi;
+ }
+
@Override
public void checkPackageStartable(String packageName, int userId) {
final int callingUid = Binder.getCallingUid();
--
2.17.1

View File

@ -0,0 +1,35 @@
From 06f3a285cd8f61a94df27fc1b062160aa73ec909 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 22 Oct 2020 23:22:46 +0200
Subject: [PATCH 09/10] Matching an input with a display uses uniqueId
Not all devices have a `location`, notably bluetooth devices.
However, we might still want to associate them with a screen,
so match them with uniqueId indeed.
This is useful to have bluetooth keyboard in desktop mode for instance.
Change-Id: Ifcbc8329d54386f58e013270d9888316c0f516b6
---
services/inputflinger/reader/InputDevice.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/services/inputflinger/reader/InputDevice.cpp b/services/inputflinger/reader/InputDevice.cpp
index 4b19e5e35..8f2d3a685 100644
--- a/services/inputflinger/reader/InputDevice.cpp
+++ b/services/inputflinger/reader/InputDevice.cpp
@@ -275,7 +275,10 @@ void InputDevice::configure(nsecs_t when, const InputReaderConfiguration* config
mAssociatedDisplayPort = std::nullopt;
mAssociatedViewport = std::nullopt;
// Find the display port that corresponds to the current input port.
- const std::string& inputPort = mIdentifier.location;
+ std::string inputPort = mIdentifier.location;
+ if (inputPort.empty()) {
+ inputPort = mIdentifier.uniqueId;
+ }
if (!inputPort.empty()) {
const std::unordered_map<std::string, uint8_t>& ports = config->portAssociations;
const auto& displayPort = ports.find(inputPort);
--
2.17.1

View File

@ -0,0 +1,173 @@
From c8dc151cee2395313b510f07119696717b73f4ef Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 26 Oct 2020 23:16:30 +0100
Subject: [PATCH 10/10] Apply associated display for joysticks
Change-Id: I5f6c237e6bf53312aff3dc02a46ce1c779063203
---
.../reader/mapper/JoystickInputMapper.cpp | 4 +-
.../reader/mapper/JoystickInputMapper.h | 2 +
.../inputflinger/tests/InputReader_test.cpp | 100 ++++++++++++++++++
3 files changed, 105 insertions(+), 1 deletion(-)
diff --git a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
index 030a84672..929bfc5f9 100644
--- a/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/JoystickInputMapper.cpp
@@ -196,6 +196,8 @@ void JoystickInputMapper::configure(nsecs_t when, const InputReaderConfiguration
}
}
}
+ std::optional<DisplayViewport> viewport = getDeviceContext().getAssociatedViewport();
+ mDisplayId = viewport ? viewport->displayId : ADISPLAY_ID_NONE;
}
bool JoystickInputMapper::haveAxis(int32_t axisId) {
@@ -334,7 +336,7 @@ void JoystickInputMapper::sync(nsecs_t when, bool force) {
uint32_t policyFlags = 0;
NotifyMotionArgs args(getContext()->getNextId(), when, getDeviceId(), AINPUT_SOURCE_JOYSTICK,
- ADISPLAY_ID_NONE, policyFlags, AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState,
+ mDisplayId, policyFlags, AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState,
buttonState, MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE, 1,
&pointerProperties, &pointerCoords, 0, 0,
AMOTION_EVENT_INVALID_CURSOR_POSITION,
diff --git a/services/inputflinger/reader/mapper/JoystickInputMapper.h b/services/inputflinger/reader/mapper/JoystickInputMapper.h
index 823a096d6..cf864ba75 100644
--- a/services/inputflinger/reader/mapper/JoystickInputMapper.h
+++ b/services/inputflinger/reader/mapper/JoystickInputMapper.h
@@ -105,6 +105,8 @@ private:
static void addMotionRange(int32_t axisId, const Axis& axis, InputDeviceInfo* info);
static void setPointerCoordsAxisValue(PointerCoords* pointerCoords, int32_t axis, float value);
+
+ int32_t mDisplayId = ADISPLAY_ID_NONE;
};
} // namespace android
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index c457a1525..c9b704993 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -20,6 +20,7 @@
#include <InputReader.h>
#include <InputReaderBase.h>
#include <InputReaderFactory.h>
+#include <JoystickInputMapper.h>
#include <KeyboardInputMapper.h>
#include <MultiTouchInputMapper.h>
#include <SingleTouchInputMapper.h>
@@ -252,6 +253,10 @@ public:
mConfig.portAssociations.insert({inputPort, displayPort});
}
+ void removeInputPortAssociation(const std::string& inputPort) {
+ mConfig.portAssociations.erase(inputPort);
+ }
+
void addDisabledDevice(int32_t deviceId) { mConfig.disabledDevices.insert(deviceId); }
void removeDisabledDevice(int32_t deviceId) { mConfig.disabledDevices.erase(deviceId); }
@@ -7336,4 +7341,99 @@ TEST_F(MultiTouchInputMapperTest_SurfaceRange, Viewports_SurfaceRange_270) {
constexpr int32_t yExpected = (x + 1) - DISPLAY_WIDTH / 4;
processPositionAndVerify(mapper, x - 1, y, x + 1, y, xExpected, yExpected);
}
+class JoystickInputMapperTest : public InputMapperTest {
+ protected:
+ const std::string PRIMARY_UNIQUE_ID = "local:0";
+ const std::string SECONDARY_UNIQUE_ID = "local:1";
+ static const uint8_t HDMI1;
+ static const uint8_t HDMI2;
+ virtual void SetUp() override {
+ InputMapperTest::SetUp(INPUT_DEVICE_CLASS_JOYSTICK);
+ }
+
+ static void process(InputMapper& mapper, nsecs_t when, int32_t type, int32_t code,
+ int32_t value) {
+ RawEvent event;
+ event.when = when;
+ event.deviceId = mapper.getDeviceContext().getEventHubId();
+ event.type = type;
+ event.code = code;
+ event.value = value;
+ mapper.process(&event);
+ }
+
+ static void process(InputMapper& mapper, int x, int y) {
+ process(mapper, ARBITRARY_TIME, EV_ABS, ABS_X, x);
+ process(mapper, ARBITRARY_TIME, EV_ABS, ABS_Y, y);
+ process(mapper, ARBITRARY_TIME, EV_SYN, SYN_REPORT, 0);
+ }
+};
+
+const uint8_t JoystickInputMapperTest::HDMI1 = 0;
+const uint8_t JoystickInputMapperTest::HDMI2 = 1;
+TEST_F(JoystickInputMapperTest, Configure_AssignsDisplayPort) {
+ NotifyMotionArgs args;
+
+ // Prepare test
+ setDisplayInfoAndReconfigure(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_0,
+ PRIMARY_UNIQUE_ID, HDMI1, ViewportType::VIEWPORT_INTERNAL);
+
+ mFakeEventHub->addAbsoluteAxis(EVENTHUB_ID, ABS_X, 0, 255, 15, 0, 0);
+ mFakeEventHub->addAbsoluteAxis(EVENTHUB_ID, ABS_Y, 0, 255, 15, 0, 0);
+
+ JoystickInputMapper& mapper =
+ addMapperAndConfigure<JoystickInputMapper>();
+ // 1. Ensure when initially unmapped, that event goes to focused display
+ // Center joystick
+ process(mapper, 127, 127);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+
+ // Joystick hasn't been mapped to any display yet, so it goes where the focus is
+ ASSERT_EQ(args.displayId, ADISPLAY_ID_NONE);
+ ASSERT_TRUE(mDevice->isEnabled());
+
+ // 2. Ensure that when mapping joystick to non-existing display, device is disabled
+
+ // Assign joystick to a non-existing display
+ mFakePolicy->addInputPortAssociation(DEVICE_LOCATION, HDMI2);
+ configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+
+ // We don't test mapper's return value here, because it may or may not have a notion
+ // of whether the viewport exists
+ ASSERT_FALSE(mDevice->isEnabled());
+
+ // 3. Ensure that when joystick is mapped and screen is attached, events go to correct display
+ // Prepare second display.
+ constexpr int32_t newDisplayId = 37;
+ setDisplayInfoAndReconfigure(newDisplayId, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_0,
+ SECONDARY_UNIQUE_ID, HDMI2, ViewportType::VIEWPORT_EXTERNAL);
+ configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+
+ // Device should be enabled after the associated display is found.
+ ASSERT_TRUE(mDevice->isEnabled());
+
+ // Send an event and ensure it goes to the correct display
+ process(mapper, 40, 127);
+
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+
+ ASSERT_EQ(args.displayId, newDisplayId);
+ ASSERT_EQ(args.pointerCount, 1U);
+
+ // ABS_{X,Y} are mapped to GENERIC_{1,2} because FakeInputReaderContext does no axis mapping
+ ASSERT_NEAR(args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_GENERIC_1), 0.16, 0.02f);
+ ASSERT_NEAR(args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_GENERIC_2), 0.5, 0.02f);
+
+ // 4. Ensure that when removing association again, joystick goes back to focus-based display
+ // Remove association
+ mFakePolicy->removeInputPortAssociation(DEVICE_LOCATION);
+ configureDevice(InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+
+ process(mapper, 127, 127);
+
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
+
+ // And check we're back to focus-based
+ ASSERT_EQ(args.displayId, ADISPLAY_ID_NONE);
+}
} // namespace android
--
2.17.1

View File

@ -0,0 +1,130 @@
From 6e55b139d548a51a13221eaa64546c21511af9dd Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 14 Aug 2018 16:59:12 +0200
Subject: [PATCH 1/4] Revert "SupplicantManager: Remove
|ensure_config_file_exists|"
This reverts commit f61dc8cd7dadda5741d6e4a1bb6b576ba89cc24b.
---
libwifi_system/supplicant_manager.cpp | 97 +++++++++++++++++++++++++++
1 file changed, 97 insertions(+)
diff --git a/libwifi_system/supplicant_manager.cpp b/libwifi_system/supplicant_manager.cpp
index 60720d40f..f22eea92e 100644
--- a/libwifi_system/supplicant_manager.cpp
+++ b/libwifi_system/supplicant_manager.cpp
@@ -33,7 +33,89 @@ namespace wifi_system {
namespace {
const char kSupplicantInitProperty[] = "init.svc.wpa_supplicant";
+const char kSupplicantConfigTemplatePath[] =
+ "/etc/wifi/wpa_supplicant.conf";
+const char kSupplicantConfigFile[] = "/data/misc/wifi/wpa_supplicant.conf";
+const char kP2pConfigFile[] = "/data/misc/wifi/p2p_supplicant.conf";
const char kSupplicantServiceName[] = "wpa_supplicant";
+constexpr mode_t kConfigFileMode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
+
+int ensure_config_file_exists(const char* config_file) {
+ char buf[2048];
+ int srcfd, destfd;
+ int nread;
+ int ret;
+ std::string templatePath;
+
+ ret = access(config_file, R_OK | W_OK);
+ if ((ret == 0) || (errno == EACCES)) {
+ if ((ret != 0) && (chmod(config_file, kConfigFileMode) != 0)) {
+ LOG(ERROR) << "Cannot set RW to \"" << config_file << "\": "
+ << strerror(errno);
+ return false;
+ }
+ return true;
+ } else if (errno != ENOENT) {
+ LOG(ERROR) << "Cannot access \"" << config_file << "\": "
+ << strerror(errno);
+ return false;
+ }
+
+ std::string configPathSystem =
+ std::string("/system") + std::string(kSupplicantConfigTemplatePath);
+ std::string configPathVendor =
+ std::string("/vendor") + std::string(kSupplicantConfigTemplatePath);
+ srcfd = TEMP_FAILURE_RETRY(open(configPathSystem.c_str(), O_RDONLY));
+ templatePath = configPathSystem;
+ if (srcfd < 0) {
+ int errnoSystem = errno;
+ srcfd = TEMP_FAILURE_RETRY(open(configPathVendor.c_str(), O_RDONLY));
+ templatePath = configPathVendor;
+ if (srcfd < 0) {
+ int errnoVendor = errno;
+ LOG(ERROR) << "Cannot open \"" << configPathSystem << "\": "
+ << strerror(errnoSystem);
+ LOG(ERROR) << "Cannot open \"" << configPathVendor << "\": "
+ << strerror(errnoVendor);
+ return false;
+ }
+ }
+
+ destfd = TEMP_FAILURE_RETRY(open(config_file,
+ O_CREAT | O_RDWR,
+ kConfigFileMode));
+ if (destfd < 0) {
+ close(srcfd);
+ LOG(ERROR) << "Cannot create \"" << config_file << "\": "
+ << strerror(errno);
+ return false;
+ }
+
+ while ((nread = TEMP_FAILURE_RETRY(read(srcfd, buf, sizeof(buf)))) != 0) {
+ if (nread < 0) {
+ LOG(ERROR) << "Error reading \"" << templatePath
+ << "\": " << strerror(errno);
+ close(srcfd);
+ close(destfd);
+ unlink(config_file);
+ return false;
+ }
+ TEMP_FAILURE_RETRY(write(destfd, buf, nread));
+ }
+
+ close(destfd);
+ close(srcfd);
+
+ /* chmod is needed because open() didn't set permisions properly */
+ if (chmod(config_file, kConfigFileMode) < 0) {
+ LOG(ERROR) << "Error changing permissions of " << config_file
+ << " to 0660: " << strerror(errno);
+ unlink(config_file);
+ return false;
+ }
+
+ return true;
+}
} // namespace
@@ -49,6 +131,21 @@ bool SupplicantManager::StartSupplicant() {
return true;
}
+ /* Before starting the daemon, make sure its config file exists */
+ if (ensure_config_file_exists(kSupplicantConfigFile) < 0) {
+ LOG(ERROR) << "Wi-Fi will not be enabled";
+ return false;
+ }
+
+ /*
+ * Some devices have another configuration file for the p2p interface.
+ * However, not all devices have this, and we'll let it slide if it
+ * is missing. For devices that do expect this file to exist,
+ * supplicant will refuse to start and emit a good error message.
+ * No need to check for it here.
+ */
+ (void)ensure_config_file_exists(kP2pConfigFile);
+
/*
* Get a reference to the status property, so we can distinguish
* the case where it goes stopped => running => stopped (i.e.,
--
2.17.1

View File

@ -0,0 +1,96 @@
From 2acdc4231294616ca3a5dd778f05e92aa0bbd9c0 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <pierre-hugues.husson@softathome.com>
Date: Tue, 18 Sep 2018 17:05:07 +0200
Subject: [PATCH 2/4] Support hostap on O/O-MR1 vendors
Two issues are fixed here:
- some vendor HALs lied (because of Android behaviour) about ap interface name.
O/O-MR1 behaviour meant hostap/sta had same interface. So "wlan0" sound
quite a good guess
- doing multiple configureChip in one IWifi session wasn't allowed.
Now, it is a requirement to be supported, so most(all?) HALs don't
support it. force stop/start for every reconfiguration
Change-Id: Ib2f1c94e7f794af65a7006fb05f14b31c910a238
---
.../android/server/wifi/HalDeviceManager.java | 22 +++++++++++++++++--
.../com/android/server/wifi/WifiNative.java | 15 ++++++++++++-
2 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/service/java/com/android/server/wifi/HalDeviceManager.java b/service/java/com/android/server/wifi/HalDeviceManager.java
index 3d0c89c4a..dd814b99d 100644
--- a/service/java/com/android/server/wifi/HalDeviceManager.java
+++ b/service/java/com/android/server/wifi/HalDeviceManager.java
@@ -62,8 +62,8 @@ import java.util.Set;
*/
public class HalDeviceManager {
private static final String TAG = "HalDevMgr";
- private static final boolean VDBG = false;
- private boolean mDbg = false;
+ private static final boolean VDBG = true;
+ private boolean mDbg = true;
private static final int START_HAL_RETRY_INTERVAL_MS = 20;
// Number of attempts a start() is re-tried. A value of 0 means no retries after a single
@@ -229,6 +229,16 @@ public class HalDeviceManager {
*/
public IWifiStaIface createStaIface(
@Nullable InterfaceDestroyedListener destroyedListener, @Nullable Handler handler) {
+ //As of O and O-MR1, configureChip MUST BE after a startWifi
+ //Pie changed this to allow dynamic configureChip
+ //No O/O-MR1 HAL support that, so restart wifi HAL when we do that
+ if(android.os.SystemProperties.getInt("persist.sys.vndk", 28) < 28) {
+ Log.e(TAG, "createStaIface: Stopping wifi");
+ stopWifi();
+ Log.e(TAG, "createStaIface: Starting wifi");
+ startWifi();
+ Log.e(TAG, "createStaIface: Creating iface");
+ }
return (IWifiStaIface) createIface(IfaceType.STA, destroyedListener, handler);
}
@@ -237,6 +247,14 @@ public class HalDeviceManager {
*/
public IWifiApIface createApIface(@Nullable InterfaceDestroyedListener destroyedListener,
@Nullable Handler handler) {
+ //cf createStaIface
+ if(android.os.SystemProperties.getInt("persist.sys.vndk", 28) < 28) {
+ Log.e(TAG, "createApIface: Stopping wifi");
+ stopWifi();
+ Log.e(TAG, "createApIface: Starting wifi");
+ startWifi();
+ Log.e(TAG, "createApIface: Creating iface");
+ }
return (IWifiApIface) createIface(IfaceType.AP, destroyedListener, handler);
}
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index cf362d6a8..41b6ff604 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -833,8 +833,21 @@ public class WifiNative {
private String createApIface(@NonNull Iface iface) {
synchronized (mLock) {
if (mWifiVendorHal.isVendorHalSupported()) {
- return mWifiVendorHal.createApIface(
+ String ret = mWifiVendorHal.createApIface(
new InterfaceDestoyedListenerInternal(iface.id));
+ //In O and O-MR1, there was only ONE wifi interface for everything (sta and ap)
+ //Most vendors used "wlan0" for those interfaces, but there is no guarantee
+ //This override exists here, because most OEMs return "ap0" when doing createApIface,
+ //even when the iface is actually called "wlan0"
+ //
+ //To be perfectly clean, we should check what value createStaIface (would have) returned
+ //and use the same one.
+ //That's overly complicated, so let's assume this is wlan0 for the moment
+ if(android.os.SystemProperties.getInt("persist.sys.vndk", 28) < 28) {
+ ret = "wlan0";
+ }
+
+ return ret;
} else {
Log.i(TAG, "Vendor Hal not supported, ignoring createApIface.");
return handleIfaceCreationWhenVendorHalNotSupported(iface);
--
2.17.1

View File

@ -0,0 +1,94 @@
From 34687b301da56b05b0677e5e5673fdce28f9e399 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 16 Sep 2019 17:42:37 +0200
Subject: [PATCH 3/4] Restore O/O-MR1 behaviour of initing ifaces before supp.
Still not perfect, because wifi can be turned on only once
Change-Id: I7a94b3c4a3fca140a50962e6787af3a7aa2c7d61
---
.../server/wifi/SupplicantStaIfaceHal.java | 4 ++--
.../java/com/android/server/wifi/WifiNative.java | 16 ++++++++++++++--
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
index 657b081dd..aed2d51f9 100644
--- a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
+++ b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
@@ -827,7 +827,7 @@ public class SupplicantStaIfaceHal {
* the device.
* @return true if supported, false otherwise.
*/
- private boolean isV1_1() {
+ /* package */ boolean isV1_1() {
return checkHalVersionByInterfaceName(
android.hardware.wifi.supplicant.V1_1.ISupplicant.kInterfaceName);
}
@@ -837,7 +837,7 @@ public class SupplicantStaIfaceHal {
* the device.
* @return true if supported, false otherwise.
*/
- private boolean isV1_2() {
+ /* package */ boolean isV1_2() {
return checkHalVersionByInterfaceName(
android.hardware.wifi.supplicant.V1_2.ISupplicant.kInterfaceName);
}
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index 41b6ff604..ee7f75325 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -439,9 +439,11 @@ public class WifiNative {
}
/** Helper method invoked to start supplicant if there were no STA ifaces */
+ private boolean supplicantOn = false;
private boolean startSupplicant() {
synchronized (mLock) {
- if (!mIfaceMgr.hasAnyStaIfaceForConnectivity()) {
+ boolean prePieWifi = !mSupplicantStaIfaceHal.isV1_2();
+ if (!mIfaceMgr.hasAnyStaIfaceForConnectivity() || (prePieWifi && !supplicantOn)) {
if (!startAndWaitForSupplicantConnection()) {
Log.e(TAG, "Failed to connect to supplicant");
return false;
@@ -451,6 +453,8 @@ public class WifiNative {
Log.e(TAG, "Failed to register supplicant death handler");
return false;
}
+
+ supplicantOn = true;
}
return true;
}
@@ -464,6 +468,7 @@ public class WifiNative {
Log.e(TAG, "Failed to deregister supplicant death handler");
}
mSupplicantStaIfaceHal.terminate();
+ supplicantOn = false;
}
}
}
@@ -1041,7 +1046,9 @@ public class WifiNative {
mWifiMetrics.incrementNumSetupClientInterfaceFailureDueToHal();
return null;
}
- if (!startSupplicant()) {
+ boolean prePieWifi = !mSupplicantStaIfaceHal.isV1_2();
+
+ if (!prePieWifi && !startSupplicant()) {
Log.e(TAG, "Failed to start supplicant");
mWifiMetrics.incrementNumSetupClientInterfaceFailureDueToSupplicant();
return null;
@@ -1067,6 +1074,11 @@ public class WifiNative {
mWifiMetrics.incrementNumSetupClientInterfaceFailureDueToWificond();
return null;
}
+ if (prePieWifi && !startSupplicant()) {
+ Log.e(TAG, "Failed to start supplicant");
+ mWifiMetrics.incrementNumSetupClientInterfaceFailureDueToSupplicant();
+ return null;
+ }
if (!mSupplicantStaIfaceHal.setupIface(iface.name)) {
Log.e(TAG, "Failed to setup iface in supplicant on " + iface);
teardownInterface(iface.name);
--
2.17.1

View File

@ -0,0 +1,36 @@
From 33c30770c097d39d62be91e6d5861589a04f6607 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 16 Sep 2019 22:47:37 +0200
Subject: [PATCH 4/4] Boot wifi supplicant both with lazy-hal style and init
style
Change-Id: I7e23348d4d16d3787f2c80bce3f8d0178dd5c4c7
---
.../com/android/server/wifi/SupplicantStaIfaceHal.java | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
index aed2d51f9..88306ab29 100644
--- a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
+++ b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
@@ -686,14 +686,13 @@ public class SupplicantStaIfaceHal {
*/
public boolean startDaemon() {
synchronized (mLock) {
+ Log.i(TAG, "Starting supplicant using init");
+ mFrameworkFacade.startSupplicant();
if (isV1_1()) {
Log.i(TAG, "Starting supplicant using HIDL");
return startDaemon_V1_1();
- } else {
- Log.i(TAG, "Starting supplicant using init");
- mFrameworkFacade.startSupplicant();
- return true;
}
+ return true;
}
}
--
2.17.1

View File

@ -0,0 +1,55 @@
From 0c26ab9bf431940096a0cf363363b7c9a8da2d71 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 13 Oct 2019 17:21:31 +0800
Subject: [PATCH] telephony: forward-port support for forceCognitive
* This is needed on some MTK devices. Android 10 refactored some code,
so now the "non-persistent/cognitive" filter is relocated to RIL and
also in DcTracker.setupData().
Change-Id: I5e93cbef317b7973e0dc1125cfc3cc576a1cf9fa
---
src/java/com/android/internal/telephony/RIL.java | 4 +++-
.../android/internal/telephony/dataconnection/DcTracker.java | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/java/com/android/internal/telephony/RIL.java b/src/java/com/android/internal/telephony/RIL.java
index 76ea3abe1..cbde5d850 100644
--- a/src/java/com/android/internal/telephony/RIL.java
+++ b/src/java/com/android/internal/telephony/RIL.java
@@ -66,6 +66,7 @@ import android.os.HwBinder;
import android.os.Message;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
+import android.os.SystemProperties;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
@@ -4476,7 +4477,8 @@ public class RIL extends BaseCommands implements CommandsInterface {
for (DataProfile dp : dps) {
// For v1.0 to v1.2, we only send data profiles that has the persistent
// (a.k.a modem cognitive) bit set to true.
- if (dp.isPersistent()) {
+ boolean forceCognitive = SystemProperties.getBoolean("persist.sys.phh.radio.force_cognitive", false);
+ if (dp.isPersistent() || forceCognitive) {
dpis.add(convertToHalDataProfile10(dp));
}
}
diff --git a/src/java/com/android/internal/telephony/dataconnection/DcTracker.java b/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
index 7b1560ffb..6920911e3 100644
--- a/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
+++ b/src/java/com/android/internal/telephony/dataconnection/DcTracker.java
@@ -1955,8 +1955,9 @@ public class DcTracker extends Handler {
}
// profile id is only meaningful when the profile is persistent on the modem.
+ boolean forceCognitive = SystemProperties.getBoolean("persist.sys.phh.radio.force_cognitive", false);
int profileId = DATA_PROFILE_INVALID;
- if (apnSetting.isPersistent()) {
+ if (apnSetting.isPersistent() || forceCognitive) {
profileId = apnSetting.getProfileId();
if (profileId == DATA_PROFILE_DEFAULT) {
profileId = getApnProfileID(apnContext.getApnType());
--
2.25.1

View File

@ -0,0 +1,35 @@
From 60e1fe62dd2cc5cc9908ed126e619a93bd902a5a Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 18 Oct 2020 18:14:47 +0200
Subject: [PATCH 8/8] Don't abandon creating property tree if there is a
conflict, and hope for the best
Change-Id: I194c815fdd58bfb84aaf7db02b8f0d00b4db21e8
---
.../libpropertyinfoserializer/property_info_serializer.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/property_service/libpropertyinfoserializer/property_info_serializer.cpp b/property_service/libpropertyinfoserializer/property_info_serializer.cpp
index 803657ab8..ecdd0be20 100644
--- a/property_service/libpropertyinfoserializer/property_info_serializer.cpp
+++ b/property_service/libpropertyinfoserializer/property_info_serializer.cpp
@@ -19,6 +19,7 @@
#include "property_info_parser/property_info_parser.h"
#include <set>
+#include <iostream>
#include "trie_builder.h"
#include "trie_serializer.h"
@@ -34,7 +35,7 @@ bool BuildTrie(const std::vector<PropertyInfoEntry>& property_info,
for (const auto& [name, context, type, is_exact] : property_info) {
if (!trie_builder.AddToTrie(name, context, type, is_exact, error)) {
- return false;
+ std::cerr << "Failed adding " << name << " to property trie... let's hope for the best" << std::endl;
}
}
--
2.17.1