Loading core/java/android/app/ActivityThread.java +7 −1 Original line number Diff line number Diff line Loading @@ -997,6 +997,7 @@ public final class ActivityThread extends ClientTransactionHandler long[] disabledCompatChanges; long[] mLoggableCompatChanges; boolean mLogChangeChecksToStatsD; SharedMemory mSerializedSystemFontMap; Loading Loading @@ -1328,6 +1329,7 @@ public final class ActivityThread extends ClientTransactionHandler ContentCaptureOptions contentCaptureOptions, long[] disabledCompatChanges, long[] loggableCompatChanges, boolean logChangeChecksToStatsD, SharedMemory serializedSystemFontMap, FileDescriptor applicationSharedMemoryFd, long startRequestedElapsedTime, Loading Loading @@ -1399,6 +1401,7 @@ public final class ActivityThread extends ClientTransactionHandler data.contentCaptureOptions = contentCaptureOptions; data.disabledCompatChanges = disabledCompatChanges; data.mLoggableCompatChanges = loggableCompatChanges; data.mLogChangeChecksToStatsD = logChangeChecksToStatsD; data.mSerializedSystemFontMap = serializedSystemFontMap; data.startRequestedElapsedTime = startRequestedElapsedTime; data.startRequestedUptime = startRequestedUptime; Loading Loading @@ -7598,7 +7601,10 @@ public final class ActivityThread extends ClientTransactionHandler Process.setStartTimes(SystemClock.elapsedRealtime(), SystemClock.uptimeMillis(), data.startRequestedElapsedTime, data.startRequestedUptime); AppCompatCallbacks.install(data.disabledCompatChanges, data.mLoggableCompatChanges); AppCompatCallbacks.install( data.disabledCompatChanges, data.mLoggableCompatChanges, data.mLogChangeChecksToStatsD); // Let libcore handle any compat changes after installing the list of compat changes. AppSpecializationHooks.handleCompatChangesBeforeBindingApplication(); Loading core/java/android/app/AppCompatCallbacks.java +29 −9 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ public final class AppCompatCallbacks implements Compatibility.BehaviorChangeDel private final long[] mDisabledChanges; private final long[] mLoggableChanges; private final ChangeReporter mChangeReporter; private boolean mLogChangeChecksToStatsD = false; /** * Install this class into the current process using the disabled and loggable changes lists. Loading @@ -40,17 +41,33 @@ public final class AppCompatCallbacks implements Compatibility.BehaviorChangeDel * @param disabledChanges Set of compatibility changes that are disabled for this process. * @param loggableChanges Set of compatibility changes that we want to log. */ public static void install(long[] disabledChanges, long[] loggableChanges) { public static void install( long[] disabledChanges, long[] loggableChanges) { Compatibility.setBehaviorChangeDelegate( new AppCompatCallbacks(disabledChanges, loggableChanges)); new AppCompatCallbacks(disabledChanges, loggableChanges, false)); } private AppCompatCallbacks(long[] disabledChanges, long[] loggableChanges) { /** * Install this class into the current process using the disabled and loggable changes lists. * * @param disabledChanges Set of compatibility changes that are disabled for this process. * @param loggableChanges Set of compatibility changes that we want to log. * @param logChangeChecksToStatsD Whether to log change checks to statsd. */ public static void install( long[] disabledChanges, long[] loggableChanges, boolean logChangeChecksToStatsD) { Compatibility.setBehaviorChangeDelegate( new AppCompatCallbacks(disabledChanges, loggableChanges, logChangeChecksToStatsD)); } private AppCompatCallbacks( long[] disabledChanges, long[] loggableChanges, boolean logChangeChecksToStatsD) { mDisabledChanges = Arrays.copyOf(disabledChanges, disabledChanges.length); mLoggableChanges = Arrays.copyOf(loggableChanges, loggableChanges.length); Arrays.sort(mDisabledChanges); Arrays.sort(mLoggableChanges); mChangeReporter = new ChangeReporter(ChangeReporter.SOURCE_APP_PROCESS); mLogChangeChecksToStatsD = logChangeChecksToStatsD; } /** Loading @@ -65,25 +82,28 @@ public final class AppCompatCallbacks implements Compatibility.BehaviorChangeDel } public void onChangeReported(long changeId) { boolean isLoggable = changeIdInChangeList(mLoggableChanges, changeId); reportChange(changeId, ChangeReporter.STATE_LOGGED, isLoggable); isChangeEnabledAndReport(changeId, true); } public boolean isChangeEnabled(long changeId) { return isChangeEnabledAndReport(changeId, mLogChangeChecksToStatsD); } private boolean isChangeEnabledAndReport(long changeId, boolean doStatsLog) { boolean isEnabled = !changeIdInChangeList(mDisabledChanges, changeId); boolean isLoggable = changeIdInChangeList(mLoggableChanges, changeId); if (isEnabled) { // Not present in the disabled changeId array reportChange(changeId, ChangeReporter.STATE_ENABLED, isLoggable); reportChange(changeId, ChangeReporter.STATE_ENABLED, isLoggable, doStatsLog); return true; } reportChange(changeId, ChangeReporter.STATE_DISABLED, isLoggable); reportChange(changeId, ChangeReporter.STATE_DISABLED, isLoggable, doStatsLog); return false; } private void reportChange(long changeId, int state, boolean isLoggable) { private void reportChange(long changeId, int state, boolean isLoggable, boolean doStatsLog) { int uid = Process.myUid(); mChangeReporter.reportChange(uid, changeId, state, false, isLoggable); mChangeReporter.reportChange(uid, changeId, state, false, isLoggable, doStatsLog); } } core/java/android/app/IApplicationThread.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -93,8 +93,8 @@ oneway interface IApplicationThread { in CompatibilityInfo compatInfo, in Map services, in Bundle coreSettings, in String buildSerial, in AutofillOptions autofillOptions, in ContentCaptureOptions contentCaptureOptions, in long[] disabledCompatChanges, in long[] loggableCompatChanges, in SharedMemory serializedSystemFontMap, in FileDescriptor applicationSharedMemoryFd, in long[] loggableCompatChanges, in boolean logChangeChecksToStatsD, in SharedMemory serializedSystemFontMap, in FileDescriptor applicationSharedMemoryFd, long startRequestedElapsedTime, long startRequestedUptime); void runIsolatedEntryPoint(in String entryPoint, in String[] entryPointArgs); void scheduleExit(); Loading core/java/com/android/internal/compat/ChangeReporter.java +6 −4 Original line number Diff line number Diff line Loading @@ -97,12 +97,13 @@ public class ChangeReporter { * @param isLoggableBySdk whether debug logging is allowed for this change based on target * SDK version. This is combined with other logic to determine whether * to actually log. If the sdk version does not matter, should be true. * @param doStatsLog whether to log to stats log. */ public void reportChange(int uid, long changeId, int state, boolean isKnownSystemApp, boolean isLoggableBySdk) { boolean isLoggableBySdk, boolean doStatsLog) { boolean isAlreadyReported = checkAndSetIsAlreadyReported(uid, new ChangeReport(changeId, state)); if (shouldWriteToStatsLog(isKnownSystemApp, isAlreadyReported)) { if (doStatsLog && shouldWriteToStatsLog(isKnownSystemApp, isAlreadyReported)) { FrameworkStatsLog.write(FrameworkStatsLog.APP_COMPATIBILITY_CHANGE_REPORTED, uid, changeId, state, mSource); } Loading @@ -118,9 +119,10 @@ public class ChangeReporter { * @param uid affected by the change * @param changeId the reported change id * @param state of the reported change - enabled/disabled/only logged * @param doStatsLog whether to log to stats log. */ public void reportChange(int uid, long changeId, int state) { reportChange(uid, changeId, state, false, true); public void reportChange(int uid, long changeId, int state, boolean doStatsLog) { reportChange(uid, changeId, state, false, true, doStatsLog); } /** Loading core/java/com/android/internal/compat/IPlatformCompat.aidl +16 −0 Original line number Diff line number Diff line Loading @@ -366,4 +366,20 @@ interface IPlatformCompat { */ @RequiresNoPermission IOverrideValidator getOverrideValidator(); /** * Indicates whether compat change checks are logged to statsd. * * <p>To be only used in tests. * */ boolean isLogChangeChecksToStatsd(); /** * Sets whether compat change checks should be logged to statsd. * * <p>To be only used in tests. * */ void setLogChangeChecksToStatsd(boolean value); } Loading
core/java/android/app/ActivityThread.java +7 −1 Original line number Diff line number Diff line Loading @@ -997,6 +997,7 @@ public final class ActivityThread extends ClientTransactionHandler long[] disabledCompatChanges; long[] mLoggableCompatChanges; boolean mLogChangeChecksToStatsD; SharedMemory mSerializedSystemFontMap; Loading Loading @@ -1328,6 +1329,7 @@ public final class ActivityThread extends ClientTransactionHandler ContentCaptureOptions contentCaptureOptions, long[] disabledCompatChanges, long[] loggableCompatChanges, boolean logChangeChecksToStatsD, SharedMemory serializedSystemFontMap, FileDescriptor applicationSharedMemoryFd, long startRequestedElapsedTime, Loading Loading @@ -1399,6 +1401,7 @@ public final class ActivityThread extends ClientTransactionHandler data.contentCaptureOptions = contentCaptureOptions; data.disabledCompatChanges = disabledCompatChanges; data.mLoggableCompatChanges = loggableCompatChanges; data.mLogChangeChecksToStatsD = logChangeChecksToStatsD; data.mSerializedSystemFontMap = serializedSystemFontMap; data.startRequestedElapsedTime = startRequestedElapsedTime; data.startRequestedUptime = startRequestedUptime; Loading Loading @@ -7598,7 +7601,10 @@ public final class ActivityThread extends ClientTransactionHandler Process.setStartTimes(SystemClock.elapsedRealtime(), SystemClock.uptimeMillis(), data.startRequestedElapsedTime, data.startRequestedUptime); AppCompatCallbacks.install(data.disabledCompatChanges, data.mLoggableCompatChanges); AppCompatCallbacks.install( data.disabledCompatChanges, data.mLoggableCompatChanges, data.mLogChangeChecksToStatsD); // Let libcore handle any compat changes after installing the list of compat changes. AppSpecializationHooks.handleCompatChangesBeforeBindingApplication(); Loading
core/java/android/app/AppCompatCallbacks.java +29 −9 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ public final class AppCompatCallbacks implements Compatibility.BehaviorChangeDel private final long[] mDisabledChanges; private final long[] mLoggableChanges; private final ChangeReporter mChangeReporter; private boolean mLogChangeChecksToStatsD = false; /** * Install this class into the current process using the disabled and loggable changes lists. Loading @@ -40,17 +41,33 @@ public final class AppCompatCallbacks implements Compatibility.BehaviorChangeDel * @param disabledChanges Set of compatibility changes that are disabled for this process. * @param loggableChanges Set of compatibility changes that we want to log. */ public static void install(long[] disabledChanges, long[] loggableChanges) { public static void install( long[] disabledChanges, long[] loggableChanges) { Compatibility.setBehaviorChangeDelegate( new AppCompatCallbacks(disabledChanges, loggableChanges)); new AppCompatCallbacks(disabledChanges, loggableChanges, false)); } private AppCompatCallbacks(long[] disabledChanges, long[] loggableChanges) { /** * Install this class into the current process using the disabled and loggable changes lists. * * @param disabledChanges Set of compatibility changes that are disabled for this process. * @param loggableChanges Set of compatibility changes that we want to log. * @param logChangeChecksToStatsD Whether to log change checks to statsd. */ public static void install( long[] disabledChanges, long[] loggableChanges, boolean logChangeChecksToStatsD) { Compatibility.setBehaviorChangeDelegate( new AppCompatCallbacks(disabledChanges, loggableChanges, logChangeChecksToStatsD)); } private AppCompatCallbacks( long[] disabledChanges, long[] loggableChanges, boolean logChangeChecksToStatsD) { mDisabledChanges = Arrays.copyOf(disabledChanges, disabledChanges.length); mLoggableChanges = Arrays.copyOf(loggableChanges, loggableChanges.length); Arrays.sort(mDisabledChanges); Arrays.sort(mLoggableChanges); mChangeReporter = new ChangeReporter(ChangeReporter.SOURCE_APP_PROCESS); mLogChangeChecksToStatsD = logChangeChecksToStatsD; } /** Loading @@ -65,25 +82,28 @@ public final class AppCompatCallbacks implements Compatibility.BehaviorChangeDel } public void onChangeReported(long changeId) { boolean isLoggable = changeIdInChangeList(mLoggableChanges, changeId); reportChange(changeId, ChangeReporter.STATE_LOGGED, isLoggable); isChangeEnabledAndReport(changeId, true); } public boolean isChangeEnabled(long changeId) { return isChangeEnabledAndReport(changeId, mLogChangeChecksToStatsD); } private boolean isChangeEnabledAndReport(long changeId, boolean doStatsLog) { boolean isEnabled = !changeIdInChangeList(mDisabledChanges, changeId); boolean isLoggable = changeIdInChangeList(mLoggableChanges, changeId); if (isEnabled) { // Not present in the disabled changeId array reportChange(changeId, ChangeReporter.STATE_ENABLED, isLoggable); reportChange(changeId, ChangeReporter.STATE_ENABLED, isLoggable, doStatsLog); return true; } reportChange(changeId, ChangeReporter.STATE_DISABLED, isLoggable); reportChange(changeId, ChangeReporter.STATE_DISABLED, isLoggable, doStatsLog); return false; } private void reportChange(long changeId, int state, boolean isLoggable) { private void reportChange(long changeId, int state, boolean isLoggable, boolean doStatsLog) { int uid = Process.myUid(); mChangeReporter.reportChange(uid, changeId, state, false, isLoggable); mChangeReporter.reportChange(uid, changeId, state, false, isLoggable, doStatsLog); } }
core/java/android/app/IApplicationThread.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -93,8 +93,8 @@ oneway interface IApplicationThread { in CompatibilityInfo compatInfo, in Map services, in Bundle coreSettings, in String buildSerial, in AutofillOptions autofillOptions, in ContentCaptureOptions contentCaptureOptions, in long[] disabledCompatChanges, in long[] loggableCompatChanges, in SharedMemory serializedSystemFontMap, in FileDescriptor applicationSharedMemoryFd, in long[] loggableCompatChanges, in boolean logChangeChecksToStatsD, in SharedMemory serializedSystemFontMap, in FileDescriptor applicationSharedMemoryFd, long startRequestedElapsedTime, long startRequestedUptime); void runIsolatedEntryPoint(in String entryPoint, in String[] entryPointArgs); void scheduleExit(); Loading
core/java/com/android/internal/compat/ChangeReporter.java +6 −4 Original line number Diff line number Diff line Loading @@ -97,12 +97,13 @@ public class ChangeReporter { * @param isLoggableBySdk whether debug logging is allowed for this change based on target * SDK version. This is combined with other logic to determine whether * to actually log. If the sdk version does not matter, should be true. * @param doStatsLog whether to log to stats log. */ public void reportChange(int uid, long changeId, int state, boolean isKnownSystemApp, boolean isLoggableBySdk) { boolean isLoggableBySdk, boolean doStatsLog) { boolean isAlreadyReported = checkAndSetIsAlreadyReported(uid, new ChangeReport(changeId, state)); if (shouldWriteToStatsLog(isKnownSystemApp, isAlreadyReported)) { if (doStatsLog && shouldWriteToStatsLog(isKnownSystemApp, isAlreadyReported)) { FrameworkStatsLog.write(FrameworkStatsLog.APP_COMPATIBILITY_CHANGE_REPORTED, uid, changeId, state, mSource); } Loading @@ -118,9 +119,10 @@ public class ChangeReporter { * @param uid affected by the change * @param changeId the reported change id * @param state of the reported change - enabled/disabled/only logged * @param doStatsLog whether to log to stats log. */ public void reportChange(int uid, long changeId, int state) { reportChange(uid, changeId, state, false, true); public void reportChange(int uid, long changeId, int state, boolean doStatsLog) { reportChange(uid, changeId, state, false, true, doStatsLog); } /** Loading
core/java/com/android/internal/compat/IPlatformCompat.aidl +16 −0 Original line number Diff line number Diff line Loading @@ -366,4 +366,20 @@ interface IPlatformCompat { */ @RequiresNoPermission IOverrideValidator getOverrideValidator(); /** * Indicates whether compat change checks are logged to statsd. * * <p>To be only used in tests. * */ boolean isLogChangeChecksToStatsd(); /** * Sets whether compat change checks should be logged to statsd. * * <p>To be only used in tests. * */ void setLogChangeChecksToStatsd(boolean value); }