forked from ahnet-69/treble_voltage
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e73e96
commit cb59e77
Showing
7 changed files
with
442 additions
and
2 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
patches/trebledroid/platform_frameworks_base/0001-Disable-vendor-mismatch-warning.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
From 1e9101cb05a625fe34cad85d36808403fa07e6e9 Mon Sep 17 00:00:00 2001 | ||
From: Andy CrossGate Yan <[email protected]> | ||
Date: Thu, 5 Apr 2018 10:01:19 +0800 | ||
Subject: [PATCH 01/50] Disable vendor mismatch warning | ||
Subject: [PATCH 01/52] Disable vendor mismatch warning | ||
|
||
Change-Id: Ieb8fe91e2f02462f074312ed0f4885d183e9780b | ||
--- | ||
|
2 changes: 1 addition & 1 deletion
2
.../platform_frameworks_base/0002-Fallback-to-stupid-autobrightness-if-brightness-valu.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
From 9cc241b77fa8b8c9fc87e4e2a2fda2199e917965 Mon Sep 17 00:00:00 2001 | ||
From: Pierre-Hugues Husson <[email protected]> | ||
Date: Tue, 5 Oct 2021 17:59:16 -0400 | ||
Subject: [PATCH 02/50] Fallback to stupid autobrightness if brightness values | ||
Subject: [PATCH 02/52] Fallback to stupid autobrightness if brightness values | ||
are broken | ||
|
||
This is needed because of: | ||
|
33 changes: 33 additions & 0 deletions
33
.../platform_frameworks_base/0053-Add-a-prop-to-disable-animation-in-for-sysui-media-c.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
From 1bae8b5afdc90051d7156b5f4e9b6e4aa0e440a9 Mon Sep 17 00:00:00 2001 | ||
From: Pierre-Hugues Husson <[email protected]> | ||
Date: Wed, 8 May 2024 11:55:07 -0400 | ||
Subject: [PATCH 53/53] Add a prop to disable animation in for sysui media | ||
carousel | ||
|
||
--- | ||
.../systemui/media/controls/ui/MediaCarouselController.kt | 3 ++- | ||
1 file changed, 2 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaCarouselController.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaCarouselController.kt | ||
index 992eeca77e54..f8fed58d2553 100644 | ||
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaCarouselController.kt | ||
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaCarouselController.kt | ||
@@ -22,6 +22,7 @@ import android.content.Intent | ||
import android.content.res.ColorStateList | ||
import android.content.res.Configuration | ||
import android.database.ContentObserver | ||
+import android.os.SystemProperties; | ||
import android.provider.Settings | ||
import android.provider.Settings.ACTION_MEDIA_CONTROLS_SETTINGS | ||
import android.util.Log | ||
@@ -1047,7 +1048,7 @@ constructor( | ||
desiredHostState.showsOnlyActiveMedia | ||
|
||
for (mediaPlayer in MediaPlayerData.players()) { | ||
- if (animate) { | ||
+ if (animate && !SystemProperties.getBoolean("persist.sys.phh.no_media_carousel_animation", false)) { | ||
mediaPlayer.mediaViewController.animatePendingStateChange( | ||
duration = duration, | ||
delay = startDelay | ||
-- | ||
2.34.1 |
24 changes: 24 additions & 0 deletions
24
...ebledroid/platform_frameworks_native/0012-Disable-gpuservice-on-old-BPF-less-kernel.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
From 470070680f5ba495f1f9571fcc8b30af2bc7ad19 Mon Sep 17 00:00:00 2001 | ||
From: Pierre-Hugues Husson <[email protected]> | ||
Date: Tue, 7 May 2024 22:34:40 +0000 | ||
Subject: [PATCH 12/12] Disable gpuservice on old BPF-less kernel | ||
|
||
Change-Id: I8e1626e2e9d12ee0dc03d758799bc88085899476 | ||
--- | ||
services/gpuservice/gpumem/GpuMem.cpp | 1 + | ||
1 file changed, 1 insertion(+) | ||
|
||
diff --git a/services/gpuservice/gpumem/GpuMem.cpp b/services/gpuservice/gpumem/GpuMem.cpp | ||
index 141fe021ee..90b8b5c52d 100644 | ||
--- a/services/gpuservice/gpumem/GpuMem.cpp | ||
+++ b/services/gpuservice/gpumem/GpuMem.cpp | ||
@@ -48,6 +48,7 @@ void GpuMem::initialize() { | ||
if (fd < 0) { | ||
ALOGE("Failed to retrieve pinned program from %s [%d(%s)]", kGpuMemTotalProgPath, errno, | ||
strerror(errno)); | ||
+ while(true) sleep(1); | ||
return; | ||
} | ||
|
||
-- | ||
2.34.1 |
307 changes: 307 additions & 0 deletions
307
...kages_modules_Connectivity/0002-Support-non-working-BPF-maps-on-old-BPF-less-kernel.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,307 @@ | ||
From 78c05bd0d6c25a47a1c3605fde8dffe2c82889c2 Mon Sep 17 00:00:00 2001 | ||
From: Pierre-Hugues Husson <[email protected]> | ||
Date: Wed, 26 Oct 2022 18:11:10 -0400 | ||
Subject: [PATCH 2/9] Support non-working BPF maps on old BPF-less kernel | ||
|
||
--- | ||
.../src/android/net/BpfNetMapsReader.java | 13 ++++++-- | ||
netbpfload/NetBpfLoad.cpp | 31 ++++++++----------- | ||
.../libs/libnetworkstats/BpfNetworkStats.cpp | 1 + | ||
.../server/net/NetworkStatsService.java | 29 ++++++++++------- | ||
.../src/com/android/server/BpfNetMaps.java | 14 +++++++-- | ||
.../native/bpf_headers/include/bpf/BpfMap.h | 21 +++++++------ | ||
6 files changed, 65 insertions(+), 44 deletions(-) | ||
|
||
diff --git a/framework/src/android/net/BpfNetMapsReader.java b/framework/src/android/net/BpfNetMapsReader.java | ||
index 4ab6d3e0b6..70890dac8c 100644 | ||
--- a/framework/src/android/net/BpfNetMapsReader.java | ||
+++ b/framework/src/android/net/BpfNetMapsReader.java | ||
@@ -125,7 +125,7 @@ public class BpfNetMapsReader { | ||
return new BpfMap<>(CONFIGURATION_MAP_PATH, BpfMap.BPF_F_RDONLY, | ||
S32.class, U32.class); | ||
} catch (ErrnoException e) { | ||
- throw new IllegalStateException("Cannot open configuration map", e); | ||
+ return null; | ||
} | ||
} | ||
|
||
@@ -135,7 +135,7 @@ public class BpfNetMapsReader { | ||
return new BpfMap<>(UID_OWNER_MAP_PATH, BpfMap.BPF_F_RDONLY, | ||
S32.class, UidOwnerValue.class); | ||
} catch (ErrnoException e) { | ||
- throw new IllegalStateException("Cannot open uid owner map", e); | ||
+ return null; | ||
} | ||
} | ||
|
||
@@ -145,7 +145,7 @@ public class BpfNetMapsReader { | ||
return new BpfMap<>(DATA_SAVER_ENABLED_MAP_PATH, BpfMap.BPF_F_RDONLY, S32.class, | ||
U8.class); | ||
} catch (ErrnoException e) { | ||
- throw new IllegalStateException("Cannot open data saver enabled map", e); | ||
+ return null; | ||
} | ||
} | ||
} | ||
@@ -192,6 +192,8 @@ public class BpfNetMapsReader { | ||
final IBpfMap<S32, U32> configurationMap, final int chain) { | ||
throwIfPreT("isChainEnabled is not available on pre-T devices"); | ||
|
||
+ if (configurationMap == null) return false; | ||
+ | ||
final long match = getMatchByFirewallChain(chain); | ||
try { | ||
final U32 config = configurationMap.getValue(UID_RULES_CONFIGURATION_KEY); | ||
@@ -217,6 +219,8 @@ public class BpfNetMapsReader { | ||
final int chain, final int uid) { | ||
throwIfPreT("getUidRule is not available on pre-T devices"); | ||
|
||
+ if (uidOwnerMap == null) return FIREWALL_RULE_ALLOW; | ||
+ | ||
final long match = getMatchByFirewallChain(chain); | ||
final boolean isAllowList = isFirewallAllowList(chain); | ||
try { | ||
@@ -245,6 +249,8 @@ public class BpfNetMapsReader { | ||
boolean isDataSaverEnabled) { | ||
throwIfPreT("isUidBlockedByFirewallChains is not available on pre-T devices"); | ||
|
||
+ if (mConfigurationMap == null) return false; | ||
+ | ||
final long uidRuleConfig; | ||
final long uidMatch; | ||
try { | ||
@@ -285,6 +291,7 @@ public class BpfNetMapsReader { | ||
Log.wtf(TAG, "getDataSaverEnabled is not expected to be called on pre-V devices"); | ||
} | ||
|
||
+ if (mDataSaverEnabledMap == null) return false; | ||
try { | ||
return mDataSaverEnabledMap.getValue(DATA_SAVER_ENABLED_KEY).val == DATA_SAVER_ENABLED; | ||
} catch (ErrnoException e) { | ||
diff --git a/netbpfload/NetBpfLoad.cpp b/netbpfload/NetBpfLoad.cpp | ||
index 6152287e45..adc78d5773 100644 | ||
--- a/netbpfload/NetBpfLoad.cpp | ||
+++ b/netbpfload/NetBpfLoad.cpp | ||
@@ -175,10 +175,11 @@ int main(int argc, char** argv, char * const envp[]) { | ||
|
||
const int device_api_level = android_get_device_api_level(); | ||
const bool isAtLeastU = (device_api_level >= __ANDROID_API_U__); | ||
+ bool failed = false; | ||
|
||
if (!android::bpf::isAtLeastKernelVersion(4, 19, 0)) { | ||
ALOGE("Android U QPR2 requires kernel 4.19."); | ||
- return 1; | ||
+ failed = true; | ||
} | ||
|
||
if (android::bpf::isUserspace32bit() && android::bpf::isAtLeastKernelVersion(6, 2, 0)) { | ||
@@ -202,14 +203,14 @@ int main(int argc, char** argv, char * const envp[]) { | ||
* and 32-bit userspace on 64-bit kernel bpf ringbuffer compatibility is broken. | ||
*/ | ||
ALOGE("64-bit userspace required on 6.2+ kernels."); | ||
- return 1; | ||
+ failed = true; | ||
} | ||
|
||
// Ensure we can determine the Android build type. | ||
if (!android::bpf::isEng() && !android::bpf::isUser() && !android::bpf::isUserdebug()) { | ||
ALOGE("Failed to determine the build type: got %s, want 'eng', 'user', or 'userdebug'", | ||
android::bpf::getBuildType().c_str()); | ||
- return 1; | ||
+ failed = true; | ||
} | ||
|
||
if (isAtLeastU) { | ||
@@ -239,31 +240,25 @@ int main(int argc, char** argv, char * const envp[]) { | ||
// which could otherwise fail with ENOENT during object pinning or renaming, | ||
// due to ordering issues) | ||
for (const auto& location : locations) { | ||
- if (createSysFsBpfSubDir(location.prefix)) return 1; | ||
+ if (createSysFsBpfSubDir(location.prefix)) failed = true; | ||
} | ||
|
||
// Load all ELF objects, create programs and maps, and pin them | ||
for (const auto& location : locations) { | ||
if (loadAllElfObjects(location) != 0) { | ||
- ALOGE("=== CRITICAL FAILURE LOADING BPF PROGRAMS FROM %s ===", location.dir); | ||
- ALOGE("If this triggers reliably, you're probably missing kernel options or patches."); | ||
- ALOGE("If this triggers randomly, you might be hitting some memory allocation " | ||
- "problems or startup script race."); | ||
- ALOGE("--- DO NOT EXPECT SYSTEM TO BOOT SUCCESSFULLY ---"); | ||
- sleep(20); | ||
- return 2; | ||
+ failed = true; | ||
} | ||
} | ||
|
||
- 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 (failed) { | ||
+ ALOGE("=== CRITICAL FAILURE LOADING BPF PROGRAMS ==="); | ||
+ ALOGE("If this triggers reliably, you're probably missing kernel options or patches."); | ||
+ ALOGE("If this triggers randomly, you might be hitting some memory allocation " | ||
+ "problems or startup script race."); | ||
+ ALOGE("--- DO NOT EXPECT SYSTEM TO BOOT SUCCESSFULLY ---"); | ||
} | ||
|
||
+ | ||
ALOGI("done, transferring control to platform bpfloader."); | ||
|
||
const char * args[] = { "/system/bin/bpfloader", NULL, }; | ||
diff --git a/service-t/native/libs/libnetworkstats/BpfNetworkStats.cpp b/service-t/native/libs/libnetworkstats/BpfNetworkStats.cpp | ||
index 31013972b8..8d6994818b 100644 | ||
--- a/service-t/native/libs/libnetworkstats/BpfNetworkStats.cpp | ||
+++ b/service-t/native/libs/libnetworkstats/BpfNetworkStats.cpp | ||
@@ -170,6 +170,7 @@ int parseBpfNetworkStatsDetail(std::vector<stats_line>* lines) { | ||
static BpfMapRO<uint32_t, uint32_t> configurationMap(CONFIGURATION_MAP_PATH); | ||
static BpfMap<StatsKey, StatsValue> statsMapA(STATS_MAP_A_PATH); | ||
static BpfMap<StatsKey, StatsValue> statsMapB(STATS_MAP_B_PATH); | ||
+ if (!configurationMap.isOk()) return -1; | ||
auto configuration = configurationMap.readValue(CURRENT_STATS_MAP_CONFIGURATION_KEY); | ||
if (!configuration.ok()) { | ||
ALOGE("Cannot read the old configuration from map: %s", | ||
diff --git a/service-t/src/com/android/server/net/NetworkStatsService.java b/service-t/src/com/android/server/net/NetworkStatsService.java | ||
index 2c9f30c8f7..5471624368 100644 | ||
--- a/service-t/src/com/android/server/net/NetworkStatsService.java | ||
+++ b/service-t/src/com/android/server/net/NetworkStatsService.java | ||
@@ -427,12 +427,12 @@ public class NetworkStatsService extends INetworkStatsService.Stub { | ||
* mActiveUidCounterSet to avoid accessing kernel too frequently. | ||
*/ | ||
private SparseIntArray mActiveUidCounterSet = new SparseIntArray(); | ||
- private final IBpfMap<S32, U8> mUidCounterSetMap; | ||
- private final IBpfMap<CookieTagMapKey, CookieTagMapValue> mCookieTagMap; | ||
- private final IBpfMap<StatsMapKey, StatsMapValue> mStatsMapA; | ||
- private final IBpfMap<StatsMapKey, StatsMapValue> mStatsMapB; | ||
- private final IBpfMap<UidStatsMapKey, StatsMapValue> mAppUidStatsMap; | ||
- private final IBpfMap<S32, StatsMapValue> mIfaceStatsMap; | ||
+ private IBpfMap<S32, U8> mUidCounterSetMap = null; | ||
+ private IBpfMap<CookieTagMapKey, CookieTagMapValue> mCookieTagMap = null; | ||
+ private IBpfMap<StatsMapKey, StatsMapValue> mStatsMapA = null; | ||
+ private IBpfMap<StatsMapKey, StatsMapValue> mStatsMapB = null; | ||
+ private IBpfMap<UidStatsMapKey, StatsMapValue> mAppUidStatsMap = null; | ||
+ private IBpfMap<S32, StatsMapValue> mIfaceStatsMap = null; | ||
|
||
/** Data layer operation counters for splicing into other structures. */ | ||
private NetworkStats mUidOperations = new NetworkStats(0L, 10); | ||
@@ -621,12 +621,16 @@ public class NetworkStatsService extends INetworkStatsService.Stub { | ||
mLocationPermissionChecker = mDeps.makeLocationPermissionChecker(mContext); | ||
mInterfaceMapUpdater = mDeps.makeBpfInterfaceMapUpdater(mContext, mHandler); | ||
mInterfaceMapUpdater.start(); | ||
- mUidCounterSetMap = mDeps.getUidCounterSetMap(); | ||
- mCookieTagMap = mDeps.getCookieTagMap(); | ||
- mStatsMapA = mDeps.getStatsMapA(); | ||
- mStatsMapB = mDeps.getStatsMapB(); | ||
- mAppUidStatsMap = mDeps.getAppUidStatsMap(); | ||
- mIfaceStatsMap = mDeps.getIfaceStatsMap(); | ||
+ try { | ||
+ mUidCounterSetMap = mDeps.getUidCounterSetMap(); | ||
+ mCookieTagMap = mDeps.getCookieTagMap(); | ||
+ mStatsMapA = mDeps.getStatsMapA(); | ||
+ mStatsMapB = mDeps.getStatsMapB(); | ||
+ mAppUidStatsMap = mDeps.getAppUidStatsMap(); | ||
+ mIfaceStatsMap = mDeps.getIfaceStatsMap(); | ||
+ } catch(Throwable t) { | ||
+ android.util.Log.e("PHH", "Failed creating bpf maps", t); | ||
+ } | ||
// To prevent any possible races, the flag is not allowed to change until rebooting. | ||
mSupportEventLogger = mDeps.supportEventLogger(mContext); | ||
if (mSupportEventLogger) { | ||
@@ -2450,6 +2454,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { | ||
* @param uid | ||
*/ | ||
private void deleteKernelTagData(int uid) { | ||
+ if(mCookieTagMap == null) return; | ||
try { | ||
mCookieTagMap.forEach((key, value) -> { | ||
// If SkDestroyListener deletes the socket tag while this code is running, | ||
diff --git a/service/src/com/android/server/BpfNetMaps.java b/service/src/com/android/server/BpfNetMaps.java | ||
index ad9cfbe10e..9b2202b295 100644 | ||
--- a/service/src/com/android/server/BpfNetMaps.java | ||
+++ b/service/src/com/android/server/BpfNetMaps.java | ||
@@ -358,7 +358,11 @@ public class BpfNetMaps { | ||
@VisibleForTesting | ||
public BpfNetMaps(final Context context, final INetd netd, final Dependencies deps) { | ||
if (!PRE_T) { | ||
- ensureInitialized(context); | ||
+ try { | ||
+ ensureInitialized(context); | ||
+ } catch(Throwable t) { | ||
+ android.util.Log.e("PHH", "Failed initialization BpfMaps, doing without it", t); | ||
+ } | ||
} | ||
mNetd = netd; | ||
mDeps = deps; | ||
@@ -794,6 +798,8 @@ public class BpfNetMaps { | ||
public void swapActiveStatsMap() { | ||
throwIfPreT("swapActiveStatsMap is not available on pre-T devices"); | ||
|
||
+ if (sConfigurationMap == null) return; | ||
+ | ||
try { | ||
synchronized (sCurrentStatsMapConfigLock) { | ||
final long config = sConfigurationMap.getValue( | ||
@@ -834,6 +840,8 @@ public class BpfNetMaps { | ||
return; | ||
} | ||
|
||
+ if (sUidPermissionMap == null) return; | ||
+ | ||
// Remove the entry if package is uninstalled or uid has only INTERNET permission. | ||
if (permissions == PERMISSION_UNINSTALLED || permissions == PERMISSION_INTERNET) { | ||
for (final int uid : uids) { | ||
@@ -932,7 +940,9 @@ public class BpfNetMaps { | ||
// deletion. netd and skDestroyListener could delete CookieTagMap entry concurrently. | ||
// So using Set to count the number of entry in the map. | ||
Set<K> keySet = new ArraySet<>(); | ||
- map.forEach((k, v) -> keySet.add(k)); | ||
+ if (map != null) { | ||
+ map.forEach((k, v) -> keySet.add(k)); | ||
+ } | ||
return keySet.size(); | ||
} | ||
|
||
diff --git a/staticlibs/native/bpf_headers/include/bpf/BpfMap.h b/staticlibs/native/bpf_headers/include/bpf/BpfMap.h | ||
index 3fede3c0ed..8266ec68c0 100644 | ||
--- a/staticlibs/native/bpf_headers/include/bpf/BpfMap.h | ||
+++ b/staticlibs/native/bpf_headers/include/bpf/BpfMap.h | ||
@@ -58,21 +58,24 @@ class BpfMapRO { | ||
|
||
protected: | ||
void abortOnMismatch(bool writable) const { | ||
- if (!mMapFd.ok()) abort(); | ||
+ (void) writable; | ||
+ } | ||
+ | ||
+ public: | ||
+ bool isOk(bool writable = false) const { | ||
+ if (!mMapFd.ok()) return false; | ||
if (isAtLeastKernelVersion(4, 14, 0)) { | ||
int flags = bpfGetFdMapFlags(mMapFd); | ||
- if (flags < 0) abort(); | ||
- if (flags & BPF_F_WRONLY) abort(); | ||
- if (writable && (flags & BPF_F_RDONLY)) abort(); | ||
- if (bpfGetFdKeySize(mMapFd) != sizeof(Key)) abort(); | ||
- if (bpfGetFdValueSize(mMapFd) != sizeof(Value)) abort(); | ||
+ if (flags < 0) return false; | ||
+ if (flags & BPF_F_WRONLY) return false; | ||
+ if (writable && (flags & BPF_F_RDONLY)) return false; | ||
+ if (bpfGetFdKeySize(mMapFd) != sizeof(Key)) return false; | ||
+ if (bpfGetFdValueSize(mMapFd) != sizeof(Value)) return false; | ||
} | ||
+ return true; | ||
} | ||
- | ||
- public: | ||
explicit BpfMapRO<Key, Value>(const char* pathname) { | ||
mMapFd.reset(mapRetrieveRO(pathname)); | ||
- abortOnMismatch(/* writable */ false); | ||
} | ||
|
||
Result<Key> getFirstKey() const { | ||
-- | ||
2.34.1 |
Oops, something went wrong.