Loading services/core/java/com/android/server/am/ActivityManagerService.java +42 −32 Original line number Diff line number Diff line Loading @@ -2486,7 +2486,7 @@ public class ActivityManagerService extends IActivityManager.Stub mUseFifoUiScheduling = false; mEnableOffloadQueue = false; mEnableModernQueue = false; mBroadcastQueues = new BroadcastQueue[0]; mBroadcastQueues = injector.getBroadcastQueues(this); mComponentAliasResolver = new ComponentAliasResolver(this); } Loading Loading @@ -2527,40 +2527,12 @@ public class ActivityManagerService extends IActivityManager.Stub ? new OomAdjusterModernImpl(this, mProcessList, activeUids) : new OomAdjuster(this, mProcessList, activeUids); // Broadcast policy parameters final BroadcastConstants foreConstants = new BroadcastConstants( Settings.Global.BROADCAST_FG_CONSTANTS); foreConstants.TIMEOUT = BROADCAST_FG_TIMEOUT; final BroadcastConstants backConstants = new BroadcastConstants( Settings.Global.BROADCAST_BG_CONSTANTS); backConstants.TIMEOUT = BROADCAST_BG_TIMEOUT; final BroadcastConstants offloadConstants = new BroadcastConstants( Settings.Global.BROADCAST_OFFLOAD_CONSTANTS); offloadConstants.TIMEOUT = BROADCAST_BG_TIMEOUT; // by default, no "slow" policy in this queue offloadConstants.SLOW_TIME = Integer.MAX_VALUE; mEnableOffloadQueue = SystemProperties.getBoolean( "persist.device_config.activity_manager_native_boot.offload_queue_enabled", true); mEnableModernQueue = foreConstants.MODERN_QUEUE_ENABLED; mEnableModernQueue = new BroadcastConstants( Settings.Global.BROADCAST_FG_CONSTANTS).MODERN_QUEUE_ENABLED; if (mEnableModernQueue) { mBroadcastQueues = new BroadcastQueue[1]; mBroadcastQueues[0] = new BroadcastQueueModernImpl(this, mHandler, foreConstants, backConstants); } else { mBroadcastQueues = new BroadcastQueue[4]; mBroadcastQueues[BROADCAST_QUEUE_FG] = new BroadcastQueueImpl(this, mHandler, "foreground", foreConstants, false, ProcessList.SCHED_GROUP_DEFAULT); mBroadcastQueues[BROADCAST_QUEUE_BG] = new BroadcastQueueImpl(this, mHandler, "background", backConstants, true, ProcessList.SCHED_GROUP_BACKGROUND); mBroadcastQueues[BROADCAST_QUEUE_BG_OFFLOAD] = new BroadcastQueueImpl(this, mHandler, "offload_bg", offloadConstants, true, ProcessList.SCHED_GROUP_BACKGROUND); mBroadcastQueues[BROADCAST_QUEUE_FG_OFFLOAD] = new BroadcastQueueImpl(this, mHandler, "offload_fg", foreConstants, true, ProcessList.SCHED_GROUP_BACKGROUND); } mBroadcastQueues = mInjector.getBroadcastQueues(this); mServices = new ActiveServices(this); mCpHelper = new ContentProviderHelper(this, true); Loading Loading @@ -20060,6 +20032,44 @@ public class ActivityManagerService extends IActivityManager.Stub } return mNmi != null; } public BroadcastQueue[] getBroadcastQueues(ActivityManagerService service) { // Broadcast policy parameters final BroadcastConstants foreConstants = new BroadcastConstants( Settings.Global.BROADCAST_FG_CONSTANTS); foreConstants.TIMEOUT = BROADCAST_FG_TIMEOUT; final BroadcastConstants backConstants = new BroadcastConstants( Settings.Global.BROADCAST_BG_CONSTANTS); backConstants.TIMEOUT = BROADCAST_BG_TIMEOUT; final BroadcastConstants offloadConstants = new BroadcastConstants( Settings.Global.BROADCAST_OFFLOAD_CONSTANTS); offloadConstants.TIMEOUT = BROADCAST_BG_TIMEOUT; // by default, no "slow" policy in this queue offloadConstants.SLOW_TIME = Integer.MAX_VALUE; final BroadcastQueue[] broadcastQueues; final Handler handler = service.mHandler; if (service.mEnableModernQueue) { broadcastQueues = new BroadcastQueue[1]; broadcastQueues[0] = new BroadcastQueueModernImpl(service, handler, foreConstants, backConstants); } else { broadcastQueues = new BroadcastQueue[4]; broadcastQueues[BROADCAST_QUEUE_FG] = new BroadcastQueueImpl(service, handler, "foreground", foreConstants, false, ProcessList.SCHED_GROUP_DEFAULT); broadcastQueues[BROADCAST_QUEUE_BG] = new BroadcastQueueImpl(service, handler, "background", backConstants, true, ProcessList.SCHED_GROUP_BACKGROUND); broadcastQueues[BROADCAST_QUEUE_BG_OFFLOAD] = new BroadcastQueueImpl(service, handler, "offload_bg", offloadConstants, true, ProcessList.SCHED_GROUP_BACKGROUND); broadcastQueues[BROADCAST_QUEUE_FG_OFFLOAD] = new BroadcastQueueImpl(service, handler, "offload_fg", foreConstants, true, ProcessList.SCHED_GROUP_BACKGROUND); } return broadcastQueues; } } @Override services/tests/mockingservicestests/src/com/android/server/am/BaseBroadcastQueueTest.java +10 −1 Original line number Diff line number Diff line Loading @@ -93,6 +93,8 @@ public abstract class BaseBroadcastQueueTest { .spyStatic(ProcessList.class) .build(); final BroadcastQueue[] mBroadcastQueues = new BroadcastQueue[1]; @Mock AppOpsService mAppOpsService; @Mock Loading Loading @@ -162,8 +164,10 @@ public abstract class BaseBroadcastQueueTest { } public void tearDown() throws Exception { if (mHandlerThread != null) { mHandlerThread.quit(); } } static int getUidForPackage(@NonNull String packageName) { switch (packageName) { Loading Loading @@ -202,6 +206,11 @@ public abstract class BaseBroadcastQueueTest { public ProcessList getProcessList(ActivityManagerService service) { return mProcessList; } @Override public BroadcastQueue[] getBroadcastQueues(ActivityManagerService service) { return mBroadcastQueues; } } abstract String getTag(); Loading services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,7 @@ public final class BroadcastQueueModernImplTest extends BaseBroadcastQueueTest { mImpl = new BroadcastQueueModernImpl(mAms, mHandlerThread.getThreadHandler(), mConstants, mConstants, mSkipPolicy, emptyHistory); mBroadcastQueues[0] = mImpl; doReturn(1L).when(mQueue1).getRunnableAt(); doReturn(2L).when(mQueue2).getRunnableAt(); Loading services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -255,6 +255,7 @@ public class BroadcastQueueTest extends BaseBroadcastQueueTest { } else { throw new UnsupportedOperationException(); } mBroadcastQueues[0] = mQueue; mQueue.start(mContext.getContentResolver()); } Loading Loading
services/core/java/com/android/server/am/ActivityManagerService.java +42 −32 Original line number Diff line number Diff line Loading @@ -2486,7 +2486,7 @@ public class ActivityManagerService extends IActivityManager.Stub mUseFifoUiScheduling = false; mEnableOffloadQueue = false; mEnableModernQueue = false; mBroadcastQueues = new BroadcastQueue[0]; mBroadcastQueues = injector.getBroadcastQueues(this); mComponentAliasResolver = new ComponentAliasResolver(this); } Loading Loading @@ -2527,40 +2527,12 @@ public class ActivityManagerService extends IActivityManager.Stub ? new OomAdjusterModernImpl(this, mProcessList, activeUids) : new OomAdjuster(this, mProcessList, activeUids); // Broadcast policy parameters final BroadcastConstants foreConstants = new BroadcastConstants( Settings.Global.BROADCAST_FG_CONSTANTS); foreConstants.TIMEOUT = BROADCAST_FG_TIMEOUT; final BroadcastConstants backConstants = new BroadcastConstants( Settings.Global.BROADCAST_BG_CONSTANTS); backConstants.TIMEOUT = BROADCAST_BG_TIMEOUT; final BroadcastConstants offloadConstants = new BroadcastConstants( Settings.Global.BROADCAST_OFFLOAD_CONSTANTS); offloadConstants.TIMEOUT = BROADCAST_BG_TIMEOUT; // by default, no "slow" policy in this queue offloadConstants.SLOW_TIME = Integer.MAX_VALUE; mEnableOffloadQueue = SystemProperties.getBoolean( "persist.device_config.activity_manager_native_boot.offload_queue_enabled", true); mEnableModernQueue = foreConstants.MODERN_QUEUE_ENABLED; mEnableModernQueue = new BroadcastConstants( Settings.Global.BROADCAST_FG_CONSTANTS).MODERN_QUEUE_ENABLED; if (mEnableModernQueue) { mBroadcastQueues = new BroadcastQueue[1]; mBroadcastQueues[0] = new BroadcastQueueModernImpl(this, mHandler, foreConstants, backConstants); } else { mBroadcastQueues = new BroadcastQueue[4]; mBroadcastQueues[BROADCAST_QUEUE_FG] = new BroadcastQueueImpl(this, mHandler, "foreground", foreConstants, false, ProcessList.SCHED_GROUP_DEFAULT); mBroadcastQueues[BROADCAST_QUEUE_BG] = new BroadcastQueueImpl(this, mHandler, "background", backConstants, true, ProcessList.SCHED_GROUP_BACKGROUND); mBroadcastQueues[BROADCAST_QUEUE_BG_OFFLOAD] = new BroadcastQueueImpl(this, mHandler, "offload_bg", offloadConstants, true, ProcessList.SCHED_GROUP_BACKGROUND); mBroadcastQueues[BROADCAST_QUEUE_FG_OFFLOAD] = new BroadcastQueueImpl(this, mHandler, "offload_fg", foreConstants, true, ProcessList.SCHED_GROUP_BACKGROUND); } mBroadcastQueues = mInjector.getBroadcastQueues(this); mServices = new ActiveServices(this); mCpHelper = new ContentProviderHelper(this, true); Loading Loading @@ -20060,6 +20032,44 @@ public class ActivityManagerService extends IActivityManager.Stub } return mNmi != null; } public BroadcastQueue[] getBroadcastQueues(ActivityManagerService service) { // Broadcast policy parameters final BroadcastConstants foreConstants = new BroadcastConstants( Settings.Global.BROADCAST_FG_CONSTANTS); foreConstants.TIMEOUT = BROADCAST_FG_TIMEOUT; final BroadcastConstants backConstants = new BroadcastConstants( Settings.Global.BROADCAST_BG_CONSTANTS); backConstants.TIMEOUT = BROADCAST_BG_TIMEOUT; final BroadcastConstants offloadConstants = new BroadcastConstants( Settings.Global.BROADCAST_OFFLOAD_CONSTANTS); offloadConstants.TIMEOUT = BROADCAST_BG_TIMEOUT; // by default, no "slow" policy in this queue offloadConstants.SLOW_TIME = Integer.MAX_VALUE; final BroadcastQueue[] broadcastQueues; final Handler handler = service.mHandler; if (service.mEnableModernQueue) { broadcastQueues = new BroadcastQueue[1]; broadcastQueues[0] = new BroadcastQueueModernImpl(service, handler, foreConstants, backConstants); } else { broadcastQueues = new BroadcastQueue[4]; broadcastQueues[BROADCAST_QUEUE_FG] = new BroadcastQueueImpl(service, handler, "foreground", foreConstants, false, ProcessList.SCHED_GROUP_DEFAULT); broadcastQueues[BROADCAST_QUEUE_BG] = new BroadcastQueueImpl(service, handler, "background", backConstants, true, ProcessList.SCHED_GROUP_BACKGROUND); broadcastQueues[BROADCAST_QUEUE_BG_OFFLOAD] = new BroadcastQueueImpl(service, handler, "offload_bg", offloadConstants, true, ProcessList.SCHED_GROUP_BACKGROUND); broadcastQueues[BROADCAST_QUEUE_FG_OFFLOAD] = new BroadcastQueueImpl(service, handler, "offload_fg", foreConstants, true, ProcessList.SCHED_GROUP_BACKGROUND); } return broadcastQueues; } } @Override
services/tests/mockingservicestests/src/com/android/server/am/BaseBroadcastQueueTest.java +10 −1 Original line number Diff line number Diff line Loading @@ -93,6 +93,8 @@ public abstract class BaseBroadcastQueueTest { .spyStatic(ProcessList.class) .build(); final BroadcastQueue[] mBroadcastQueues = new BroadcastQueue[1]; @Mock AppOpsService mAppOpsService; @Mock Loading Loading @@ -162,8 +164,10 @@ public abstract class BaseBroadcastQueueTest { } public void tearDown() throws Exception { if (mHandlerThread != null) { mHandlerThread.quit(); } } static int getUidForPackage(@NonNull String packageName) { switch (packageName) { Loading Loading @@ -202,6 +206,11 @@ public abstract class BaseBroadcastQueueTest { public ProcessList getProcessList(ActivityManagerService service) { return mProcessList; } @Override public BroadcastQueue[] getBroadcastQueues(ActivityManagerService service) { return mBroadcastQueues; } } abstract String getTag(); Loading
services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -126,6 +126,7 @@ public final class BroadcastQueueModernImplTest extends BaseBroadcastQueueTest { mImpl = new BroadcastQueueModernImpl(mAms, mHandlerThread.getThreadHandler(), mConstants, mConstants, mSkipPolicy, emptyHistory); mBroadcastQueues[0] = mImpl; doReturn(1L).when(mQueue1).getRunnableAt(); doReturn(2L).when(mQueue2).getRunnableAt(); Loading
services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -255,6 +255,7 @@ public class BroadcastQueueTest extends BaseBroadcastQueueTest { } else { throw new UnsupportedOperationException(); } mBroadcastQueues[0] = mQueue; mQueue.start(mContext.getContentResolver()); } Loading