Narrow access to getDataLayerSnapshotForUid().
This method is used in TrafficStats to obtain the snapshot for the calling UID, so narrow it to only return data for that specific case. We might be tempted to throw an exception or adjust the method signature, but apps are using the raw AIDL in the greylist, so we return them an empty NetworkStats if they ask about other UIDs. Bug: 119672472 Test: manual Change-Id: I3064630039f1d8473d6425dd663f17813a4ae3a1
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.server.net;
|
||||
|
||||
import static android.Manifest.permission.ACCESS_NETWORK_STATE;
|
||||
import static android.Manifest.permission.NETWORK_STATS_PROVIDER;
|
||||
import static android.Manifest.permission.READ_NETWORK_USAGE_HISTORY;
|
||||
import static android.Manifest.permission.UPDATE_DEVICE_STATS;
|
||||
@@ -845,7 +844,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
||||
@Override
|
||||
public NetworkStats getDataLayerSnapshotForUid(int uid) throws RemoteException {
|
||||
if (Binder.getCallingUid() != uid) {
|
||||
mContext.enforceCallingOrSelfPermission(ACCESS_NETWORK_STATE, TAG);
|
||||
Log.w(TAG, "Snapshots only available for calling UID");
|
||||
return new NetworkStats(SystemClock.elapsedRealtime(), 0);
|
||||
}
|
||||
|
||||
// TODO: switch to data layer stats once kernel exports
|
||||
|
||||
Reference in New Issue
Block a user