mirror of
https://github.com/yurisieucuti/treble_evolution.git
synced 2024-11-24 09:46:19 +00:00
77 lines
3.8 KiB
Diff
77 lines
3.8 KiB
Diff
From 72b267d143e3b07c08e9b21ad90c82896c3e7f16 Mon Sep 17 00:00:00 2001
|
|
From: Pierre-Hugues Husson <phh@phh.me>
|
|
Date: Fri, 6 Oct 2023 09:27:33 -0400
|
|
Subject: [PATCH 03/13] Make the use of IBpfMaps optional
|
|
|
|
---
|
|
.../server/net/NetworkStatsService.java | 28 +++++++++++--------
|
|
.../src/com/android/server/BpfNetMaps.java | 6 +++-
|
|
2 files changed, 21 insertions(+), 13 deletions(-)
|
|
|
|
diff --git a/service-t/src/com/android/server/net/NetworkStatsService.java b/service-t/src/com/android/server/net/NetworkStatsService.java
|
|
index 40c214ed96..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) {
|
|
diff --git a/service/src/com/android/server/BpfNetMaps.java b/service/src/com/android/server/BpfNetMaps.java
|
|
index ad9cfbe10e..029c1e2de1 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;
|
|
--
|
|
2.25.1
|
|
|