Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit abde8efc authored by Yisroel Forta's avatar Yisroel Forta
Browse files

Remove app_start_info_keep_records_sorted flag

Bug: 411482727
Test: presubmit
Flag: EXEMPT - flag cleanup
Change-Id: I2a5f6b4a081a1f21efa8aba2aea58d4f55a310e6
parent 8f419ee3
Loading
Loading
Loading
Loading
+0 −10
Original line number Original line Diff line number Diff line
@@ -116,16 +116,6 @@ flag {
     }
     }
}
}


flag {
     namespace: "system_performance"
     name: "app_start_info_keep_records_sorted"
     description: "Ensure records are kept sorted to avoid extra work"
     bug: "384539178"
     metadata {
         purpose: PURPOSE_BUGFIX
     }
}

flag {
flag {
     name: "enable_process_observer_broadcast_on_process_started"
     name: "enable_process_observer_broadcast_on_process_started"
     namespace: "system_performance"
     namespace: "system_performance"
+7 −41
Original line number Original line Diff line number Diff line
@@ -1193,13 +1193,6 @@ public final class AppStartInfoTracker {
                return;
                return;
            }
            }


            if (!android.app.Flags.appStartInfoKeepRecordsSorted()) {
                // Sort records so we can remove the least recent ones.
                Collections.sort(mInfos, (a, b) ->
                        Long.compare(b.getMonotonicCreationTimeMs(),
                                a.getMonotonicCreationTimeMs()));
            }

            // Remove records and trim list object back to size.
            // Remove records and trim list object back to size.
            mInfos.subList(0, mInfos.size() - getMaxCapacity()).clear();
            mInfos.subList(0, mInfos.size() - getMaxCapacity()).clear();
            mInfos.trimToSize();
            mInfos.trimToSize();
@@ -1213,34 +1206,11 @@ public final class AppStartInfoTracker {


        @GuardedBy("mLock")
        @GuardedBy("mLock")
        void addStartInfoLocked(ApplicationStartInfo info) {
        void addStartInfoLocked(ApplicationStartInfo info) {
            if (android.app.Flags.appStartInfoKeepRecordsSorted()) {
            while (mInfos.size() >= getMaxCapacity()) {
            while (mInfos.size() >= getMaxCapacity()) {
                // Expected to execute at most once.
                // Expected to execute at most once.
                mInfos.removeLast();
                mInfos.removeLast();
            }
            }
            mInfos.addFirst(info);
            mInfos.addFirst(info);
            } else {
                int size = mInfos.size();
                if (size >= getMaxCapacity()) {
                    // Remove oldest record if size is over max capacity.
                    int oldestIndex = -1;
                    long oldestTimeStamp = Long.MAX_VALUE;
                    for (int i = 0; i < size; i++) {
                        ApplicationStartInfo startInfo = mInfos.get(i);
                        if (startInfo.getMonotonicCreationTimeMs() < oldestTimeStamp) {
                            oldestTimeStamp = startInfo.getMonotonicCreationTimeMs();
                            oldestIndex = i;
                        }
                    }
                    if (oldestIndex >= 0) {
                        mInfos.remove(oldestIndex);
                    }
                }
                mInfos.add(info);
                Collections.sort(mInfos, (a, b) ->
                        Long.compare(b.getMonotonicCreationTimeMs(),
                                a.getMonotonicCreationTimeMs()));
            }
        }
        }


        /**
        /**
@@ -1427,13 +1397,9 @@ public final class AppStartInfoTracker {
                        info.readFromProto(proto, AppsStartInfoProto.Package.User.APP_START_INFO,
                        info.readFromProto(proto, AppsStartInfoProto.Package.User.APP_START_INFO,
                                byteArrayInputStream, objectInputStream, typedXmlPullParser);
                                byteArrayInputStream, objectInputStream, typedXmlPullParser);
                        info.setPackageName(packageName);
                        info.setPackageName(packageName);
                        if (android.app.Flags.appStartInfoKeepRecordsSorted()) {
                        // Since the writes are done from oldest to newest, each additional
                        // Since the writes are done from oldest to newest, each additional
                        // record will be newer than the previous so use addFirst.
                        // record will be newer than the previous so use addFirst.
                        mInfos.addFirst(info);
                        mInfos.addFirst(info);
                        } else {
                            mInfos.add(info);
                        }
                        break;
                        break;
                    case (int) AppsStartInfoProto.Package.User.MONITORING_ENABLED:
                    case (int) AppsStartInfoProto.Package.User.MONITORING_ENABLED:
                        mMonitoringModeEnabled = proto.readBoolean(
                        mMonitoringModeEnabled = proto.readBoolean(