Compare commits

..

No commits in common. "aosp15" and "aosp13" have entirely different histories.

62 changed files with 1202 additions and 5467 deletions

View file

@ -1,4 +1,4 @@
From 9f770e862954f07e8a7cce36aedd4879b10641c6 Mon Sep 17 00:00:00 2001
From ea0f283eec1e7750351302dbc2009fa905cef375 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 19 Feb 2022 08:20:25 -0500
Subject: [PATCH] Add new mechanism to fake vendor props on a per-process basis
@ -17,10 +17,10 @@ Squashed: Rework property overriding
1 file changed, 79 insertions(+), 2 deletions(-)
diff --git a/libc/system_properties/system_properties.cpp b/libc/system_properties/system_properties.cpp
index e0d38a8..4f54885 100644
index 1cb15c3df..40ff48bad 100644
--- a/libc/system_properties/system_properties.cpp
+++ b/libc/system_properties/system_properties.cpp
@@ -36,6 +36,8 @@
@@ -35,6 +35,8 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
@ -29,9 +29,9 @@ index e0d38a8..4f54885 100644
#include <new>
@@ -53,6 +55,79 @@
@@ -50,6 +52,79 @@
#define SERIAL_DIRTY(serial) ((serial)&1)
#define SERIAL_VALUE_LEN(serial) ((serial) >> 24)
#define APPCOMPAT_PREFIX "ro.appcompat_override."
+static char comm[128];
+static bool self_ok = false;
@ -109,7 +109,7 @@ index e0d38a8..4f54885 100644
static bool is_dir(const char* pathname) {
struct stat info;
if (stat(pathname, &info) == -1) {
@@ -160,17 +235,19 @@ uint32_t SystemProperties::AreaSerial() {
@@ -123,17 +198,19 @@ uint32_t SystemProperties::AreaSerial() {
}
const prop_info* SystemProperties::Find(const char* name) {
@ -130,7 +130,7 @@ index e0d38a8..4f54885 100644
+ return pa->find(newName);
}
static bool is_appcompat_override(const char* name) {
static bool is_read_only(const char* name) {
--
2.48.1
2.40.0

View file

@ -1,7 +1,7 @@
From d483a03149f587b3078d81256ac356382aafdd6b Mon Sep 17 00:00:00 2001
From f9be27ef60cd4ccca6803458ff29ee7a2236769c Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Thu, 18 Aug 2022 15:44:46 -0400
Subject: [PATCH 6/6] APM: Restore S, R and Q behavior respectively for
Subject: [PATCH 1/4] APM: Restore S, R and Q behavior respectively for
telephony audio
This conditionally reverts part of b2e5cb (T), 51c9cc (S) and afd4ce (R)
@ -31,17 +31,17 @@ relying on the value of `ro.vndk.version`.
Change-Id: I56d36d2aef4319935cb88a3e4771b23c6d5b2145
---
.../managerdefault/AudioPolicyManager.cpp | 206 ++++++++++++------
.../managerdefault/AudioPolicyManager.cpp | 103 ++++++++++++++++--
.../managerdefault/AudioPolicyManager.h | 3 +
2 files changed, 148 insertions(+), 61 deletions(-)
2 files changed, 96 insertions(+), 10 deletions(-)
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 73b574ccfa..4c44acb966 100644
index 4573382a06..c218c7ce2d 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -746,6 +746,17 @@ status_t AudioPolicyManager::updateCallRoutingInternal(
ALOGV("%s device rxDevice %s txDevice %s", __func__,
rxDevices.itemAt(0)->toString().c_str(), txSourceDevice->toString().c_str());
@@ -675,6 +675,17 @@ status_t AudioPolicyManager::updateCallRoutingInternal(
disconnectTelephonyAudioSource(mCallRxSourceClient);
disconnectTelephonyAudioSource(mCallTxSourceClient);
+ // release existing RX patch if any
+ if (mCallRxPatch != 0) {
@ -57,7 +57,7 @@ index 73b574ccfa..4c44acb966 100644
auto telephonyRxModule =
mHwModules.getModuleForDeviceType(AUDIO_DEVICE_IN_TELEPHONY_RX, AUDIO_FORMAT_DEFAULT);
auto telephonyTxModule =
@@ -768,9 +779,20 @@ status_t AudioPolicyManager::updateCallRoutingInternal(
@@ -697,9 +708,20 @@ status_t AudioPolicyManager::updateCallRoutingInternal(
ALOGE("%s() no telephony Tx and/or RX device", __func__);
return INVALID_OPERATION;
}
@ -81,13 +81,13 @@ index 73b574ccfa..4c44acb966 100644
} else {
// If the RX device is on the primary HW module, then use legacy routing method for
// voice calls via setOutputDevice() on primary output.
@@ -794,7 +816,14 @@ status_t AudioPolicyManager::updateCallRoutingInternal(
}
muteWaitMs = setOutputDevices(__func__, mPrimaryOutput, rxDevices, true, delayMs);
@@ -716,7 +738,14 @@ status_t AudioPolicyManager::updateCallRoutingInternal(
if (!createRxPatch) {
muteWaitMs = setOutputDevices(mPrimaryOutput, rxDevices, true, delayMs);
} else { // create RX path audio patch
- connectTelephonyRxAudioSource(delayMs);
- connectTelephonyRxAudioSource();
+ if (property_get_int32("ro.vndk.version", 31) >= 31) {
+ connectTelephonyRxAudioSource(delayMs);
+ connectTelephonyRxAudioSource();
+ } else {
+ // pre-S behavior: some devices do not support SW bridging correctly when HW bridge is
+ // available through createAudioPatch(); startAudioSource() forces SW bridging.
@ -97,21 +97,21 @@ index 73b574ccfa..4c44acb966 100644
// If the TX device is on the primary HW module but RX device is
// on other HW module, SinkMetaData of telephony input should handle it
// assuming the device uses audio HAL V5.0 and above
@@ -810,6 +839,13 @@ status_t AudioPolicyManager::updateCallRoutingInternal(
@@ -731,7 +760,12 @@ status_t AudioPolicyManager::updateCallRoutingInternal(
closeActiveClients(activeDesc);
}
}
connectTelephonyTxAudioSource(txSourceDevice, txSinkDevice, delayMs);
+
- connectTelephonyTxAudioSource(txSourceDevice, txSinkDevice, delayMs);
+ if (property_get_int32("ro.vndk.version", 33) >= 33) {
+ connectTelephonyTxAudioSource(txSourceDevice, txSinkDevice, delayMs);
+ } else {
+ // pre-T behavior: hw bridging for tx too; skip the SwOutput
+ mCallTxPatch = createTelephonyPatch(false /*isRx*/, txSourceDevice, delayMs);
+ }
} else if (fix_call_audio_patch()) {
disconnectTelephonyAudioSource(mCallTxSourceClient);
}
@@ -819,6 +855,36 @@ status_t AudioPolicyManager::updateCallRoutingInternal(
if (waitMs != nullptr) {
*waitMs = muteWaitMs;
@@ -739,6 +773,36 @@ status_t AudioPolicyManager::updateCallRoutingInternal(
return NO_ERROR;
}
@ -148,119 +148,25 @@ index 73b574ccfa..4c44acb966 100644
bool AudioPolicyManager::isDeviceOfModule(
const sp<DeviceDescriptor>& devDesc, const char *moduleId) const {
sp<HwModule> module = mHwModules.getModuleFromName(moduleId);
@@ -5636,83 +5702,101 @@ status_t AudioPolicyManager::createAudioPatchInternal(const struct audio_patch *
@@ -4541,6 +4605,7 @@ status_t AudioPolicyManager::createAudioPatchInternal(const struct audio_patch *
// in config XML to reach the sink so that is can be declared as available.
audio_io_handle_t output = AUDIO_IO_HANDLE_NONE;
sp<SwAudioOutputDescriptor> outputDesc;
- if (!sourceDesc->isInternal()) {
- // take care of dynamic routing for SwOutput selection,
- audio_attributes_t attributes = sourceDesc->attributes();
- audio_stream_type_t stream = sourceDesc->stream();
- audio_attributes_t resultAttr;
- audio_config_t config = AUDIO_CONFIG_INITIALIZER;
- config.sample_rate = sourceDesc->config().sample_rate;
- audio_channel_mask_t sourceMask = sourceDesc->config().channel_mask;
- config.channel_mask =
- (audio_channel_mask_get_representation(sourceMask)
- == AUDIO_CHANNEL_REPRESENTATION_INDEX) ? sourceMask
- : audio_channel_mask_in_to_out(sourceMask);
- config.format = sourceDesc->config().format;
- audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE;
- DeviceIdVector selectedDeviceIds;
- bool isRequestedDeviceForExclusiveUse = false;
- output_type_t outputType;
- bool isSpatialized;
- bool isBitPerfect;
- getOutputForAttrInt(&resultAttr, &output, AUDIO_SESSION_NONE, &attributes,
- &stream, sourceDesc->uid(), &config, &flags,
- &selectedDeviceIds, &isRequestedDeviceForExclusiveUse,
- nullptr, &outputType, &isSpatialized, &isBitPerfect);
- if (output == AUDIO_IO_HANDLE_NONE) {
- ALOGV("%s no output for device %s",
- __FUNCTION__, sinkDevice->toString().c_str());
- return INVALID_OPERATION;
- }
- outputDesc = mOutputs.valueFor(output);
- if (outputDesc->isDuplicated()) {
- ALOGE("%s output is duplicated", __func__);
- return INVALID_OPERATION;
- }
- bool closeOutput = outputDesc->mDirectOpenCount != 0;
- sourceDesc->setSwOutput(outputDesc, closeOutput);
- } else {
- // Same for "raw patches" aka created from createAudioPatch API
- SortedVector<audio_io_handle_t> outputs =
- getOutputsForDevices(DeviceVector(sinkDevice), mOutputs);
- // if the sink device is reachable via an opened output stream, request to
- // go via this output stream by adding a second source to the patch
- // description
- output = selectOutput(outputs);
- if (output == AUDIO_IO_HANDLE_NONE) {
- ALOGE("%s no output available for internal patch sink", __func__);
- return INVALID_OPERATION;
- }
- outputDesc = mOutputs.valueFor(output);
- if (outputDesc->isDuplicated()) {
- ALOGV("%s output for device %s is duplicated",
+ if (sourceDesc != nullptr) { // Ignore indentation, we don't want to cuase huge conflicts...
if (!sourceDesc->isInternal()) {
// take care of dynamic routing for SwOutput selection,
audio_attributes_t attributes = sourceDesc->attributes();
@@ -4586,33 +4651,51 @@ status_t AudioPolicyManager::createAudioPatchInternal(const struct audio_patch *
outputDesc = mOutputs.valueFor(output);
if (outputDesc->isDuplicated()) {
ALOGV("%s output for device %s is duplicated",
- __func__, sinkDevice->toString().c_str());
- return INVALID_OPERATION;
+ if (sourceDesc != nullptr) {
+ if (!sourceDesc->isInternal()) {
+ // take care of dynamic routing for SwOutput selection,
+ audio_attributes_t attributes = sourceDesc->attributes();
+ audio_stream_type_t stream = sourceDesc->stream();
+ audio_attributes_t resultAttr;
+ audio_config_t config = AUDIO_CONFIG_INITIALIZER;
+ config.sample_rate = sourceDesc->config().sample_rate;
+ audio_channel_mask_t sourceMask = sourceDesc->config().channel_mask;
+ config.channel_mask =
+ (audio_channel_mask_get_representation(sourceMask)
+ == AUDIO_CHANNEL_REPRESENTATION_INDEX) ? sourceMask
+ : audio_channel_mask_in_to_out(sourceMask);
+ config.format = sourceDesc->config().format;
+ audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE;
+ DeviceIdVector selectedDeviceIds;
+ bool isRequestedDeviceForExclusiveUse = false;
+ output_type_t outputType;
+ bool isSpatialized;
+ bool isBitPerfect;
+ getOutputForAttrInt(&resultAttr, &output, AUDIO_SESSION_NONE, &attributes,
+ &stream, sourceDesc->uid(), &config, &flags,
+ &selectedDeviceIds, &isRequestedDeviceForExclusiveUse,
+ nullptr, &outputType, &isSpatialized, &isBitPerfect);
+ if (output == AUDIO_IO_HANDLE_NONE) {
+ ALOGV("%s no output for device %s",
+ __FUNCTION__, sinkDevice->toString().c_str());
+ return INVALID_OPERATION;
+ }
+ outputDesc = mOutputs.valueFor(output);
+ if (outputDesc->isDuplicated()) {
+ ALOGE("%s output is duplicated", __func__);
+ return INVALID_OPERATION;
+ }
+ bool closeOutput = outputDesc->mDirectOpenCount != 0;
+ sourceDesc->setSwOutput(outputDesc, closeOutput);
+ } else {
+ // Same for "raw patches" aka created from createAudioPatch API
+ SortedVector<audio_io_handle_t> outputs =
+ getOutputsForDevices(DeviceVector(sinkDevice), mOutputs);
+ // if the sink device is reachable via an opened output stream, request to
+ // go via this output stream by adding a second source to the patch
+ // description
+ output = selectOutput(outputs);
+ if (output == AUDIO_IO_HANDLE_NONE) {
+ ALOGE("%s no output available for internal patch sink", __func__);
+ return INVALID_OPERATION;
+ }
+ outputDesc = mOutputs.valueFor(output);
+ if (outputDesc->isDuplicated()) {
+ ALOGV("%s output for device %s is duplicated",
+ __func__, sinkDevice->toString().c_str());
+ return INVALID_OPERATION;
return INVALID_OPERATION;
}
sourceDesc->setSwOutput(outputDesc, /* closeOutput= */ false);
}
+ }
}
- sourceDesc->setSwOutput(outputDesc, /* closeOutput= */ false);
}
// create a software bridge in PatchPanel if:
// - source and sink devices are on different HW modules OR
// - audio HAL version is < 3.0
@ -302,16 +208,16 @@ index 73b574ccfa..4c44acb966 100644
outputDesc->toAudioPortConfig(&srcMixPortConfig, nullptr);
// for volume control, we may need a valid stream
srcMixPortConfig.ext.mix.usecase.stream =
- (!sourceDesc->isInternal() || sourceDesc->isCallTx()) ?
+ (sourceDesc != nullptr && (!sourceDesc->isInternal() || sourceDesc->isCallTx())) ?
- (!sourceDesc->isInternal() || isCallTxAudioSource(sourceDesc)) ?
+ ((sourceDesc != nullptr && !sourceDesc->isInternal()) || isCallTxAudioSource(sourceDesc)) ?
mEngine->getStreamTypeForAttributes(sourceDesc->attributes()) :
AUDIO_STREAM_PATCH;
patchBuilder.addSource(srcMixPortConfig);
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index 44863eedc2..e8024942fd 100644
index a69e08871b..f8762016db 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -1017,6 +1017,9 @@ protected:
@@ -944,6 +944,9 @@ protected:
SoundTriggerSessionCollection mSoundTriggerSessions;
@ -322,5 +228,5 @@ index 44863eedc2..e8024942fd 100644
SourceClientCollection mAudioSources;
--
2.48.1
2.39.2

View file

@ -1,7 +1,7 @@
From 875011b65d3839871b488b18d483fd56f2306a7b Mon Sep 17 00:00:00 2001
From 5ae18168ff97d9e4eb66fc6dc8e087bd0ead8f31 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Wed, 24 Aug 2022 15:42:39 -0400
Subject: [PATCH 1/6] APM: Optionally force-load audio policy for system-side
Subject: [PATCH 2/4] APM: Optionally force-load audio policy for system-side
bt audio HAL
Required to support our system-side bt audio implementation, i.e.
@ -14,7 +14,7 @@ Change-Id: I279fff541a531f922f3fa55b8f14d00237db59ff
1 file changed, 25 insertions(+)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index 6f19a7a145..08836377b7 100644
index d446e9667b..f5233f2a42 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -25,6 +25,7 @@
@ -25,7 +25,7 @@ index 6f19a7a145..08836377b7 100644
#include <utils/Log.h>
#include <utils/StrongPointer.h>
#include <utils/Errors.h>
@@ -895,6 +896,30 @@ status_t PolicySerializer::deserialize(const char *configFile, AudioPolicyConfig
@@ -890,6 +891,30 @@ status_t PolicySerializer::deserialize(const char *configFile, AudioPolicyConfig
if (status != NO_ERROR) {
return status;
}
@ -57,5 +57,5 @@ index 6f19a7a145..08836377b7 100644
// Global Configuration
--
2.48.1
2.39.2

View file

@ -1,7 +1,7 @@
From d24b962cb20fb0a3e807d05c534f43f8bd0ce350 Mon Sep 17 00:00:00 2001
From d11e204968cbf01851042f03fe2a12aabbe84a93 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Thu, 25 Aug 2022 13:30:29 -0400
Subject: [PATCH 2/6] APM: Remove A2DP audio ports from the primary HAL
Subject: [PATCH 3/4] APM: Remove A2DP audio ports from the primary HAL
These ports defined in the primary HAL are intended for A2DP offloading,
however they do not work in general on GSIs, and will interfere with
@ -16,7 +16,7 @@ Change-Id: I3305594a17285da113167b419543543f0ef71122
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index 08836377b7..0f7c903909 100644
index f5233f2a42..6630d06f6d 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -26,6 +26,7 @@
@ -40,7 +40,7 @@ index 08836377b7..0f7c903909 100644
}
}
if (!xmlStrcmp(cur->name, reinterpret_cast<const xmlChar*>(Trait::tag))) {
@@ -683,6 +681,7 @@ std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<Modu
@@ -679,6 +677,7 @@ std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<Modu
ALOGE("%s: No %s found", __func__, Attributes::name);
return BAD_VALUE;
}
@ -48,7 +48,7 @@ index 08836377b7..0f7c903909 100644
uint32_t versionMajor = 0, versionMinor = 0;
std::string versionLiteral = getXmlAttribute(cur, Attributes::version);
if (!versionLiteral.empty()) {
@@ -708,6 +707,25 @@ std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<Modu
@@ -704,6 +703,25 @@ std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<Modu
if (status != NO_ERROR) {
return status;
}
@ -75,5 +75,5 @@ index 08836377b7..0f7c903909 100644
RouteTraits::Collection routes;
--
2.48.1
2.39.2

View file

@ -1,56 +0,0 @@
From b3bc05d8e2bb94c4992a12a943d16c27554fa54d Mon Sep 17 00:00:00 2001
From: ponces <ponces26@gmail.com>
Date: Mon, 24 Oct 2022 09:38:34 +0100
Subject: [PATCH 3/6] voip: Fix high pitched voice on Qualcomm devices
Change-Id: I6d314912169776b76d07d8c0301ec5249c1870a2
---
.../common/managerdefinitions/src/Serializer.cpp | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index 0f7c903909..c4474cf1c2 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -252,6 +252,7 @@ private:
std::string mChannelMasksSeparator = ",";
std::string mSamplingRatesSeparator = ",";
std::string mFlagsSeparator = "|";
+ std::string mMixPortName = "";
// Children: ModulesTraits, VolumeTraits, SurroundSoundTraits (optional)
};
@@ -426,13 +427,21 @@ PolicySerializer::deserialize<AudioProfileTraits>(
std::string samplingRates = getXmlAttribute(cur, Attributes::samplingRates);
std::string format = getXmlAttribute(cur, Attributes::format);
std::string channels = getXmlAttribute(cur, Attributes::channelMasks);
+ ChannelTraits::Collection channelsMask = channelMasksFromString(channels, mChannelMasksSeparator.c_str());
+
+ // This breaks in-game voice chat and audio in some messaging apps causing it to play with a higher pitch and speed
+ bool disableStereoVoip = property_get_bool("persist.sys.phh.disable_stereo_voip", false);
+ if (disableStereoVoip && mMixPortName == "voip_rx") {
+ ALOGI("%s: disabling stereo support on voip_rx", __func__);
+ channelsMask = channelMasksFromString("AUDIO_CHANNEL_OUT_MONO", ",");
+ }
if (mIgnoreVendorExtensions && maybeVendorExtension(format)) {
ALOGI("%s: vendor extension format \"%s\" skipped", __func__, format.c_str());
return NO_INIT;
}
AudioProfileTraits::Element profile = new AudioProfile(formatFromString(format, gDynamicFormat),
- channelMasksFromString(channels, mChannelMasksSeparator.c_str()),
+ channelsMask,
samplingRatesFromString(samplingRates, mSamplingRatesSeparator.c_str()));
profile->setDynamicFormat(profile->getFormat() == gDynamicFormat);
@@ -449,6 +458,7 @@ std::variant<status_t, MixPortTraits::Element> PolicySerializer::deserialize<Mix
using Attributes = MixPortTraits::Attributes;
std::string name = getXmlAttribute(child, Attributes::name);
+ mMixPortName = name;
if (name.empty()) {
ALOGE("%s: No %s found", __func__, Attributes::name);
return BAD_VALUE;
--
2.48.1

View file

@ -0,0 +1,43 @@
From 628ff965d6ade74843a58cab6fe58069ef0ec3ad Mon Sep 17 00:00:00 2001
From: Emilian Peev <epeev@google.com>
Date: Fri, 5 Aug 2022 17:28:06 -0700
Subject: [PATCH 4/4] Camera: Avoid unnecessary close of buffer acquire fence
fds
According to the gralloc lock documentation:
The ownership of acquireFence is always transferred to the callee, even
on errors.
Bug: 241455881
Test: Manual using camera application
Change-Id: Ieec34b54aaa7f0d773eccb593c3daaa3e41bae0b
Merged-In: Ieec34b54aaa7f0d773eccb593c3daaa3e41bae0b
---
.../camera/libcameraservice/device3/Camera3OutputStream.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/services/camera/libcameraservice/device3/Camera3OutputStream.cpp b/services/camera/libcameraservice/device3/Camera3OutputStream.cpp
index 396104c4fd..c725aadb79 100644
--- a/services/camera/libcameraservice/device3/Camera3OutputStream.cpp
+++ b/services/camera/libcameraservice/device3/Camera3OutputStream.cpp
@@ -331,7 +331,7 @@ status_t Camera3OutputStream::fixUpHidlJpegBlobHeader(ANativeWindowBuffer* anwBu
status_t res =
gbLocker.lockAsync(
GraphicBuffer::USAGE_SW_READ_OFTEN | GraphicBuffer::USAGE_SW_WRITE_RARELY,
- &mapped, fenceFd.get());
+ &mapped, fenceFd.release());
if (res != OK) {
ALOGE("%s: Failed to lock the buffer: %s (%d)", __FUNCTION__, strerror(-res), res);
return res;
@@ -1327,7 +1327,7 @@ void Camera3OutputStream::dumpImageToDisk(nsecs_t timestamp,
void* mapped = nullptr;
base::unique_fd fenceFd(dup(fence));
status_t res = graphicBuffer->lockAsync(GraphicBuffer::USAGE_SW_READ_OFTEN, &mapped,
- fenceFd.get());
+ fenceFd.release());
if (res != OK) {
ALOGE("%s: Failed to lock the buffer: %s (%d)", __FUNCTION__, strerror(-res), res);
return;
--
2.39.2

View file

@ -1,131 +0,0 @@
From 88eee2c55fa4e85aeef0df59c9b788b2b7868c6b Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 5 Aug 2019 18:09:50 +0200
Subject: [PATCH 4/6] Fix BT in-call on CAF devices
See https://github.com/phhusson/treble_experimentations/issues/374
In Qualcomm's BSP audio_policy_configuration.xml, one route is missing,
from primary output and telephony to BT SCO.
Add it if we detect telephony and bt sco, but no such route.
Change-Id: Ifea0f88276ec9a0811f3cb1973c4b06f2c82077b
---
.../managerdefinitions/src/Serializer.cpp | 93 +++++++++++++++++++
1 file changed, 93 insertions(+)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index c4474cf1c2..c1df8f278b 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -676,6 +676,98 @@ std::variant<status_t, RouteTraits::Element> PolicySerializer::deserialize<Route
return route;
}
+static void fixupQualcommBtScoRoute(RouteTraits::Collection& routes, DevicePortTraits::Collection& devicePorts, HwModule* ctx) {
+ // On many Qualcomm devices, there is a BT SCO Headset Mic => primary input mix
+ // But Telephony Rx => BT SCO Headset route is missing
+ // When we detect such case, add the missing route
+
+ // If we have:
+ // <route type="mix" sink="Telephony Tx" sources="voice_tx"/>
+ // <route type="mix" sink="primary input" sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic"/>
+ // <devicePort tagName="BT SCO Headset" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET" role="sink" />
+ // And no <route type="mix" sink="BT SCO Headset" />
+
+ // Add:
+ // <route type="mix" sink="BT SCO Headset" sources="primary output,deep_buffer,compressed_offload,Telephony Rx"/>
+ bool foundBtScoHeadsetDevice = false;
+ for(const auto& device: devicePorts) {
+ if(device->getTagName() == "BT SCO Headset") {
+ foundBtScoHeadsetDevice = true;
+ break;
+ }
+ }
+ if(!foundBtScoHeadsetDevice) {
+ ALOGE("No BT SCO Headset device found, don't patch policy");
+ return;
+ }
+
+ bool foundTelephony = false;
+ bool foundBtScoInput = false;
+ bool foundScoHeadsetRoute = false;
+ for(const auto& route: routes) {
+ ALOGE("Looking at route %d\n", route->getType());
+ if(route->getType() != AUDIO_ROUTE_MIX)
+ continue;
+ auto sink = route->getSink();
+ ALOGE("... With sink %s\n", sink->getTagName().c_str());
+ if(sink->getTagName() == "Telephony Tx") {
+ foundTelephony = true;
+ continue;
+ }
+ if(sink->getTagName() == "BT SCO Headset") {
+ foundScoHeadsetRoute = true;
+ break;
+ }
+ for(const auto& source: route->getSources()) {
+ ALOGE("... With source %s\n", source->getTagName().c_str());
+ if(source->getTagName() == "BT SCO Headset Mic") {
+ foundBtScoInput = true;
+ break;
+ }
+ }
+ }
+ //The route we want to add is already there
+ ALOGE("Done looking for existing routes");
+ if(foundScoHeadsetRoute)
+ return;
+
+ ALOGE("No existing route found... %d %d", foundTelephony ? 1 : 0, foundBtScoInput ? 1 : 0);
+ //We couldn't find the routes we assume are required for the function we want to add
+ if(!foundTelephony || !foundBtScoInput)
+ return;
+ ALOGE("Adding our own.");
+
+ // Add:
+ // <route type="mix" sink="BT SCO Headset" sources="primary output,deep_buffer,compressed_offload,Telephony Rx"/>
+ AudioRoute *newRoute = new AudioRoute(AUDIO_ROUTE_MIX);
+
+ auto sink = ctx->findPortByTagName("BT SCO Headset");
+ ALOGE("Got sink %p\n", sink.get());
+ newRoute->setSink(sink);
+
+ Vector<sp<PolicyAudioPort>> sources;
+ for(const auto& sourceName: {
+ "primary output",
+ "deep_buffer",
+ "compressed_offload",
+ "Telephony Rx"
+ }) {
+ auto source = ctx->findPortByTagName(sourceName);
+ ALOGE("Got source %p\n", source.get());
+ if (source.get() != nullptr) {
+ sources.add(source);
+ source->addRoute(newRoute);
+ }
+ }
+
+ newRoute->setSources(sources);
+
+ sink->addRoute(newRoute);
+
+ auto ret = routes.add(newRoute);
+ ALOGE("route add returned %zd", ret);
+}
+
template<>
std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<ModuleTraits>(
const xmlNode *cur, ModuleTraits::PtrSerializingCtx ctx)
@@ -743,6 +835,7 @@ std::variant<status_t, ModuleTraits::Element> PolicySerializer::deserialize<Modu
if (status != NO_ERROR) {
return status;
}
+ fixupQualcommBtScoRoute(routes, devicePorts, module.get());
module->setRoutes(routes);
for (const xmlNode *children = cur->xmlChildrenNode; children != NULL;
--
2.48.1

View file

@ -1,47 +0,0 @@
From 79a670c8e20a8eb68849be7e3f9b4c0421d92073 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 21 Dec 2020 20:19:11 +0100
Subject: [PATCH 5/6] Make camera IDs filter-out optional
Nowadays most people have Camera 2 apps, and would like to have all
cameras, rather than limit which cameras are available.
Add a property for that.
---
.../common/CameraProviderManager.cpp | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp
index a8d748028b..203a166a36 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
@@ -324,7 +324,9 @@ std::vector<std::string> CameraProviderManager::getAPI1CompatibleCameraDeviceIds
// API1 app doesn't handle logical and physical camera devices well. So
// for each camera facing, only take the first id advertised by HAL in
// all [logical, physical1, physical2, ...] id combos, and filter out the rest.
- filterLogicalCameraIdsLocked(providerDeviceIds);
+ if(!property_get_bool("persist.sys.phh.include_all_cameras", false)) {
+ filterLogicalCameraIdsLocked(providerDeviceIds);
+ }
collectDeviceIdsLocked(providerDeviceIds, publicDeviceIds, systemDeviceIds);
}
auto sortFunc =
@@ -1108,10 +1110,12 @@ SystemCameraKind CameraProviderManager::ProviderInfo::DeviceInfo3::getSystemCame
// Go through the capabilities and check if it has
// ANDROID_REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA
- for (size_t i = 0; i < entryCap.count; ++i) {
- uint8_t capability = entryCap.data.u8[i];
- if (capability == ANDROID_REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA) {
- return SystemCameraKind::SYSTEM_ONLY_CAMERA;
+ if(!property_get_bool("persist.sys.phh.include_all_cameras", false)) {
+ for (size_t i = 0; i < entryCap.count; ++i) {
+ uint8_t capability = entryCap.data.u8[i];
+ if (capability == ANDROID_REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA) {
+ return SystemCameraKind::SYSTEM_ONLY_CAMERA;
+ }
}
}
return SystemCameraKind::PUBLIC;
--
2.48.1

View file

@ -1,7 +1,7 @@
From 3c6a1bbffa88d93be209b41b911f192618a3b8e6 Mon Sep 17 00:00:00 2001
From 5e94fc70ba1963ed33eb6633702cce706b6814d1 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Tue, 12 Oct 2021 21:37:22 -0400
Subject: [PATCH 01/11] PackageParser: support glob matching for properties
Subject: [PATCH 1/6] PackageParser: support glob matching for properties
Needed to make phh's vendor overlays work
---
@ -9,7 +9,7 @@ Needed to make phh's vendor overlays work
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 4b579e7db..8176cf8e8 100644
index c15b3e0b80c3..05bb843c0c4d 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -2545,8 +2545,16 @@ public class PackageParser {
@ -32,5 +32,5 @@ index 4b579e7db..8176cf8e8 100644
}
return true;
--
2.48.1
2.41.0

View file

@ -0,0 +1,163 @@
From 3199a7f449d08acf306aafb180ccbcbacd993616 Mon Sep 17 00:00:00 2001
From: Danny Lin <danny@kdrag0n.dev>
Date: Sat, 16 Oct 2021 05:27:57 -0700
Subject: [PATCH 2/6] 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
Changes made for Android 12:
- Moved mayFakeSignature into lock-free Computer subclass
- Always get permissions for packages that request signature spoofing
(otherwise permissions are usually ommitted and thus the permission
check doesn't work properly)
- Optimize mayFakeSignature check order to improve performance
Changes made for Android 13:
- Computer subclass is now an independent class.
Change-Id: Ied7d6ce0b83a2d2345c3abba0429998d86494a88
---
core/api/current.txt | 2 ++
core/res/AndroidManifest.xml | 15 ++++++++++
core/res/res/values/strings.xml | 12 ++++++++
.../com/android/server/pm/ComputerEngine.java | 30 +++++++++++++++++--
4 files changed, 56 insertions(+), 3 deletions(-)
diff --git a/core/api/current.txt b/core/api/current.txt
index 487e57d114c9..04e69741b9fd 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -87,6 +87,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";
@@ -222,6 +223,7 @@ package android {
field public static final String CALL_LOG = "android.permission-group.CALL_LOG";
field public static final String CAMERA = "android.permission-group.CAMERA";
field public static final String CONTACTS = "android.permission-group.CONTACTS";
+ field public static final String FAKE_PACKAGE = "android.permission-group.FAKE_PACKAGE";
field public static final String LOCATION = "android.permission-group.LOCATION";
field public static final String MICROPHONE = "android.permission-group.MICROPHONE";
field public static final String NEARBY_DEVICES = "android.permission-group.NEARBY_DEVICES";
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 0e95e30a99b8..a456ac6b7129 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -3569,6 +3569,21 @@
android:description="@string/permdesc_getPackageSize"
android:protectionLevel="normal" />
+ <!-- Dummy user-facing group for faking package signature -->
+ <permission-group android:name="android.permission-group.FAKE_PACKAGE"
+ android:label="@string/permgrouplab_fake_package_signature"
+ android:description="@string/permgroupdesc_fake_package_signature"
+ android:request="@string/permgrouprequest_fake_package_signature"
+ android:priority="100" />
+
+ <!-- Allows an application to change the package signature as
+ seen by applications -->
+ <permission android:name="android.permission.FAKE_PACKAGE_SIGNATURE"
+ android:permissionGroup="android.permission-group.UNDEFINED"
+ 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/strings.xml b/core/res/res/values/strings.xml
index 2091c0502b6f..6888edcf7d3c 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -982,6 +982,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/services/core/java/com/android/server/pm/ComputerEngine.java b/services/core/java/com/android/server/pm/ComputerEngine.java
index 46b7460dff1b..40549962436f 100644
--- a/services/core/java/com/android/server/pm/ComputerEngine.java
+++ b/services/core/java/com/android/server/pm/ComputerEngine.java
@@ -1603,6 +1603,29 @@ public class ComputerEngine implements Computer {
return result;
}
+ private boolean requestsFakeSignature(AndroidPackage p) {
+ return p.getMetaData() != null &&
+ p.getMetaData().getString("fake-signature") != null;
+ }
+
+ private PackageInfo mayFakeSignature(AndroidPackage p, PackageInfo pi,
+ Set<String> permissions) {
+ try {
+ if (p.getMetaData() != null &&
+ p.getTargetSdkVersion() > Build.VERSION_CODES.LOLLIPOP_MR1) {
+ String sig = p.getMetaData().getString("fake-signature");
+ if (sig != null &&
+ permissions.contains("android.permission.FAKE_PACKAGE_SIGNATURE")) {
+ 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;
+ }
+
public final PackageInfo generatePackageInfo(PackageStateInternal ps,
@PackageManager.PackageInfoFlagsBits long flags, int userId) {
if (!mUserManager.exists(userId)) return null;
@@ -1632,13 +1655,14 @@ public class ComputerEngine implements Computer {
final int[] gids = (flags & PackageManager.GET_GIDS) == 0 ? EMPTY_INT_ARRAY
: mPermissionManager.getGidsForUid(UserHandle.getUid(userId, ps.getAppId()));
// Compute granted permissions only if package has requested permissions
- final Set<String> permissions = ((flags & PackageManager.GET_PERMISSIONS) == 0
+ final Set<String> permissions = (((flags & PackageManager.GET_PERMISSIONS) == 0
+ && !requestsFakeSignature(p))
|| ArrayUtils.isEmpty(p.getRequestedPermissions())) ? Collections.emptySet()
: mPermissionManager.getGrantedPermissions(ps.getPackageName(), userId);
- PackageInfo packageInfo = PackageInfoUtils.generate(p, gids, flags,
+ PackageInfo packageInfo = mayFakeSignature(p, PackageInfoUtils.generate(p, gids, flags,
state.getFirstInstallTime(), ps.getLastUpdateTime(), permissions, state, userId,
- ps);
+ ps), permissions);
if (packageInfo == null) {
return null;
--
2.41.0

View file

@ -1,7 +1,7 @@
From 6d3e460a5e0df0f6ac2f653d0577560a2c8f32d3 Mon Sep 17 00:00:00 2001
From 734839b7918f93cb746ebbe82179a9cbcf165424 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Fri, 2 Sep 2022 21:36:06 -0400
Subject: [PATCH 02/11] FrameworkParsingPackageUtils: Add glob matching support
Subject: [PATCH 3/6] FrameworkParsingPackageUtils: Add glob matching support
for properties
This is now required in addition to the one in PackageParser in order
@ -13,7 +13,7 @@ Change-Id: Ie8679c0ffe03cead4a68bd2d0eb429f05af2d417
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java b/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java
index e30f871b6..a2979f695 100644
index 3e1c5bb3d7ec..f15978c57574 100644
--- a/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java
+++ b/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java
@@ -215,8 +215,16 @@ public class FrameworkParsingPackageUtils {
@ -36,5 +36,5 @@ index e30f871b6..a2979f695 100644
}
return true;
--
2.48.1
2.41.0

View file

@ -1,7 +1,7 @@
From 176fce488f4206d10e3d4873bce3a43a97540890 Mon Sep 17 00:00:00 2001
From af0cbe50e889694dc72ab84c4e1af816bdd199b9 Mon Sep 17 00:00:00 2001
From: Oliver Scott <olivercscott@gmail.com>
Date: Thu, 8 Jul 2021 10:41:43 -0400
Subject: [PATCH 03/11] Global VPN feature [1/2]
Subject: [PATCH 4/6] Global VPN feature [1/2]
* Modify existing VPN user range functions to conditionally have traffic
from all users pass through the global VPN.
@ -28,10 +28,10 @@ Signed-off-by: Mohammad Hasan Keramat J <ikeramat@protonmail.com>
3 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 4acb6312f..dbc9845a8 100644
index 8d8379831e87..bd6cc1d4d7bf 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -18232,6 +18232,12 @@ public final class Settings {
@@ -16060,6 +16060,12 @@ public final class Settings {
CLOCKWORK_HOME_READY,
};
@ -45,10 +45,10 @@ index 4acb6312f..dbc9845a8 100644
* Keys we no longer back up under the current schema, but want to continue to
* process when restoring historical backup datasets.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java
index f39762766..c7dc809c9 100644
index ba947149d287..e5eb04c7818d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java
@@ -44,6 +44,7 @@ import android.os.Handler;
@@ -39,6 +39,7 @@ import android.os.Handler;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
@ -56,7 +56,7 @@ index f39762766..c7dc809c9 100644
import android.security.KeyChain;
import android.util.ArrayMap;
import android.util.Log;
@@ -383,8 +384,13 @@ public class SecurityControllerImpl implements SecurityController {
@@ -332,8 +333,13 @@ public class SecurityControllerImpl implements SecurityController {
@Override
public void onUserSwitched(int newUserId) {
mCurrentUserId = newUserId;
@ -72,10 +72,10 @@ index f39762766..c7dc809c9 100644
mVpnUserId = newUserInfo.restrictedProfileParentId;
} else {
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java
index 4c5f65285..1c546be6f 100644
index 8510de4ef201..7c02924a711d 100644
--- a/services/core/java/com/android/server/connectivity/Vpn.java
+++ b/services/core/java/com/android/server/connectivity/Vpn.java
@@ -778,6 +778,15 @@ public class Vpn {
@@ -691,6 +691,15 @@ public class Vpn {
return mAlwaysOn;
}
@ -91,7 +91,7 @@ index 4c5f65285..1c546be6f 100644
/**
* Checks if a VPN app supports always-on mode.
*
@@ -1720,6 +1729,7 @@ public class Vpn {
@@ -1559,6 +1568,7 @@ public class Vpn {
try {
// Restricted users are not allowed to create VPNs, they are tied to Owner
enforceNotRestrictedUser();
@ -99,7 +99,7 @@ index 4c5f65285..1c546be6f 100644
final PackageManager packageManager = mUserIdContext.getPackageManager();
if (packageManager == null) {
@@ -1870,7 +1880,7 @@ public class Vpn {
@@ -1720,7 +1730,7 @@ public class Vpn {
addUserToRanges(ranges, userId, allowedApplications, disallowedApplications);
// If the user can have restricted profiles, assign all its restricted profiles too
@ -108,7 +108,7 @@ index 4c5f65285..1c546be6f 100644
final long token = Binder.clearCallingIdentity();
List<UserInfo> users;
try {
@@ -1879,7 +1889,8 @@ public class Vpn {
@@ -1729,7 +1739,8 @@ public class Vpn {
Binder.restoreCallingIdentity(token);
}
for (UserInfo user : users) {
@ -118,7 +118,7 @@ index 4c5f65285..1c546be6f 100644
addUserToRanges(ranges, user.id, allowedApplications, disallowedApplications);
}
}
@@ -1960,7 +1971,8 @@ public class Vpn {
@@ -1810,7 +1821,8 @@ public class Vpn {
public void onUserAdded(int userId) {
// If the user is restricted tie them to the parent user's VPN
UserInfo user = mUserManager.getUserInfo(userId);
@ -128,7 +128,7 @@ index 4c5f65285..1c546be6f 100644
synchronized(Vpn.this) {
final Set<Range<Integer>> existingRanges = mNetworkCapabilities.getUids();
if (existingRanges != null) {
@@ -1989,7 +2001,8 @@ public class Vpn {
@@ -1839,7 +1851,8 @@ public class Vpn {
public void onUserRemoved(int userId) {
// clean up if restricted
UserInfo user = mUserManager.getUserInfo(userId);
@ -138,7 +138,7 @@ index 4c5f65285..1c546be6f 100644
synchronized(Vpn.this) {
final Set<Range<Integer>> existingRanges = mNetworkCapabilities.getUids();
if (existingRanges != null) {
@@ -2414,6 +2427,17 @@ public class Vpn {
@@ -2278,6 +2291,17 @@ public class Vpn {
}
}
@ -156,15 +156,15 @@ index 4c5f65285..1c546be6f 100644
/**
* Start legacy VPN, controlling native daemons as needed. Creates a
* secondary thread to perform connection work, returning quickly.
@@ -2497,6 +2521,7 @@ public class Vpn {
@@ -2362,6 +2386,7 @@ public class Vpn {
new UserHandle(mUserId))) {
throw new SecurityException("Restricted users cannot establish VPNs");
}
+ enforceNotGlobalVpn();
// Load certificates.
String privateKey = "";
@@ -4039,6 +4064,7 @@ public class Vpn {
final RouteInfo ipv4DefaultRoute = findIPv4DefaultRoute(egress);
final String gateway = ipv4DefaultRoute.getGateway().getHostAddress();
@@ -3859,6 +3884,7 @@ public class Vpn {
verifyCallingUidAndPackage(packageName);
enforceNotRestrictedUser();
@ -172,7 +172,7 @@ index 4c5f65285..1c546be6f 100644
validateRequiredFeatures(profile);
if (profile.isRestrictedToTestNetworks) {
@@ -4081,6 +4107,7 @@ public class Vpn {
@@ -3901,6 +3927,7 @@ public class Vpn {
verifyCallingUidAndPackage(packageName);
enforceNotRestrictedUser();
@ -180,7 +180,7 @@ index 4c5f65285..1c546be6f 100644
final long token = Binder.clearCallingIdentity();
try {
@@ -4150,6 +4177,7 @@ public class Vpn {
@@ -3964,6 +3991,7 @@ public class Vpn {
requireNonNull(packageName, "No package name provided");
enforceNotRestrictedUser();
@ -188,7 +188,7 @@ index 4c5f65285..1c546be6f 100644
// Prepare VPN for startup
if (!prepare(packageName, null /* newPackage */, VpnManager.TYPE_VPN_PLATFORM)) {
@@ -4272,6 +4300,7 @@ public class Vpn {
@@ -4085,6 +4113,7 @@ public class Vpn {
requireNonNull(packageName, "No package name provided");
enforceNotRestrictedUser();
@ -197,5 +197,5 @@ index 4c5f65285..1c546be6f 100644
// To stop the VPN profile, the caller must be the current prepared package and must be
// running an Ikev2VpnProfile.
--
2.48.1
2.41.0

View file

@ -1,40 +0,0 @@
From cca38c720efc73912913a59be2a3d261017c2863 Mon Sep 17 00:00:00 2001
From: Andy CrossGate Yan <GeForce8800Ultra@gmail.com>
Date: Wed, 2 Aug 2023 20:59:53 +0800
Subject: [PATCH 04/11] Restore getSimStateForSlotIndex in SubscriptionManager
MTK IMS still needs it here
Change-Id: I41bac57c68055f369232359a464642daab94403b
---
.../android/telephony/SubscriptionManager.java | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index e0af22369..2175b3d96 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -2913,6 +2913,20 @@ public class SubscriptionManager {
return TelephonyManager.getDefault().isNetworkRoaming(subId);
}
+ /**
+ * Returns a constant indicating the state of sim for the slot index.
+ *
+ * @param slotIndex Logical SIM slot index.
+ *
+ * @see TelephonyManager.SimState
+ *
+ * @hide
+ */
+ @TelephonyManager.SimState
+ public static int getSimStateForSlotIndex(int slotIndex) {
+ return TelephonyManager.getSimStateForSlotIndex(slotIndex);
+ }
+
/**
* Set a field in the subscription database. Note not all fields are supported.
*
--
2.48.1

View file

@ -1,65 +0,0 @@
From f9a12ae1920588f2d75849462abf7d2ba9d0373b Mon Sep 17 00:00:00 2001
From: Andy CrossGate Yan <GeForce8800Ultra@gmail.com>
Date: Sat, 12 Aug 2023 20:11:17 +0800
Subject: [PATCH 05/11] Add runWithCleanCallingIdentity variant with both
executor and return value
This complements the fixup to ImsPhoneCallTracker (in fw/o/t) for U
Change-Id: If444290787025e130dce4bdeaf92372ae32793fe
---
.../telephony/util/TelephonyUtils.java | 30 +++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java b/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java
index 422433891..3bbecf0f2 100644
--- a/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java
+++ b/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java
@@ -47,7 +47,9 @@ import com.android.internal.telephony.ITelephony;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
@@ -159,6 +161,34 @@ public final class TelephonyUtils {
}
}
+ /**
+ * Convenience method for running the provided action in the provided
+ * executor enclosed in
+ * {@link Binder#clearCallingIdentity}/{@link Binder#restoreCallingIdentity} and return
+ * the result.
+ *
+ * Any exception thrown by the given action will need to be handled by caller.
+ *
+ */
+ public static <T> T runWithCleanCallingIdentity(
+ @NonNull Supplier<T> action, @NonNull Executor executor) {
+ if (action != null) {
+ if (executor != null) {
+ try {
+ return CompletableFuture.supplyAsync(
+ () -> runWithCleanCallingIdentity(action), executor).get();
+ } catch (ExecutionException | InterruptedException e) {
+ Log.w(LOG_TAG, "TelephonyUtils : runWithCleanCallingIdentity exception: "
+ + e.getMessage());
+ return null;
+ }
+ } else {
+ return runWithCleanCallingIdentity(action);
+ }
+ }
+ return null;
+ }
+
/**
* Filter values in bundle to only basic types.
*/
--
2.48.1

View file

@ -0,0 +1,236 @@
From 628ab41923ce082cd68ab8d4a184823b62a75ab3 Mon Sep 17 00:00:00 2001
From: dhacker29 <dhackerdvm@gmail.com>
Date: Tue, 24 Nov 2015 01:53:47 -0500
Subject: [PATCH 5/6] fw/b: Use ro.build.version.incremental to signal OTA
upgrades
Squash of:
Author: dhacker29 <dhackerdvm@gmail.com>
Date: Tue Nov 24 01:53:47 2015 -0500
Core: Use ro.build.date to signal mIsUpgrade
M: We use a static fingerprint that is only changed when a new OEM build is released, so
every flash shows Android is starting instead of upgrading. This will fix that.
N: even though we dont have the dexopt sceen on N, this is still needed to delete the
correct caches, and grant/deny specific runtime permissions like a true oem update
would do.
Updated for Nougat By: BeansTown106
Change-Id: I0e3ed5c8f0351e48944432ae6a0c5194ddeff1fa
Author: Sam Mortimer <sam@mortimer.me.uk>
Date: Fri Sep 28 13:45:00 2018 -0700
fw/b UserManagerService: Use ro.build.date to signal upgrades
*) We changed PackageManagerService to use Build.DATE instead of
Build.FINGERPRINT to detect upgrade. Do the same for
UserManagerService.
*) Affects generation of preboot intent and app data migration.
Change-Id: I56887b7ca842afdcf3cf84b27b4c04667cf43307
Author: Wang Han <416810799@qq.com>
Date: Sat Dec 29 23:33:20 2018 +0800
ShortcutService: Use ro.build.date to signal package scanning
* Affects system apps scanning.
Change-Id: I5f6d6647929f5b5ae7e820b18e95bf5ed2ec8d1c
Author: maxwen <max.weninger@gmail.com>
Date: Tue Nov 19 01:02:01 2019 +0100
base: Use ro.build.date to clear cache dirs on update
instead of using ro.build.fingerprint we explictly need to use ro.build.date
Change-Id: Ib3e80e58eb8c9a21c108e9f5cd2dbdb7ada8e3a4
Author: maxwen <max.weninger@gmail.com>
Date: Wed Oct 28 07:07:10 2020 -0400
One more Build.FINGERPRINT to Build.DATE change
Change-Id: I13dbf3d7f6587d3fcd6591cc0f861b34b6d5561c
Change-Id: If0eb969ba509981f9209ffa37a949d9042ef4c2a
---
core/java/android/app/admin/SystemUpdateInfo.java | 4 ++--
.../java/com/android/server/am/UserController.java | 3 ++-
.../com/android/server/pm/PackageManagerService.java | 12 ++++++------
.../core/java/com/android/server/pm/Settings.java | 4 ++--
.../java/com/android/server/pm/ShortcutService.java | 2 +-
.../com/android/server/pm/UserManagerService.java | 8 ++++----
6 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/core/java/android/app/admin/SystemUpdateInfo.java b/core/java/android/app/admin/SystemUpdateInfo.java
index b88bf76c96ca..fdf2b3f54311 100644
--- a/core/java/android/app/admin/SystemUpdateInfo.java
+++ b/core/java/android/app/admin/SystemUpdateInfo.java
@@ -132,7 +132,7 @@ public final class SystemUpdateInfo implements Parcelable {
out.startTag(null, tag);
out.attributeLong(null, ATTR_RECEIVED_TIME, mReceivedTime);
out.attributeInt(null, ATTR_SECURITY_PATCH_STATE, mSecurityPatchState);
- out.attribute(null, ATTR_ORIGINAL_BUILD , Build.FINGERPRINT);
+ out.attribute(null, ATTR_ORIGINAL_BUILD , Build.VERSION.INCREMENTAL);
out.endTag(null, tag);
}
@@ -141,7 +141,7 @@ public final class SystemUpdateInfo implements Parcelable {
public static SystemUpdateInfo readFromXml(TypedXmlPullParser parser) {
// If an OTA has been applied (build fingerprint has changed), discard stale info.
final String buildFingerprint = parser.getAttributeValue(null, ATTR_ORIGINAL_BUILD );
- if (!Build.FINGERPRINT.equals(buildFingerprint)) {
+ if (!Build.VERSION.INCREMENTAL.equals(buildFingerprint)) {
return null;
}
try {
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java
index 44b186e1541f..9470a728389f 100644
--- a/services/core/java/com/android/server/am/UserController.java
+++ b/services/core/java/com/android/server/am/UserController.java
@@ -71,6 +71,7 @@ import android.content.pm.PackagePartitions;
import android.content.pm.UserInfo;
import android.os.BatteryStats;
import android.os.Binder;
+import android.os.Build;
import android.os.Bundle;
import android.os.Debug;
import android.os.Handler;
@@ -761,7 +762,7 @@ class UserController implements Handler.Callback {
// purposefully block sending BOOT_COMPLETED until after all
// PRE_BOOT receivers are finished to avoid ANR'ing apps
final UserInfo info = getUserInfo(userId);
- if (!Objects.equals(info.lastLoggedInFingerprint, PackagePartitions.FINGERPRINT)
+ if (!Objects.equals(info.lastLoggedInFingerprint, Build.VERSION.INCREMENTAL)
|| SystemProperties.getBoolean("persist.pm.mock-upgrade", false)) {
// Suppress double notifications for managed profiles that
// were unlocked automatically as part of their parent user being
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 47860373156b..858bf1aad92f 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -1492,7 +1492,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
}
PackageManagerService m = new PackageManagerService(injector, onlyCore, factoryTest,
- PackagePartitions.FINGERPRINT, Build.IS_ENG, Build.IS_USERDEBUG,
+ Build.VERSION.INCREMENTAL, Build.IS_ENG, Build.IS_USERDEBUG,
Build.VERSION.SDK_INT, Build.VERSION.INCREMENTAL);
t.traceEnd(); // "create package manager"
@@ -1954,7 +1954,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
!buildFingerprint.equals(ver.fingerprint);
if (mIsUpgrade) {
PackageManagerServiceUtils.logCriticalInfo(Log.INFO, "Upgrading from "
- + ver.fingerprint + " to " + PackagePartitions.FINGERPRINT);
+ + ver.fingerprint + " to " + Build.VERSION.INCREMENTAL);
}
mInitAppsHelper = new InitAppsHelper(this, mApexManager, mInstallPackageHelper,
@@ -2068,8 +2068,8 @@ public class PackageManagerService implements PackageSender, TestUtilityService
// allow... it would be nice to have some better way to handle
// this situation.
if (mIsUpgrade) {
- Slog.i(TAG, "Build fingerprint changed from " + ver.fingerprint + " to "
- + PackagePartitions.FINGERPRINT
+ Slog.i(TAG, "Build incremental version changed from " + ver.fingerprint + " to "
+ + Build.VERSION.INCREMENTAL
+ "; regranting permissions for internal storage");
}
mPermissionManager.onStorageVolumeMounted(
@@ -2091,7 +2091,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
// across OTAs and are used to drive profile verification (post OTA) and
// profile compilation (without waiting to collect a fresh set of profiles).
if (mIsUpgrade && !mOnlyCore) {
- Slog.i(TAG, "Build fingerprint changed; clearing code caches");
+ Slog.i(TAG, "Build incremental version changed; clearing code caches");
for (int i = 0; i < packageSettings.size(); i++) {
final PackageSetting ps = packageSettings.valueAt(i);
if (Objects.equals(StorageManager.UUID_PRIVATE_INTERNAL, ps.getVolumeUuid())) {
@@ -2102,7 +2102,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
| Installer.FLAG_CLEAR_APP_DATA_KEEP_ART_PROFILES);
}
}
- ver.fingerprint = PackagePartitions.FINGERPRINT;
+ ver.fingerprint = Build.VERSION.INCREMENTAL;
}
// Defer the app data fixup until we are done with app data clearing above.
diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java
index cfd029346340..a9b624653b92 100644
--- a/services/core/java/com/android/server/pm/Settings.java
+++ b/services/core/java/com/android/server/pm/Settings.java
@@ -445,7 +445,7 @@ public final class Settings implements Watchable, Snappable {
public void forceCurrent() {
sdkVersion = Build.VERSION.SDK_INT;
databaseVersion = CURRENT_DATABASE_VERSION;
- fingerprint = PackagePartitions.FINGERPRINT;
+ fingerprint = Build.VERSION.INCREMENTAL;
}
}
@@ -5527,7 +5527,7 @@ public final class Settings implements Watchable, Snappable {
}
private String getExtendedFingerprint(long version) {
- return PackagePartitions.FINGERPRINT + "?pc_version=" + version;
+ return Build.VERSION.INCREMENTAL + "?pc_version=" + version;
}
private static long uniformRandom(double low, double high) {
diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java
index a2b2983a8f35..4564e9dccc13 100644
--- a/services/core/java/com/android/server/pm/ShortcutService.java
+++ b/services/core/java/com/android/server/pm/ShortcutService.java
@@ -5168,7 +5168,7 @@ public class ShortcutService extends IShortcutService.Stub {
// Injection point.
String injectBuildFingerprint() {
- return Build.FINGERPRINT;
+ return Build.VERSION.INCREMENTAL;
}
final void wtf(String message) {
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 88aeb17dc2b4..af7b481dd311 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -4104,7 +4104,7 @@ public class UserManagerService extends IUserManager.Stub {
userInfo.creationTime = getCreationTime();
userInfo.partial = true;
userInfo.preCreated = preCreate;
- userInfo.lastLoggedInFingerprint = PackagePartitions.FINGERPRINT;
+ userInfo.lastLoggedInFingerprint = Build.VERSION.INCREMENTAL;
if (userTypeDetails.hasBadge() && parentId != UserHandle.USER_NULL) {
userInfo.profileBadge = getFreeProfileBadgeLU(parentId, userType);
}
@@ -5390,7 +5390,7 @@ public class UserManagerService extends IUserManager.Stub {
t.traceBegin("onBeforeStartUser-" + userId);
final int userSerial = userInfo.serialNumber;
// Migrate only if build fingerprints mismatch
- boolean migrateAppsData = !PackagePartitions.FINGERPRINT.equals(
+ boolean migrateAppsData = !Build.VERSION.INCREMENTAL.equals(
userInfo.lastLoggedInFingerprint);
t.traceBegin("prepareUserData");
mUserDataPreparer.prepareUserData(userId, userSerial, StorageManager.FLAG_STORAGE_DE);
@@ -5421,7 +5421,7 @@ public class UserManagerService extends IUserManager.Stub {
}
final int userSerial = userInfo.serialNumber;
// Migrate only if build fingerprints mismatch
- boolean migrateAppsData = !PackagePartitions.FINGERPRINT.equals(
+ boolean migrateAppsData = !Build.VERSION.INCREMENTAL.equals(
userInfo.lastLoggedInFingerprint);
final TimingsTraceAndSlog t = new TimingsTraceAndSlog();
@@ -5466,7 +5466,7 @@ public class UserManagerService extends IUserManager.Stub {
if (now > EPOCH_PLUS_30_YEARS) {
userData.info.lastLoggedInTime = now;
}
- userData.info.lastLoggedInFingerprint = PackagePartitions.FINGERPRINT;
+ userData.info.lastLoggedInFingerprint = Build.VERSION.INCREMENTAL;
scheduleWriteUser(userData);
}
--
2.41.0

View file

@ -1,42 +0,0 @@
From 45736b5d760fdac0ec405f1620942ff9a7c023d9 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Sun, 22 Sep 2024 22:53:01 -0400
Subject: [PATCH 06/11] AuthService: HIDL and AIDL fingerprint services are
mutually exclusive
...and make sure that we prioritize AIDL over HIDL. This is essential
for GSIs to boot on newer devices while having the HIDL property set for
compatibility with older ones.
Change-Id: I834297a44674820d813d8f6d376dfd294f084f3b
---
.../com/android/server/biometrics/AuthService.java | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/services/core/java/com/android/server/biometrics/AuthService.java b/services/core/java/com/android/server/biometrics/AuthService.java
index 2d802b21c..0730d634f 100644
--- a/services/core/java/com/android/server/biometrics/AuthService.java
+++ b/services/core/java/com/android/server/biometrics/AuthService.java
@@ -908,15 +908,13 @@ public class AuthService extends SystemService {
handlerProvider.getFingerprintHandler().post(() -> {
final FingerprintSensorConfigurations mFingerprintSensorConfigurations =
- new FingerprintSensorConfigurations(!(hidlConfigStrings != null
- && hidlConfigStrings.length > 0));
-
- if (hidlConfigStrings != null && hidlConfigStrings.length > 0) {
- mFingerprintSensorConfigurations.addHidlSensors(hidlConfigStrings, context);
- }
+ new FingerprintSensorConfigurations(fingerprintAidlInstances != null
+ && fingerprintAidlInstances.length > 0);
if (fingerprintAidlInstances != null && fingerprintAidlInstances.length > 0) {
mFingerprintSensorConfigurations.addAidlSensors(fingerprintAidlInstances);
+ } else if (hidlConfigStrings != null && hidlConfigStrings.length > 0) {
+ mFingerprintSensorConfigurations.addHidlSensors(hidlConfigStrings, context);
}
if (fingerprintService != null) {
--
2.48.1

View file

@ -0,0 +1,127 @@
From 54e70eb7ce231f6a1bef4ffdedb6008b3a949820 Mon Sep 17 00:00:00 2001
From: Andy CrossGate Yan <GeForce8800Ultra@gmail.com>
Date: Sat, 15 Oct 2022 09:33:56 +0000
Subject: [PATCH 6/6] Revert "Remove more FDE methods from StorageManager"
This reverts commit bd13f84152449a3ead6fa8604fd31f48c0224676.
---
.../android/os/storage/StorageManager.java | 69 ++++++++++++++++---
.../internal/os/RoSystemProperties.java | 4 ++
2 files changed, 65 insertions(+), 8 deletions(-)
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java
index d9604b3f0145..603612e82007 100644
--- a/core/java/android/os/storage/StorageManager.java
+++ b/core/java/android/os/storage/StorageManager.java
@@ -1681,13 +1681,18 @@ public class StorageManager {
}
/** {@hide}
- * Is this device encrypted?
- * <p>
- * Note: all devices launching with Android 10 (API level 29) or later are
- * required to be encrypted. This should only ever return false for
- * in-development devices on which encryption has not yet been configured.
- *
- * @return true if encrypted, false if not encrypted
+ * Is this device encryptable or already encrypted?
+ * @return true for encryptable or encrypted
+ * false not encrypted and not encryptable
+ */
+ public static boolean isEncryptable() {
+ return RoSystemProperties.CRYPTO_ENCRYPTABLE;
+ }
+
+ /** {@hide}
+ * Is this device already encrypted?
+ * @return true for encrypted. (Implies isEncryptable() == true)
+ * false not encrypted
*/
public static boolean isEncrypted() {
return RoSystemProperties.CRYPTO_ENCRYPTED;
@@ -1696,7 +1701,7 @@ public class StorageManager {
/** {@hide}
* Is this device file encrypted?
* @return true for file encrypted. (Implies isEncrypted() == true)
- * false not encrypted or using "managed" encryption
+ * false not encrypted or block encrypted
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static boolean isFileEncryptedNativeOnly() {
@@ -1706,6 +1711,54 @@ public class StorageManager {
return RoSystemProperties.CRYPTO_FILE_ENCRYPTED;
}
+ /** {@hide}
+ * Is this device block encrypted?
+ * @return true for block encrypted. (Implies isEncrypted() == true)
+ * false not encrypted or file encrypted
+ */
+ public static boolean isBlockEncrypted() {
+ return false;
+ }
+
+ /** {@hide}
+ * Is this device block encrypted with credentials?
+ * @return true for crediential block encrypted.
+ * (Implies isBlockEncrypted() == true)
+ * false not encrypted, file encrypted or default block encrypted
+ */
+ public static boolean isNonDefaultBlockEncrypted() {
+ return false;
+ }
+
+ /** {@hide}
+ * Is this device in the process of being block encrypted?
+ * @return true for encrypting.
+ * false otherwise
+ * Whether device isEncrypted at this point is undefined
+ * Note that only system services and CryptKeeper will ever see this return
+ * true - no app will ever be launched in this state.
+ * Also note that this state will not change without a teardown of the
+ * framework, so no service needs to check for changes during their lifespan
+ */
+ public static boolean isBlockEncrypting() {
+ return false;
+ }
+
+ /** {@hide}
+ * Is this device non default block encrypted and in the process of
+ * prompting for credentials?
+ * @return true for prompting for credentials.
+ * (Implies isNonDefaultBlockEncrypted() == true)
+ * false otherwise
+ * Note that only system services and CryptKeeper will ever see this return
+ * true - no app will ever be launched in this state.
+ * Also note that this state will not change without a teardown of the
+ * framework, so no service needs to check for changes during their lifespan
+ */
+ public static boolean inCryptKeeperBounce() {
+ return false;
+ }
+
/** {@hide} */
public static boolean isFileEncryptedEmulatedOnly() {
return SystemProperties.getBoolean(StorageManager.PROP_EMULATE_FBE, false);
diff --git a/core/java/com/android/internal/os/RoSystemProperties.java b/core/java/com/android/internal/os/RoSystemProperties.java
index cccd80e82420..adb5c107bc62 100644
--- a/core/java/com/android/internal/os/RoSystemProperties.java
+++ b/core/java/com/android/internal/os/RoSystemProperties.java
@@ -62,10 +62,14 @@ public class RoSystemProperties {
public static final CryptoProperties.type_values CRYPTO_TYPE =
CryptoProperties.type().orElse(CryptoProperties.type_values.NONE);
// These are pseudo-properties
+ public static final boolean CRYPTO_ENCRYPTABLE =
+ CRYPTO_STATE != CryptoProperties.state_values.UNSUPPORTED;
public static final boolean CRYPTO_ENCRYPTED =
CRYPTO_STATE == CryptoProperties.state_values.ENCRYPTED;
public static final boolean CRYPTO_FILE_ENCRYPTED =
CRYPTO_TYPE == CryptoProperties.type_values.FILE;
+ public static final boolean CRYPTO_BLOCK_ENCRYPTED =
+ CRYPTO_TYPE == CryptoProperties.type_values.BLOCK;
public static final boolean CONTROL_PRIVAPP_PERMISSIONS_LOG =
"log".equalsIgnoreCase(CONTROL_PRIVAPP_PERMISSIONS);
--
2.41.0

View file

@ -1,150 +0,0 @@
From 6cd16322e3d44ea9d96c74af96a967e48fa88d44 Mon Sep 17 00:00:00 2001
From: dhacker29 <dhackerdvm@gmail.com>
Date: Tue, 24 Nov 2015 01:53:47 -0500
Subject: [PATCH 07/11] fw/b: Use ro.build.version.incremental to signal OTA
upgrades
Co-authored-by: maxwen <max.weninger@gmail.com>
Co-authored-by: Sam Mortimer <sam@mortimer.me.uk>
Co-authored-by: Wang Han <416810799@qq.com>
Change-Id: If0eb969ba509981f9209ffa37a949d9042ef4c2a
---
core/java/android/app/admin/SystemUpdateInfo.java | 4 ++--
core/java/android/content/pm/PackagePartitions.java | 2 +-
.../java/com/android/server/appwidget/AppWidgetXmlUtil.java | 4 ++--
.../java/com/android/server/pm/PackageManagerService.java | 5 +++--
.../com/android/server/pm/PackageManagerServiceUtils.java | 3 +--
services/core/java/com/android/server/pm/Settings.java | 2 +-
.../core/java/com/android/server/pm/ShortcutService.java | 2 +-
7 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/core/java/android/app/admin/SystemUpdateInfo.java b/core/java/android/app/admin/SystemUpdateInfo.java
index 9e6c91f4e..7459b0e05 100644
--- a/core/java/android/app/admin/SystemUpdateInfo.java
+++ b/core/java/android/app/admin/SystemUpdateInfo.java
@@ -133,7 +133,7 @@ public final class SystemUpdateInfo implements Parcelable {
out.startTag(null, tag);
out.attributeLong(null, ATTR_RECEIVED_TIME, mReceivedTime);
out.attributeInt(null, ATTR_SECURITY_PATCH_STATE, mSecurityPatchState);
- out.attribute(null, ATTR_ORIGINAL_BUILD , Build.FINGERPRINT);
+ out.attribute(null, ATTR_ORIGINAL_BUILD , Build.VERSION.INCREMENTAL);
out.endTag(null, tag);
}
@@ -142,7 +142,7 @@ public final class SystemUpdateInfo implements Parcelable {
public static SystemUpdateInfo readFromXml(TypedXmlPullParser parser) {
// If an OTA has been applied (build fingerprint has changed), discard stale info.
final String buildFingerprint = parser.getAttributeValue(null, ATTR_ORIGINAL_BUILD );
- if (!Build.FINGERPRINT.equals(buildFingerprint)) {
+ if (!Build.VERSION.INCREMENTAL.equals(buildFingerprint)) {
return null;
}
try {
diff --git a/core/java/android/content/pm/PackagePartitions.java b/core/java/android/content/pm/PackagePartitions.java
index ff80e614b..da3b68ecf 100644
--- a/core/java/android/content/pm/PackagePartitions.java
+++ b/core/java/android/content/pm/PackagePartitions.java
@@ -131,7 +131,7 @@ public class PackagePartitions {
final String partitionName = SYSTEM_PARTITIONS.get(i).getName();
digestProperties[i] = "ro." + partitionName + ".build.fingerprint";
}
- digestProperties[SYSTEM_PARTITIONS.size()] = "ro.build.fingerprint"; // build fingerprint
+ digestProperties[SYSTEM_PARTITIONS.size()] = "ro.build.version.incremental";
return SystemProperties.digestOf(digestProperties);
}
diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetXmlUtil.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetXmlUtil.java
index ce9130ad5..737ecae1c 100644
--- a/services/appwidget/java/com/android/server/appwidget/AppWidgetXmlUtil.java
+++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetXmlUtil.java
@@ -117,7 +117,7 @@ public class AppWidgetXmlUtil {
out.attributeInt(null, ATTR_WIDGET_FEATURES, info.widgetFeatures);
out.attributeInt(null, ATTR_DESCRIPTION_RES, info.descriptionRes);
out.attributeBoolean(null, ATTR_PROVIDER_INHERITANCE, info.isExtendedFromAppWidgetProvider);
- out.attribute(null, ATTR_OS_FINGERPRINT, Build.FINGERPRINT);
+ out.attribute(null, ATTR_OS_FINGERPRINT, Build.VERSION.INCREMENTAL);
}
/**
@@ -128,7 +128,7 @@ public class AppWidgetXmlUtil {
@NonNull final TypedXmlPullParser parser) {
Objects.requireNonNull(parser);
final String fingerprint = parser.getAttributeValue(null, ATTR_OS_FINGERPRINT);
- if (!Build.FINGERPRINT.equals(fingerprint)) {
+ if (!Build.VERSION.INCREMENTAL.equals(fingerprint)) {
return null;
}
final AppWidgetProviderInfo info = new AppWidgetProviderInfo();
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index aadf11227..8b0c4f42b 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -2239,7 +2239,8 @@ public class PackageManagerService implements PackageSender, TestUtilityService
if (mIsUpgrade) {
PackageManagerServiceUtils.logCriticalInfo(Log.INFO,
"Upgrading from " + ver.fingerprint + " (" + ver.buildFingerprint + ") to "
- + PackagePartitions.FINGERPRINT + " (" + Build.FINGERPRINT + ")");
+ + PackagePartitions.FINGERPRINT
+ + " (" + Build.VERSION.INCREMENTAL + ")");
}
mPriorSdkVersion = mIsUpgrade ? ver.sdkVersion : -1;
mInitAppsHelper = new InitAppsHelper(this, mApexManager, mInstallPackageHelper,
@@ -2397,7 +2398,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
| Installer.FLAG_CLEAR_APP_DATA_KEEP_ART_PROFILES);
}
}
- ver.buildFingerprint = Build.FINGERPRINT;
+ ver.buildFingerprint = Build.VERSION.INCREMENTAL;
ver.fingerprint = PackagePartitions.FINGERPRINT;
}
diff --git a/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java b/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java
index 7af39f74d..4bd83e739 100644
--- a/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java
+++ b/services/core/java/com/android/server/pm/PackageManagerServiceUtils.java
@@ -1400,8 +1400,6 @@ public class PackageManagerServiceUtils {
// that starts with "eng." to signify that this is an engineering build and not
// destined for release.
if (isUserDebugBuild && incrementalVersion.startsWith("eng.")) {
- Slog.w(TAG, "Wiping cache directory because the system partition changed.");
-
// Heuristic: If the /system directory has been modified recently due to an "adb sync"
// or a regular make, then blow away the cache. Note that mtimes are *NOT* reliable
// in general and should not be used for production changes. In this specific case,
@@ -1409,6 +1407,7 @@ public class PackageManagerServiceUtils {
File frameworkDir =
new File(Environment.getRootDirectory(), "framework");
if (cacheDir.lastModified() < frameworkDir.lastModified()) {
+ Slog.w(TAG, "Wiping cache directory because the system partition changed.");
FileUtils.deleteContents(cacheBaseDir);
cacheDir = FileUtils.createDir(cacheBaseDir, cacheName);
}
diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java
index 485a28070..78086791a 100644
--- a/services/core/java/com/android/server/pm/Settings.java
+++ b/services/core/java/com/android/server/pm/Settings.java
@@ -485,7 +485,7 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile
public void forceCurrent() {
sdkVersion = Build.VERSION.SDK_INT;
databaseVersion = CURRENT_DATABASE_VERSION;
- buildFingerprint = Build.FINGERPRINT;
+ buildFingerprint = Build.VERSION.INCREMENTAL;
fingerprint = PackagePartitions.FINGERPRINT;
}
}
diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java
index 1052c94d7..21481d216 100644
--- a/services/core/java/com/android/server/pm/ShortcutService.java
+++ b/services/core/java/com/android/server/pm/ShortcutService.java
@@ -5259,7 +5259,7 @@ public class ShortcutService extends IShortcutService.Stub {
// Injection point.
String injectBuildFingerprint() {
- return Build.FINGERPRINT;
+ return Build.VERSION.INCREMENTAL;
}
final void wtf(String message) {
--
2.48.1

View file

@ -1,49 +0,0 @@
From 8b3f59482cf7f27406d9a8c9ef717e6bc70cfb88 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Sat, 21 Dec 2024 11:04:35 -0500
Subject: [PATCH 08/11] Add support for treating virtual biometric sensors as
real ones
This happens on Unihertz Jelly Max. They forgot to change their sensor
instance name from "virtual" to something else.
Change-Id: I106d41cd078e6b1e354c72ec35fa240a44397c5e
---
.../fingerprint/FingerprintSensorConfigurations.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/core/java/android/hardware/fingerprint/FingerprintSensorConfigurations.java b/core/java/android/hardware/fingerprint/FingerprintSensorConfigurations.java
index 48c5887d8..bec56d9a6 100644
--- a/core/java/android/hardware/fingerprint/FingerprintSensorConfigurations.java
+++ b/core/java/android/hardware/fingerprint/FingerprintSensorConfigurations.java
@@ -29,6 +29,7 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.SystemProperties;
import android.util.Log;
import android.util.Slog;
@@ -172,6 +173,10 @@ public class FingerprintSensorConfigurations implements Parcelable {
* @return real fqName
*/
public static String remapFqName(String fqName) {
+ if (SystemProperties.getBoolean("persist.sys.phh.virtual_sensors_are_real", false)) {
+ return fqName;
+ }
+
if (!fqName.contains(IFingerprint.DESCRIPTOR + "/virtual")) {
return fqName; //no remap needed for real hardware HAL
} else {
@@ -185,7 +190,7 @@ public class FingerprintSensorConfigurations implements Parcelable {
* @return aidl interface
*/
public static IFingerprint getIFingerprint(String fqName) {
- if (fqName.contains("virtual")) {
+ if (fqName.contains("virtual") && !SystemProperties.getBoolean("persist.sys.phh.virtual_sensors_are_real", false)) {
String fqNameMapped = remapFqName(fqName);
Slog.i(TAG, "getIFingerprint fqName is mapped: " + fqName + "->" + fqNameMapped);
try {
--
2.48.1

View file

@ -1,87 +0,0 @@
From 2f4c395069d1dfd7cce9a896f17868aa4aaf91c4 Mon Sep 17 00:00:00 2001
From: Pranav Vashi <neobuddy89@gmail.com>
Date: Sat, 21 Sep 2024 13:44:09 +0530
Subject: [PATCH 09/11] WebView: Add check before setting default or fallback
provider
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
---
.../webkit/WebViewUpdateServiceImpl2.java | 34 ++++++++++++++-----
1 file changed, 26 insertions(+), 8 deletions(-)
diff --git a/services/core/java/com/android/server/webkit/WebViewUpdateServiceImpl2.java b/services/core/java/com/android/server/webkit/WebViewUpdateServiceImpl2.java
index 9e8dc2690..9e415bf63 100644
--- a/services/core/java/com/android/server/webkit/WebViewUpdateServiceImpl2.java
+++ b/services/core/java/com/android/server/webkit/WebViewUpdateServiceImpl2.java
@@ -15,6 +15,7 @@
*/
package com.android.server.webkit;
+import android.app.AppGlobals;
import android.annotation.Nullable;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -113,7 +114,7 @@ class WebViewUpdateServiceImpl2 {
WebViewProviderInfo defaultProvider = null;
for (WebViewProviderInfo provider : webviewProviders) {
- if (provider.availableByDefault) {
+ if (provider.availableByDefault && isPackageAvailable(provider.packageName)) {
defaultProvider = provider;
break;
}
@@ -182,6 +183,15 @@ class WebViewUpdateServiceImpl2 {
}
}
+ private static boolean isPackageAvailable(String packageName) {
+ try {
+ AppGlobals.getInitialApplication().getPackageManager().getPackageInfo(packageName, 0);
+ return true;
+ } catch (NameNotFoundException e) {
+ return false;
+ }
+ }
+
private boolean shouldTriggerRepairLocked() {
if (mAttemptedToRepairBefore) {
return false;
@@ -208,12 +218,20 @@ class WebViewUpdateServiceImpl2 {
}
mAttemptedToRepairBefore = true;
}
- Slog.w(
- TAG,
- "No provider available for all users, trying to install and enable "
- + mDefaultProvider.packageName);
- mSystemInterface.installExistingPackageForAllUsers(mDefaultProvider.packageName);
- mSystemInterface.enablePackageForAllUsers(mDefaultProvider.packageName, true);
+
+ WebViewProviderInfo[] webviewProviders = mSystemInterface.getWebViewPackages();
+ WebViewProviderInfo fallbackProvider = getFallbackProvider(webviewProviders);
+ if (fallbackProvider != null) {
+ Slog.w(TAG, "No valid provider, trying to install and enable "
+ + fallbackProvider.packageName);
+ mSystemInterface.installExistingPackageForAllUsers(fallbackProvider.packageName);
+ mSystemInterface.enablePackageForAllUsers(fallbackProvider.packageName, true);
+ } else {
+ Slog.w(TAG, "No provider available for all users, trying to install and enable "
+ + mDefaultProvider.packageName);
+ mSystemInterface.installExistingPackageForAllUsers(mDefaultProvider.packageName);
+ mSystemInterface.enablePackageForAllUsers(mDefaultProvider.packageName, true);
+ }
}
public void prepareWebViewInSystemServer() {
@@ -691,7 +709,7 @@ class WebViewUpdateServiceImpl2 {
*/
private static WebViewProviderInfo getFallbackProvider(WebViewProviderInfo[] webviewPackages) {
for (WebViewProviderInfo provider : webviewPackages) {
- if (provider.isFallback) {
+ if (provider.isFallback && isPackageAvailable(provider.packageName)) {
return provider;
}
}
--
2.48.1

View file

@ -1,229 +0,0 @@
From 30058cdf576d1496ca63560f878eacf940e36ea2 Mon Sep 17 00:00:00 2001
From: LuK1337 <priv.luk@gmail.com>
Date: Mon, 19 Feb 2024 16:20:04 +0100
Subject: [PATCH 10/11] Allow signature spoofing for microG Companion/Services
This patch enables signature spoofing when the following conditions are
met:
* Build is debuggable (userdebug/eng)
* Package name is com.android.vending or com.google.android.gms
* Package is signed with microG release keys
* Fake signature is correct
Additionally, we let these apps be forceQueryable if they so desire.
Change-Id: I8fc82ed266a2cc59636b662c7ea7e29c94f509b5
---
.../com/android/server/pm/AppsFilterImpl.java | 2 +
.../com/android/server/pm/ComputerEngine.java | 54 +++++++++++++++++++
services/core/jni/Android.bp | 7 +++
.../com_android_server_pm_ComputerEngine.cpp | 38 +++++++++++++
services/core/jni/onload.cpp | 2 +
5 files changed, 103 insertions(+)
create mode 100644 services/core/jni/com_android_server_pm_ComputerEngine.cpp
diff --git a/services/core/java/com/android/server/pm/AppsFilterImpl.java b/services/core/java/com/android/server/pm/AppsFilterImpl.java
index cc4c2b5bf..57263da93 100644
--- a/services/core/java/com/android/server/pm/AppsFilterImpl.java
+++ b/services/core/java/com/android/server/pm/AppsFilterImpl.java
@@ -36,6 +36,7 @@ import static com.android.server.pm.AppsFilterUtils.canQueryAsUpdateOwner;
import static com.android.server.pm.AppsFilterUtils.canQueryViaComponents;
import static com.android.server.pm.AppsFilterUtils.canQueryViaPackage;
import static com.android.server.pm.AppsFilterUtils.canQueryViaUsesLibrary;
+import static com.android.server.pm.ComputerEngine.isMicrogSigned;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -599,6 +600,7 @@ public final class AppsFilterImpl extends AppsFilterLocked implements Watchable,
newIsForceQueryable = mForceQueryable.contains(newPkgSetting.getAppId())
/* shared user that is already force queryable */
|| newPkgSetting.isForceQueryableOverride() /* adb override */
+ || (newPkg.isForceQueryable() && isMicrogSigned(newPkg))
|| (newPkgSetting.isSystem() && (mSystemAppsQueryable
|| newPkg.isForceQueryable()
|| ArrayUtils.contains(mForceQueryableByDevicePackageNames,
diff --git a/services/core/java/com/android/server/pm/ComputerEngine.java b/services/core/java/com/android/server/pm/ComputerEngine.java
index be2f58dc2..3eb3df412 100644
--- a/services/core/java/com/android/server/pm/ComputerEngine.java
+++ b/services/core/java/com/android/server/pm/ComputerEngine.java
@@ -103,6 +103,7 @@ import android.content.pm.UserPackage;
import android.content.pm.VersionedPackage;
import android.os.Binder;
import android.os.Build;
+import android.os.Bundle;
import android.os.IBinder;
import android.os.ParcelableException;
import android.os.PatternMatcher;
@@ -176,6 +177,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
+import java.util.Optional;
import java.util.Set;
import java.util.UUID;
@@ -424,6 +426,10 @@ public class ComputerEngine implements Computer {
private final PackageManagerInternal.ExternalSourcesPolicy mExternalSourcesPolicy;
private final CrossProfileIntentResolverEngine mCrossProfileIntentResolverEngine;
+ // Signatures used by microG
+ private static final Signature MICROG_FAKE_SIGNATURE = new Signature("308204433082032ba003020102020900c2e08746644a308d300d06092a864886f70d01010405003074310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f69643110300e06035504031307416e64726f6964301e170d3038303832313233313333345a170d3336303130373233313333345a3074310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f69643110300e06035504031307416e64726f696430820120300d06092a864886f70d01010105000382010d00308201080282010100ab562e00d83ba208ae0a966f124e29da11f2ab56d08f58e2cca91303e9b754d372f640a71b1dcb130967624e4656a7776a92193db2e5bfb724a91e77188b0e6a47a43b33d9609b77183145ccdf7b2e586674c9e1565b1f4c6a5955bff251a63dabf9c55c27222252e875e4f8154a645f897168c0b1bfc612eabf785769bb34aa7984dc7e2ea2764cae8307d8c17154d7ee5f64a51a44a602c249054157dc02cd5f5c0e55fbef8519fbe327f0b1511692c5a06f19d18385f5c4dbc2d6b93f68cc2979c70e18ab93866b3bd5db8999552a0e3b4c99df58fb918bedc182ba35e003c1b4b10dd244a8ee24fffd333872ab5221985edab0fc0d0b145b6aa192858e79020103a381d93081d6301d0603551d0e04160414c77d8cc2211756259a7fd382df6be398e4d786a53081a60603551d2304819e30819b8014c77d8cc2211756259a7fd382df6be398e4d786a5a178a4763074310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f69643110300e06035504031307416e64726f6964820900c2e08746644a308d300c0603551d13040530030101ff300d06092a864886f70d010104050003820101006dd252ceef85302c360aaace939bcff2cca904bb5d7a1661f8ae46b2994204d0ff4a68c7ed1a531ec4595a623ce60763b167297a7ae35712c407f208f0cb109429124d7b106219c084ca3eb3f9ad5fb871ef92269a8be28bf16d44c8d9a08e6cb2f005bb3fe2cb96447e868e731076ad45b33f6009ea19c161e62641aa99271dfd5228c5c587875ddb7f452758d661f6cc0cccb7352e424cc4365c523532f7325137593c4ae341f4db41edda0d0b1071a7c440f0fe9ea01cb627ca674369d084bd2fd911ff06cdbf2cfa10dc0f893ae35762919048c7efc64c7144178342f70581c9de573af55b390dd7fdb9418631895d5f759f30112687ff621410c069308a");
+ private static final Signature MICROG_REAL_SIGNATURE = new Signature("308202ed308201d5a003020102020426ffa009300d06092a864886f70d01010b05003027310b300906035504061302444531183016060355040a130f4e4f47415050532050726f6a656374301e170d3132313030363132303533325a170d3337303933303132303533325a3027310b300906035504061302444531183016060355040a130f4e4f47415050532050726f6a65637430820122300d06092a864886f70d01010105000382010f003082010a02820101009a8d2a5336b0eaaad89ce447828c7753b157459b79e3215dc962ca48f58c2cd7650df67d2dd7bda0880c682791f32b35c504e43e77b43c3e4e541f86e35a8293a54fb46e6b16af54d3a4eda458f1a7c8bc1b7479861ca7043337180e40079d9cdccb7e051ada9b6c88c9ec635541e2ebf0842521c3024c826f6fd6db6fd117c74e859d5af4db04448965ab5469b71ce719939a06ef30580f50febf96c474a7d265bb63f86a822ff7b643de6b76e966a18553c2858416cf3309dd24278374bdd82b4404ef6f7f122cec93859351fc6e5ea947e3ceb9d67374fe970e593e5cd05c905e1d24f5a5484f4aadef766e498adf64f7cf04bddd602ae8137b6eea40722d0203010001a321301f301d0603551d0e04160414110b7aa9ebc840b20399f69a431f4dba6ac42a64300d06092a864886f70d01010b0500038201010007c32ad893349cf86952fb5a49cfdc9b13f5e3c800aece77b2e7e0e9c83e34052f140f357ec7e6f4b432dc1ed542218a14835acd2df2deea7efd3fd5e8f1c34e1fb39ec6a427c6e6f4178b609b369040ac1f8844b789f3694dc640de06e44b247afed11637173f36f5886170fafd74954049858c6096308fc93c1bc4dd5685fa7a1f982a422f2a3b36baa8c9500474cf2af91c39cbec1bc898d10194d368aa5e91f1137ec115087c31962d8f76cd120d28c249cf76f4c70f5baa08c70a7234ce4123be080cee789477401965cfe537b924ef36747e8caca62dfefdd1a6288dcb1c4fd2aaa6131a7ad254e9742022cfd597d2ca5c660ce9e41ff537e5a4041e37");
+
// PackageManagerService attributes that are primitives are referenced through the
// pms object directly. Primitives are the only attributes so referenced.
protected final PackageManagerService mService;
@@ -1483,6 +1489,49 @@ public class ComputerEngine implements Computer {
return result;
}
+ private static native boolean isDebuggable();
+
+ public static boolean isMicrogSigned(AndroidPackage p) {
+ if (!isDebuggable()) {
+ return false;
+ }
+
+ // Allowlist the following apps:
+ // * com.android.vending - microG Companion
+ // * com.google.android.gms - microG Services
+ if (!p.getPackageName().equals("com.android.vending") &&
+ !p.getPackageName().equals("com.google.android.gms")) {
+ return false;
+ }
+
+ return Signature.areExactMatch(
+ p.getSigningDetails(), new Signature[]{MICROG_REAL_SIGNATURE});
+ }
+
+ private static Optional<Signature> generateFakeSignature(AndroidPackage p) {
+ if (!isMicrogSigned(p)) {
+ return Optional.empty();
+ }
+
+ Bundle metadata = p.getMetaData();
+ if (metadata == null) {
+ return Optional.empty();
+ }
+
+ String fakeSignatureStr = metadata.getString("fake-signature");
+ if (TextUtils.isEmpty(fakeSignatureStr)) {
+ return Optional.empty();
+ }
+
+ // Only MICROG_FAKE_SIGNATURE can be faked
+ Signature fakeSignature = new Signature(fakeSignatureStr);
+ if (!fakeSignature.equals(MICROG_FAKE_SIGNATURE)) {
+ return Optional.empty();
+ }
+
+ return Optional.of(fakeSignature);
+ }
+
public final PackageInfo generatePackageInfo(PackageStateInternal ps,
@PackageManager.PackageInfoFlagsBits long flags, int userId) {
if (!mUserManager.exists(userId)) return null;
@@ -1538,6 +1587,11 @@ public class ComputerEngine implements Computer {
mApexManager.getActivePackageNameForApexModuleName(apexModuleName));
}
}
+
+ generateFakeSignature(p).ifPresent(fakeSignature -> {
+ packageInfo.signatures = new Signature[]{fakeSignature};
+ });
+
return packageInfo;
} else if ((flags & (MATCH_UNINSTALLED_PACKAGES | MATCH_ARCHIVED_PACKAGES)) != 0
&& PackageUserStateUtils.isAvailable(state, flags)) {
diff --git a/services/core/jni/Android.bp b/services/core/jni/Android.bp
index 4c0cee404..a4d192c8e 100644
--- a/services/core/jni/Android.bp
+++ b/services/core/jni/Android.bp
@@ -71,6 +71,7 @@ cc_library_static {
"com_android_server_vibrator_VibratorManagerService.cpp",
"com_android_server_pdb_PersistentDataBlockService.cpp",
"com_android_server_am_LowMemDetector.cpp",
+ "com_android_server_pm_ComputerEngine.cpp",
"com_android_server_pm_PackageManagerShellCommandDataLoader.cpp",
"com_android_server_sensor_SensorService.cpp",
"com_android_server_wm_TaskFpsCallbackController.cpp",
@@ -94,6 +95,12 @@ cc_library_static {
header_libs: [
"bionic_libc_platform_headers",
],
+
+ product_variables: {
+ debuggable: {
+ cflags: ["-DANDROID_DEBUGGABLE"],
+ }
+ },
}
cc_defaults {
diff --git a/services/core/jni/com_android_server_pm_ComputerEngine.cpp b/services/core/jni/com_android_server_pm_ComputerEngine.cpp
new file mode 100644
index 000000000..bbe298097
--- /dev/null
+++ b/services/core/jni/com_android_server_pm_ComputerEngine.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2024 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <nativehelper/JNIHelp.h>
+
+namespace android {
+
+static bool isDebuggable(JNIEnv* env) {
+#ifdef ANDROID_DEBUGGABLE
+ return true;
+#else
+ return false;
+#endif
+}
+
+static const JNINativeMethod method_table[] = {
+ {"isDebuggable", "()Z", (void*)isDebuggable},
+};
+
+int register_android_server_com_android_server_pm_ComputerEngine(JNIEnv* env) {
+ return jniRegisterNativeMethods(env, "com/android/server/pm/ComputerEngine",
+ method_table, NELEM(method_table));
+}
+
+} // namespace android
diff --git a/services/core/jni/onload.cpp b/services/core/jni/onload.cpp
index 09fd8d4ac..0d61a13d2 100644
--- a/services/core/jni/onload.cpp
+++ b/services/core/jni/onload.cpp
@@ -58,6 +58,7 @@ int register_android_server_utils_AnrTimer(JNIEnv *env);
int register_android_server_utils_LazyJniRegistrar(JNIEnv* env);
int register_com_android_server_soundtrigger_middleware_AudioSessionProviderImpl(JNIEnv* env);
int register_com_android_server_soundtrigger_middleware_ExternalCaptureStateTracker(JNIEnv* env);
+int register_android_server_com_android_server_pm_ComputerEngine(JNIEnv* env);
int register_android_server_com_android_server_pm_PackageManagerShellCommandDataLoader(JNIEnv* env);
int register_android_server_AdbDebuggingManager(JNIEnv* env);
int register_android_server_FaceService(JNIEnv* env);
@@ -124,6 +125,7 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void* /* reserved */)
register_android_server_utils_LazyJniRegistrar(env);
register_com_android_server_soundtrigger_middleware_AudioSessionProviderImpl(env);
register_com_android_server_soundtrigger_middleware_ExternalCaptureStateTracker(env);
+ register_android_server_com_android_server_pm_ComputerEngine(env);
register_android_server_com_android_server_pm_PackageManagerShellCommandDataLoader(env);
register_android_server_AdbDebuggingManager(env);
register_android_server_FaceService(env);
--
2.48.1

View file

@ -1,49 +0,0 @@
From 31cfef8a4245e49b99fc36cc8eaf7b0452ae9985 Mon Sep 17 00:00:00 2001
From: Jonathan Klee <jonathan.klee@e.email>
Date: Thu, 12 Dec 2024 15:27:57 +0100
Subject: [PATCH 11/11] Allow spoofing signingInfo for microG
Companion/Services
- Spoof PackageInfo signingInfo + signatures so that
G suite apps do not complain anymore.
Change-Id: I86f182c9e1d18b0e997803842577a90ef740cfd1
Signed-off-by: althafvly <althafvly@gmail.com>
---
.../java/com/android/server/pm/ComputerEngine.java | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/services/core/java/com/android/server/pm/ComputerEngine.java b/services/core/java/com/android/server/pm/ComputerEngine.java
index 3eb3df412..6f5813065 100644
--- a/services/core/java/com/android/server/pm/ComputerEngine.java
+++ b/services/core/java/com/android/server/pm/ComputerEngine.java
@@ -170,6 +170,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
+import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -1590,6 +1591,18 @@ public class ComputerEngine implements Computer {
generateFakeSignature(p).ifPresent(fakeSignature -> {
packageInfo.signatures = new Signature[]{fakeSignature};
+ try {
+ packageInfo.signingInfo = new SigningInfo(
+ new SigningDetails(
+ packageInfo.signatures,
+ SigningDetails.SignatureSchemeVersion.SIGNING_BLOCK_V3,
+ SigningDetails.toSigningKeys(packageInfo.signatures),
+ null
+ )
+ );
+ } catch (CertificateException e) {
+ Slog.e(TAG, "Caught an exception when creating signing keys: ", e);
+ }
});
return packageInfo;
--
2.48.1

View file

@ -1,61 +0,0 @@
From b02d33fe80bed126c8caeebb51ced31e9b0c710e Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Sun, 6 Oct 2024 09:06:48 -0400
Subject: [PATCH 1/7] sensorservice: Add support for ignoring broken sensors
This allows those sensors to be replaced by SensorFusion when possible.
Change-Id: I5509ee1f54fdf4838f6e3b109819a689f483cfc4
---
services/sensorservice/SensorDevice.cpp | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp
index 9c4d1ace15..5a95096fdb 100644
--- a/services/sensorservice/SensorDevice.cpp
+++ b/services/sensorservice/SensorDevice.cpp
@@ -17,6 +17,7 @@
#include "SensorDevice.h"
#include <android-base/logging.h>
+#include <android-base/properties.h>
#include <android/util/ProtoOutputStream.h>
#include <com_android_frameworks_sensorservice_flags.h>
#include <cutils/atomic.h>
@@ -32,6 +33,8 @@
#include <condition_variable>
#include <cstddef>
#include <mutex>
+#include <sstream>
+#include <string>
#include <thread>
#include "AidlSensorHalWrapper.h"
@@ -86,10 +89,24 @@ void SensorDevice::initializeSensorList() {
auto list = mHalWrapper->getSensorsList();
const size_t count = list.size();
+ auto sensorFilter = base::GetProperty("persist.sys.phh.sensor_filter", "");
+
mActivationCount.setCapacity(count);
Info model;
for (size_t i = 0; i < count; i++) {
sensor_t sensor = list[i];
+ std::string vendorNamePair = std::string(sensor.vendor) + ":" + std::string(sensor.name);
+
+ std::istringstream iss(sensorFilter);
+ std::string item;
+ bool shouldIgnore = false;
+ while (std::getline(iss, item, ';')) {
+ if (item == vendorNamePair) {
+ shouldIgnore = true;
+ }
+ }
+
+ if (shouldIgnore) continue;
if (sensor.type < DEVICE_PRIVATE_BASE) {
sensor.resolution = SensorDeviceUtils::resolutionForSensor(sensor);
--
2.48.1

View file

@ -1,297 +0,0 @@
From 050301ed102cd6b41756adf114243a3cfa8b70a6 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 25 Nov 2023 08:15:28 -0500
Subject: [PATCH 2/7] Add MTK GED KPI support to fix broken Mediatek gpufreq
Mediatek GPU scheduler likes to have the timestamps of the frames to be
able to adjust DVFS.
Technically this isn't completely needed, because it looks like DVFS can
work once we started triggering /proc/ged. But now that the work is
done, let's do it completely.
In benchmarks on Poco X4 GT, before this patch result is 1500, after is
5700. If we disable the patch after enabling it without rebooting, it
goes to 5400. So looks like GED KPI thingy does try to do a bit more
than just standard DVFS.
Thanks @sarthakroy2002 for the help and support (other people helped as
well)
Change-Id: Ic29a231ea8651efd598083611197aaa9e3c1fbbe
---
libs/gui/Surface.cpp | 202 +++++++++++++++++++++++++++++++++
libs/gui/include/gui/Surface.h | 3 +
2 files changed, 205 insertions(+)
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index e41f9bbf43..d6863467a3 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -26,6 +26,9 @@
#include <deque>
#include <mutex>
#include <thread>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <unistd.h>
#include <inttypes.h>
@@ -50,6 +53,9 @@
#include <gui/LayerState.h>
#include <private/gui/ComposerService.h>
#include <private/gui/ComposerServiceAIDL.h>
+#include <android-base/properties.h>
+
+#include <binder/IPCThreadState.h>
#include <com_android_graphics_libgui_flags.h>
@@ -76,6 +82,37 @@ bool isInterceptorRegistrationOp(int op) {
}
} // namespace
+ //
+#define GED_MAGIC 'g'
+#define GED_BRIDGE_COMMAND_GPU_TIMESTAMP 103
+#define GED_IOWR(INDEX) _IOWR(GED_MAGIC, INDEX, GED_BRIDGE_PACKAGE)
+#define GED_BRIDGE_IO_GPU_TIMESTAMP \
+ GED_IOWR(GED_BRIDGE_COMMAND_GPU_TIMESTAMP)
+typedef struct _GED_BRIDGE_PACKAGE {
+ unsigned int ui32FunctionID;
+ int i32Size;
+ void *pvParamIn;
+ int i32InBufferSize;
+ void *pvParamOut;
+ int i32OutBufferSize;
+} GED_BRIDGE_PACKAGE;
+
+struct GED_BRIDGE_IN_GPU_TIMESTAMP {
+ int pid;
+ uint64_t ullWnd;
+ int32_t i32FrameID;
+ int fence_fd;
+ int QedBuffer_length;
+ int isSF;
+};
+
+struct GED_BRIDGE_OUT_GPU_TIMESTAMP {
+ int eError;
+ int is_ged_kpi_enabled;
+};
+
+static int doMtkGedKpi = -1;
+static int ged_fd = -1;
#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
Surface::ProducerDeathListenerProxy::ProducerDeathListenerProxy(wp<SurfaceListener> surfaceListener)
@@ -147,6 +184,47 @@ Surface::Surface(const sp<IGraphicBufferProducer>& bufferProducer, bool controll
mSwapIntervalZero = false;
mMaxBufferCount = NUM_BUFFER_SLOTS;
mSurfaceControlHandle = surfaceControlHandle;
+
+ if (doMtkGedKpi == -1) {
+ doMtkGedKpi = android::base::GetIntProperty("persist.sys.phh.mtk_ged_kpi", 0);
+ }
+
+ if (ged_fd == -1 && doMtkGedKpi == 1) {
+ ALOGE("Opening ged");
+ ged_fd = open("/proc/ged", O_RDONLY);
+ ALOGE("Opening ged ret = %d", ged_fd);
+ {
+ struct GED_BRIDGE_IN_GPU_TIMESTAMP in = {
+ .pid = 0,
+ //.ullWnd = (uint64_t)(intptr_t)this,
+ .ullWnd = 0,
+ .i32FrameID = 0,
+ .fence_fd = 0,
+ .isSF = 0,
+ .QedBuffer_length = 0,
+ };
+ struct GED_BRIDGE_OUT_GPU_TIMESTAMP out;
+ memset(&in, 0, sizeof(in));
+ GED_BRIDGE_PACKAGE package = {
+ .ui32FunctionID = GED_BRIDGE_IO_GPU_TIMESTAMP,
+ .i32Size = sizeof(GED_BRIDGE_PACKAGE),
+ .pvParamIn = &in,
+ .i32InBufferSize = sizeof(in),
+ .pvParamOut = &out,
+ .i32OutBufferSize = sizeof(out),
+ };
+ if (ged_fd >= 0) {
+ int ret = ioctl(ged_fd, GED_BRIDGE_IO_GPU_TIMESTAMP, &package);
+ ALOGE("First null timestamp ioctl returned %d %d %d", ret, out.eError, out.is_ged_kpi_enabled);
+ if (out.is_ged_kpi_enabled != 1) {
+ ALOGE("is_ged_kpi_enabled reported disabled");
+ doMtkGedKpi = 0;
+ }
+ } else {
+ ALOGE("No /proc/ged");
+ }
+ }
+ }
}
Surface::~Surface() {
@@ -699,6 +777,36 @@ int Surface::dequeueBuffer(android_native_buffer_t** buffer, int* fenceFd) {
}
}
+ if (mGraphicBufferProducer != nullptr && ged_fd >= 0) {
+ uint64_t uniqueId;
+ mGraphicBufferProducer->getUniqueId(&uniqueId);
+
+ const int32_t dupFenceFd = fence->isValid() ? fence->dup() : -1;
+
+ struct GED_BRIDGE_IN_GPU_TIMESTAMP in = {
+ .pid = mPid,
+ .ullWnd = uniqueId,
+ .i32FrameID = static_cast<int32_t>(reinterpret_cast<intptr_t>(gbuf->handle)) & 0x3fffffff,
+ .fence_fd = dupFenceFd,
+ .isSF = mIsSurfaceFlinger ? 1 : 0,
+ .QedBuffer_length = -2,
+ };
+ struct GED_BRIDGE_OUT_GPU_TIMESTAMP out;
+ memset(&out, 0, sizeof(out));
+ GED_BRIDGE_PACKAGE package = {
+ .ui32FunctionID = GED_BRIDGE_IO_GPU_TIMESTAMP,
+ .i32Size = sizeof(GED_BRIDGE_PACKAGE),
+ .pvParamIn = &in,
+ .i32InBufferSize = sizeof(in),
+ .pvParamOut = &out,
+ .i32OutBufferSize = sizeof(out),
+ };
+
+ int ret = ioctl(ged_fd, GED_BRIDGE_IO_GPU_TIMESTAMP, &package);
+ ALOGV("GPU timestamp ioctl returned %d %d %d %d", ret, out.eError, out.is_ged_kpi_enabled, in.i32FrameID);
+
+ close(dupFenceFd);
+ }
if (fence->isValid()) {
*fenceFd = fence->dup();
if (*fenceFd == -1) {
@@ -1187,6 +1295,60 @@ void Surface::onBufferQueuedLocked(int slot, sp<Fence> fence,
}
mQueueBufferCondition.broadcast();
+ if (mGraphicBufferProducer != nullptr && ged_fd >= 0) {
+ sp<GraphicBuffer>& gbuf(mSlots[slot].buffer);
+ uint64_t uniqueId;
+ mGraphicBufferProducer->getUniqueId(&uniqueId);
+
+ const int32_t dupFenceFd = fence->isValid() ? fence->dup() : -1;
+ // onQueue
+ {
+ struct GED_BRIDGE_IN_GPU_TIMESTAMP in = {
+ .pid = mPid,
+ .ullWnd = uniqueId,
+ .i32FrameID = static_cast<int32_t>(reinterpret_cast<intptr_t>(gbuf->handle)) & 0x3fffffff,
+ .fence_fd = dupFenceFd,
+ .isSF = mIsSurfaceFlinger ? 1 : 0,
+ .QedBuffer_length = static_cast<int>(output.numPendingBuffers),
+ };
+ struct GED_BRIDGE_OUT_GPU_TIMESTAMP out;
+ memset(&out, 0, sizeof(out));
+ GED_BRIDGE_PACKAGE package = {
+ .ui32FunctionID = GED_BRIDGE_IO_GPU_TIMESTAMP,
+ .i32Size = sizeof(GED_BRIDGE_PACKAGE),
+ .pvParamIn = &in,
+ .i32InBufferSize = sizeof(in),
+ .pvParamOut = &out,
+ .i32OutBufferSize = sizeof(out),
+ };
+ int ret = ioctl(ged_fd, GED_BRIDGE_IO_GPU_TIMESTAMP, &package);
+ ALOGV("GPU timestamp ioctl returned %d %d %d", ret, out.eError, in.i32FrameID);
+ }
+ // acquire
+ {
+ struct GED_BRIDGE_IN_GPU_TIMESTAMP in = {
+ .pid = mPid,
+ .isSF = mIsSurfaceFlinger ? 1 : 0,
+ .ullWnd = uniqueId,
+ .i32FrameID = static_cast<int32_t>(reinterpret_cast<intptr_t>(gbuf->handle)) & 0x3fffffff,
+ .fence_fd = dupFenceFd,
+ .QedBuffer_length = -1,
+ };
+ struct GED_BRIDGE_OUT_GPU_TIMESTAMP out;
+ memset(&out, 0, sizeof(out));
+ GED_BRIDGE_PACKAGE package = {
+ .ui32FunctionID = GED_BRIDGE_IO_GPU_TIMESTAMP,
+ .i32Size = sizeof(GED_BRIDGE_PACKAGE),
+ .pvParamIn = &in,
+ .i32InBufferSize = sizeof(in),
+ .pvParamOut = &in,
+ .i32OutBufferSize = sizeof(out),
+ };
+ int ret = ioctl(ged_fd, GED_BRIDGE_IO_GPU_TIMESTAMP, &package);
+ ALOGV("GPU timestamp ioctl returned %d %d %d", ret, out.eError, in.i32FrameID);
+ }
+ close(dupFenceFd);
+ }
if (CC_UNLIKELY(atrace_is_tag_enabled(ATRACE_TAG_GRAPHICS))) {
static gui::FenceMonitor gpuCompletionThread("GPU completion");
@@ -2111,6 +2273,46 @@ int Surface::connect(int api, const sp<SurfaceListener>& listener, bool reportBu
}
#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_PLATFORM_API_IMPROVEMENTS)
}
+
+ // For MTK GED KPI, we need to grab the Surface owner's PID
+ // and also know whether that owner is surfaceflinger
+ if (api == NATIVE_WINDOW_API_EGL && ged_fd >= 0) {
+ IPCThreadState *ipc = IPCThreadState::selfOrNull();
+ const sp<IBinder>& token = IInterface::asBinder(mGraphicBufferProducer);
+ mPid = (token != NULL && NULL != token->localBinder())
+ ? getpid()
+ : (ipc != nullptr)?ipc->getCallingPid():-1;
+
+ // We've got caller PID. Now checking whether it is surfaceflinger
+ char cmdline[128];
+ char path[128];
+ snprintf(path, sizeof(path)-1, "/proc/%d/cmdline", mPid);
+ int fd = open(path, O_RDONLY);
+ read(fd, cmdline, sizeof(cmdline)-1);
+ // Normally cmdline is already \0-separated, but well
+ for(unsigned i=0; i<sizeof(cmdline); i++)
+ if(cmdline[i] == '\n')
+ cmdline[i] = 0;
+ cmdline[sizeof(cmdline)-1] = 0;
+
+ close(fd);
+
+ // Truncate to last / (also called basename)
+ const char *c = strrchr(cmdline, '/');
+ if (c != nullptr) {
+ c = c+1;
+ } else {
+ c = cmdline;
+ }
+ if(strcmp(c, "surfaceflinger") == 0) {
+ ALOGE("is surfaceflinger = 1");
+ mIsSurfaceFlinger = true;
+ } else {
+ ALOGE("is surfaceflinger = 0");
+ mIsSurfaceFlinger = false;
+ }
+ }
+
if (!err && api == NATIVE_WINDOW_API_CPU) {
mConnectedToCpu = true;
// Clear the dirty region in case we're switching from a non-CPU API
diff --git a/libs/gui/include/gui/Surface.h b/libs/gui/include/gui/Surface.h
index 14a351316d..e0843a8016 100644
--- a/libs/gui/include/gui/Surface.h
+++ b/libs/gui/include/gui/Surface.h
@@ -742,6 +742,9 @@ protected:
// Buffers that are successfully dequeued/attached and handed to clients
std::unordered_set<int> mDequeuedSlots;
+
+ pid_t mPid;
+ bool mIsSurfaceFlinger;
};
} // namespace android
--
2.48.1

View file

@ -1,101 +0,0 @@
From 37580f1924099111b2995e910ed64bb4182b9c39 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Mon, 7 Oct 2024 22:07:58 -0400
Subject: [PATCH 3/7] vibratorservice: Support optionally ignoring vibrator
effects
On Unihertz Jelly Max the preloaded vibrator HAL is utterly broken.
Change-Id: I308190a225932fba2a4aa1c830c03ab874d8032e
---
services/vibratorservice/Android.bp | 1 +
.../vibratorservice/VibratorHalWrapper.cpp | 31 +++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/services/vibratorservice/Android.bp b/services/vibratorservice/Android.bp
index 4735ae5897..6263b0506f 100644
--- a/services/vibratorservice/Android.bp
+++ b/services/vibratorservice/Android.bp
@@ -41,6 +41,7 @@ cc_library_shared {
},
shared_libs: [
+ "libbase",
"libbinder_ndk",
"libhidlbase",
"liblog",
diff --git a/services/vibratorservice/VibratorHalWrapper.cpp b/services/vibratorservice/VibratorHalWrapper.cpp
index 3ddc4f2aca..11178659ff 100644
--- a/services/vibratorservice/VibratorHalWrapper.cpp
+++ b/services/vibratorservice/VibratorHalWrapper.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "VibratorHalWrapper"
#include <aidl/android/hardware/vibrator/IVibrator.h>
+#include <android-base/properties.h>
#include <android/hardware/vibrator/1.3/IVibrator.h>
#include <hardware/vibrator.h>
#include <cmath>
@@ -44,6 +45,22 @@ namespace V1_2 = android::hardware::vibrator::V1_2;
namespace V1_3 = android::hardware::vibrator::V1_3;
namespace Aidl = aidl::android::hardware::vibrator;
+const Effect EFFECT_WITH_FALLBACK[] = {
+ Effect::CLICK,
+ Effect::DOUBLE_CLICK,
+ Effect::HEAVY_CLICK,
+ Effect::TICK,
+};
+
+#define RETURN_UNSUPPORTED_IF_IGNORED() \
+ bool shouldIgnoreEffects = android::base::GetBoolProperty("persist.sys.phh.ignore_vibrator_effects", false); \
+ auto casted_effect = static_cast<Effect>(effect); \
+ bool isEffectWithFallback = std::find(std::begin(EFFECT_WITH_FALLBACK), std::end(EFFECT_WITH_FALLBACK), casted_effect) \
+ != std::end(EFFECT_WITH_FALLBACK); \
+ if (shouldIgnoreEffects && isEffectWithFallback) { \
+ return HalResult<milliseconds>::unsupported(); \
+ }
+
namespace android {
namespace vibrator {
@@ -63,8 +80,18 @@ Info HalWrapper::getInfo() {
getCapabilities();
getPrimitiveDurations();
std::lock_guard<std::mutex> lock(mInfoMutex);
+ bool shouldIgnoreEffects = android::base::GetBoolProperty("persist.sys.phh.ignore_vibrator_effects", false);
if (mInfoCache.mSupportedEffects.isFailed()) {
mInfoCache.mSupportedEffects = getSupportedEffectsInternal();
+ if (mInfoCache.mSupportedEffects.isOk()) {
+ std::vector<Effect> filtered;
+ for (auto& effect : mInfoCache.mSupportedEffects.value()) {
+ if (std::find(std::begin(EFFECT_WITH_FALLBACK), std::end(EFFECT_WITH_FALLBACK), effect) == std::end(EFFECT_WITH_FALLBACK)) {
+ filtered.push_back(effect);
+ }
+ }
+ mInfoCache.mSupportedEffects = HalResult<std::vector<Effect>>::ok(filtered);
+ }
}
if (mInfoCache.mSupportedBraking.isFailed()) {
mInfoCache.mSupportedBraking = getSupportedBrakingInternal();
@@ -305,6 +332,8 @@ HalResult<void> AidlHalWrapper::alwaysOnDisable(int32_t id) {
HalResult<milliseconds> AidlHalWrapper::performEffect(
Effect effect, EffectStrength strength, const std::function<void()>& completionCallback) {
+ RETURN_UNSUPPORTED_IF_IGNORED();
+
HalResult<Capabilities> capabilities = getCapabilities();
bool supportsCallback = capabilities.isOk() &&
static_cast<int32_t>(capabilities.value() & Capabilities::PERFORM_CALLBACK);
@@ -582,6 +611,8 @@ template <typename T>
HalResult<milliseconds> HidlHalWrapper<I>::performInternal(
perform_fn<T> performFn, sp<I> handle, T effect, EffectStrength strength,
const std::function<void()>& completionCallback) {
+ RETURN_UNSUPPORTED_IF_IGNORED();
+
V1_0::Status status;
int32_t lengthMs;
auto effectCallback = [&status, &lengthMs](V1_0::Status retStatus, uint32_t retLengthMs) {
--
2.48.1

View file

@ -1,348 +0,0 @@
From b12faaf3064de58caf0f6bfaf7fcac5a47f5024d Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Sun, 16 Mar 2025 12:54:56 -0400
Subject: [PATCH 4/7] Revert "Remove flag single_hop_screenshots"
This reverts commit 16c4c32c55231dc241c386a0423710baa452b7de.
Change-Id: Ib1618cd4e1f83ba1f211a04429538b32e8de79da
---
.../surfaceflinger/RegionSamplingThread.cpp | 22 ++-
services/surfaceflinger/SurfaceFlinger.cpp | 184 ++++++++++++++----
services/surfaceflinger/SurfaceFlinger.h | 10 +-
.../surfaceflinger/common/FlagManager.cpp | 2 +
.../common/include/common/FlagManager.h | 1 +
.../tests/unittests/TestableSurfaceFlinger.h | 3 +-
6 files changed, 171 insertions(+), 51 deletions(-)
diff --git a/services/surfaceflinger/RegionSamplingThread.cpp b/services/surfaceflinger/RegionSamplingThread.cpp
index 21d3396ebe..08f831c8e5 100644
--- a/services/surfaceflinger/RegionSamplingThread.cpp
+++ b/services/surfaceflinger/RegionSamplingThread.cpp
@@ -353,13 +353,21 @@ void RegionSamplingThread::captureSample() {
sampledBounds.getSize(), ui::Dataspace::V0_SRGB, displayWeak,
RenderArea::Options::CAPTURE_SECURE_LAYERS);
- std::vector<std::pair<Layer*, sp<LayerFE>>> layers;
- auto displayState =
- mFlinger.getSnapshotsFromMainThread(renderAreaBuilder, getLayerSnapshotsFn, layers);
- FenceResult fenceResult =
- mFlinger.captureScreenshot(renderAreaBuilder, buffer, kRegionSampling, kGrayscale,
- kIsProtected, kAttachGainmap, nullptr, displayState, layers)
- .get();
+ FenceResult fenceResult;
+ if (FlagManager::getInstance().single_hop_screenshot()) {
+ std::vector<std::pair<Layer*, sp<LayerFE>>> layers;
+ auto displayState =
+ mFlinger.getSnapshotsFromMainThread(renderAreaBuilder, getLayerSnapshotsFn, layers);
+ fenceResult = mFlinger.captureScreenshot(renderAreaBuilder, buffer, kRegionSampling,
+ kGrayscale, kIsProtected, kAttachGainmap, nullptr,
+ displayState, layers)
+ .get();
+ } else {
+ fenceResult = mFlinger.captureScreenshotLegacy(renderAreaBuilder, getLayerSnapshotsFn,
+ buffer, kRegionSampling, kGrayscale,
+ kIsProtected, kAttachGainmap, nullptr)
+ .get();
+ }
if (fenceResult.ok()) {
fenceResult.value()->waitForever(LOG_TAG);
}
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 896d13d31d..852a8b81e1 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -7389,41 +7389,79 @@ void SurfaceFlinger::captureScreenCommon(RenderAreaBuilderVariant renderAreaBuil
return;
}
- std::vector<std::pair<Layer*, sp<LayerFE>>> layers;
- auto displayState = getSnapshotsFromMainThread(renderAreaBuilder, getLayerSnapshotsFn, layers);
-
- const bool supportsProtected = getRenderEngine().supportsProtectedContent();
- bool hasProtectedLayer = false;
- if (allowProtected && supportsProtected) {
- hasProtectedLayer = layersHasProtectedLayer(layers);
- }
- const bool isProtected = hasProtectedLayer && allowProtected && supportsProtected;
- const uint32_t usage = GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_RENDER |
- GRALLOC_USAGE_HW_TEXTURE |
- (isProtected ? GRALLOC_USAGE_PROTECTED
- : GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
- sp<GraphicBuffer> buffer =
- getFactory().createGraphicBuffer(bufferSize.getWidth(), bufferSize.getHeight(),
- static_cast<android_pixel_format>(reqPixelFormat),
- 1 /* layerCount */, usage, "screenshot");
-
- const status_t bufferStatus = buffer->initCheck();
- if (bufferStatus != OK) {
- // Animations may end up being really janky, but don't crash here.
- // Otherwise an irreponsible process may cause an SF crash by allocating
- // too much.
- ALOGE("%s: Buffer failed to allocate: %d", __func__, bufferStatus);
- invokeScreenCaptureError(bufferStatus, captureListener);
- return;
+ if (FlagManager::getInstance().single_hop_screenshot()) {
+ std::vector<std::pair<Layer*, sp<LayerFE>>> layers;
+ auto displayState =
+ getSnapshotsFromMainThread(renderAreaBuilder, getLayerSnapshotsFn, layers);
+
+ const bool supportsProtected = getRenderEngine().supportsProtectedContent();
+ bool hasProtectedLayer = false;
+ if (allowProtected && supportsProtected) {
+ hasProtectedLayer = layersHasProtectedLayer(layers);
+ }
+ const bool isProtected = hasProtectedLayer && allowProtected && supportsProtected;
+ const uint32_t usage = GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_RENDER |
+ GRALLOC_USAGE_HW_TEXTURE |
+ (isProtected ? GRALLOC_USAGE_PROTECTED
+ : GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
+ sp<GraphicBuffer> buffer =
+ getFactory().createGraphicBuffer(bufferSize.getWidth(), bufferSize.getHeight(),
+ static_cast<android_pixel_format>(reqPixelFormat),
+ 1 /* layerCount */, usage, "screenshot");
+
+ const status_t bufferStatus = buffer->initCheck();
+ if (bufferStatus != OK) {
+ // Animations may end up being really janky, but don't crash here.
+ // Otherwise an irreponsible process may cause an SF crash by allocating
+ // too much.
+ ALOGE("%s: Buffer failed to allocate: %d", __func__, bufferStatus);
+ invokeScreenCaptureError(bufferStatus, captureListener);
+ return;
+ }
+ const std::shared_ptr<renderengine::ExternalTexture> texture = std::make_shared<
+ renderengine::impl::ExternalTexture>(buffer, getRenderEngine(),
+ renderengine::impl::ExternalTexture::Usage::
+ WRITEABLE);
+ auto futureFence = captureScreenshot(renderAreaBuilder, texture, false /* regionSampling */,
+ grayscale, isProtected, attachGainmap, captureListener,
+ displayState, layers);
+ futureFence.get();
+
+ } else {
+ const bool supportsProtected = getRenderEngine().supportsProtectedContent();
+ bool hasProtectedLayer = false;
+ if (allowProtected && supportsProtected) {
+ auto layers = mScheduler->schedule([=]() { return getLayerSnapshotsFn(); }).get();
+ hasProtectedLayer = layersHasProtectedLayer(layers);
+ }
+ const bool isProtected = hasProtectedLayer && allowProtected && supportsProtected;
+ const uint32_t usage = GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_RENDER |
+ GRALLOC_USAGE_HW_TEXTURE |
+ (isProtected ? GRALLOC_USAGE_PROTECTED
+ : GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
+ sp<GraphicBuffer> buffer =
+ getFactory().createGraphicBuffer(bufferSize.getWidth(), bufferSize.getHeight(),
+ static_cast<android_pixel_format>(reqPixelFormat),
+ 1 /* layerCount */, usage, "screenshot");
+
+ const status_t bufferStatus = buffer->initCheck();
+ if (bufferStatus != OK) {
+ // Animations may end up being really janky, but don't crash here.
+ // Otherwise an irreponsible process may cause an SF crash by allocating
+ // too much.
+ ALOGE("%s: Buffer failed to allocate: %d", __func__, bufferStatus);
+ invokeScreenCaptureError(bufferStatus, captureListener);
+ return;
+ }
+ const std::shared_ptr<renderengine::ExternalTexture> texture = std::make_shared<
+ renderengine::impl::ExternalTexture>(buffer, getRenderEngine(),
+ renderengine::impl::ExternalTexture::Usage::
+ WRITEABLE);
+ auto futureFence = captureScreenshotLegacy(renderAreaBuilder, getLayerSnapshotsFn, texture,
+ false /* regionSampling */, grayscale,
+ isProtected, attachGainmap, captureListener);
+ futureFence.get();
}
- const std::shared_ptr<renderengine::ExternalTexture> texture = std::make_shared<
- renderengine::impl::ExternalTexture>(buffer, getRenderEngine(),
- renderengine::impl::ExternalTexture::Usage::
- WRITEABLE);
- auto futureFence =
- captureScreenshot(renderAreaBuilder, texture, false /* regionSampling */, grayscale,
- isProtected, attachGainmap, captureListener, displayState, layers);
- futureFence.get();
}
std::optional<SurfaceFlinger::OutputCompositionState>
@@ -7489,7 +7527,7 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::captureScreenshot(
ftl::SharedFuture<FenceResult> renderFuture =
renderScreenImpl(renderArea.get(), buffer, regionSampling, grayscale, isProtected,
- captureResults, displayState, layers);
+ attachGainmap, captureResults, displayState, layers);
if (captureResults.capturedHdrLayers && attachGainmap &&
FlagManager::getInstance().true_hdr_screenshots()) {
@@ -7524,7 +7562,8 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::captureScreenshot(
ScreenCaptureResults unusedResults;
ftl::SharedFuture<FenceResult> hdrRenderFuture =
renderScreenImpl(renderArea.get(), hdrTexture, regionSampling, grayscale,
- isProtected, unusedResults, displayState, layers);
+ isProtected, attachGainmap, unusedResults, displayState,
+ layers);
renderFuture =
ftl::Future(std::move(renderFuture))
@@ -7570,10 +7609,67 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::captureScreenshot(
return renderFuture;
}
+ftl::SharedFuture<FenceResult> SurfaceFlinger::captureScreenshotLegacy(
+ RenderAreaBuilderVariant renderAreaBuilder, GetLayerSnapshotsFunction getLayerSnapshotsFn,
+ const std::shared_ptr<renderengine::ExternalTexture>& buffer, bool regionSampling,
+ bool grayscale, bool isProtected, bool attachGainmap,
+ const sp<IScreenCaptureListener>& captureListener) {
+ SFTRACE_CALL();
+
+ auto takeScreenshotFn = [=, this, renderAreaBuilder = std::move(renderAreaBuilder)]() REQUIRES(
+ kMainThreadContext) mutable -> ftl::SharedFuture<FenceResult> {
+ auto layers = getLayerSnapshotsFn();
+ auto displayState = getDisplayStateFromRenderAreaBuilder(renderAreaBuilder);
+
+ ScreenCaptureResults captureResults;
+ std::unique_ptr<const RenderArea> renderArea =
+ std::visit([](auto&& arg) -> std::unique_ptr<RenderArea> { return arg.build(); },
+ renderAreaBuilder);
+
+ if (!renderArea) {
+ ALOGW("Skipping screen capture because of invalid render area.");
+ if (captureListener) {
+ captureResults.fenceResult = base::unexpected(NO_MEMORY);
+ captureListener->onScreenCaptureCompleted(captureResults);
+ }
+ return ftl::yield<FenceResult>(base::unexpected(NO_ERROR)).share();
+ }
+
+ ftl::SharedFuture<FenceResult> renderFuture =
+ renderScreenImpl(renderArea.get(), buffer, regionSampling, grayscale, isProtected,
+ attachGainmap, captureResults, displayState, layers);
+
+ if (captureListener) {
+ // Defer blocking on renderFuture back to the Binder thread.
+ return ftl::Future(std::move(renderFuture))
+ .then([captureListener, captureResults = std::move(captureResults)](
+ FenceResult fenceResult) mutable -> FenceResult {
+ captureResults.fenceResult = std::move(fenceResult);
+ captureListener->onScreenCaptureCompleted(captureResults);
+ return base::unexpected(NO_ERROR);
+ })
+ .share();
+ }
+ return renderFuture;
+ };
+
+ // TODO(b/294936197): Run takeScreenshotsFn() in a binder thread to reduce the number
+ // of calls on the main thread.
+ auto future =
+ mScheduler->schedule(FTL_FAKE_GUARD(kMainThreadContext, std::move(takeScreenshotFn)));
+
+ // Flatten nested futures.
+ auto chain = ftl::Future(std::move(future)).then([](ftl::SharedFuture<FenceResult> future) {
+ return future;
+ });
+
+ return chain.share();
+}
+
ftl::SharedFuture<FenceResult> SurfaceFlinger::renderScreenImpl(
const RenderArea* renderArea, const std::shared_ptr<renderengine::ExternalTexture>& buffer,
- bool regionSampling, bool grayscale, bool isProtected, ScreenCaptureResults& captureResults,
- std::optional<OutputCompositionState>& displayState,
+ bool regionSampling, bool grayscale, bool isProtected, bool attachGainmap,
+ ScreenCaptureResults& captureResults, std::optional<OutputCompositionState>& displayState,
std::vector<std::pair<Layer*, sp<LayerFE>>>& layers) {
SFTRACE_CALL();
@@ -7719,9 +7815,15 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::renderScreenImpl(
//
// TODO(b/196334700) Once we use RenderEngineThreaded everywhere we can always defer the call
// to CompositionEngine::present.
- ftl::SharedFuture<FenceResult> presentFuture = mRenderEngine->isThreaded()
- ? ftl::yield(present()).share()
- : mScheduler->schedule(std::move(present)).share();
+ ftl::SharedFuture<FenceResult> presentFuture;
+ if (FlagManager::getInstance().single_hop_screenshot()) {
+ presentFuture = mRenderEngine->isThreaded()
+ ? ftl::yield(present()).share()
+ : mScheduler->schedule(std::move(present)).share();
+ } else {
+ presentFuture = mRenderEngine->isThreaded() ? ftl::defer(std::move(present)).share()
+ : ftl::yield(present()).share();
+ }
return presentFuture;
}
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 1e2c08747b..835cb572b4 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -885,10 +885,16 @@ private:
std::optional<OutputCompositionState>& displayState,
std::vector<std::pair<Layer*, sp<LayerFE>>>& layers);
+ ftl::SharedFuture<FenceResult> captureScreenshotLegacy(
+ RenderAreaBuilderVariant, GetLayerSnapshotsFunction,
+ const std::shared_ptr<renderengine::ExternalTexture>&, bool regionSampling,
+ bool grayscale, bool isProtected, bool attachGainmap,
+ const sp<IScreenCaptureListener>&);
+
ftl::SharedFuture<FenceResult> renderScreenImpl(
const RenderArea*, const std::shared_ptr<renderengine::ExternalTexture>&,
- bool regionSampling, bool grayscale, bool isProtected, ScreenCaptureResults&,
- std::optional<OutputCompositionState>& displayState,
+ bool regionSampling, bool grayscale, bool isProtected, bool attachGainmap,
+ ScreenCaptureResults&, std::optional<OutputCompositionState>& displayState,
std::vector<std::pair<Layer*, sp<LayerFE>>>& layers);
void readPersistentProperties();
diff --git a/services/surfaceflinger/common/FlagManager.cpp b/services/surfaceflinger/common/FlagManager.cpp
index 5e78426c77..5c417ba748 100644
--- a/services/surfaceflinger/common/FlagManager.cpp
+++ b/services/surfaceflinger/common/FlagManager.cpp
@@ -166,6 +166,7 @@ void FlagManager::dump(std::string& result) const {
DUMP_ACONFIG_FLAG(skip_invisible_windows_in_input);
DUMP_ACONFIG_FLAG(begone_bright_hlg);
DUMP_ACONFIG_FLAG(window_blur_kawase2);
+ DUMP_ACONFIG_FLAG(single_hop_screenshot);
#undef DUMP_ACONFIG_FLAG
#undef DUMP_LEGACY_SERVER_FLAG
@@ -259,6 +260,7 @@ FLAG_MANAGER_ACONFIG_FLAG(local_tonemap_screenshots, "debug.sf.local_tonemap_scr
FLAG_MANAGER_ACONFIG_FLAG(override_trusted_overlay, "");
FLAG_MANAGER_ACONFIG_FLAG(flush_buffer_slots_to_uncache, "");
FLAG_MANAGER_ACONFIG_FLAG(force_compile_graphite_renderengine, "");
+FLAG_MANAGER_ACONFIG_FLAG(single_hop_screenshot, "");
FLAG_MANAGER_ACONFIG_FLAG(true_hdr_screenshots, "debug.sf.true_hdr_screenshots");
FLAG_MANAGER_ACONFIG_FLAG(display_config_error_hal, "");
FLAG_MANAGER_ACONFIG_FLAG(connected_display_hdr, "debug.sf.connected_display_hdr");
diff --git a/services/surfaceflinger/common/include/common/FlagManager.h b/services/surfaceflinger/common/include/common/FlagManager.h
index d8887f538f..15284ba0ee 100644
--- a/services/surfaceflinger/common/include/common/FlagManager.h
+++ b/services/surfaceflinger/common/include/common/FlagManager.h
@@ -95,6 +95,7 @@ public:
bool override_trusted_overlay() const;
bool flush_buffer_slots_to_uncache() const;
bool force_compile_graphite_renderengine() const;
+ bool single_hop_screenshot() const;
bool trace_frame_rate_override() const;
bool true_hdr_screenshots() const;
bool display_config_error_hal() const;
diff --git a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
index 7f0b7a6585..fd8bc0d22d 100644
--- a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
+++ b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
@@ -475,7 +475,8 @@ public:
return mFlinger->renderScreenImpl(renderArea.get(), buffer, regionSampling,
false /* grayscale */, false /* isProtected */,
- captureResults, displayState, layers);
+ false /* attachGainmap */, captureResults, displayState,
+ layers);
}
auto getLayerSnapshotsForScreenshotsFn(ui::LayerStack layerStack, uint32_t uid) {
--
2.48.1

View file

@ -1,334 +0,0 @@
From aa5e6f794b3e2c9f5bdbc40da702b14dd9a1764e Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Sun, 16 Mar 2025 13:19:17 -0400
Subject: [PATCH 5/7] Revert "Reorder release fence attachment for non-threaded
RE"
This reverts commit 0b80c74300b73e937ee9a9cb58487bd126daa4d8.
---
.../surfaceflinger/RegionSamplingThread.cpp | 11 ++-
services/surfaceflinger/SurfaceFlinger.cpp | 97 ++++++++++---------
services/surfaceflinger/SurfaceFlinger.h | 16 ++-
.../tests/unittests/TestableSurfaceFlinger.h | 3 +-
4 files changed, 69 insertions(+), 58 deletions(-)
diff --git a/services/surfaceflinger/RegionSamplingThread.cpp b/services/surfaceflinger/RegionSamplingThread.cpp
index 08f831c8e5..011fd9e20a 100644
--- a/services/surfaceflinger/RegionSamplingThread.cpp
+++ b/services/surfaceflinger/RegionSamplingThread.cpp
@@ -354,13 +354,14 @@ void RegionSamplingThread::captureSample() {
RenderArea::Options::CAPTURE_SECURE_LAYERS);
FenceResult fenceResult;
- if (FlagManager::getInstance().single_hop_screenshot()) {
- std::vector<std::pair<Layer*, sp<LayerFE>>> layers;
- auto displayState =
- mFlinger.getSnapshotsFromMainThread(renderAreaBuilder, getLayerSnapshotsFn, layers);
+ if (FlagManager::getInstance().single_hop_screenshot() &&
+ mFlinger.mRenderEngine->isThreaded()) {
+ std::vector<sp<LayerFE>> layerFEs;
+ auto displayState = mFlinger.getSnapshotsFromMainThread(renderAreaBuilder,
+ getLayerSnapshotsFn, layerFEs);
fenceResult = mFlinger.captureScreenshot(renderAreaBuilder, buffer, kRegionSampling,
kGrayscale, kIsProtected, kAttachGainmap, nullptr,
- displayState, layers)
+ displayState, layerFEs)
.get();
} else {
fenceResult = mFlinger.captureScreenshotLegacy(renderAreaBuilder, getLayerSnapshotsFn,
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 852a8b81e1..067a8bafe0 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -7335,10 +7335,9 @@ void SurfaceFlinger::attachReleaseFenceFutureToLayer(Layer* layer, LayerFE* laye
// typically a layer with DRM contents, or have the GRALLOC_USAGE_PROTECTED set on the buffer.
// A protected layer has no implication on whether it's secure, which is explicitly set by
// application to avoid being screenshot or drawn via unsecure display.
-bool SurfaceFlinger::layersHasProtectedLayer(
- const std::vector<std::pair<Layer*, sp<LayerFE>>>& layers) const {
+bool SurfaceFlinger::layersHasProtectedLayer(const std::vector<sp<LayerFE>>& layers) const {
bool protectedLayerFound = false;
- for (auto& [_, layerFE] : layers) {
+ for (auto& layerFE : layers) {
protectedLayerFound |=
(layerFE->mSnapshot->isVisible && layerFE->mSnapshot->hasProtectedContent);
if (protectedLayerFound) {
@@ -7354,21 +7353,15 @@ bool SurfaceFlinger::layersHasProtectedLayer(
// risk of deadlocks.
std::optional<SurfaceFlinger::OutputCompositionState> SurfaceFlinger::getSnapshotsFromMainThread(
RenderAreaBuilderVariant& renderAreaBuilder, GetLayerSnapshotsFunction getLayerSnapshotsFn,
- std::vector<std::pair<Layer*, sp<LayerFE>>>& layers) {
+ std::vector<sp<LayerFE>>& layerFEs) {
return mScheduler
- ->schedule([=, this, &renderAreaBuilder, &layers]() REQUIRES(kMainThreadContext) {
+ ->schedule([=, this, &renderAreaBuilder, &layerFEs]() REQUIRES(kMainThreadContext) {
SFTRACE_NAME("getSnapshotsFromMainThread");
- layers = getLayerSnapshotsFn();
- // Non-threaded RenderEngine eventually returns to the main thread a 2nd time
- // to complete the screenshot. Release fences should only be added during the 2nd
- // hop to main thread in order to avoid potential deadlocks from waiting for the
- // the future fence to fire.
- if (mRenderEngine->isThreaded()) {
- for (auto& [layer, layerFE] : layers) {
- attachReleaseFenceFutureToLayer(layer, layerFE.get(),
- ui::INVALID_LAYER_STACK);
- }
+ auto layers = getLayerSnapshotsFn();
+ for (auto& [layer, layerFE] : layers) {
+ attachReleaseFenceFutureToLayer(layer, layerFE.get(), ui::INVALID_LAYER_STACK);
}
+ layerFEs = extractLayerFEs(layers);
return getDisplayStateFromRenderAreaBuilder(renderAreaBuilder);
})
.get();
@@ -7389,15 +7382,15 @@ void SurfaceFlinger::captureScreenCommon(RenderAreaBuilderVariant renderAreaBuil
return;
}
- if (FlagManager::getInstance().single_hop_screenshot()) {
- std::vector<std::pair<Layer*, sp<LayerFE>>> layers;
+ if (FlagManager::getInstance().single_hop_screenshot() && mRenderEngine->isThreaded()) {
+ std::vector<sp<LayerFE>> layerFEs;
auto displayState =
- getSnapshotsFromMainThread(renderAreaBuilder, getLayerSnapshotsFn, layers);
+ getSnapshotsFromMainThread(renderAreaBuilder, getLayerSnapshotsFn, layerFEs);
const bool supportsProtected = getRenderEngine().supportsProtectedContent();
bool hasProtectedLayer = false;
if (allowProtected && supportsProtected) {
- hasProtectedLayer = layersHasProtectedLayer(layers);
+ hasProtectedLayer = layersHasProtectedLayer(layerFEs);
}
const bool isProtected = hasProtectedLayer && allowProtected && supportsProtected;
const uint32_t usage = GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_RENDER |
@@ -7424,7 +7417,7 @@ void SurfaceFlinger::captureScreenCommon(RenderAreaBuilderVariant renderAreaBuil
WRITEABLE);
auto futureFence = captureScreenshot(renderAreaBuilder, texture, false /* regionSampling */,
grayscale, isProtected, attachGainmap, captureListener,
- displayState, layers);
+ displayState, layerFEs);
futureFence.get();
} else {
@@ -7432,7 +7425,7 @@ void SurfaceFlinger::captureScreenCommon(RenderAreaBuilderVariant renderAreaBuil
bool hasProtectedLayer = false;
if (allowProtected && supportsProtected) {
auto layers = mScheduler->schedule([=]() { return getLayerSnapshotsFn(); }).get();
- hasProtectedLayer = layersHasProtectedLayer(layers);
+ hasProtectedLayer = layersHasProtectedLayer(extractLayerFEs(layers));
}
const bool isProtected = hasProtectedLayer && allowProtected && supportsProtected;
const uint32_t usage = GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_RENDER |
@@ -7500,13 +7493,22 @@ SurfaceFlinger::getDisplayStateFromRenderAreaBuilder(RenderAreaBuilderVariant& r
return std::nullopt;
}
+std::vector<sp<LayerFE>> SurfaceFlinger::extractLayerFEs(
+ const std::vector<std::pair<Layer*, sp<LayerFE>>>& layers) const {
+ std::vector<sp<LayerFE>> layerFEs;
+ layerFEs.reserve(layers.size());
+ for (const auto& [_, layerFE] : layers) {
+ layerFEs.push_back(layerFE);
+ }
+ return layerFEs;
+}
+
ftl::SharedFuture<FenceResult> SurfaceFlinger::captureScreenshot(
const RenderAreaBuilderVariant& renderAreaBuilder,
const std::shared_ptr<renderengine::ExternalTexture>& buffer, bool regionSampling,
bool grayscale, bool isProtected, bool attachGainmap,
const sp<IScreenCaptureListener>& captureListener,
- std::optional<OutputCompositionState>& displayState,
- std::vector<std::pair<Layer*, sp<LayerFE>>>& layers) {
+ std::optional<OutputCompositionState>& displayState, std::vector<sp<LayerFE>>& layerFEs) {
SFTRACE_CALL();
ScreenCaptureResults captureResults;
@@ -7525,9 +7527,11 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::captureScreenshot(
float displayBrightnessNits = displayState.value().displayBrightnessNits;
float sdrWhitePointNits = displayState.value().sdrWhitePointNits;
+ // Empty vector needed to pass into renderScreenImpl for legacy path
+ std::vector<std::pair<Layer*, sp<android::LayerFE>>> layers;
ftl::SharedFuture<FenceResult> renderFuture =
renderScreenImpl(renderArea.get(), buffer, regionSampling, grayscale, isProtected,
- attachGainmap, captureResults, displayState, layers);
+ attachGainmap, captureResults, displayState, layers, layerFEs);
if (captureResults.capturedHdrLayers && attachGainmap &&
FlagManager::getInstance().true_hdr_screenshots()) {
@@ -7563,7 +7567,7 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::captureScreenshot(
ftl::SharedFuture<FenceResult> hdrRenderFuture =
renderScreenImpl(renderArea.get(), hdrTexture, regionSampling, grayscale,
isProtected, attachGainmap, unusedResults, displayState,
- layers);
+ layers, layerFEs);
renderFuture =
ftl::Future(std::move(renderFuture))
@@ -7619,6 +7623,9 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::captureScreenshotLegacy(
auto takeScreenshotFn = [=, this, renderAreaBuilder = std::move(renderAreaBuilder)]() REQUIRES(
kMainThreadContext) mutable -> ftl::SharedFuture<FenceResult> {
auto layers = getLayerSnapshotsFn();
+ for (auto& [layer, layerFE] : layers) {
+ attachReleaseFenceFutureToLayer(layer, layerFE.get(), ui::INVALID_LAYER_STACK);
+ }
auto displayState = getDisplayStateFromRenderAreaBuilder(renderAreaBuilder);
ScreenCaptureResults captureResults;
@@ -7635,9 +7642,10 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::captureScreenshotLegacy(
return ftl::yield<FenceResult>(base::unexpected(NO_ERROR)).share();
}
+ auto layerFEs = extractLayerFEs(layers);
ftl::SharedFuture<FenceResult> renderFuture =
renderScreenImpl(renderArea.get(), buffer, regionSampling, grayscale, isProtected,
- attachGainmap, captureResults, displayState, layers);
+ attachGainmap, captureResults, displayState, layers, layerFEs);
if (captureListener) {
// Defer blocking on renderFuture back to the Binder thread.
@@ -7670,10 +7678,10 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::renderScreenImpl(
const RenderArea* renderArea, const std::shared_ptr<renderengine::ExternalTexture>& buffer,
bool regionSampling, bool grayscale, bool isProtected, bool attachGainmap,
ScreenCaptureResults& captureResults, std::optional<OutputCompositionState>& displayState,
- std::vector<std::pair<Layer*, sp<LayerFE>>>& layers) {
+ std::vector<std::pair<Layer*, sp<LayerFE>>>& layers, std::vector<sp<LayerFE>>& layerFEs) {
SFTRACE_CALL();
- for (auto& [_, layerFE] : layers) {
+ for (auto& layerFE : layerFEs) {
frontend::LayerSnapshot* snapshot = layerFE->mSnapshot.get();
captureResults.capturedSecureLayers |= (snapshot->isVisible && snapshot->isSecure);
captureResults.capturedHdrLayers |= isHdrLayer(*snapshot);
@@ -7732,32 +7740,29 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::renderScreenImpl(
captureResults.buffer = capturedBuffer->getBuffer();
ui::LayerStack layerStack{ui::DEFAULT_LAYER_STACK};
- if (!layers.empty()) {
- const sp<LayerFE>& layerFE = layers.back().second;
+ if (!layerFEs.empty()) {
+ const sp<LayerFE>& layerFE = layerFEs.back();
layerStack = layerFE->getCompositionState()->outputFilter.layerStack;
}
+ auto copyLayerFEs = [&layerFEs]() {
+ std::vector<sp<compositionengine::LayerFE>> ceLayerFEs;
+ ceLayerFEs.reserve(layerFEs.size());
+ for (const auto& layerFE : layerFEs) {
+ ceLayerFEs.push_back(layerFE);
+ }
+ return ceLayerFEs;
+ };
+
auto present = [this, buffer = capturedBuffer, dataspace = captureResults.capturedDataspace,
sdrWhitePointNits, displayBrightnessNits, grayscale, isProtected,
- layers = std::move(layers), layerStack, regionSampling,
+ layerFEs = copyLayerFEs(), layerStack, regionSampling,
renderArea = std::move(renderArea), renderIntent,
enableLocalTonemapping]() -> FenceResult {
std::unique_ptr<compositionengine::CompositionEngine> compositionEngine =
mFactory.createCompositionEngine();
compositionEngine->setRenderEngine(mRenderEngine.get());
- std::vector<sp<compositionengine::LayerFE>> layerFEs;
- layerFEs.reserve(layers.size());
- for (auto& [layer, layerFE] : layers) {
- // Release fences were not yet added for non-threaded render engine. To avoid
- // deadlocks between main thread and binder threads waiting for the future fence
- // result, fences should be added to layers in the same hop onto the main thread.
- if (!mRenderEngine->isThreaded()) {
- attachReleaseFenceFutureToLayer(layer, layerFE.get(), ui::INVALID_LAYER_STACK);
- }
- layerFEs.push_back(layerFE);
- }
-
compositionengine::Output::ColorProfile colorProfile{.dataspace = dataspace,
.renderIntent = renderIntent};
@@ -7816,10 +7821,8 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::renderScreenImpl(
// TODO(b/196334700) Once we use RenderEngineThreaded everywhere we can always defer the call
// to CompositionEngine::present.
ftl::SharedFuture<FenceResult> presentFuture;
- if (FlagManager::getInstance().single_hop_screenshot()) {
- presentFuture = mRenderEngine->isThreaded()
- ? ftl::yield(present()).share()
- : mScheduler->schedule(std::move(present)).share();
+ if (FlagManager::getInstance().single_hop_screenshot() && mRenderEngine->isThreaded()) {
+ presentFuture = ftl::yield(present()).share();
} else {
presentFuture = mRenderEngine->isThreaded() ? ftl::defer(std::move(present)).share()
: ftl::yield(present()).share();
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 835cb572b4..1df78acbf9 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -861,14 +861,13 @@ private:
void attachReleaseFenceFutureToLayer(Layer* layer, LayerFE* layerFE, ui::LayerStack layerStack);
// Checks if a protected layer exists in a list of layers.
- bool layersHasProtectedLayer(const std::vector<std::pair<Layer*, sp<LayerFE>>>& layers) const;
+ bool layersHasProtectedLayer(const std::vector<sp<LayerFE>>& layers) const;
using OutputCompositionState = compositionengine::impl::OutputCompositionState;
std::optional<OutputCompositionState> getSnapshotsFromMainThread(
RenderAreaBuilderVariant& renderAreaBuilder,
- GetLayerSnapshotsFunction getLayerSnapshotsFn,
- std::vector<std::pair<Layer*, sp<LayerFE>>>& layers);
+ GetLayerSnapshotsFunction getLayerSnapshotsFn, std::vector<sp<LayerFE>>& layerFEs);
void captureScreenCommon(RenderAreaBuilderVariant, GetLayerSnapshotsFunction,
ui::Size bufferSize, ui::PixelFormat, bool allowProtected,
@@ -877,13 +876,19 @@ private:
std::optional<OutputCompositionState> getDisplayStateFromRenderAreaBuilder(
RenderAreaBuilderVariant& renderAreaBuilder) REQUIRES(kMainThreadContext);
+ // Legacy layer raw pointer is not safe to access outside the main thread.
+ // Creates a new vector consisting only of LayerFEs, which can be safely
+ // accessed outside the main thread.
+ std::vector<sp<LayerFE>> extractLayerFEs(
+ const std::vector<std::pair<Layer*, sp<LayerFE>>>& layers) const;
+
ftl::SharedFuture<FenceResult> captureScreenshot(
const RenderAreaBuilderVariant& renderAreaBuilder,
const std::shared_ptr<renderengine::ExternalTexture>& buffer, bool regionSampling,
bool grayscale, bool isProtected, bool attachGainmap,
const sp<IScreenCaptureListener>& captureListener,
std::optional<OutputCompositionState>& displayState,
- std::vector<std::pair<Layer*, sp<LayerFE>>>& layers);
+ std::vector<sp<LayerFE>>& layerFEs);
ftl::SharedFuture<FenceResult> captureScreenshotLegacy(
RenderAreaBuilderVariant, GetLayerSnapshotsFunction,
@@ -895,7 +900,8 @@ private:
const RenderArea*, const std::shared_ptr<renderengine::ExternalTexture>&,
bool regionSampling, bool grayscale, bool isProtected, bool attachGainmap,
ScreenCaptureResults&, std::optional<OutputCompositionState>& displayState,
- std::vector<std::pair<Layer*, sp<LayerFE>>>& layers);
+ std::vector<std::pair<Layer*, sp<LayerFE>>>& layers,
+ std::vector<sp<LayerFE>>& layerFEs);
void readPersistentProperties();
diff --git a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
index fd8bc0d22d..2ba739b462 100644
--- a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
+++ b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
@@ -472,11 +472,12 @@ public:
ScreenCaptureResults captureResults;
auto displayState = std::optional{display->getCompositionDisplay()->getState()};
auto layers = getLayerSnapshotsFn();
+ auto layerFEs = mFlinger->extractLayerFEs(layers);
return mFlinger->renderScreenImpl(renderArea.get(), buffer, regionSampling,
false /* grayscale */, false /* isProtected */,
false /* attachGainmap */, captureResults, displayState,
- layers);
+ layers, layerFEs);
}
auto getLayerSnapshotsForScreenshotsFn(ui::LayerStack layerStack, uint32_t uid) {
--
2.48.1

View file

@ -1,755 +0,0 @@
From c2edb476e76d96dc48ed0f5b46367d1b0137e8b7 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Sun, 16 Mar 2025 13:24:30 -0400
Subject: [PATCH 6/7] Revert "Remove release fence flags"
This reverts commit 0077fde3aba6f2bde4e878f88c0dd466350fc1b1.
Change-Id: I04eb5f0a45cc63e55b6b74f2327d182cd9f15098
---
.../src/CompositionEngine.cpp | 32 +++--
.../CompositionEngine/src/Output.cpp | 15 +-
.../tests/CompositionEngineTest.cpp | 5 +
.../CompositionEngine/tests/OutputTest.cpp | 134 ++++++++++++++++++
services/surfaceflinger/Layer.cpp | 59 +++++++-
services/surfaceflinger/Layer.h | 16 +++
services/surfaceflinger/LayerFE.cpp | 4 +-
.../surfaceflinger/RegionSamplingThread.cpp | 2 +-
services/surfaceflinger/SurfaceFlinger.cpp | 123 +++++++++++-----
.../TransactionCallbackInvoker.cpp | 11 +-
.../TransactionCallbackInvoker.h | 1 +
.../surfaceflinger/common/FlagManager.cpp | 4 +
.../common/include/common/FlagManager.h | 2 +
.../tests/TransactionTestHarnesses.h | 15 +-
14 files changed, 364 insertions(+), 59 deletions(-)
diff --git a/services/surfaceflinger/CompositionEngine/src/CompositionEngine.cpp b/services/surfaceflinger/CompositionEngine/src/CompositionEngine.cpp
index cfcce473a2..5c5d0cd74d 100644
--- a/services/surfaceflinger/CompositionEngine/src/CompositionEngine.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/CompositionEngine.cpp
@@ -198,23 +198,25 @@ void CompositionEngine::preComposition(CompositionRefreshArgs& args) {
// these buffers and fire a NO_FENCE to release it. This ensures that all
// promises for buffer releases are fulfilled at the end of composition.
void CompositionEngine::postComposition(CompositionRefreshArgs& args) {
- SFTRACE_CALL();
- ALOGV(__FUNCTION__);
-
- for (auto& layerFE : args.layers) {
- if (layerFE->getReleaseFencePromiseStatus() ==
- LayerFE::ReleaseFencePromiseStatus::INITIALIZED) {
- layerFE->setReleaseFence(Fence::NO_FENCE);
+ if (FlagManager::getInstance().ce_fence_promise()) {
+ SFTRACE_CALL();
+ ALOGV(__FUNCTION__);
+
+ for (auto& layerFE : args.layers) {
+ if (layerFE->getReleaseFencePromiseStatus() ==
+ LayerFE::ReleaseFencePromiseStatus::INITIALIZED) {
+ layerFE->setReleaseFence(Fence::NO_FENCE);
+ }
}
- }
- // List of layersWithQueuedFrames does not necessarily overlap with
- // list of layers, so those layersWithQueuedFrames also need any
- // unfulfilled promises to be resolved for completeness.
- for (auto& layerFE : args.layersWithQueuedFrames) {
- if (layerFE->getReleaseFencePromiseStatus() ==
- LayerFE::ReleaseFencePromiseStatus::INITIALIZED) {
- layerFE->setReleaseFence(Fence::NO_FENCE);
+ // List of layersWithQueuedFrames does not necessarily overlap with
+ // list of layers, so those layersWithQueuedFrames also need any
+ // unfulfilled promises to be resolved for completeness.
+ for (auto& layerFE : args.layersWithQueuedFrames) {
+ if (layerFE->getReleaseFencePromiseStatus() ==
+ LayerFE::ReleaseFencePromiseStatus::INITIALIZED) {
+ layerFE->setReleaseFence(Fence::NO_FENCE);
+ }
}
}
}
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index f9ed92d1ee..34773de107 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -1664,7 +1664,13 @@ void Output::presentFrameAndReleaseLayers(bool flushEvenWhenDisabled) {
releaseFence =
Fence::merge("LayerRelease", releaseFence, frame.clientTargetAcquireFence);
}
- layer->getLayerFE().setReleaseFence(releaseFence);
+ if (FlagManager::getInstance().ce_fence_promise()) {
+ layer->getLayerFE().setReleaseFence(releaseFence);
+ } else {
+ layer->getLayerFE()
+ .onLayerDisplayed(ftl::yield<FenceResult>(std::move(releaseFence)).share(),
+ outputState.layerFilter.layerStack);
+ }
}
// We've got a list of layers needing fences, that are disjoint with
@@ -1672,7 +1678,12 @@ void Output::presentFrameAndReleaseLayers(bool flushEvenWhenDisabled) {
// supply them with the present fence.
for (auto& weakLayer : mReleasedLayers) {
if (const auto layer = weakLayer.promote()) {
- layer->setReleaseFence(frame.presentFence);
+ if (FlagManager::getInstance().ce_fence_promise()) {
+ layer->setReleaseFence(frame.presentFence);
+ } else {
+ layer->onLayerDisplayed(ftl::yield<FenceResult>(frame.presentFence).share(),
+ outputState.layerFilter.layerStack);
+ }
}
}
diff --git a/services/surfaceflinger/CompositionEngine/tests/CompositionEngineTest.cpp b/services/surfaceflinger/CompositionEngine/tests/CompositionEngineTest.cpp
index 3e0c390a5d..deb90deaf7 100644
--- a/services/surfaceflinger/CompositionEngine/tests/CompositionEngineTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/CompositionEngineTest.cpp
@@ -29,6 +29,8 @@
#include "TimeStats/TimeStats.h"
#include "mock/DisplayHardware/MockHWComposer.h"
+#include <variant>
+
using namespace com::android::graphics::surfaceflinger;
namespace android::compositionengine {
@@ -491,6 +493,9 @@ struct CompositionEnginePostCompositionTest : public CompositionEngineTest {
};
TEST_F(CompositionEnginePostCompositionTest, postCompositionReleasesAllFences) {
+ SET_FLAG_FOR_TEST(com::android::graphics::surfaceflinger::flags::ce_fence_promise, true);
+ ASSERT_TRUE(FlagManager::getInstance().ce_fence_promise());
+
EXPECT_CALL(*mLayer1FE, getReleaseFencePromiseStatus)
.WillOnce(Return(LayerFE::ReleaseFencePromiseStatus::FULFILLED));
EXPECT_CALL(*mLayer2FE, getReleaseFencePromiseStatus)
diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
index 442b603ca0..eb7f0ddc37 100644
--- a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp
@@ -35,6 +35,7 @@
#include <ui/Rect.h>
#include <ui/Region.h>
+#include <cmath>
#include <cstdint>
#include <variant>
@@ -3289,9 +3290,57 @@ TEST_F(OutputPostFramebufferTest, ifEnabledMustFlipThenPresentThenSendPresentCom
mOutput.presentFrameAndReleaseLayers(kFlushEvenWhenDisabled);
}
+TEST_F(OutputPostFramebufferTest, releaseFencesAreSentToLayerFE) {
+ SET_FLAG_FOR_TEST(com::android::graphics::surfaceflinger::flags::ce_fence_promise, false);
+ ASSERT_FALSE(FlagManager::getInstance().ce_fence_promise());
+ // Simulate getting release fences from each layer, and ensure they are passed to the
+ // front-end layer interface for each layer correctly.
+
+ mOutput.mState.isEnabled = true;
+
+ // Create three unique fence instances
+ sp<Fence> layer1Fence = sp<Fence>::make();
+ sp<Fence> layer2Fence = sp<Fence>::make();
+ sp<Fence> layer3Fence = sp<Fence>::make();
+
+ Output::FrameFences frameFences;
+ frameFences.layerFences.emplace(&mLayer1.hwc2Layer, layer1Fence);
+ frameFences.layerFences.emplace(&mLayer2.hwc2Layer, layer2Fence);
+ frameFences.layerFences.emplace(&mLayer3.hwc2Layer, layer3Fence);
+
+ EXPECT_CALL(mOutput, presentFrame()).WillOnce(Return(frameFences));
+ EXPECT_CALL(*mRenderSurface, onPresentDisplayCompleted());
+
+ // Compare the pointers values of each fence to make sure the correct ones
+ // are passed. This happens to work with the current implementation, but
+ // would not survive certain calls like Fence::merge() which would return a
+ // new instance.
+ EXPECT_CALL(*mLayer1.layerFE, onLayerDisplayed(_, _))
+ .WillOnce([&layer1Fence](ftl::SharedFuture<FenceResult> futureFenceResult,
+ ui::LayerStack) {
+ EXPECT_EQ(FenceResult(layer1Fence), futureFenceResult.get());
+ });
+ EXPECT_CALL(*mLayer2.layerFE, onLayerDisplayed(_, _))
+ .WillOnce([&layer2Fence](ftl::SharedFuture<FenceResult> futureFenceResult,
+ ui::LayerStack) {
+ EXPECT_EQ(FenceResult(layer2Fence), futureFenceResult.get());
+ });
+ EXPECT_CALL(*mLayer3.layerFE, onLayerDisplayed(_, _))
+ .WillOnce([&layer3Fence](ftl::SharedFuture<FenceResult> futureFenceResult,
+ ui::LayerStack) {
+ EXPECT_EQ(FenceResult(layer3Fence), futureFenceResult.get());
+ });
+
+ constexpr bool kFlushEvenWhenDisabled = false;
+ mOutput.presentFrameAndReleaseLayers(kFlushEvenWhenDisabled);
+}
+
TEST_F(OutputPostFramebufferTest, releaseFencesAreSetInLayerFE) {
+ SET_FLAG_FOR_TEST(com::android::graphics::surfaceflinger::flags::ce_fence_promise, true);
+ ASSERT_TRUE(FlagManager::getInstance().ce_fence_promise());
// Simulate getting release fences from each layer, and ensure they are passed to the
// front-end layer interface for each layer correctly.
+
mOutput.mState.isEnabled = true;
// Create three unique fence instances
@@ -3328,7 +3377,37 @@ TEST_F(OutputPostFramebufferTest, releaseFencesAreSetInLayerFE) {
mOutput.presentFrameAndReleaseLayers(kFlushEvenWhenDisabled);
}
+TEST_F(OutputPostFramebufferTest, releaseFencesIncludeClientTargetAcquireFence) {
+ SET_FLAG_FOR_TEST(com::android::graphics::surfaceflinger::flags::ce_fence_promise, false);
+ ASSERT_FALSE(FlagManager::getInstance().ce_fence_promise());
+
+ mOutput.mState.isEnabled = true;
+ mOutput.mState.usesClientComposition = true;
+
+ Output::FrameFences frameFences;
+ frameFences.clientTargetAcquireFence = sp<Fence>::make();
+ frameFences.layerFences.emplace(&mLayer1.hwc2Layer, sp<Fence>::make());
+ frameFences.layerFences.emplace(&mLayer2.hwc2Layer, sp<Fence>::make());
+ frameFences.layerFences.emplace(&mLayer3.hwc2Layer, sp<Fence>::make());
+
+ EXPECT_CALL(mOutput, presentFrame()).WillOnce(Return(frameFences));
+ EXPECT_CALL(*mRenderSurface, onPresentDisplayCompleted());
+
+ // Fence::merge is called, and since none of the fences are actually valid,
+ // Fence::NO_FENCE is returned and passed to each onLayerDisplayed() call.
+ // This is the best we can do without creating a real kernel fence object.
+ EXPECT_CALL(*mLayer1.layerFE, onLayerDisplayed).WillOnce(Return());
+ EXPECT_CALL(*mLayer2.layerFE, onLayerDisplayed).WillOnce(Return());
+ EXPECT_CALL(*mLayer3.layerFE, onLayerDisplayed).WillOnce(Return());
+
+ constexpr bool kFlushEvenWhenDisabled = false;
+ mOutput.presentFrameAndReleaseLayers(kFlushEvenWhenDisabled);
+}
+
TEST_F(OutputPostFramebufferTest, setReleaseFencesIncludeClientTargetAcquireFence) {
+ SET_FLAG_FOR_TEST(com::android::graphics::surfaceflinger::flags::ce_fence_promise, true);
+ ASSERT_TRUE(FlagManager::getInstance().ce_fence_promise());
+
mOutput.mState.isEnabled = true;
mOutput.mState.usesClientComposition = true;
@@ -3351,7 +3430,62 @@ TEST_F(OutputPostFramebufferTest, setReleaseFencesIncludeClientTargetAcquireFenc
mOutput.presentFrameAndReleaseLayers(kFlushEvenWhenDisabled);
}
+TEST_F(OutputPostFramebufferTest, releasedLayersSentPresentFence) {
+ SET_FLAG_FOR_TEST(com::android::graphics::surfaceflinger::flags::ce_fence_promise, false);
+ ASSERT_FALSE(FlagManager::getInstance().ce_fence_promise());
+
+ mOutput.mState.isEnabled = true;
+ mOutput.mState.usesClientComposition = true;
+
+ // This should happen even if there are no (current) output layers.
+ EXPECT_CALL(mOutput, getOutputLayerCount()).WillOnce(Return(0u));
+
+ // Load up the released layers with some mock instances
+ sp<StrictMock<mock::LayerFE>> releasedLayer1 = sp<StrictMock<mock::LayerFE>>::make();
+ sp<StrictMock<mock::LayerFE>> releasedLayer2 = sp<StrictMock<mock::LayerFE>>::make();
+ sp<StrictMock<mock::LayerFE>> releasedLayer3 = sp<StrictMock<mock::LayerFE>>::make();
+ Output::ReleasedLayers layers;
+ layers.push_back(releasedLayer1);
+ layers.push_back(releasedLayer2);
+ layers.push_back(releasedLayer3);
+ mOutput.setReleasedLayers(std::move(layers));
+
+ // Set up a fake present fence
+ sp<Fence> presentFence = sp<Fence>::make();
+ Output::FrameFences frameFences;
+ frameFences.presentFence = presentFence;
+
+ EXPECT_CALL(mOutput, presentFrame()).WillOnce(Return(frameFences));
+ EXPECT_CALL(*mRenderSurface, onPresentDisplayCompleted());
+
+ // Each released layer should be given the presentFence.
+ EXPECT_CALL(*releasedLayer1, onLayerDisplayed(_, _))
+ .WillOnce([&presentFence](ftl::SharedFuture<FenceResult> futureFenceResult,
+ ui::LayerStack) {
+ EXPECT_EQ(FenceResult(presentFence), futureFenceResult.get());
+ });
+ EXPECT_CALL(*releasedLayer2, onLayerDisplayed(_, _))
+ .WillOnce([&presentFence](ftl::SharedFuture<FenceResult> futureFenceResult,
+ ui::LayerStack) {
+ EXPECT_EQ(FenceResult(presentFence), futureFenceResult.get());
+ });
+ EXPECT_CALL(*releasedLayer3, onLayerDisplayed(_, _))
+ .WillOnce([&presentFence](ftl::SharedFuture<FenceResult> futureFenceResult,
+ ui::LayerStack) {
+ EXPECT_EQ(FenceResult(presentFence), futureFenceResult.get());
+ });
+
+ constexpr bool kFlushEvenWhenDisabled = false;
+ mOutput.presentFrameAndReleaseLayers(kFlushEvenWhenDisabled);
+
+ // After the call the list of released layers should have been cleared.
+ EXPECT_TRUE(mOutput.getReleasedLayersForTest().empty());
+}
+
TEST_F(OutputPostFramebufferTest, setReleasedLayersSentPresentFence) {
+ SET_FLAG_FOR_TEST(com::android::graphics::surfaceflinger::flags::ce_fence_promise, true);
+ ASSERT_TRUE(FlagManager::getInstance().ce_fence_promise());
+
mOutput.mState.isEnabled = true;
mOutput.mState.usesClientComposition = true;
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 195461f47e..a8e60f1632 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -805,6 +805,54 @@ void Layer::prepareReleaseCallbacks(ftl::Future<FenceResult> futureFenceResult,
}
}
+void Layer::onLayerDisplayed(ftl::SharedFuture<FenceResult> futureFenceResult,
+ ui::LayerStack layerStack,
+ std::function<FenceResult(FenceResult)>&& continuation) {
+ sp<CallbackHandle> ch = findCallbackHandle();
+
+ if (!FlagManager::getInstance().screenshot_fence_preservation() && continuation) {
+ futureFenceResult = ftl::Future(futureFenceResult).then(std::move(continuation)).share();
+ }
+
+ if (ch != nullptr) {
+ ch->previousReleaseCallbackId = mPreviousReleaseCallbackId;
+ ch->previousSharedReleaseFences.emplace_back(std::move(futureFenceResult));
+ ch->name = mName;
+ } else if (FlagManager::getInstance().screenshot_fence_preservation()) {
+ // If we didn't get a release callback yet, e.g. some scenarios when capturing screenshots
+ // asynchronously, then make sure we don't drop the fence.
+ mPreviousReleaseFenceAndContinuations.emplace_back(std::move(futureFenceResult),
+ std::move(continuation));
+ std::vector<FenceAndContinuation> mergedFences;
+ sp<Fence> prevFence = nullptr;
+ // For a layer that's frequently screenshotted, try to merge fences to make sure we don't
+ // grow unbounded.
+ for (const auto& futureAndContinuation : mPreviousReleaseFenceAndContinuations) {
+ auto result = futureAndContinuation.future.wait_for(0s);
+ if (result != std::future_status::ready) {
+ mergedFences.emplace_back(futureAndContinuation);
+ continue;
+ }
+
+ mergeFence(getDebugName(),
+ futureAndContinuation.chain().get().value_or(Fence::NO_FENCE), prevFence);
+ }
+ if (prevFence != nullptr) {
+ mergedFences.emplace_back(ftl::yield(FenceResult(std::move(prevFence))).share());
+ }
+
+ mPreviousReleaseFenceAndContinuations.swap(mergedFences);
+ }
+
+ if (mBufferInfo.mBuffer) {
+ mPreviouslyPresentedLayerStacks.push_back(layerStack);
+ }
+
+ if (mDrawingState.frameNumber > 0) {
+ mDrawingState.previousFrameNumber = mDrawingState.frameNumber;
+ }
+}
+
void Layer::releasePendingBuffer(nsecs_t dequeueReadyTime) {
for (const auto& handle : mDrawingState.callbackHandles) {
handle->bufferReleaseChannel = mBufferReleaseChannel;
@@ -1117,13 +1165,22 @@ bool Layer::setTransactionCompletedListeners(const std::vector<sp<CallbackHandle
handle->acquireTimeOrFence = mCallbackHandleAcquireTimeOrFence;
handle->frameNumber = mDrawingState.frameNumber;
handle->previousFrameNumber = mDrawingState.previousFrameNumber;
- if (mPreviousReleaseBufferEndpoint == handle->listener) {
+ if (FlagManager::getInstance().ce_fence_promise() &&
+ mPreviousReleaseBufferEndpoint == handle->listener) {
// Add fence from previous screenshot now so that it can be dispatched to the
// client.
for (auto& [_, future] : mAdditionalPreviousReleaseFences) {
handle->previousReleaseFences.emplace_back(std::move(future));
}
mAdditionalPreviousReleaseFences.clear();
+ } else if (FlagManager::getInstance().screenshot_fence_preservation() &&
+ mPreviousReleaseBufferEndpoint == handle->listener) {
+ // Add fences from previous screenshots now so that they can be dispatched to the
+ // client.
+ for (const auto& futureAndContinution : mPreviousReleaseFenceAndContinuations) {
+ handle->previousSharedReleaseFences.emplace_back(futureAndContinution.chain());
+ }
+ mPreviousReleaseFenceAndContinuations.clear();
}
// Store so latched time and release fence can be set
mDrawingState.callbackHandles.push_back(handle);
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index c234a75693..c4ffe1ef2d 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -261,6 +261,8 @@ public:
bool fenceHasSignaled() const;
void onPreComposition(nsecs_t refreshStartTime);
+ void onLayerDisplayed(ftl::SharedFuture<FenceResult>, ui::LayerStack layerStack,
+ std::function<FenceResult(FenceResult)>&& continuation = nullptr);
// Tracks mLastClientCompositionFence and gets the callback handle for this layer.
sp<CallbackHandle> findCallbackHandle();
@@ -389,6 +391,20 @@ public:
// from the layer.
std::vector<ui::LayerStack> mPreviouslyPresentedLayerStacks;
+ struct FenceAndContinuation {
+ ftl::SharedFuture<FenceResult> future;
+ std::function<FenceResult(FenceResult)> continuation;
+
+ ftl::SharedFuture<FenceResult> chain() const {
+ if (continuation) {
+ return ftl::Future(future).then(continuation).share();
+ } else {
+ return future;
+ }
+ }
+ };
+ std::vector<FenceAndContinuation> mPreviousReleaseFenceAndContinuations;
+
// Release fences for buffers that have not yet received a release
// callback. A release callback may not be given when capturing
// screenshots asynchronously. There may be no buffer update for the
diff --git a/services/surfaceflinger/LayerFE.cpp b/services/surfaceflinger/LayerFE.cpp
index fea7671af2..de64b271f5 100644
--- a/services/surfaceflinger/LayerFE.cpp
+++ b/services/surfaceflinger/LayerFE.cpp
@@ -26,6 +26,7 @@
#include "LayerFE.h"
#include "SurfaceFlinger.h"
+#include "common/FlagManager.h"
#include "ui/FenceResult.h"
namespace android {
@@ -82,7 +83,8 @@ LayerFE::~LayerFE() {
// Ensures that no promise is left unfulfilled before the LayerFE is destroyed.
// An unfulfilled promise could occur when a screenshot is attempted, but the
// render area is invalid and there is no memory for the capture result.
- if (mReleaseFencePromiseStatus == ReleaseFencePromiseStatus::INITIALIZED) {
+ if (FlagManager::getInstance().ce_fence_promise() &&
+ mReleaseFencePromiseStatus == ReleaseFencePromiseStatus::INITIALIZED) {
setReleaseFence(Fence::NO_FENCE);
}
}
diff --git a/services/surfaceflinger/RegionSamplingThread.cpp b/services/surfaceflinger/RegionSamplingThread.cpp
index 011fd9e20a..06c2f26a6d 100644
--- a/services/surfaceflinger/RegionSamplingThread.cpp
+++ b/services/surfaceflinger/RegionSamplingThread.cpp
@@ -355,7 +355,7 @@ void RegionSamplingThread::captureSample() {
FenceResult fenceResult;
if (FlagManager::getInstance().single_hop_screenshot() &&
- mFlinger.mRenderEngine->isThreaded()) {
+ FlagManager::getInstance().ce_fence_promise() && mFlinger.mRenderEngine->isThreaded()) {
std::vector<sp<LayerFE>> layerFEs;
auto displayState = mFlinger.getSnapshotsFromMainThread(renderAreaBuilder,
getLayerSnapshotsFn, layerFEs);
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 067a8bafe0..47a3c2c2bf 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2820,6 +2820,16 @@ CompositeResultsPerDisplay SurfaceFlinger::composite(
compositionengine::Feature::kSnapshotLayerMetadata);
refreshArgs.bufferIdsToUncache = std::move(mBufferIdsToUncache);
+
+ if (!FlagManager::getInstance().ce_fence_promise()) {
+ refreshArgs.layersWithQueuedFrames.reserve(mLayersWithQueuedFrames.size());
+ for (auto& [layer, _] : mLayersWithQueuedFrames) {
+ if (const auto& layerFE = layer->getCompositionEngineLayerFE(
+ {static_cast<uint32_t>(layer->sequence)}))
+ refreshArgs.layersWithQueuedFrames.push_back(layerFE);
+ }
+ }
+
refreshArgs.outputColorSetting = mDisplayColorSetting;
refreshArgs.forceOutputColorMode = mForceColorMode;
@@ -2883,38 +2893,54 @@ CompositeResultsPerDisplay SurfaceFlinger::composite(
layer->onPreComposition(refreshArgs.refreshStartTime);
}
- for (auto& [layer, layerFE] : layers) {
- attachReleaseFenceFutureToLayer(layer, layerFE,
- layerFE->mSnapshot->outputFilter.layerStack);
- }
-
- refreshArgs.layersWithQueuedFrames.reserve(mLayersWithQueuedFrames.size());
- for (auto& [layer, _] : mLayersWithQueuedFrames) {
- if (const auto& layerFE =
- layer->getCompositionEngineLayerFE({static_cast<uint32_t>(layer->sequence)})) {
- refreshArgs.layersWithQueuedFrames.push_back(layerFE);
- // Some layers are not displayed and do not yet have a future release fence
- if (layerFE->getReleaseFencePromiseStatus() ==
- LayerFE::ReleaseFencePromiseStatus::UNINITIALIZED ||
- layerFE->getReleaseFencePromiseStatus() ==
- LayerFE::ReleaseFencePromiseStatus::FULFILLED) {
- // layerStack is invalid because layer is not on a display
- attachReleaseFenceFutureToLayer(layer.get(), layerFE.get(),
- ui::INVALID_LAYER_STACK);
+ if (FlagManager::getInstance().ce_fence_promise()) {
+ for (auto& [layer, layerFE] : layers) {
+ attachReleaseFenceFutureToLayer(layer, layerFE,
+ layerFE->mSnapshot->outputFilter.layerStack);
+ }
+
+ refreshArgs.layersWithQueuedFrames.reserve(mLayersWithQueuedFrames.size());
+ for (auto& [layer, _] : mLayersWithQueuedFrames) {
+ if (const auto& layerFE = layer->getCompositionEngineLayerFE(
+ {static_cast<uint32_t>(layer->sequence)})) {
+ refreshArgs.layersWithQueuedFrames.push_back(layerFE);
+ // Some layers are not displayed and do not yet have a future release fence
+ if (layerFE->getReleaseFencePromiseStatus() ==
+ LayerFE::ReleaseFencePromiseStatus::UNINITIALIZED ||
+ layerFE->getReleaseFencePromiseStatus() ==
+ LayerFE::ReleaseFencePromiseStatus::FULFILLED) {
+ // layerStack is invalid because layer is not on a display
+ attachReleaseFenceFutureToLayer(layer.get(), layerFE.get(),
+ ui::INVALID_LAYER_STACK);
+ }
}
}
- }
- mCompositionEngine->present(refreshArgs);
- moveSnapshotsFromCompositionArgs(refreshArgs, layers);
+ mCompositionEngine->present(refreshArgs);
+ moveSnapshotsFromCompositionArgs(refreshArgs, layers);
- for (auto& [layer, layerFE] : layers) {
- CompositionResult compositionResult{layerFE->stealCompositionResult()};
- if (compositionResult.lastClientCompositionFence) {
- layer->setWasClientComposed(compositionResult.lastClientCompositionFence);
+ for (auto& [layer, layerFE] : layers) {
+ CompositionResult compositionResult{layerFE->stealCompositionResult()};
+ if (compositionResult.lastClientCompositionFence) {
+ layer->setWasClientComposed(compositionResult.lastClientCompositionFence);
+ }
}
- if (com_android_graphics_libgui_flags_apply_picture_profiles()) {
- mActivePictureUpdater.onLayerComposed(*layer, *layerFE, compositionResult);
+
+ } else {
+ mCompositionEngine->present(refreshArgs);
+ moveSnapshotsFromCompositionArgs(refreshArgs, layers);
+
+ for (auto [layer, layerFE] : layers) {
+ CompositionResult compositionResult{layerFE->stealCompositionResult()};
+ for (auto& [releaseFence, layerStack] : compositionResult.releaseFences) {
+ layer->onLayerDisplayed(std::move(releaseFence), layerStack);
+ }
+ if (compositionResult.lastClientCompositionFence) {
+ layer->setWasClientComposed(compositionResult.lastClientCompositionFence);
+ }
+ if (com_android_graphics_libgui_flags_apply_picture_profiles()) {
+ mActivePictureUpdater.onLayerComposed(*layer, *layerFE, compositionResult);
+ }
}
}
@@ -3196,8 +3222,13 @@ void SurfaceFlinger::onCompositionPresented(PhysicalDisplayId pacesetterId,
auto optDisplay = layerStackToDisplay.get(layerStack);
if (optDisplay && !optDisplay->get()->isVirtual()) {
auto fence = getHwComposer().getPresentFence(optDisplay->get()->getPhysicalId());
- layer->prepareReleaseCallbacks(ftl::yield<FenceResult>(fence),
- ui::INVALID_LAYER_STACK);
+ if (FlagManager::getInstance().ce_fence_promise()) {
+ layer->prepareReleaseCallbacks(ftl::yield<FenceResult>(fence),
+ ui::INVALID_LAYER_STACK);
+ } else {
+ layer->onLayerDisplayed(ftl::yield<FenceResult>(fence).share(),
+ ui::INVALID_LAYER_STACK);
+ }
}
}
layer->releasePendingBuffer(presentTime.ns());
@@ -7382,7 +7413,8 @@ void SurfaceFlinger::captureScreenCommon(RenderAreaBuilderVariant renderAreaBuil
return;
}
- if (FlagManager::getInstance().single_hop_screenshot() && mRenderEngine->isThreaded()) {
+ if (FlagManager::getInstance().single_hop_screenshot() &&
+ FlagManager::getInstance().ce_fence_promise() && mRenderEngine->isThreaded()) {
std::vector<sp<LayerFE>> layerFEs;
auto displayState =
getSnapshotsFromMainThread(renderAreaBuilder, getLayerSnapshotsFn, layerFEs);
@@ -7623,8 +7655,10 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::captureScreenshotLegacy(
auto takeScreenshotFn = [=, this, renderAreaBuilder = std::move(renderAreaBuilder)]() REQUIRES(
kMainThreadContext) mutable -> ftl::SharedFuture<FenceResult> {
auto layers = getLayerSnapshotsFn();
- for (auto& [layer, layerFE] : layers) {
- attachReleaseFenceFutureToLayer(layer, layerFE.get(), ui::INVALID_LAYER_STACK);
+ if (FlagManager::getInstance().ce_fence_promise()) {
+ for (auto& [layer, layerFE] : layers) {
+ attachReleaseFenceFutureToLayer(layer, layerFE.get(), ui::INVALID_LAYER_STACK);
+ }
}
auto displayState = getDisplayStateFromRenderAreaBuilder(renderAreaBuilder);
@@ -7821,13 +7855,36 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::renderScreenImpl(
// TODO(b/196334700) Once we use RenderEngineThreaded everywhere we can always defer the call
// to CompositionEngine::present.
ftl::SharedFuture<FenceResult> presentFuture;
- if (FlagManager::getInstance().single_hop_screenshot() && mRenderEngine->isThreaded()) {
+ if (FlagManager::getInstance().single_hop_screenshot() &&
+ FlagManager::getInstance().ce_fence_promise() && mRenderEngine->isThreaded()) {
presentFuture = ftl::yield(present()).share();
} else {
presentFuture = mRenderEngine->isThreaded() ? ftl::defer(std::move(present)).share()
: ftl::yield(present()).share();
}
+ if (!FlagManager::getInstance().ce_fence_promise()) {
+ for (auto& [layer, layerFE] : layers) {
+ layer->onLayerDisplayed(presentFuture, ui::INVALID_LAYER_STACK,
+ [layerFE = std::move(layerFE)](FenceResult) {
+ if (FlagManager::getInstance()
+ .screenshot_fence_preservation()) {
+ const auto compositionResult =
+ layerFE->stealCompositionResult();
+ const auto& fences = compositionResult.releaseFences;
+ // CompositionEngine may choose to cull layers that
+ // aren't visible, so pass a non-fence.
+ return fences.empty() ? Fence::NO_FENCE
+ : fences.back().first.get();
+ } else {
+ return layerFE->stealCompositionResult()
+ .releaseFences.back()
+ .first.get();
+ }
+ });
+ }
+ }
+
return presentFuture;
}
diff --git a/services/surfaceflinger/TransactionCallbackInvoker.cpp b/services/surfaceflinger/TransactionCallbackInvoker.cpp
index b22ec66819..cc79acbbf5 100644
--- a/services/surfaceflinger/TransactionCallbackInvoker.cpp
+++ b/services/surfaceflinger/TransactionCallbackInvoker.cpp
@@ -28,6 +28,7 @@
#include "Utils/FenceUtils.h"
#include <binder/IInterface.h>
+#include <common/FlagManager.h>
#include <common/trace.h>
#include <utils/RefBase.h>
@@ -126,8 +127,14 @@ status_t TransactionCallbackInvoker::addCallbackHandle(const sp<CallbackHandle>&
if (surfaceControl) {
sp<Fence> prevFence = nullptr;
- for (auto& future : handle->previousReleaseFences) {
- mergeFence(handle->name.c_str(), future.get().value_or(Fence::NO_FENCE), prevFence);
+ if (FlagManager::getInstance().ce_fence_promise()) {
+ for (auto& future : handle->previousReleaseFences) {
+ mergeFence(handle->name.c_str(), future.get().value_or(Fence::NO_FENCE), prevFence);
+ }
+ } else {
+ for (const auto& future : handle->previousSharedReleaseFences) {
+ mergeFence(handle->name.c_str(), future.get().value_or(Fence::NO_FENCE), prevFence);
+ }
}
handle->previousReleaseFence = prevFence;
diff --git a/services/surfaceflinger/TransactionCallbackInvoker.h b/services/surfaceflinger/TransactionCallbackInvoker.h
index 178ddbbe79..9c7bb0d588 100644
--- a/services/surfaceflinger/TransactionCallbackInvoker.h
+++ b/services/surfaceflinger/TransactionCallbackInvoker.h
@@ -43,6 +43,7 @@ public:
std::string name;
sp<Fence> previousReleaseFence;
std::vector<ftl::Future<FenceResult>> previousReleaseFences;
+ std::vector<ftl::SharedFuture<FenceResult>> previousSharedReleaseFences;
std::variant<nsecs_t, sp<Fence>> acquireTimeOrFence = -1;
nsecs_t latchTime = -1;
std::optional<uint32_t> transformHint = std::nullopt;
diff --git a/services/surfaceflinger/common/FlagManager.cpp b/services/surfaceflinger/common/FlagManager.cpp
index 5c417ba748..b86e815b57 100644
--- a/services/surfaceflinger/common/FlagManager.cpp
+++ b/services/surfaceflinger/common/FlagManager.cpp
@@ -167,6 +167,8 @@ void FlagManager::dump(std::string& result) const {
DUMP_ACONFIG_FLAG(begone_bright_hlg);
DUMP_ACONFIG_FLAG(window_blur_kawase2);
DUMP_ACONFIG_FLAG(single_hop_screenshot);
+ DUMP_ACONFIG_FLAG(screenshot_fence_preservation);
+ DUMP_ACONFIG_FLAG(ce_fence_promise);
#undef DUMP_ACONFIG_FLAG
#undef DUMP_LEGACY_SERVER_FLAG
@@ -268,6 +270,8 @@ FLAG_MANAGER_ACONFIG_FLAG(deprecate_frame_tracker, "");
FLAG_MANAGER_ACONFIG_FLAG(skip_invisible_windows_in_input, "");
FLAG_MANAGER_ACONFIG_FLAG(begone_bright_hlg, "debug.sf.begone_bright_hlg");
FLAG_MANAGER_ACONFIG_FLAG(window_blur_kawase2, "");
+FLAG_MANAGER_ACONFIG_FLAG(screenshot_fence_preservation, "debug.sf.screenshot_fence_preservation");
+FLAG_MANAGER_ACONFIG_FLAG(ce_fence_promise, "");
/// Trunk stable server (R/W) flags ///
FLAG_MANAGER_ACONFIG_FLAG(refresh_rate_overlay_on_external_display, "")
diff --git a/services/surfaceflinger/common/include/common/FlagManager.h b/services/surfaceflinger/common/include/common/FlagManager.h
index 15284ba0ee..4766f6be38 100644
--- a/services/surfaceflinger/common/include/common/FlagManager.h
+++ b/services/surfaceflinger/common/include/common/FlagManager.h
@@ -74,6 +74,7 @@ public:
bool fp16_client_target() const;
bool game_default_frame_rate() const;
bool enable_layer_command_batching() const;
+ bool screenshot_fence_preservation() const;
bool vulkan_renderengine() const;
bool vrr_bugfix_24q4() const;
bool vrr_bugfix_dropped_frame() const;
@@ -82,6 +83,7 @@ public:
bool dont_skip_on_early_ro() const;
bool no_vsyncs_on_screen_off() const;
bool protected_if_client() const;
+ bool ce_fence_promise() const;
bool idle_screen_refresh_rate_timeout() const;
bool graphite_renderengine() const;
bool filter_frames_before_trace_starts() const;
diff --git a/services/surfaceflinger/tests/TransactionTestHarnesses.h b/services/surfaceflinger/tests/TransactionTestHarnesses.h
index c95c875746..5899c7e8b6 100644
--- a/services/surfaceflinger/tests/TransactionTestHarnesses.h
+++ b/services/surfaceflinger/tests/TransactionTestHarnesses.h
@@ -17,6 +17,7 @@
#define ANDROID_TRANSACTION_TEST_HARNESSES
#include <com_android_graphics_libgui_flags.h>
+#include <common/FlagManager.h>
#include <ui/DisplayState.h>
#include "LayerTransactionTest.h"
@@ -95,8 +96,12 @@ public:
#endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ)
t.setDisplayProjection(vDisplay, displayState.orientation,
Rect(displayState.layerStackSpaceRect), Rect(resolution));
- t.setDisplayLayerStack(vDisplay, layerStack);
- t.setLayerStack(mirrorSc, layerStack);
+ if (FlagManager::getInstance().ce_fence_promise()) {
+ t.setDisplayLayerStack(vDisplay, layerStack);
+ t.setLayerStack(mirrorSc, layerStack);
+ } else {
+ t.setDisplayLayerStack(vDisplay, ui::DEFAULT_LAYER_STACK);
+ }
t.apply();
SurfaceComposerClient::Transaction().apply(true);
@@ -116,8 +121,10 @@ public:
// CompositionEngine::present may attempt to be called on the same
// display multiple times. The layerStack is set to invalid here so
// that the display is ignored if that scenario occurs.
- t.setLayerStack(mirrorSc, ui::INVALID_LAYER_STACK);
- t.apply(true);
+ if (FlagManager::getInstance().ce_fence_promise()) {
+ t.setLayerStack(mirrorSc, ui::INVALID_LAYER_STACK);
+ t.apply(true);
+ }
SurfaceComposerClient::destroyVirtualDisplay(vDisplay);
return sc;
}
--
2.48.1

View file

@ -1,97 +0,0 @@
From 76923ab930a6fee15aa477bea3638e09fe7b604a Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Sun, 16 Mar 2025 13:25:10 -0400
Subject: [PATCH 7/7] Revert "Remove dead code from LayerFE"
This reverts commit 330571240ff3d44fdbecbe513309d73ba82404e6.
Change-Id: If3af99ec76a8c595dcd1ea22965f2d126d74a315
---
.../CompositionEngine/include/compositionengine/LayerFE.h | 3 +++
.../include/compositionengine/mock/LayerFE.h | 3 +++
services/surfaceflinger/LayerFE.cpp | 6 ++++++
services/surfaceflinger/LayerFE.h | 3 +++
4 files changed, 15 insertions(+)
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFE.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFE.h
index cda4edc216..8199c929e5 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFE.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/LayerFE.h
@@ -148,6 +148,9 @@ public:
virtual std::optional<LayerSettings> prepareClientComposition(
ClientCompositionTargetSettings&) const = 0;
+ // Called after the layer is displayed to update the presentation fence
+ virtual void onLayerDisplayed(ftl::SharedFuture<FenceResult>, ui::LayerStack layerStack) = 0;
+
// Initializes a promise for a buffer release fence and provides the future for that
// fence. This should only be called when a promise has not yet been created, or
// after the previous promise has already been fulfilled. Attempting to call this
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/LayerFE.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/LayerFE.h
index 272fa3eef7..a236ebf180 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/LayerFE.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/LayerFE.h
@@ -50,6 +50,9 @@ public:
std::optional<compositionengine::LayerFE::LayerSettings>(
compositionengine::LayerFE::ClientCompositionTargetSettings&));
+ MOCK_METHOD(void, onLayerDisplayed, (ftl::SharedFuture<FenceResult>, ui::LayerStack),
+ (override));
+
MOCK_METHOD0(createReleaseFenceFuture, ftl::Future<FenceResult>());
MOCK_METHOD1(setReleaseFence, void(const FenceResult&));
MOCK_METHOD0(getReleaseFencePromiseStatus, LayerFE::ReleaseFencePromiseStatus());
diff --git a/services/surfaceflinger/LayerFE.cpp b/services/surfaceflinger/LayerFE.cpp
index de64b271f5..012aa32c30 100644
--- a/services/surfaceflinger/LayerFE.cpp
+++ b/services/surfaceflinger/LayerFE.cpp
@@ -28,6 +28,7 @@
#include "SurfaceFlinger.h"
#include "common/FlagManager.h"
#include "ui/FenceResult.h"
+#include "ui/LayerStack.h"
namespace android {
@@ -355,6 +356,11 @@ CompositionResult LayerFE::stealCompositionResult() {
return result;
}
+void LayerFE::onLayerDisplayed(ftl::SharedFuture<FenceResult> futureFenceResult,
+ ui::LayerStack layerStack) {
+ mCompositionResult.releaseFences.emplace_back(std::move(futureFenceResult), layerStack);
+}
+
const char* LayerFE::getDebugName() const {
return mName.c_str();
}
diff --git a/services/surfaceflinger/LayerFE.h b/services/surfaceflinger/LayerFE.h
index 9483aebafa..ce6d27a91a 100644
--- a/services/surfaceflinger/LayerFE.h
+++ b/services/surfaceflinger/LayerFE.h
@@ -25,12 +25,14 @@
#include "compositionengine/LayerFE.h"
#include "compositionengine/LayerFECompositionState.h"
#include "renderengine/LayerSettings.h"
+#include "ui/LayerStack.h"
#include <ftl/future.h>
namespace android {
struct CompositionResult {
+ std::vector<std::pair<ftl::SharedFuture<FenceResult>, ui::LayerStack>> releaseFences;
sp<Fence> lastClientCompositionFence = nullptr;
bool wasPictureProfileCommitted = false;
// TODO(b/337330263): Why does LayerFE coming from SF have a null composition state?
@@ -46,6 +48,7 @@ public:
// compositionengine::LayerFE overrides
const compositionengine::LayerFECompositionState* getCompositionState() const override;
bool onPreComposition(bool updatingOutputGeometryThisFrame) override;
+ void onLayerDisplayed(ftl::SharedFuture<FenceResult>, ui::LayerStack) override;
const char* getDebugName() const override;
int32_t getSequence() const override;
bool hasRoundedCorners() const override;
--
2.48.1

View file

@ -1,4 +1,4 @@
From 7fc0423bce6be78bf802dcd16e9c3cb2b417c19b Mon Sep 17 00:00:00 2001
From 9f88617d1af3f068efdff111984a7a631464a205 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 14 Nov 2021 13:47:29 -0500
Subject: [PATCH] Pie MTK IMS calls static
@ -10,10 +10,10 @@ Change-Id: I3dd66d436629d37c8ec795df6569736195ae570e
1 file changed, 8 insertions(+)
diff --git a/src/java/com/android/ims/ImsManager.java b/src/java/com/android/ims/ImsManager.java
index 217a26f..b687e4b 100644
index c41426d0..2c6d656f 100644
--- a/src/java/com/android/ims/ImsManager.java
+++ b/src/java/com/android/ims/ImsManager.java
@@ -1679,6 +1679,14 @@ public class ImsManager implements FeatureUpdates {
@@ -1667,6 +1667,14 @@ public class ImsManager implements FeatureUpdates {
}
}
@ -29,5 +29,5 @@ index 217a26f..b687e4b 100644
* Push configuration updates to the ImsService implementation.
*/
--
2.44.0
2.40.0

View file

@ -0,0 +1,45 @@
From 02041484d88e3c8a6cd62e1253f4b12b15be6852 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Mon, 5 Sep 2022 14:02:37 -0400
Subject: [PATCH 1/5] SubscriptionController: Do not override default calling
account from third-party apps
When the user has selected a calling account from a third-party app as
default, it should not be overridden by the rest of the telephony
subsystem (e.g. SIM subcription updates, or default SIM slot selection).
Otherwise, it creates a somewhat annoying situation where the user has
to keep re-selecting the desired calling account after every reboot.
Test: manual
Change-Id: Iccab64e9b3b3ab4773bd8944d47c2006f229d472
---
.../internal/telephony/SubscriptionController.java | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java
index 82799bea8b..5105d3a183 100644
--- a/src/java/com/android/internal/telephony/SubscriptionController.java
+++ b/src/java/com/android/internal/telephony/SubscriptionController.java
@@ -2855,8 +2855,17 @@ public class SubscriptionController extends ISub.Stub {
subId);
TelecomManager telecomManager = mContext.getSystemService(TelecomManager.class);
+ PhoneAccountHandle currentHandle = telecomManager.getUserSelectedOutgoingPhoneAccount();
+ String currentPackageName =
+ currentHandle == null ? null : currentHandle.getComponentName().getPackageName();
+ boolean currentIsSim = "com.android.phone".equals(currentPackageName);
+ // Do not override user selected outgoing calling account
+ // if the user has selected a third-party app as default
+ boolean shouldKeepOutgoingAccount = currentHandle != null && !currentIsSim;
- telecomManager.setUserSelectedOutgoingPhoneAccount(newHandle);
+ if (!shouldKeepOutgoingAccount) {
+ telecomManager.setUserSelectedOutgoingPhoneAccount(newHandle);
+ }
logd("[setDefaultVoiceSubId] requesting change to phoneAccountHandle=" + newHandle);
if (previousDefaultSub != getDefaultSubId()) {
--
2.40.0

View file

@ -1,7 +1,7 @@
From b172f8039cd27e782a964dc905de2efc6f4d84e4 Mon Sep 17 00:00:00 2001
From bcaff4d8a493c657519ae50cf7f3661da6c4a46b Mon Sep 17 00:00:00 2001
From: ironydelerium <42721860+ironydelerium@users.noreply.github.com>
Date: Fri, 31 Dec 2021 02:20:28 -0800
Subject: [PATCH 1/4] Reintroduce 'public void
Subject: [PATCH 2/5] Reintroduce 'public void
TelephonyMetrics.writeRilSendSms(int, int, int, int)'. (#8)
The MediaTek IMS package for Android Q, at the very least (likely for the rest, too)
@ -18,7 +18,7 @@ Co-authored-by: Sarah Vandomelen <sarah@sightworks.com>
1 file changed, 13 insertions(+)
diff --git a/src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java b/src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java
index 3fdbfe0..fb8011c 100644
index 3fdbfe0ed7..fb8011c3df 100644
--- a/src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java
+++ b/src/java/com/android/internal/telephony/metrics/TelephonyMetrics.java
@@ -2320,6 +2320,19 @@ public class TelephonyMetrics {
@ -42,5 +42,5 @@ index 3fdbfe0..fb8011c 100644
* Write Send SMS event using ImsService. Expecting response from
* {@link #writeOnSmsSolicitedResponse}.
--
2.44.0
2.40.0

View file

@ -0,0 +1,53 @@
From 9550951ff96e643d143da826cb9560da572850a1 Mon Sep 17 00:00:00 2001
From: LuK1337 <priv.luk@gmail.com>
Date: Fri, 21 Oct 2022 20:55:05 +0200
Subject: [PATCH 3/5] Pass correct value to setPreferredNetworkType() for RIL
version < 1.4
Change-Id: Id14be66a2ea4e85b6504bc03fd7d2f038185c17d
---
src/java/com/android/internal/telephony/RIL.java | 3 ++-
.../com/android/internal/telephony/RadioNetworkProxy.java | 5 +++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/java/com/android/internal/telephony/RIL.java b/src/java/com/android/internal/telephony/RIL.java
index 6de66527e1..0c1b7cdf8c 100644
--- a/src/java/com/android/internal/telephony/RIL.java
+++ b/src/java/com/android/internal/telephony/RIL.java
@@ -2879,7 +2879,8 @@ public class RIL extends BaseCommands implements CommandsInterface {
mMetrics.writeSetPreferredNetworkType(mPhoneId, networkType);
try {
- networkProxy.setPreferredNetworkTypeBitmap(rr.mSerial, mAllowedNetworkTypesBitmask);
+ networkProxy.setPreferredNetworkTypeBitmap(
+ rr.mSerial, mAllowedNetworkTypesBitmask, networkType);
} catch (RemoteException | RuntimeException e) {
handleRadioProxyExceptionForRR(NETWORK_SERVICE, "setPreferredNetworkType", e);
}
diff --git a/src/java/com/android/internal/telephony/RadioNetworkProxy.java b/src/java/com/android/internal/telephony/RadioNetworkProxy.java
index b88103510a..661fa56954 100644
--- a/src/java/com/android/internal/telephony/RadioNetworkProxy.java
+++ b/src/java/com/android/internal/telephony/RadioNetworkProxy.java
@@ -379,16 +379,17 @@ public class RadioNetworkProxy extends RadioServiceProxy {
* Call IRadioNetwork#setPreferredNetworkTypeBitmap
* @param serial Serial number of request
* @param networkTypesBitmask Preferred network types bitmask to set
+ * @param networkType Preferred network type to set for RIL version < 1.4
* @throws RemoteException
*/
- public void setPreferredNetworkTypeBitmap(int serial, int networkTypesBitmask)
+ public void setPreferredNetworkTypeBitmap(int serial, int networkTypesBitmask, int networkType)
throws RemoteException {
if (isEmpty() || mHalVersion.greaterOrEqual(RIL.RADIO_HAL_VERSION_1_6)) return;
if (mHalVersion.greaterOrEqual(RIL.RADIO_HAL_VERSION_1_4)) {
((android.hardware.radio.V1_4.IRadio) mRadioProxy).setPreferredNetworkTypeBitmap(serial,
RILUtils.convertToHalRadioAccessFamily(networkTypesBitmask));
} else {
- mRadioProxy.setPreferredNetworkType(serial, networkTypesBitmask);
+ mRadioProxy.setPreferredNetworkType(serial, networkType);
}
}
--
2.40.0

View file

@ -1,58 +0,0 @@
From f31cd295a7431bdb6c1cc126f32348d7fe84301a Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Mon, 5 Sep 2022 14:02:37 -0400
Subject: [PATCH 3/4] SubscriptionController: Do not override default calling
account from third-party apps
When the user has selected a calling account from a third-party app as
default, it should not be overridden by the rest of the telephony
subsystem (e.g. SIM subcription updates, or default SIM slot selection).
Otherwise, it creates a somewhat annoying situation where the user has
to keep re-selecting the desired calling account after every reboot.
Test: manual
Change-Id: Iccab64e9b3b3ab4773bd8944d47c2006f229d472
---
.../SubscriptionManagerService.java | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java b/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java
index 353493b..9857641 100644
--- a/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java
+++ b/src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java
@@ -86,6 +86,7 @@ import android.util.Base64;
import android.util.EventLog;
import android.util.IndentingPrintWriter;
import android.util.LocalLog;
+import android.util.Log;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
@@ -3268,7 +3269,22 @@ public class SubscriptionManagerService extends ISub.Stub {
TelecomManager telecomManager = mContext.getSystemService(TelecomManager.class);
if (telecomManager != null) {
- telecomManager.setUserSelectedOutgoingPhoneAccount(newHandle);
+ PhoneAccountHandle currentHandle = telecomManager.getUserSelectedOutgoingPhoneAccount();
+ log("[setDefaultVoiceSubId] current phoneAccountHandle=" + currentHandle);
+
+ String currentPackageName =
+ currentHandle == null ? null : currentHandle.getComponentName().getPackageName();
+ boolean currentIsSim = "com.android.phone".equals(currentPackageName);
+ // Do not override user selected outgoing calling account
+ // if the user has selected a third-party app as default
+ boolean shouldKeepOutgoingAccount = currentHandle != null && !currentIsSim;
+
+ if (!shouldKeepOutgoingAccount) {
+ telecomManager.setUserSelectedOutgoingPhoneAccount(newHandle);
+ log("[setDefaultVoiceSubId] change to phoneAccountHandle=" + newHandle);
+ } else {
+ log("[setDefaultVoiceSubId] default phoneAccountHandle not changed.");
+ }
}
updateDefaultSubId();
--
2.44.0

View file

@ -1,7 +1,7 @@
From 0dd5ea9e9e05b4ef9e01d0c9c6a66a25b321791f Mon Sep 17 00:00:00 2001
From c527732943bc02fd434cbecbd07787e2d429023d Mon Sep 17 00:00:00 2001
From: ExactExampl <exactxmpl@pixelexperience.org>
Date: Tue, 11 Oct 2022 12:38:00 +0300
Subject: [PATCH 4/4] Conditionally revert "Block Binder thread until incoming
Subject: [PATCH 4/5] Conditionally revert "Block Binder thread until incoming
call process completes"
* Legacy IMS packages handling incoming calls in such a way that
@ -13,42 +13,45 @@ This conditionally reverts commit 75c3dc9ba272b43971f519caba0382f9871c7d9d.
Change-Id: I55a8f3bbca4a2b9a6bc7511e9fe2d0884a8818e5
---
.../telephony/imsphone/ImsPhoneCallTracker.java | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
.../imsphone/ImsPhoneCallTracker.java | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java b/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
index 26b6e18..c6b3355 100644
index 5968ba6fa1..86034f6fa1 100644
--- a/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
+++ b/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
@@ -70,6 +70,7 @@ import android.os.Registrant;
@@ -50,6 +50,7 @@ import android.os.Registrant;
import android.os.RegistrantList;
import android.os.RemoteException;
import android.os.SystemClock;
+import android.os.SystemProperties;
import android.os.UserHandle;
import android.preference.PreferenceManager;
import android.provider.Settings;
@@ -390,7 +391,19 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
@Nullable
public IImsCallSessionListener onIncomingCall(
@NonNull IImsCallSession c, @Nullable String callId, @Nullable Bundle extras) {
- return executeAndWaitForReturn(()-> processIncomingCall(c, callId, extras));
import android.sysprop.TelephonyProperties;
@@ -322,10 +323,19 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
@Override
public void onIncomingCall(IImsCallSession c, Bundle extras) {
- // we want to ensure we block this binder thread until incoming call setup completes
- // as to avoid race conditions where the ImsService tries to update the state of the
- // call before the listeners have been attached.
- executeAndWait(()-> processIncomingCall(c, extras));
+ final boolean shouldBlockBinderThreadOnIncomingCalls = SystemProperties.getBoolean(
+ "ro.telephony.block_binder_thread_on_incoming_calls", true);
+ if (shouldBlockBinderThreadOnIncomingCalls) {
+ // we want to ensure we block this binder thread until incoming call setup completes
+ // as to avoid race conditions where the ImsService tries to update the state of the
+ // call before the listeners have been attached.
+ return executeAndWaitForReturn(()-> processIncomingCall(c, callId, extras));
+ executeAndWait(()-> processIncomingCall(c, extras));
+ } else {
+ // for legacy IMS we want to avoid blocking the binder thread, otherwise
+ // we end up with half dead incoming calls with unattached call session
+ return TelephonyUtils.runWithCleanCallingIdentity(()-> processIncomingCall(c, callId, extras),
+ TelephonyUtils.runWithCleanCallingIdentity(()-> processIncomingCall(c, extras),
+ mExecutor);
+ }
}
@Override
--
2.44.0
2.40.0

View file

@ -1,7 +1,7 @@
From 7dde5cf40fdf6c8c1d968d8baa9af7cc105e3201 Mon Sep 17 00:00:00 2001
From 53160d33c83afe4f56862c3c12d4b61e2970209b Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 6 Dec 2021 16:28:22 -0500
Subject: [PATCH 2/4] Fix baseband being too long to fit into a 91 chars
Subject: [PATCH 5/5] Fix baseband being too long to fit into a 91 chars
property, preventing telephony subsystem from starting
Change-Id: I1762e4a8cc137626be89f350229d6be162bdaf57
@ -10,10 +10,10 @@ Change-Id: I1762e4a8cc137626be89f350229d6be162bdaf57
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/java/com/android/internal/telephony/GsmCdmaPhone.java b/src/java/com/android/internal/telephony/GsmCdmaPhone.java
index 5d59327..b5f6509 100644
index 76a8d57246..9a72712c59 100644
--- a/src/java/com/android/internal/telephony/GsmCdmaPhone.java
+++ b/src/java/com/android/internal/telephony/GsmCdmaPhone.java
@@ -3448,7 +3448,7 @@ public class GsmCdmaPhone extends Phone {
@@ -3124,7 +3124,7 @@ public class GsmCdmaPhone extends Phone {
String version = (String)ar.result;
if (version != null) {
int length = version.length();
@ -23,5 +23,5 @@ index 5d59327..b5f6509 100644
length <= MAX_VERSION_LEN ? version
: version.substring(length - MAX_VERSION_LEN, length));
--
2.44.0
2.40.0

View file

@ -1,24 +0,0 @@
From 6acc862452fd91732f63afa4a3829d0e249355e0 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Sun, 16 Mar 2025 13:55:53 -0400
Subject: [PATCH 1/2] Stop using resource processor
---
Android.bp | 1 +
1 file changed, 1 insertion(+)
diff --git a/Android.bp b/Android.bp
index 0b368c8e..a2dff379 100644
--- a/Android.bp
+++ b/Android.bp
@@ -5,6 +5,7 @@
android_app {
name: "org.lineageos.platform-res",
+ use_resource_processor: false,
sdk_version: "core_platform",
certificate: "platform",
--
2.48.1

View file

@ -1,133 +0,0 @@
From 6cf57340bf1d906438a112942763c12eb35feb51 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Sun, 16 Mar 2025 13:56:06 -0400
Subject: [PATCH 2/2] Add spninfo / schema
---
lib/SpnInfo.xsd | 47 +++++++++++++++++++++++++++++++++++++
lib/schema/current.txt | 40 +++++++++++++++++++++++++++++++
lib/schema/last_current.txt | 0
lib/schema/last_removed.txt | 0
lib/schema/removed.txt | 1 +
5 files changed, 88 insertions(+)
create mode 100644 lib/SpnInfo.xsd
create mode 100644 lib/schema/current.txt
create mode 100644 lib/schema/last_current.txt
create mode 100644 lib/schema/last_removed.txt
create mode 100644 lib/schema/removed.txt
diff --git a/lib/SpnInfo.xsd b/lib/SpnInfo.xsd
new file mode 100644
index 00000000..d30630dc
--- /dev/null
+++ b/lib/SpnInfo.xsd
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2021 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<xs:schema version="2.0"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="sensitivePNS">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="sensitivePN" maxOccurs="unbounded" type="sensitivePN" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:complexType name="sensitivePN">
+ <xs:sequence>
+ <xs:element name="item" maxOccurs="unbounded" type="item" />
+ </xs:sequence>
+ <xs:attribute name="network" type="xs:string" use="required" />
+ </xs:complexType>
+
+ <xs:complexType name="item">
+ <xs:sequence>
+ <xs:element name="number" type="xs:string" />
+ <xs:element name="name" minOccurs="0" type="xs:string" />
+ <xs:element name="categories" minOccurs="0" type="xs:string" />
+ <xs:element name="languages" minOccurs="0" type="xs:string" />
+ <xs:element name="organization" minOccurs="0" type="xs:string" />
+ <xs:element name="website" minOccurs="0" type="xs:anyURI" />
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
diff --git a/lib/schema/current.txt b/lib/schema/current.txt
new file mode 100644
index 00000000..13e52c67
--- /dev/null
+++ b/lib/schema/current.txt
@@ -0,0 +1,40 @@
+// Signature format: 2.0
+package org.lineageos.lib.phone.spn {
+
+ public class Item {
+ ctor public Item();
+ method public String getCategories();
+ method public String getLanguages();
+ method public String getName();
+ method public String getNumber();
+ method public String getOrganization();
+ method public String getWebsite();
+ method public void setCategories(String);
+ method public void setLanguages(String);
+ method public void setName(String);
+ method public void setNumber(String);
+ method public void setOrganization(String);
+ method public void setWebsite(String);
+ }
+
+ public class SensitivePN {
+ ctor public SensitivePN();
+ method public java.util.List<org.lineageos.lib.phone.spn.Item> getItem();
+ method public String getNetwork();
+ method public void setNetwork(String);
+ }
+
+ public class SensitivePNS {
+ ctor public SensitivePNS();
+ method public java.util.List<org.lineageos.lib.phone.spn.SensitivePN> getSensitivePN();
+ }
+
+ public class XmlParser {
+ ctor public XmlParser();
+ method public static org.lineageos.lib.phone.spn.SensitivePNS read(java.io.InputStream) throws javax.xml.datatype.DatatypeConfigurationException, java.io.IOException, org.xmlpull.v1.XmlPullParserException;
+ method public static String readText(org.xmlpull.v1.XmlPullParser) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
+ method public static void skip(org.xmlpull.v1.XmlPullParser) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
+ }
+
+}
+
diff --git a/lib/schema/last_current.txt b/lib/schema/last_current.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/lib/schema/last_removed.txt b/lib/schema/last_removed.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/lib/schema/removed.txt b/lib/schema/removed.txt
new file mode 100644
index 00000000..d802177e
--- /dev/null
+++ b/lib/schema/removed.txt
@@ -0,0 +1 @@
+// Signature format: 2.0
--
2.48.1

View file

@ -1,24 +0,0 @@
From 4a576ac73698b2232c51a4b6b3c9a21845801136 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Sun, 6 Oct 2024 14:22:49 -0400
Subject: [PATCH 1/3] Downgrade target_sdk_version to 34 for now
---
Android.bp | 1 +
1 file changed, 1 insertion(+)
diff --git a/Android.bp b/Android.bp
index 388f4c00c..498e7c8f0 100644
--- a/Android.bp
+++ b/Android.bp
@@ -207,6 +207,7 @@ android_app {
"java/com/android/voicemail/impl/configui/res",
"java/com/android/voicemail/impl/res",
],
+ target_sdk_version: "34",
sdk_version: "system_current",
srcs: [
"java/**/I*.aidl",
--
2.48.1

View file

@ -1,31 +0,0 @@
From 080c04159988f202694f087f442e3e32f18d4625 Mon Sep 17 00:00:00 2001
From: Jihoon Kang <jihoonkang@google.com>
Date: Fri, 30 Aug 2024 00:29:34 +0000
Subject: [PATCH 2/3] Make java_sdk_library dependencies explicit
modules should specify the submodule of java_sdk_library that the module
actually depends on
Test: CI
Bug: 358613520
Change-Id: I23a22e9d3dc001a5b061177273d407b01bb77a50
---
Android.bp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Android.bp b/Android.bp
index 498e7c8f0..299c1a6e7 100644
--- a/Android.bp
+++ b/Android.bp
@@ -102,7 +102,7 @@ android_app {
exclude_srcs: ["java/com/android/dialer/rootcomponentgenerator/*.java"],
libs: [
"auto_value_annotations",
- "org.apache.http.legacy",
+ "org.apache.http.legacy.stubs.system",
],
optimize: {
proguard_flags_files: [
--
2.48.1

View file

@ -1,24 +0,0 @@
From fa83fab06f1bd59551b926a224e0cf4cdfcb86da Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Sun, 16 Mar 2025 13:51:15 -0400
Subject: [PATCH 3/3] Opt-out from the resource processor (for now)
---
Android.bp | 1 +
1 file changed, 1 insertion(+)
diff --git a/Android.bp b/Android.bp
index 299c1a6e7..b35b8913e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -9,6 +9,7 @@ package {
android_app {
name: "Dialer",
+ use_resource_processor: false,
aaptflags: [
"--auto-add-overlay",
"--extra-packages com.android.contacts.common",
--
2.48.1

View file

@ -1,7 +1,7 @@
From 09d183a632ab5ba6ef0f1f76765fc94ef24035f4 Mon Sep 17 00:00:00 2001
From 8cd54396bbf29cc977497b53c1464a80aea69825 Mon Sep 17 00:00:00 2001
From: Danny Lin <danny@kdrag0n.dev>
Date: Mon, 11 Oct 2021 20:48:44 -0700
Subject: [PATCH 1/3] Expose themed icon setting in ThemePicker
Subject: [PATCH 1/4] Expose themed icon setting in ThemePicker
Change-Id: I44e9288c3de13a3604b7a03857ec400753317d9a
---
@ -10,7 +10,7 @@ Change-Id: I44e9288c3de13a3604b7a03857ec400753317d9a
2 files changed, 6 insertions(+)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 517bd6d..89291c1 100644
index 4f580e0bd6..d5b14e5bb9 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -67,6 +67,9 @@
@ -24,10 +24,10 @@ index 517bd6d..89291c1 100644
</application>
diff --git a/quickstep/AndroidManifest-launcher.xml b/quickstep/AndroidManifest-launcher.xml
index 80d8154..813ef75 100644
index 7d7054f5a5..d2955c4327 100644
--- a/quickstep/AndroidManifest-launcher.xml
+++ b/quickstep/AndroidManifest-launcher.xml
@@ -65,6 +65,9 @@
@@ -66,6 +66,9 @@
<meta-data
android:name="com.android.launcher3.grid.control"
android:value="${packageName}.grid_control" />
@ -38,5 +38,5 @@ index 80d8154..813ef75 100644
</application>
--
2.48.1
2.40.1

View file

@ -1,7 +1,7 @@
From de7b698be0f1e01b337672d919854e3a28b8685f Mon Sep 17 00:00:00 2001
From 0d97b73a079dd81b0dd8c0bb512a926d37f76cf9 Mon Sep 17 00:00:00 2001
From: Luca Stefani <luca.stefani.ge1@gmail.com>
Date: Fri, 1 Nov 2019 23:17:59 +0100
Subject: [PATCH 3/3] Properly expose GridCustomizationsProvider
Subject: [PATCH 2/4] Properly expose GridCustomizationsProvider
Change-Id: I8268a215257ae0e399c56ac8b44cdfdff8cc92a0
---
@ -9,13 +9,13 @@ Change-Id: I8268a215257ae0e399c56ac8b44cdfdff8cc92a0
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/AndroidManifest-common.xml b/AndroidManifest-common.xml
index 80d2eac..53bdfff 100644
index 0c7b48fe66..1fe86ad022 100644
--- a/AndroidManifest-common.xml
+++ b/AndroidManifest-common.xml
@@ -138,7 +138,9 @@
@@ -137,7 +137,9 @@
<provider
android:name="com.android.launcher3.graphics.GridCustomizationsProvider"
android:authorities="${applicationId}.grid_control"
android:authorities="${packageName}.grid_control"
- android:exported="true" />
+ android:exported="true"
+ android:writePermission="${packageName}.permission.WRITE_SETTINGS"
@ -24,5 +24,5 @@ index 80d2eac..53bdfff 100644
<!--
The settings activity. To extend point settings_fragment_name to appropriate fragment class
--
2.48.1
2.40.1

View file

@ -0,0 +1,25 @@
From 4fd73068a8fa6246676d52b6ae63f04341319520 Mon Sep 17 00:00:00 2001
From: Danny Lin <danny@kdrag0n.dev>
Date: Wed, 6 Oct 2021 22:45:33 -0700
Subject: [PATCH 3/4] Fix all apps header color in dark mode
Change-Id: Ib2ce7f6e3c9b87a4626699cb54673d88392a5f41
---
res/values/styles.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 5dc4f0afa1..f5d64729c8 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -94,6 +94,7 @@
<item name="android:colorControlHighlight">#19FFFFFF</item>
<item name="android:colorPrimary">#FF212121</item>
<item name="allAppsScrimColor">?android:attr/colorBackgroundFloating</item>
+ <item name="allappsHeaderProtectionColor">@color/popup_color_tertiary_dark</item>
<item name="allAppsNavBarScrimColor">#80000000</item>
<item name="popupColorPrimary">@color/popup_color_primary_dark</item>
<item name="popupColorSecondary">@color/popup_color_secondary_dark</item>
--
2.40.1

View file

@ -1,7 +1,7 @@
From c2cafe53a8b6acf97dc9a634ada0d4ab53b5fd9f Mon Sep 17 00:00:00 2001
From 8f1880d3576c0c6521e38558d56e55df92922c8a Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Fri, 7 Jul 2023 18:13:32 -0400
Subject: [PATCH 2/3] Disable QSB in BuildConfig
Subject: [PATCH 4/4] Disable QSB in BuildConfig
Change-Id: I3150ef1d9b8c161ed2a6569d1ae75bba0060b36f
---
@ -9,7 +9,7 @@ Change-Id: I3150ef1d9b8c161ed2a6569d1ae75bba0060b36f
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src_build_config/com/android/launcher3/BuildConfig.java b/src_build_config/com/android/launcher3/BuildConfig.java
index 6d4f56d..2630ec1 100644
index 1f2e0e5387..ab6c528580 100644
--- a/src_build_config/com/android/launcher3/BuildConfig.java
+++ b/src_build_config/com/android/launcher3/BuildConfig.java
@@ -24,7 +24,7 @@ public final class BuildConfig {
@ -20,7 +20,7 @@ index 6d4f56d..2630ec1 100644
+ public static final boolean QSB_ON_FIRST_SCREEN = false;
/**
* Flag to state if the widget on the top of the first screen should be shown.
* Flag to control various developer centric features
--
2.48.1
2.40.1

View file

@ -1,27 +1,27 @@
From c8463140729b40cca3cb143561d652fa06c6d628 Mon Sep 17 00:00:00 2001
From 16c9311e41992ddd8d0bfb5a340cedbf001e3413 Mon Sep 17 00:00:00 2001
From: Oliver Scott <olivercscott@gmail.com>
Date: Thu, 8 Jul 2021 10:40:49 -0400
Subject: [PATCH 2/2] Global VPN feature [2/2]
Subject: [PATCH] Global VPN feature [2/2]
* Create a global VPN toggle for VPNs in the system user. It is only
enabled when no VPN is active in any user.
Change-Id: If4a552b8f59bc15f53c324afa93a67e086b9c5a9
Change-Id: Ic3b79beb635afe03642fce9473bc481239166566
Signed-off-by: Mohammad Hasan Keramat J <ikeramat@protonmail.com>
---
res/values/strings.xml | 6 +++
res/values/strings.xml | 5 ++
res/xml/vpn_app_management.xml | 6 +++
.../settings/vpn2/AppManagementFragment.java | 48 ++++++++++++++++++-
3 files changed, 59 insertions(+), 1 deletion(-)
3 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 730c258..0feb0f6 100644
index 28b35b3fcf..29ca3882e9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -13910,4 +13910,10 @@
<string name="search_gesture_feature_title">Circle to Search</string>
<!-- Summary text for press and hold nav handle OR home button to invoke Circle to Search. [CHAR LIMIT=NONE] -->
<string name="search_gesture_feature_summary">Touch and hold the Home button or the navigation handle to search using the content on your screen.</string>
+
@@ -14457,4 +14457,9 @@
<!-- [CHAR LIMIT=NONE] Hint for QR code process failure -->
<string name="bt_le_audio_qr_code_is_not_valid_format">QR code isn\u0027t a valid format</string>
+ <!-- VPN app management screen, global VPN -->
+ <string name="global_vpn_title">Global VPN</string>
+ <string name="global_vpn_summary">Force all traffic on the device through this VPN, including work profile and other users.</string>
@ -29,12 +29,12 @@ index 730c258..0feb0f6 100644
+ <string name="global_vpn_summary_any_vpn_active">You need to disable all active VPN connections first to enable this</string>
</resources>
diff --git a/res/xml/vpn_app_management.xml b/res/xml/vpn_app_management.xml
index dffbbbe..93df378 100644
index adc441d846..e00f23ccfa 100644
--- a/res/xml/vpn_app_management.xml
+++ b/res/xml/vpn_app_management.xml
@@ -23,6 +23,12 @@
android:key="version"
@@ -31,6 +31,12 @@
android:selectable="false"/>
-->
+ <SwitchPreference
+ android:key="global_vpn"
@ -43,13 +43,13 @@ index dffbbbe..93df378 100644
+ android:summary="@string/global_vpn_summary" />
+
<com.android.settingslib.RestrictedSwitchPreference
android:order="10"
android:key="always_on_vpn"
android:title="@string/vpn_menu_lockdown"
diff --git a/src/com/android/settings/vpn2/AppManagementFragment.java b/src/com/android/settings/vpn2/AppManagementFragment.java
index 00c8f59..c4f447f 100644
index d4ee5b9c47..7a52e0c42c 100644
--- a/src/com/android/settings/vpn2/AppManagementFragment.java
+++ b/src/com/android/settings/vpn2/AppManagementFragment.java
@@ -27,10 +27,12 @@ import android.content.pm.ApplicationInfo;
@@ -28,10 +28,12 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
@ -61,16 +61,16 @@ index 00c8f59..c4f447f 100644
+import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
@@ -39,6 +41,7 @@ import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import android.widget.TextView;
@@ -41,6 +43,7 @@ import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
+import androidx.preference.SwitchPreference;
import com.android.internal.net.VpnConfig;
import com.android.internal.util.ArrayUtils;
@@ -63,6 +66,7 @@ public class AppManagementFragment extends SettingsPreferenceFragment
@@ -64,6 +67,7 @@ public class AppManagementFragment extends SettingsPreferenceFragment
private static final String ARG_PACKAGE_NAME = "package";
private static final String KEY_VERSION = "version";
@ -78,18 +78,18 @@ index 00c8f59..c4f447f 100644
private static final String KEY_ALWAYS_ON_VPN = "always_on_vpn";
private static final String KEY_LOCKDOWN_VPN = "lockdown_vpn";
private static final String KEY_FORGET_VPN = "forget_vpn";
@@ -80,6 +84,7 @@ public class AppManagementFragment extends SettingsPreferenceFragment
@@ -79,6 +83,7 @@ public class AppManagementFragment extends SettingsPreferenceFragment
private String mVpnLabel;
// UI preference
private Preference mPreferenceVersion;
+ private SwitchPreference mPreferenceGlobal;
private RestrictedSwitchPreference mPreferenceAlwaysOn;
private RestrictedSwitchPreference mPreferenceLockdown;
private RestrictedPreference mPreferenceForget;
@@ -126,10 +131,16 @@ public class AppManagementFragment extends SettingsPreferenceFragment
mFeatureProvider = FeatureFactory.getFeatureFactory().getAdvancedVpnFeatureProvider();
@@ -123,10 +128,16 @@ public class AppManagementFragment extends SettingsPreferenceFragment
mDevicePolicyManager = getContext().getSystemService(DevicePolicyManager.class);
mVpnManager = getContext().getSystemService(VpnManager.class);
mPreferenceVersion = findPreference(KEY_VERSION);
+ mPreferenceGlobal = (SwitchPreference) findPreference(KEY_GLOBAL_VPN);
mPreferenceAlwaysOn = (RestrictedSwitchPreference) findPreference(KEY_ALWAYS_ON_VPN);
mPreferenceLockdown = (RestrictedSwitchPreference) findPreference(KEY_LOCKDOWN_VPN);
@ -103,7 +103,7 @@ index 00c8f59..c4f447f 100644
mPreferenceAlwaysOn.setOnPreferenceChangeListener(this);
mPreferenceLockdown.setOnPreferenceChangeListener(this);
mPreferenceForget.setOnPreferenceClickListener(this);
@@ -163,6 +174,8 @@ public class AppManagementFragment extends SettingsPreferenceFragment
@@ -204,6 +215,8 @@ public class AppManagementFragment extends SettingsPreferenceFragment
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
switch (preference.getKey()) {
@ -112,7 +112,7 @@ index 00c8f59..c4f447f 100644
case KEY_ALWAYS_ON_VPN:
return onAlwaysOnVpnClick((Boolean) newValue, mPreferenceLockdown.isChecked());
case KEY_LOCKDOWN_VPN:
@@ -202,6 +215,11 @@ public class AppManagementFragment extends SettingsPreferenceFragment
@@ -243,6 +256,11 @@ public class AppManagementFragment extends SettingsPreferenceFragment
return setAlwaysOnVpnByUI(alwaysOnSetting, lockdown);
}
@ -124,7 +124,7 @@ index 00c8f59..c4f447f 100644
@Override
public void onConfirmLockdown(Bundle options, boolean isEnabled, boolean isLockdown) {
setAlwaysOnVpnByUI(isEnabled, isLockdown);
@@ -235,7 +253,18 @@ public class AppManagementFragment extends SettingsPreferenceFragment
@@ -276,7 +294,18 @@ public class AppManagementFragment extends SettingsPreferenceFragment
final boolean alwaysOn = isVpnAlwaysOn();
final boolean lockdown = alwaysOn
&& VpnUtils.isAnyLockdownActive(getActivity());
@ -144,7 +144,7 @@ index 00c8f59..c4f447f 100644
mPreferenceAlwaysOn.setChecked(alwaysOn);
mPreferenceLockdown.setChecked(lockdown);
updateRestrictedViews();
@@ -298,6 +327,11 @@ public class AppManagementFragment extends SettingsPreferenceFragment
@@ -322,6 +351,11 @@ public class AppManagementFragment extends SettingsPreferenceFragment
return mPackageName.equals(getAlwaysOnVpnPackage());
}
@ -156,7 +156,7 @@ index 00c8f59..c4f447f 100644
/**
* @return false if the intent doesn't contain an existing package or can't retrieve activated
* vpn info.
@@ -352,6 +386,18 @@ public class AppManagementFragment extends SettingsPreferenceFragment
@@ -376,6 +410,18 @@ public class AppManagementFragment extends SettingsPreferenceFragment
return config != null && !TextUtils.equals(config.user, mPackageName);
}
@ -176,5 +176,5 @@ index 00c8f59..c4f447f 100644
private static final String TAG = "CannotConnect";
private static final String ARG_VPN_LABEL = "label";
--
2.48.1
2.40.0

View file

@ -1,26 +1,26 @@
From bc50b3024c266f307ce804ef1887062cf1f34944 Mon Sep 17 00:00:00 2001
From 12224023faccc52724a443670bd77c6aa229ce58 Mon Sep 17 00:00:00 2001
From: Luca Stefani <luca.stefani.ge1@gmail.com>
Date: Fri, 1 Nov 2019 21:14:29 +0100
Subject: [PATCH 1/4] Add wallpaper privapp whitelist
Subject: [PATCH 1/5] Add wallpaper privapp whitelist
Change-Id: I044b1d9201ac0b8780fc37a387f401f3dd0ddeac
---
Android.bp | 9 ++++++++
Android.bp | 10 +++++++++
privapp_whitelist_com.android.wallpaper.xml | 24 +++++++++++++++++++++
2 files changed, 33 insertions(+)
2 files changed, 34 insertions(+)
create mode 100644 privapp_whitelist_com.android.wallpaper.xml
diff --git a/Android.bp b/Android.bp
index 58e6413..40e2241 100644
index 6d9ff8f6..ff9413ac 100644
--- a/Android.bp
+++ b/Android.bp
@@ -140,6 +140,15 @@ android_app {
@@ -117,5 +117,15 @@ android_app {
platform_apis: true,
manifest: "AndroidManifest.xml",
additional_manifests: [":WallpaperPicker2_Manifest"],
+
+ required: ["privapp_whitelist_com.android.wallpaper.xml"],
overrides: ["WallpaperPicker", "WallpaperPicker2"],
static_libs: ["ThemePickerApplicationLib"],
overrides: ["WallpaperPicker2"],
}
+
+prebuilt_etc_xml {
@ -32,7 +32,7 @@ index 58e6413..40e2241 100644
+}
diff --git a/privapp_whitelist_com.android.wallpaper.xml b/privapp_whitelist_com.android.wallpaper.xml
new file mode 100644
index 0000000..e3f3b65
index 00000000..e3f3b658
--- /dev/null
+++ b/privapp_whitelist_com.android.wallpaper.xml
@@ -0,0 +1,24 @@
@ -61,5 +61,5 @@ index 0000000..e3f3b65
+ </privapp-permissions>
+</permissions>
--
2.48.1
2.40.0

View file

@ -0,0 +1,26 @@
From 4b626d87eafd37bf950550f5c14b42f5eaab19eb Mon Sep 17 00:00:00 2001
From: Danny Lin <danny@kdrag0n.dev>
Date: Tue, 5 Oct 2021 19:00:36 -0700
Subject: [PATCH 2/5] Override legacy WallpaperPicker app
Change-Id: I9a1907527eea0e8e7cd10bab64ba79c2c4006c59
---
Android.bp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Android.bp b/Android.bp
index ff9413ac..dee08f45 100644
--- a/Android.bp
+++ b/Android.bp
@@ -119,7 +119,7 @@ android_app {
additional_manifests: [":WallpaperPicker2_Manifest"],
required: ["privapp_whitelist_com.android.wallpaper.xml"],
- overrides: ["WallpaperPicker2"],
+ overrides: ["WallpaperPicker2", "WallpaperPicker"],
}
prebuilt_etc_xml {
--
2.40.0

View file

@ -1,32 +1,33 @@
From b255f705538f7e55d445c60c1a12f60dd309df1d Mon Sep 17 00:00:00 2001
From 0068121d698911e9bc86a224b3f9a2fb7bdc6cbc Mon Sep 17 00:00:00 2001
From: LuK1337 <priv.luk@gmail.com>
Date: Tue, 15 Sep 2020 03:27:19 +0200
Subject: [PATCH 2/4] Add wallpaper default permissions
Subject: [PATCH 3/5] Add wallpaper default permissions
Change-Id: If43a594da31fbab9280ce45b049737f6c534b620
---
Android.bp | 13 ++++++-
Android.bp | 14 ++++++-
default_permissions_com.android.wallpaper.xml | 37 +++++++++++++++++++
2 files changed, 49 insertions(+), 1 deletion(-)
2 files changed, 50 insertions(+), 1 deletion(-)
create mode 100644 default_permissions_com.android.wallpaper.xml
diff --git a/Android.bp b/Android.bp
index 40e2241..614739a 100644
index dee08f45..74479801 100644
--- a/Android.bp
+++ b/Android.bp
@@ -140,7 +140,10 @@ android_app {
platform_apis: true,
@@ -118,7 +118,11 @@ android_app {
manifest: "AndroidManifest.xml",
additional_manifests: [":WallpaperPicker2_Manifest"],
- required: ["privapp_whitelist_com.android.wallpaper.xml"],
+ required: [
+ "privapp_whitelist_com.android.wallpaper.xml",
+ "default_permissions_com.android.wallpaper.xml",
+ ],
overrides: ["WallpaperPicker", "WallpaperPicker2"],
static_libs: ["ThemePickerApplicationLib"],
+
overrides: ["WallpaperPicker2", "WallpaperPicker"],
}
@@ -152,3 +155,11 @@ prebuilt_etc_xml {
@@ -129,3 +133,11 @@ prebuilt_etc_xml {
filename_from_src: true,
sub_dir: "permissions",
}
@ -40,7 +41,7 @@ index 40e2241..614739a 100644
+}
diff --git a/default_permissions_com.android.wallpaper.xml b/default_permissions_com.android.wallpaper.xml
new file mode 100644
index 0000000..41b23ce
index 00000000..41b23ce1
--- /dev/null
+++ b/default_permissions_com.android.wallpaper.xml
@@ -0,0 +1,37 @@
@ -82,5 +83,5 @@ index 0000000..41b23ce
+ </exception>
+</exceptions>
--
2.48.1
2.40.0

View file

@ -1,7 +1,7 @@
From 623014b94ae4bb08328684bb077b05973ab858eb Mon Sep 17 00:00:00 2001
From e51787a4ad9f2a70d9d68cad29a8974244c2c0b6 Mon Sep 17 00:00:00 2001
From: Luca Stefani <luca.stefani.ge1@gmail.com>
Date: Fri, 1 Nov 2019 23:17:08 +0100
Subject: [PATCH 3/4] Specify we read and write launcher settings
Subject: [PATCH 4/5] Specify we read and write launcher settings
Change-Id: Ifc8196588443b007602118389ca76d34ab531f14
---
@ -9,10 +9,10 @@ Change-Id: Ifc8196588443b007602118389ca76d34ab531f14
1 file changed, 3 insertions(+)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index f89ff6e..95f5b0e 100755
index 4e71bcc6..26f4fce0 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -60,6 +60,9 @@
@@ -45,6 +45,9 @@
</intent>
</queries>
@ -23,5 +23,5 @@ index f89ff6e..95f5b0e 100755
tools:replace="android:icon,android:name"
android:extractNativeLibs="false"
--
2.48.1
2.40.0

View file

@ -1,7 +1,7 @@
From 5880006d7be5eeb3fff8a6d9154ae16e2e6ffac7 Mon Sep 17 00:00:00 2001
From 3156edaae20291237f095d2d5bb66e8ba0a4cea5 Mon Sep 17 00:00:00 2001
From: Danny Lin <danny@kdrag0n.dev>
Date: Tue, 5 Oct 2021 22:40:58 -0700
Subject: [PATCH 4/4] Add permission for launcher preview rendering
Subject: [PATCH 5/5] Add permission for launcher preview rendering
Change-Id: Ie707dcd98161e8f5993b0504295fddc3f395cd20
---
@ -10,10 +10,10 @@ Change-Id: Ie707dcd98161e8f5993b0504295fddc3f395cd20
2 files changed, 2 insertions(+)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 95f5b0e..8c55499 100755
index 26f4fce0..40281cf9 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -13,6 +13,7 @@
@@ -8,6 +8,7 @@
<uses-permission android:name="android.permission.CHANGE_OVERLAY_PACKAGES"/>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
<uses-permission android:name="android.permission.SET_WALLPAPER_COMPONENT" />
@ -22,7 +22,7 @@ index 95f5b0e..8c55499 100755
<uses-permission android:name="android.permission.MODIFY_DAY_NIGHT_MODE" />
<uses-permission android:name="android.permission.CUSTOMIZE_SYSTEM_UI" />
diff --git a/privapp_whitelist_com.android.wallpaper.xml b/privapp_whitelist_com.android.wallpaper.xml
index e3f3b65..47133be 100644
index e3f3b658..47133be8 100644
--- a/privapp_whitelist_com.android.wallpaper.xml
+++ b/privapp_whitelist_com.android.wallpaper.xml
@@ -20,5 +20,6 @@
@ -33,5 +33,5 @@ index e3f3b65..47133be 100644
</privapp-permissions>
</permissions>
--
2.48.1
2.40.0

View file

@ -0,0 +1,57 @@
From 08cae5289428f6a99f2a6d28145fa542d1288916 Mon Sep 17 00:00:00 2001
From: "tzu-hsien.huang" <tzu-hsien.huang@mediatek.com>
Date: Wed, 20 Jul 2022 15:12:01 +0800
Subject: [PATCH 1/3] Additionally check le_set_event_mask command resturn
status with UNSUPPORTED_LMP_OR_LL_PARAMETER
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In GD BT stack, stack will check each return status of HCI Commands. E.g. reset , le_set_event_mask, set_event_mask …etc.
In BT spec 5.2, SIG add some parameters for le_set_event_mask for le audio, like LE Terminate BIG Complete event: Supported.
However, some legacy chips do not support LE Audio feature, and controller will return Status: Unsupported LMP Parameter Value when it receives this HCI Command
When it checks the return value and find the status is not SUCCESS, it will cause FAIL and cannot be compatible with old legacy chip.
After brushing GSI, Bluetooth will turn off automatically when it is turned on.
So all CTS test will always fail.
Check le_set_event_mask command return status with SUCCESS or UNSUPPORTED_LMP_OR_LL_PARAMETER
Bug: 239662211
Test: CtsBluetoothTestCases
Change-Id: I2b0cede7f47eecd2124a386e958773289eb6f11c
---
system/gd/hci/controller.cc | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/system/gd/hci/controller.cc b/system/gd/hci/controller.cc
index 9dac2b6a84..50342d639e 100644
--- a/system/gd/hci/controller.cc
+++ b/system/gd/hci/controller.cc
@@ -548,7 +548,7 @@ struct Controller::impl {
void le_set_event_mask(uint64_t le_event_mask) {
std::unique_ptr<LeSetEventMaskBuilder> packet = LeSetEventMaskBuilder::Create(le_event_mask);
hci_->EnqueueCommand(std::move(packet), module_.GetHandler()->BindOnceOn(
- this, &Controller::impl::check_status<LeSetEventMaskCompleteView>));
+ this, &Controller::impl::check_event_mask_status<LeSetEventMaskCompleteView>));
}
template <class T>
@@ -559,6 +559,15 @@ struct Controller::impl {
ASSERT(status_view.GetStatus() == ErrorCode::SUCCESS);
}
+ template <class T>
+ void check_event_mask_status(CommandCompleteView view) {
+ ASSERT(view.IsValid());
+ auto status_view = T::Create(view);
+ ASSERT(status_view.IsValid());
+ ASSERT(status_view.GetStatus() == ErrorCode::SUCCESS ||
+ status_view.GetStatus() == ErrorCode::UNSUPPORTED_LMP_OR_LL_PARAMETER);
+ }
+
#define OP_CODE_MAPPING(name) \
case OpCode::name: { \
uint16_t index = (uint16_t)OpCodeIndex::name; \
--
2.40.1

View file

@ -1,192 +0,0 @@
From 73a87c7bcc594cc3da4b9c2394cda066d36bb557 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Wed, 24 Aug 2022 15:45:18 -0400
Subject: [PATCH 1/2] audio_hal_interface: Optionally use sysbta HAL
Required to support sysbta, our system-side bt audio implementation.
Change-Id: I59973e6ec84c5923be8a7c67b36b2e237f000860
---
.../aidl/a2dp/client_interface_aidl.cc | 8 ++++----
.../aidl/a2dp/client_interface_aidl.h | 7 +++++++
.../audio_hal_interface/aidl/client_interface_aidl.cc | 8 ++++----
.../audio_hal_interface/aidl/client_interface_aidl.h | 7 +++++++
system/audio_hal_interface/hal_version_manager.cc | 11 +++++++++--
5 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.cc b/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.cc
index f022ec3ea2..283beb22fa 100644
--- a/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.cc
+++ b/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.cc
@@ -58,7 +58,7 @@ BluetoothAudioClientInterface::~BluetoothAudioClientInterface() {
bool BluetoothAudioClientInterface::IsValid() const { return provider_ != nullptr; }
bool BluetoothAudioClientInterface::is_aidl_available() {
- return AServiceManager_isDeclared(kDefaultAudioProviderFactoryInterface.c_str());
+ return AServiceManager_isDeclared(audioProviderFactoryInterface().c_str());
}
std::vector<AudioCapabilities> BluetoothAudioClientInterface::GetAudioCapabilities() const {
@@ -72,7 +72,7 @@ std::vector<AudioCapabilities> BluetoothAudioClientInterface::GetAudioCapabiliti
return capabilities;
}
auto provider_factory = IBluetoothAudioProviderFactory::fromBinder(::ndk::SpAIBinder(
- AServiceManager_waitForService(kDefaultAudioProviderFactoryInterface.c_str())));
+ AServiceManager_waitForService(audioProviderFactoryInterface().c_str())));
if (provider_factory == nullptr) {
log::error("can't get capability from unknown factory");
@@ -97,7 +97,7 @@ BluetoothAudioClientInterface::GetProviderInfo(
if (provider_factory == nullptr) {
provider_factory = IBluetoothAudioProviderFactory::fromBinder(::ndk::SpAIBinder(
- AServiceManager_waitForService(kDefaultAudioProviderFactoryInterface.c_str())));
+ AServiceManager_waitForService(audioProviderFactoryInterface().c_str())));
}
if (provider_factory == nullptr) {
@@ -173,7 +173,7 @@ void BluetoothAudioClientInterface::FetchAudioProvider() {
// re-registered, so we need to re-fetch the service.
for (int retry_no = 0; retry_no < kFetchAudioProviderRetryNumber; ++retry_no) {
auto provider_factory = IBluetoothAudioProviderFactory::fromBinder(::ndk::SpAIBinder(
- AServiceManager_waitForService(kDefaultAudioProviderFactoryInterface.c_str())));
+ AServiceManager_waitForService(audioProviderFactoryInterface().c_str())));
if (provider_factory == nullptr) {
log::error("can't get capability from unknown factory");
diff --git a/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.h b/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.h
index a45ff946f2..4c99832e1b 100644
--- a/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.h
+++ b/system/audio_hal_interface/aidl/a2dp/client_interface_aidl.h
@@ -28,6 +28,7 @@
#include "bta/le_audio/broadcaster/broadcaster_types.h"
#include "bta/le_audio/le_audio_types.h"
#include "transport_instance.h"
+#include "osi/include/properties.h"
// Keep after audio_aidl_interfaces.h because of <base/logging.h>
// conflicting definitions.
@@ -156,6 +157,12 @@ protected:
// "android.hardware.bluetooth.audio.IBluetoothAudioProviderFactory/default";
static inline const std::string kDefaultAudioProviderFactoryInterface =
std::string() + IBluetoothAudioProviderFactory::descriptor + "/default";
+ static inline const std::string kSystemAudioProviderFactoryInterface =
+ std::string() + IBluetoothAudioProviderFactory::descriptor + "/sysbta";
+ static inline const std::string audioProviderFactoryInterface() {
+ return osi_property_get_bool("persist.bluetooth.system_audio_hal.enabled", false)
+ ? kSystemAudioProviderFactoryInterface : kDefaultAudioProviderFactoryInterface;
+ }
private:
IBluetoothTransportInstance* transport_;
diff --git a/system/audio_hal_interface/aidl/client_interface_aidl.cc b/system/audio_hal_interface/aidl/client_interface_aidl.cc
index 176b355eeb..9d8ddd2cac 100644
--- a/system/audio_hal_interface/aidl/client_interface_aidl.cc
+++ b/system/audio_hal_interface/aidl/client_interface_aidl.cc
@@ -69,7 +69,7 @@ BluetoothAudioClientInterface::BluetoothAudioClientInterface(IBluetoothTransport
bool BluetoothAudioClientInterface::IsValid() const { return provider_ != nullptr; }
bool BluetoothAudioClientInterface::is_aidl_available() {
- return AServiceManager_isDeclared(kDefaultAudioProviderFactoryInterface.c_str());
+ return AServiceManager_isDeclared(audioProviderFactoryInterface().c_str());
}
std::vector<AudioCapabilities> BluetoothAudioClientInterface::GetAudioCapabilities() const {
@@ -83,7 +83,7 @@ std::vector<AudioCapabilities> BluetoothAudioClientInterface::GetAudioCapabiliti
return capabilities;
}
auto provider_factory = IBluetoothAudioProviderFactory::fromBinder(::ndk::SpAIBinder(
- AServiceManager_waitForService(kDefaultAudioProviderFactoryInterface.c_str())));
+ AServiceManager_waitForService(audioProviderFactoryInterface().c_str())));
if (provider_factory == nullptr) {
log::error("can't get capability from unknown factory");
@@ -108,7 +108,7 @@ BluetoothAudioClientInterface::GetProviderInfo(
if (provider_factory == nullptr) {
provider_factory = IBluetoothAudioProviderFactory::fromBinder(::ndk::SpAIBinder(
- AServiceManager_waitForService(kDefaultAudioProviderFactoryInterface.c_str())));
+ AServiceManager_waitForService(audioProviderFactoryInterface().c_str())));
}
if (provider_factory == nullptr) {
@@ -140,7 +140,7 @@ void BluetoothAudioClientInterface::FetchAudioProvider() {
// re-registered, so we need to re-fetch the service.
for (int retry_no = 0; retry_no < kFetchAudioProviderRetryNumber; ++retry_no) {
auto provider_factory = IBluetoothAudioProviderFactory::fromBinder(::ndk::SpAIBinder(
- AServiceManager_waitForService(kDefaultAudioProviderFactoryInterface.c_str())));
+ AServiceManager_waitForService(audioProviderFactoryInterface().c_str())));
if (provider_factory == nullptr) {
log::error("can't get capability from unknown factory");
diff --git a/system/audio_hal_interface/aidl/client_interface_aidl.h b/system/audio_hal_interface/aidl/client_interface_aidl.h
index a3c60384ab..ee5901e32a 100644
--- a/system/audio_hal_interface/aidl/client_interface_aidl.h
+++ b/system/audio_hal_interface/aidl/client_interface_aidl.h
@@ -29,6 +29,7 @@
#include "bta/le_audio/broadcaster/broadcaster_types.h"
#include "bta/le_audio/le_audio_types.h"
#include "transport_instance.h"
+#include "osi/include/properties.h"
namespace bluetooth {
namespace audio {
@@ -150,6 +151,12 @@ protected:
// "android.hardware.bluetooth.audio.IBluetoothAudioProviderFactory/default";
static inline const std::string kDefaultAudioProviderFactoryInterface =
std::string() + IBluetoothAudioProviderFactory::descriptor + "/default";
+ static inline const std::string kSystemAudioProviderFactoryInterface =
+ std::string() + IBluetoothAudioProviderFactory::descriptor + "/sysbta";
+ static inline const std::string audioProviderFactoryInterface() {
+ return osi_property_get_bool("persist.bluetooth.system_audio_hal.enabled", false)
+ ? kSystemAudioProviderFactoryInterface : kDefaultAudioProviderFactoryInterface;
+ }
private:
IBluetoothTransportInstance* transport_;
diff --git a/system/audio_hal_interface/hal_version_manager.cc b/system/audio_hal_interface/hal_version_manager.cc
index f9843df858..3931bc6a8d 100644
--- a/system/audio_hal_interface/hal_version_manager.cc
+++ b/system/audio_hal_interface/hal_version_manager.cc
@@ -20,6 +20,7 @@
#include <android/hidl/manager/1.2/IServiceManager.h>
#include <bluetooth/log.h>
#include <hidl/ServiceManagement.h>
+#include "osi/include/properties.h"
#include <memory>
@@ -32,6 +33,12 @@ using ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProviderFactor
static const std::string kDefaultAudioProviderFactoryInterface =
std::string() + IBluetoothAudioProviderFactory::descriptor + "/default";
+static const std::string kSystemAudioProviderFactoryInterface =
+ std::string() + IBluetoothAudioProviderFactory::descriptor + "/sysbta";
+static inline const std::string audioProviderFactoryInterface() {
+ return osi_property_get_bool("persist.bluetooth.system_audio_hal.enabled", false)
+ ? kSystemAudioProviderFactoryInterface : kDefaultAudioProviderFactoryInterface;
+}
std::string toString(BluetoothAudioHalTransport transport) {
switch (transport) {
@@ -72,7 +79,7 @@ BluetoothAudioHalVersion GetAidlInterfaceVersion() {
static auto aidl_version = []() -> BluetoothAudioHalVersion {
int version = 0;
auto provider_factory = IBluetoothAudioProviderFactory::fromBinder(::ndk::SpAIBinder(
- AServiceManager_waitForService(kDefaultAudioProviderFactoryInterface.c_str())));
+ AServiceManager_waitForService(audioProviderFactoryInterface().c_str())));
if (provider_factory == nullptr) {
log::error("getInterfaceVersion: Can't get aidl version from unknown factory");
@@ -137,7 +144,7 @@ android::sp<IBluetoothAudioProvidersFactory_2_0> HalVersionManager::GetProviders
HalVersionManager::HalVersionManager() {
hal_transport_ = BluetoothAudioHalTransport::UNKNOWN;
- if (AServiceManager_checkService(kDefaultAudioProviderFactoryInterface.c_str()) != nullptr) {
+ if (AServiceManager_checkService(audioProviderFactoryInterface().c_str()) != nullptr) {
hal_version_ = GetAidlInterfaceVersion();
hal_transport_ = BluetoothAudioHalTransport::AIDL;
return;
--
2.48.1

View file

@ -1,32 +0,0 @@
From 29c09f59e76930a00cefd474c96eb40e63a475f5 Mon Sep 17 00:00:00 2001
From: DerTeufel <dominik-kassel@gmx.de>
Date: Wed, 4 Jan 2023 21:39:37 +0100
Subject: [PATCH 2/2] Don't crash on status:UNSUPPORTED_REMOTE_OR_LMP_FEATURE
especially 'opcode:0x811 (SNIFF_SUBRATING)' which is the only one I had observed
Change-Id: Ic57d6631185370cbfdeafdac00801c6ca27fb755
---
system/gd/hci/hci_layer.cc | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/system/gd/hci/hci_layer.cc b/system/gd/hci/hci_layer.cc
index 1311815633..7b913888b2 100644
--- a/system/gd/hci/hci_layer.cc
+++ b/system/gd/hci/hci_layer.cc
@@ -238,8 +238,10 @@ struct HciLayer::impl {
using WaitingFor = CommandQueueEntry::WaitingFor;
WaitingFor waiting_for = command_queue_.front().waiting_for_;
CommandStatusView status_view = CommandStatusView::Create(event);
- if (is_vendor_specific && (is_status && waiting_for == WaitingFor::COMPLETE) &&
- (status_view.IsValid() && status_view.GetStatus() == ErrorCode::UNKNOWN_HCI_COMMAND)) {
+ if ((is_vendor_specific && (is_status && waiting_for == WaitingFor::COMPLETE) &&
+ (status_view.IsValid() && status_view.GetStatus() == ErrorCode::UNKNOWN_HCI_COMMAND)) ||
+ ((is_status && waiting_for == WaitingFor::COMPLETE) &&
+ (status_view.IsValid() && status_view.GetStatus() == ErrorCode::UNSUPPORTED_REMOTE_OR_LMP_FEATURE))) {
// If this is a command status of a vendor specific command, and command complete is expected,
// we can't treat this as hard failure since we have no way of probing this lack of support at
// earlier time. Instead we let the command complete handler handle a empty Command Complete
--
2.48.1

View file

@ -0,0 +1,43 @@
From 55a4e7e7158f50f3e8840b526e15d7c9f10423de Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Wed, 24 Aug 2022 10:41:29 -0400
Subject: [PATCH 2/3] gd: hci: Ignore unexpected status events
For some reason, on some old devices, the controller will report a
remote to support SNIFF_SUBRATING even when it does not. Just ignore the
error here (the status event comes from the failure response).
Change-Id: Ifb9a65fd77f21d15a8dc1ced9240194d38218ef6
---
system/gd/hci/hci_layer.cc | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/system/gd/hci/hci_layer.cc b/system/gd/hci/hci_layer.cc
index 5def729ac8..9c235294bb 100644
--- a/system/gd/hci/hci_layer.cc
+++ b/system/gd/hci/hci_layer.cc
@@ -195,14 +195,13 @@ struct HciLayer::impl {
EventView::Create(PacketView<kLittleEndian>(std::make_shared<std::vector<uint8_t>>(std::vector<uint8_t>()))));
command_queue_.front().GetCallback<CommandCompleteView>()->Invoke(move(command_complete_view));
} else {
- ASSERT_LOG(
- command_queue_.front().waiting_for_status_ == is_status,
- "0x%02hx (%s) was not expecting %s event",
- op_code,
- OpCodeText(op_code).c_str(),
- logging_id.c_str());
-
- command_queue_.front().GetCallback<TResponse>()->Invoke(move(response_view));
+ if (command_queue_.front().waiting_for_status_ == is_status) {
+ command_queue_.front().GetCallback<TResponse>()->Invoke(move(response_view));
+ } else {
+ CommandCompleteView command_complete_view = CommandCompleteView::Create(
+ EventView::Create(PacketView<kLittleEndian>(std::make_shared<std::vector<uint8_t>>(std::vector<uint8_t>()))));
+ command_queue_.front().GetCallback<CommandCompleteView>()->Invoke(move(command_complete_view));
+ }
}
command_queue_.pop_front();
--
2.40.1

View file

@ -0,0 +1,107 @@
From f2d820597f4dcbb08e4e0c9026dc1d56fe7b3bfd Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Wed, 24 Aug 2022 15:45:18 -0400
Subject: [PATCH 3/3] audio_hal_interface: Optionally use sysbta HAL
Required to support sysbta, our system-side bt audio implementation.
Change-Id: I59973e6ec84c5923be8a7c67b36b2e237f000860
---
system/audio_hal_interface/aidl/client_interface_aidl.cc | 6 +++---
system/audio_hal_interface/aidl/client_interface_aidl.h | 7 +++++++
system/audio_hal_interface/hal_version_manager.cc | 9 ++++++++-
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/system/audio_hal_interface/aidl/client_interface_aidl.cc b/system/audio_hal_interface/aidl/client_interface_aidl.cc
index 9af28031f7..5a9dbbccad 100644
--- a/system/audio_hal_interface/aidl/client_interface_aidl.cc
+++ b/system/audio_hal_interface/aidl/client_interface_aidl.cc
@@ -56,7 +56,7 @@ BluetoothAudioClientInterface::BluetoothAudioClientInterface(
bool BluetoothAudioClientInterface::is_aidl_available() {
return AServiceManager_isDeclared(
- kDefaultAudioProviderFactoryInterface.c_str());
+ audioProviderFactoryInterface().c_str());
}
std::vector<AudioCapabilities>
@@ -72,7 +72,7 @@ BluetoothAudioClientInterface::GetAudioCapabilities(SessionType session_type) {
}
auto provider_factory = IBluetoothAudioProviderFactory::fromBinder(
::ndk::SpAIBinder(AServiceManager_waitForService(
- kDefaultAudioProviderFactoryInterface.c_str())));
+ audioProviderFactoryInterface().c_str())));
if (provider_factory == nullptr) {
LOG(ERROR) << __func__ << ", can't get capability from unknown factory";
@@ -99,7 +99,7 @@ void BluetoothAudioClientInterface::FetchAudioProvider() {
}
auto provider_factory = IBluetoothAudioProviderFactory::fromBinder(
::ndk::SpAIBinder(AServiceManager_waitForService(
- kDefaultAudioProviderFactoryInterface.c_str())));
+ audioProviderFactoryInterface().c_str())));
if (provider_factory == nullptr) {
LOG(ERROR) << __func__ << ", can't get capability from unknown factory";
diff --git a/system/audio_hal_interface/aidl/client_interface_aidl.h b/system/audio_hal_interface/aidl/client_interface_aidl.h
index 17abefe8fe..07dd11266f 100644
--- a/system/audio_hal_interface/aidl/client_interface_aidl.h
+++ b/system/audio_hal_interface/aidl/client_interface_aidl.h
@@ -28,6 +28,7 @@
#include "bluetooth_audio_port_impl.h"
#include "common/message_loop_thread.h"
#include "transport_instance.h"
+#include "osi/include/properties.h"
#define BLUETOOTH_AUDIO_HAL_PROP_DISABLED \
"persist.bluetooth.bluetooth_audio_hal.disabled"
@@ -117,6 +118,12 @@ class BluetoothAudioClientInterface {
// "android.hardware.bluetooth.audio.IBluetoothAudioProviderFactory/default";
static inline const std::string kDefaultAudioProviderFactoryInterface =
std::string() + IBluetoothAudioProviderFactory::descriptor + "/default";
+ static inline const std::string kSystemAudioProviderFactoryInterface =
+ std::string() + IBluetoothAudioProviderFactory::descriptor + "/sysbta";
+ static inline const std::string audioProviderFactoryInterface() {
+ return osi_property_get_bool("persist.bluetooth.system_audio_hal.enabled", false)
+ ? kSystemAudioProviderFactoryInterface : kDefaultAudioProviderFactoryInterface;
+ }
private:
IBluetoothTransportInstance* transport_;
diff --git a/system/audio_hal_interface/hal_version_manager.cc b/system/audio_hal_interface/hal_version_manager.cc
index a2c192f37d..c3d1cf35c2 100644
--- a/system/audio_hal_interface/hal_version_manager.cc
+++ b/system/audio_hal_interface/hal_version_manager.cc
@@ -24,6 +24,7 @@
#include <memory>
#include "aidl/audio_aidl_interfaces.h"
+#include "osi/include/properties.h"
namespace bluetooth {
namespace audio {
@@ -33,6 +34,12 @@ using ::aidl::android::hardware::bluetooth::audio::
static const std::string kDefaultAudioProviderFactoryInterface =
std::string() + IBluetoothAudioProviderFactory::descriptor + "/default";
+static const std::string kSystemAudioProviderFactoryInterface =
+ std::string() + IBluetoothAudioProviderFactory::descriptor + "/sysbta";
+static inline const std::string audioProviderFactoryInterface() {
+ return osi_property_get_bool("persist.bluetooth.system_audio_hal.enabled", false)
+ ? kSystemAudioProviderFactoryInterface : kDefaultAudioProviderFactoryInterface;
+}
std::unique_ptr<HalVersionManager> HalVersionManager::instance_ptr =
std::make_unique<HalVersionManager>();
@@ -92,7 +99,7 @@ HalVersionManager::GetProvidersFactory_2_0() {
HalVersionManager::HalVersionManager() {
if (AServiceManager_checkService(
- kDefaultAudioProviderFactoryInterface.c_str()) != nullptr) {
+ audioProviderFactoryInterface().c_str()) != nullptr) {
hal_version_ = BluetoothAudioHalVersion::VERSION_AIDL_V1;
return;
}
--
2.40.1

View file

@ -1,44 +0,0 @@
From c632ab2581f8dbff4381aba8fd94979e71edc356 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Sat, 16 Mar 2024 15:27:27 -0400
Subject: [PATCH] Revert "drop support for V gsi on pixel 5 R base kernel"
This reverts commit bbbd18a71368a80f689b924dcf82062c2ee351b2.
---
..._android_server_connectivity_ClatCoordinator.cpp | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/service/jni/com_android_server_connectivity_ClatCoordinator.cpp b/service/jni/com_android_server_connectivity_ClatCoordinator.cpp
index c0082bb..619f4a3 100644
--- a/service/jni/com_android_server_connectivity_ClatCoordinator.cpp
+++ b/service/jni/com_android_server_connectivity_ClatCoordinator.cpp
@@ -91,6 +91,11 @@ static void verifyPerms(const char * const path,
#undef ALOGF
+bool isGsiImage() {
+ // this implementation matches 2 other places in the codebase (same function name too)
+ return !access("/system/system_ext/etc/init/init.gsi.rc", F_OK);
+}
+
static const char* kClatdDir = "/apex/com.android.tethering/bin/for-system";
static const char* kClatdBin = "/apex/com.android.tethering/bin/for-system/clatd";
@@ -132,6 +137,14 @@ static void verifyClatPerms() {
#undef V2
+ // HACK: Some old vendor kernels lack ~5.10 backport of 'bpffs selinux genfscon' support.
+ // This is *NOT* supported, but let's allow, at least for now, U+ GSI to boot on them.
+ // (without this hack pixel5 R vendor + U gsi breaks)
+ if (isGsiImage() && !bpf::isAtLeastKernelVersion(5, 10, 0)) {
+ ALOGE("GSI with *BAD* pre-5.10 kernel lacking bpffs selinux genfscon support.");
+ return;
+ }
+
if (fatal) abort();
}
--
2.44.0

View file

@ -0,0 +1,34 @@
From cf04b02d96fef364996067ca4ecc51b65f521dca Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Tue, 6 Dec 2022 18:30:32 -0500
Subject: [PATCH] Revert "detect inability to write to index != 0 of bpf map
array"
This reverts commit ead9d83423877458023056f6ccf9390950d6726f.
---
bpfloader/BpfLoader.cpp | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/bpfloader/BpfLoader.cpp b/bpfloader/BpfLoader.cpp
index 5cd80b7..bc72811 100644
--- a/bpfloader/BpfLoader.cpp
+++ b/bpfloader/BpfLoader.cpp
@@ -199,15 +199,6 @@ int main(int argc, char** argv) {
}
}
- int key = 1;
- int value = 123;
- android::base::unique_fd map(
- android::bpf::createMap(BPF_MAP_TYPE_ARRAY, sizeof(key), sizeof(value), 2, 0));
- if (android::bpf::writeToMapEntry(map, &key, &value, BPF_ANY)) {
- ALOGE("Critical kernel bug - failure to write into index 1 of 2 element bpf map array.");
- return 1;
- }
-
if (android::base::SetProperty("bpf.progs_loaded", "1") == false) {
ALOGE("Failed to set bpf.progs_loaded property");
return 1;
--
2.38.1

View file

@ -1,7 +1,7 @@
From f1bdfa28ee093ca4db697560ccd4b1e4b24be937 Mon Sep 17 00:00:00 2001
From f53da166596fc34df3255b1c5120fd7cdcf21e5f Mon Sep 17 00:00:00 2001
From: Isaac Chen <tingyi364@gmail.com>
Date: Wed, 23 Jun 2021 13:07:30 +0800
Subject: [PATCH 2/2] init: Do not start console service when debuggable
Subject: [PATCH 1/2] init: Do not start console service when debuggable
Google added a check for this in R, when it's running it will show a
notification about that performance is impacted.
@ -13,19 +13,19 @@ Change-Id: I34cfd6b42d3b9aee4b3e63181480cfb8b1255f29
1 file changed, 3 deletions(-)
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 1acd637..c3d963f 100644
index 02e51d2c4..ab45bb032 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -1355,9 +1355,6 @@ on property:ro.debuggable=1
@@ -1277,9 +1277,6 @@ on property:ro.debuggable=1
# Give reads to anyone for the accessibility trace folder on debug builds.
chmod 0775 /data/misc/a11ytrace
-on init && property:ro.debuggable=1
- start console
-
# Multi-Gen LRU Experiment
on property:persist.device_config.mglru_native.lru_gen_config=none
write /sys/kernel/mm/lru_gen/enabled 0
on userspace-reboot-requested
# TODO(b/135984674): reset all necessary properties here.
setprop sys.boot_completed ""
--
2.44.0
2.40.0

View file

@ -1,44 +0,0 @@
From bb84dbc1eafbe7604912a7cba72ae65417c2923d Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 23 Feb 2022 17:37:47 -0500
Subject: [PATCH 1/2] init: Override select system properties
* adb secure props and logd can be overridden from system.
Change-Id: I94efa3f108ae97711026f099f367b6bea325629f
---
init/property_service.cpp | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/init/property_service.cpp b/init/property_service.cpp
index f2606e3..d12fac1 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -797,13 +797,20 @@ static void LoadProperties(char* data, const char* filter, const char* filename,
std::string error;
if (CheckPermissions(key, value, context, cr, &error) == PROP_SUCCESS) {
auto it = properties->find(key);
+ const char *new_value = value;
+
if (it == properties->end()) {
- (*properties)[key] = value;
- } else if (it->second != value) {
+ (*properties)[key] = new_value;
+ } else if (it->second != new_value) {
LOG(WARNING) << "Overriding previous property '" << key << "':'" << it->second
<< "' with new value '" << value << "'";
- it->second = value;
- }
+ if (strstr(key, "adb") || strstr(key, "secure") || strstr(key, "ro.logd.kernel")
+ || strcmp("ro.control_privapp_permissions", key) == 0) {
+ LOG(WARNING) << "... Ignored";
+ } else {
+ it->second = new_value;
+ }
+ }
} else {
LOG(ERROR) << "Do not have permissions to set '" << key << "' to '" << value
<< "' in property file '" << filename << "': " << error;
--
2.44.0

View file

@ -0,0 +1,32 @@
From b50dd85e88568bddedbab1e18984a5b5578c8612 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Fri, 21 Apr 2023 13:08:48 -0400
Subject: [PATCH 2/2] Let system override some properties (ro.apex.updatable,
ro.adb.secure, etc.)
Change-Id: I3c84fa617f0ab7990abb0d905230a8703cf39bf7
---
init/property_service.cpp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/init/property_service.cpp b/init/property_service.cpp
index 26341b196..19fc09d63 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -726,7 +726,12 @@ static void LoadProperties(char* data, const char* filter, const char* filename,
} else if (it->second != value) {
LOG(WARNING) << "Overriding previous property '" << key << "':'" << it->second
<< "' with new value '" << value << "'";
- it->second = value;
+ if (strcmp("ro.apex.updatable", key) == 0 || strcmp("ro.control_privapp_permissions", key) == 0
+ || strstr(key, "adb") || strstr(key, "secure")) {
+ LOG(WARNING) << "... Ignored";
+ } else {
+ it->second = value;
+ }
}
} else {
LOG(ERROR) << "Do not have permissions to set '" << key << "' to '" << value
--
2.40.0