Loading apex/jobscheduler/service/java/com/android/server/tare/EconomicPolicy.java +6 −5 Original line number Diff line number Diff line Loading @@ -55,12 +55,13 @@ public abstract class EconomicPolicy { static final int TYPE_ACTION = 1 << SHIFT_TYPE; static final int TYPE_REWARD = 2 << SHIFT_TYPE; private static final int SHIFT_POLICY = 29; static final int MASK_POLICY = 0b1 << SHIFT_POLICY; static final int POLICY_AM = 0 << SHIFT_POLICY; static final int POLICY_JS = 1 << SHIFT_POLICY; private static final int SHIFT_POLICY = 28; static final int MASK_POLICY = 0b11 << SHIFT_POLICY; // Reserve 0 for the base/common policy. static final int POLICY_AM = 1 << SHIFT_POLICY; static final int POLICY_JS = 2 << SHIFT_POLICY; static final int MASK_EVENT = ~0 - (0b111 << SHIFT_POLICY); static final int MASK_EVENT = -1 ^ (MASK_TYPE | MASK_POLICY); static final int REGULATION_BASIC_INCOME = TYPE_REGULATION | 0; static final int REGULATION_BIRTHRIGHT = TYPE_REGULATION | 1; Loading services/tests/mockingservicestests/src/com/android/server/tare/EconomicPolicyTest.java 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.tare; import static org.junit.Assert.assertEquals; import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) public class EconomicPolicyTest { @Test public void testMasksDisjoint() { assertEquals(-1, (-1 & EconomicPolicy.MASK_TYPE) + (-1 & EconomicPolicy.MASK_POLICY) + (-1 & EconomicPolicy.MASK_EVENT)); } } Loading
apex/jobscheduler/service/java/com/android/server/tare/EconomicPolicy.java +6 −5 Original line number Diff line number Diff line Loading @@ -55,12 +55,13 @@ public abstract class EconomicPolicy { static final int TYPE_ACTION = 1 << SHIFT_TYPE; static final int TYPE_REWARD = 2 << SHIFT_TYPE; private static final int SHIFT_POLICY = 29; static final int MASK_POLICY = 0b1 << SHIFT_POLICY; static final int POLICY_AM = 0 << SHIFT_POLICY; static final int POLICY_JS = 1 << SHIFT_POLICY; private static final int SHIFT_POLICY = 28; static final int MASK_POLICY = 0b11 << SHIFT_POLICY; // Reserve 0 for the base/common policy. static final int POLICY_AM = 1 << SHIFT_POLICY; static final int POLICY_JS = 2 << SHIFT_POLICY; static final int MASK_EVENT = ~0 - (0b111 << SHIFT_POLICY); static final int MASK_EVENT = -1 ^ (MASK_TYPE | MASK_POLICY); static final int REGULATION_BASIC_INCOME = TYPE_REGULATION | 0; static final int REGULATION_BIRTHRIGHT = TYPE_REGULATION | 1; Loading
services/tests/mockingservicestests/src/com/android/server/tare/EconomicPolicyTest.java 0 → 100644 +36 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.tare; import static org.junit.Assert.assertEquals; import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) public class EconomicPolicyTest { @Test public void testMasksDisjoint() { assertEquals(-1, (-1 & EconomicPolicy.MASK_TYPE) + (-1 & EconomicPolicy.MASK_POLICY) + (-1 & EconomicPolicy.MASK_EVENT)); } }