Merge "Remove references to Discrete Register from AppOpsService." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0f8bab9ea4
@@ -848,10 +848,7 @@ public class AppOpsService extends IAppOpsService.Stub {
|
|||||||
proxyAttributionTag, uidState, flags);
|
proxyAttributionTag, uidState, flags);
|
||||||
|
|
||||||
mHistoricalRegistry.incrementOpAccessedCount(parent.op, parent.uid, parent.packageName,
|
mHistoricalRegistry.incrementOpAccessedCount(parent.op, parent.uid, parent.packageName,
|
||||||
tag, uidState, flags);
|
tag, uidState, flags, accessTime);
|
||||||
|
|
||||||
mHistoricalRegistry.mDiscreteRegistry.recordDiscreteAccess(parent.uid,
|
|
||||||
parent.packageName, parent.op, tag, flags, uidState, accessTime, -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -955,9 +952,10 @@ public class AppOpsService extends IAppOpsService.Stub {
|
|||||||
mInProgressEvents = new ArrayMap<>(1);
|
mInProgressEvents = new ArrayMap<>(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
InProgressStartOpEvent event = mInProgressEvents.get(clientId);
|
InProgressStartOpEvent event = mInProgressEvents.get(clientId);
|
||||||
if (event == null) {
|
if (event == null) {
|
||||||
event = mInProgressStartOpEventPool.acquire(System.currentTimeMillis(),
|
event = mInProgressStartOpEventPool.acquire(startTime,
|
||||||
SystemClock.elapsedRealtime(), clientId,
|
SystemClock.elapsedRealtime(), clientId,
|
||||||
PooledLambda.obtainRunnable(AppOpsService::onClientDeath, this, clientId),
|
PooledLambda.obtainRunnable(AppOpsService::onClientDeath, this, clientId),
|
||||||
proxyUid, proxyPackageName, proxyAttributionTag, uidState, flags);
|
proxyUid, proxyPackageName, proxyAttributionTag, uidState, flags);
|
||||||
@@ -971,7 +969,7 @@ public class AppOpsService extends IAppOpsService.Stub {
|
|||||||
event.numUnfinishedStarts++;
|
event.numUnfinishedStarts++;
|
||||||
|
|
||||||
mHistoricalRegistry.incrementOpAccessedCount(parent.op, parent.uid, parent.packageName,
|
mHistoricalRegistry.incrementOpAccessedCount(parent.op, parent.uid, parent.packageName,
|
||||||
tag, uidState, flags);
|
tag, uidState, flags, startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1017,11 +1015,7 @@ public class AppOpsService extends IAppOpsService.Stub {
|
|||||||
|
|
||||||
mHistoricalRegistry.increaseOpAccessDuration(parent.op, parent.uid,
|
mHistoricalRegistry.increaseOpAccessDuration(parent.op, parent.uid,
|
||||||
parent.packageName, tag, event.getUidState(),
|
parent.packageName, tag, event.getUidState(),
|
||||||
event.getFlags(), finishedEvent.getDuration());
|
event.getFlags(), finishedEvent.getNoteTime(), finishedEvent.getDuration());
|
||||||
|
|
||||||
mHistoricalRegistry.mDiscreteRegistry.recordDiscreteAccess(parent.uid,
|
|
||||||
parent.packageName, parent.op, tag, event.getFlags(), event.getUidState(),
|
|
||||||
event.getStartTime(), accessDurationMillis);
|
|
||||||
|
|
||||||
mInProgressStartOpEventPool.release(event);
|
mInProgressStartOpEventPool.release(event);
|
||||||
|
|
||||||
@@ -4769,7 +4763,7 @@ public class AppOpsService extends IAppOpsService.Stub {
|
|||||||
mFile.failWrite(stream);
|
mFile.failWrite(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mHistoricalRegistry.mDiscreteRegistry.writeAndClearAccessHistory();
|
mHistoricalRegistry.writeAndClearDiscreteHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Shell extends ShellCommand {
|
static class Shell extends ShellCommand {
|
||||||
@@ -6125,8 +6119,7 @@ public class AppOpsService extends IAppOpsService.Stub {
|
|||||||
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_APPOPS,
|
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MANAGE_APPOPS,
|
||||||
"clearHistory");
|
"clearHistory");
|
||||||
// Must not hold the appops lock
|
// Must not hold the appops lock
|
||||||
mHistoricalRegistry.clearHistory();
|
mHistoricalRegistry.clearAllHistory();
|
||||||
mHistoricalRegistry.mDiscreteRegistry.clearHistory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -495,6 +495,12 @@ final class DiscreteRegistry {
|
|||||||
int nAttributedOps = attributedOps.size();
|
int nAttributedOps = attributedOps.size();
|
||||||
for (int i = nAttributedOps - 1; i >= 0; i--) {
|
for (int i = nAttributedOps - 1; i >= 0; i--) {
|
||||||
DiscreteOpEvent previousOp = attributedOps.get(i);
|
DiscreteOpEvent previousOp = attributedOps.get(i);
|
||||||
|
if (i == nAttributedOps - 1 && previousOp.mNoteTime == accessTime
|
||||||
|
&& accessDuration > -1) {
|
||||||
|
// existing event with updated duration
|
||||||
|
attributedOps.remove(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (previousOp.mNoteTime < accessTime) {
|
if (previousOp.mNoteTime < accessTime) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ final class HistoricalRegistry {
|
|||||||
private static final String PARAMETER_ASSIGNMENT = "=";
|
private static final String PARAMETER_ASSIGNMENT = "=";
|
||||||
private static final String PROPERTY_PERMISSIONS_HUB_ENABLED = "permissions_hub_enabled";
|
private static final String PROPERTY_PERMISSIONS_HUB_ENABLED = "permissions_hub_enabled";
|
||||||
|
|
||||||
volatile @NonNull DiscreteRegistry mDiscreteRegistry;
|
private volatile @NonNull DiscreteRegistry mDiscreteRegistry;
|
||||||
|
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
private @NonNull LinkedList<HistoricalOps> mPendingWrites = new LinkedList<>();
|
private @NonNull LinkedList<HistoricalOps> mPendingWrites = new LinkedList<>();
|
||||||
@@ -477,7 +477,8 @@ final class HistoricalRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void incrementOpAccessedCount(int op, int uid, @NonNull String packageName,
|
void incrementOpAccessedCount(int op, int uid, @NonNull String packageName,
|
||||||
@Nullable String attributionTag, @UidState int uidState, @OpFlags int flags) {
|
@Nullable String attributionTag, @UidState int uidState, @OpFlags int flags,
|
||||||
|
long accessTime) {
|
||||||
synchronized (mInMemoryLock) {
|
synchronized (mInMemoryLock) {
|
||||||
if (mMode == AppOpsManager.HISTORICAL_MODE_ENABLED_ACTIVE) {
|
if (mMode == AppOpsManager.HISTORICAL_MODE_ENABLED_ACTIVE) {
|
||||||
if (!isPersistenceInitializedMLocked()) {
|
if (!isPersistenceInitializedMLocked()) {
|
||||||
@@ -487,6 +488,9 @@ final class HistoricalRegistry {
|
|||||||
getUpdatedPendingHistoricalOpsMLocked(
|
getUpdatedPendingHistoricalOpsMLocked(
|
||||||
System.currentTimeMillis()).increaseAccessCount(op, uid, packageName,
|
System.currentTimeMillis()).increaseAccessCount(op, uid, packageName,
|
||||||
attributionTag, uidState, flags, 1);
|
attributionTag, uidState, flags, 1);
|
||||||
|
|
||||||
|
mDiscreteRegistry.recordDiscreteAccess(uid, packageName, op, attributionTag,
|
||||||
|
flags, uidState, accessTime, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -508,7 +512,7 @@ final class HistoricalRegistry {
|
|||||||
|
|
||||||
void increaseOpAccessDuration(int op, int uid, @NonNull String packageName,
|
void increaseOpAccessDuration(int op, int uid, @NonNull String packageName,
|
||||||
@Nullable String attributionTag, @UidState int uidState, @OpFlags int flags,
|
@Nullable String attributionTag, @UidState int uidState, @OpFlags int flags,
|
||||||
long increment) {
|
long eventStartTime, long increment) {
|
||||||
synchronized (mInMemoryLock) {
|
synchronized (mInMemoryLock) {
|
||||||
if (mMode == AppOpsManager.HISTORICAL_MODE_ENABLED_ACTIVE) {
|
if (mMode == AppOpsManager.HISTORICAL_MODE_ENABLED_ACTIVE) {
|
||||||
if (!isPersistenceInitializedMLocked()) {
|
if (!isPersistenceInitializedMLocked()) {
|
||||||
@@ -518,6 +522,8 @@ final class HistoricalRegistry {
|
|||||||
getUpdatedPendingHistoricalOpsMLocked(
|
getUpdatedPendingHistoricalOpsMLocked(
|
||||||
System.currentTimeMillis()).increaseAccessDuration(op, uid, packageName,
|
System.currentTimeMillis()).increaseAccessDuration(op, uid, packageName,
|
||||||
attributionTag, uidState, flags, increment);
|
attributionTag, uidState, flags, increment);
|
||||||
|
mDiscreteRegistry.recordDiscreteAccess(uid, packageName, op, attributionTag,
|
||||||
|
flags, uidState, increment, eventStartTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -562,7 +568,7 @@ final class HistoricalRegistry {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final List<HistoricalOps> history = mPersistence.readHistoryDLocked();
|
final List<HistoricalOps> history = mPersistence.readHistoryDLocked();
|
||||||
clearHistory();
|
clearHistoricalRegistry();
|
||||||
if (history != null) {
|
if (history != null) {
|
||||||
final int historySize = history.size();
|
final int historySize = history.size();
|
||||||
for (int i = 0; i < historySize; i++) {
|
for (int i = 0; i < historySize; i++) {
|
||||||
@@ -631,7 +637,16 @@ final class HistoricalRegistry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearHistory() {
|
void writeAndClearDiscreteHistory() {
|
||||||
|
mDiscreteRegistry.writeAndClearAccessHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearAllHistory() {
|
||||||
|
clearHistoricalRegistry();
|
||||||
|
mDiscreteRegistry.clearHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearHistoricalRegistry() {
|
||||||
synchronized (mOnDiskLock) {
|
synchronized (mOnDiskLock) {
|
||||||
synchronized (mInMemoryLock) {
|
synchronized (mInMemoryLock) {
|
||||||
if (!isPersistenceInitializedMLocked()) {
|
if (!isPersistenceInitializedMLocked()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user