Loading core/java/android/app/StatusBarManager.java +4 −0 Original line number Diff line number Diff line Loading @@ -58,8 +58,10 @@ import com.android.internal.statusbar.IStatusBarService; import com.android.internal.statusbar.IUndoMediaTransferCallback; import com.android.internal.statusbar.NotificationVisibility; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.ArrayList; import java.util.HashMap; import java.util.List; Loading Loading @@ -119,6 +121,7 @@ public class StatusBarManager { | DISABLE_SEARCH | DISABLE_ONGOING_CALL_CHIP; /** @hide */ @Target(ElementType.TYPE_USE) @IntDef(flag = true, prefix = {"DISABLE_"}, value = { DISABLE_NONE, DISABLE_EXPAND, Loading Loading @@ -161,6 +164,7 @@ public class StatusBarManager { | DISABLE2_NOTIFICATION_SHADE | DISABLE2_GLOBAL_ACTIONS | DISABLE2_ROTATE_SUGGESTIONS; /** @hide */ @Target(ElementType.TYPE_USE) @IntDef(flag = true, prefix = { "DISABLE2_" }, value = { DISABLE2_NONE, DISABLE2_MASK, Loading core/java/com/android/internal/statusbar/DisableStates.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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.internal.statusbar; parcelable DisableStates; core/java/com/android/internal/statusbar/DisableStates.java 0 → 100644 +95 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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.internal.statusbar; import android.app.StatusBarManager.Disable2Flags; import android.app.StatusBarManager.DisableFlags; import android.os.Parcel; import android.os.Parcelable; import android.util.Pair; import java.util.HashMap; import java.util.Map; /** * Holds display ids with their disable flags. */ public class DisableStates implements Parcelable { /** * A map of display IDs (integers) with corresponding disable flags. */ public Map<Integer, Pair<@DisableFlags Integer, @Disable2Flags Integer>> displaysWithStates; /** * Whether the disable state change should be animated. */ public boolean animate; public DisableStates( Map<Integer, Pair<@DisableFlags Integer, @Disable2Flags Integer>> displaysWithStates, boolean animate) { this.displaysWithStates = displaysWithStates; this.animate = animate; } public DisableStates( Map<Integer, Pair<@DisableFlags Integer, @Disable2Flags Integer>> displaysWithStates) { this(displaysWithStates, true); } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(displaysWithStates.size()); // Write the size of the map for (Map.Entry<Integer, Pair<Integer, Integer>> entry : displaysWithStates.entrySet()) { dest.writeInt(entry.getKey()); dest.writeInt(entry.getValue().first); dest.writeInt(entry.getValue().second); } dest.writeBoolean(animate); } /** * Used to make this class parcelable. */ public static final Parcelable.Creator<DisableStates> CREATOR = new Parcelable.Creator<>() { @Override public DisableStates createFromParcel(Parcel source) { int size = source.readInt(); // Read the size of the map Map<Integer, Pair<Integer, Integer>> displaysWithStates = new HashMap<>(size); for (int i = 0; i < size; i++) { int key = source.readInt(); int first = source.readInt(); int second = source.readInt(); displaysWithStates.put(key, new Pair<>(first, second)); } final boolean animate = source.readBoolean(); return new DisableStates(displaysWithStates, animate); } @Override public DisableStates[] newArray(int size) { return new DisableStates[size]; } }; } core/java/com/android/internal/statusbar/IStatusBar.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.os.UserHandle; import android.view.KeyEvent; import android.service.notification.StatusBarNotification; import com.android.internal.statusbar.DisableStates; import com.android.internal.statusbar.IAddTileResultCallback; import com.android.internal.statusbar.IUndoMediaTransferCallback; import com.android.internal.statusbar.LetterboxDetails; Loading @@ -44,6 +45,7 @@ oneway interface IStatusBar void setIcon(String slot, in StatusBarIcon icon); void removeIcon(String slot); void disable(int displayId, int state1, int state2); void disableForAllDisplays(in DisableStates disableStates); void animateExpandNotificationsPanel(); void animateExpandSettingsPanel(String subPanel); void animateCollapsePanels(); Loading core/tests/coretests/src/com/android/internal/statusbar/DisableStatesTest.java 0 → 100644 +64 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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.internal.statusbar; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import android.os.Parcel; import android.util.Pair; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; import org.junit.Test; import org.junit.runner.RunWith; import java.util.HashMap; import java.util.Map; @RunWith(AndroidJUnit4.class) @SmallTest public class DisableStatesTest { @Test public void testParcelable() { Map<Integer, Pair<Integer, Integer>> displaysWithStates = new HashMap<>(); displaysWithStates.put(1, new Pair<>(10, 20)); displaysWithStates.put(2, new Pair<>(30, 40)); boolean animate = true; DisableStates original = new DisableStates(displaysWithStates, animate); Parcel parcel = Parcel.obtain(); original.writeToParcel(parcel, 0); parcel.setDataPosition(0); DisableStates restored = DisableStates.CREATOR.createFromParcel(parcel); assertNotNull(restored); assertEquals(original.displaysWithStates.size(), restored.displaysWithStates.size()); for (Map.Entry<Integer, Pair<Integer, Integer>> entry : original.displaysWithStates.entrySet()) { int displayId = entry.getKey(); Pair<Integer, Integer> originalDisplayStates = entry.getValue(); Pair<Integer, Integer> restoredDisplayStates = restored.displaysWithStates.get( displayId); assertEquals(originalDisplayStates.first, restoredDisplayStates.first); assertEquals(originalDisplayStates.second, restoredDisplayStates.second); } assertEquals(original.animate, restored.animate); } } Loading
core/java/android/app/StatusBarManager.java +4 −0 Original line number Diff line number Diff line Loading @@ -58,8 +58,10 @@ import com.android.internal.statusbar.IStatusBarService; import com.android.internal.statusbar.IUndoMediaTransferCallback; import com.android.internal.statusbar.NotificationVisibility; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.ArrayList; import java.util.HashMap; import java.util.List; Loading Loading @@ -119,6 +121,7 @@ public class StatusBarManager { | DISABLE_SEARCH | DISABLE_ONGOING_CALL_CHIP; /** @hide */ @Target(ElementType.TYPE_USE) @IntDef(flag = true, prefix = {"DISABLE_"}, value = { DISABLE_NONE, DISABLE_EXPAND, Loading Loading @@ -161,6 +164,7 @@ public class StatusBarManager { | DISABLE2_NOTIFICATION_SHADE | DISABLE2_GLOBAL_ACTIONS | DISABLE2_ROTATE_SUGGESTIONS; /** @hide */ @Target(ElementType.TYPE_USE) @IntDef(flag = true, prefix = { "DISABLE2_" }, value = { DISABLE2_NONE, DISABLE2_MASK, Loading
core/java/com/android/internal/statusbar/DisableStates.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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.internal.statusbar; parcelable DisableStates;
core/java/com/android/internal/statusbar/DisableStates.java 0 → 100644 +95 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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.internal.statusbar; import android.app.StatusBarManager.Disable2Flags; import android.app.StatusBarManager.DisableFlags; import android.os.Parcel; import android.os.Parcelable; import android.util.Pair; import java.util.HashMap; import java.util.Map; /** * Holds display ids with their disable flags. */ public class DisableStates implements Parcelable { /** * A map of display IDs (integers) with corresponding disable flags. */ public Map<Integer, Pair<@DisableFlags Integer, @Disable2Flags Integer>> displaysWithStates; /** * Whether the disable state change should be animated. */ public boolean animate; public DisableStates( Map<Integer, Pair<@DisableFlags Integer, @Disable2Flags Integer>> displaysWithStates, boolean animate) { this.displaysWithStates = displaysWithStates; this.animate = animate; } public DisableStates( Map<Integer, Pair<@DisableFlags Integer, @Disable2Flags Integer>> displaysWithStates) { this(displaysWithStates, true); } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(displaysWithStates.size()); // Write the size of the map for (Map.Entry<Integer, Pair<Integer, Integer>> entry : displaysWithStates.entrySet()) { dest.writeInt(entry.getKey()); dest.writeInt(entry.getValue().first); dest.writeInt(entry.getValue().second); } dest.writeBoolean(animate); } /** * Used to make this class parcelable. */ public static final Parcelable.Creator<DisableStates> CREATOR = new Parcelable.Creator<>() { @Override public DisableStates createFromParcel(Parcel source) { int size = source.readInt(); // Read the size of the map Map<Integer, Pair<Integer, Integer>> displaysWithStates = new HashMap<>(size); for (int i = 0; i < size; i++) { int key = source.readInt(); int first = source.readInt(); int second = source.readInt(); displaysWithStates.put(key, new Pair<>(first, second)); } final boolean animate = source.readBoolean(); return new DisableStates(displaysWithStates, animate); } @Override public DisableStates[] newArray(int size) { return new DisableStates[size]; } }; }
core/java/com/android/internal/statusbar/IStatusBar.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.os.UserHandle; import android.view.KeyEvent; import android.service.notification.StatusBarNotification; import com.android.internal.statusbar.DisableStates; import com.android.internal.statusbar.IAddTileResultCallback; import com.android.internal.statusbar.IUndoMediaTransferCallback; import com.android.internal.statusbar.LetterboxDetails; Loading @@ -44,6 +45,7 @@ oneway interface IStatusBar void setIcon(String slot, in StatusBarIcon icon); void removeIcon(String slot); void disable(int displayId, int state1, int state2); void disableForAllDisplays(in DisableStates disableStates); void animateExpandNotificationsPanel(); void animateExpandSettingsPanel(String subPanel); void animateCollapsePanels(); Loading
core/tests/coretests/src/com/android/internal/statusbar/DisableStatesTest.java 0 → 100644 +64 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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.internal.statusbar; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import android.os.Parcel; import android.util.Pair; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; import org.junit.Test; import org.junit.runner.RunWith; import java.util.HashMap; import java.util.Map; @RunWith(AndroidJUnit4.class) @SmallTest public class DisableStatesTest { @Test public void testParcelable() { Map<Integer, Pair<Integer, Integer>> displaysWithStates = new HashMap<>(); displaysWithStates.put(1, new Pair<>(10, 20)); displaysWithStates.put(2, new Pair<>(30, 40)); boolean animate = true; DisableStates original = new DisableStates(displaysWithStates, animate); Parcel parcel = Parcel.obtain(); original.writeToParcel(parcel, 0); parcel.setDataPosition(0); DisableStates restored = DisableStates.CREATOR.createFromParcel(parcel); assertNotNull(restored); assertEquals(original.displaysWithStates.size(), restored.displaysWithStates.size()); for (Map.Entry<Integer, Pair<Integer, Integer>> entry : original.displaysWithStates.entrySet()) { int displayId = entry.getKey(); Pair<Integer, Integer> originalDisplayStates = entry.getValue(); Pair<Integer, Integer> restoredDisplayStates = restored.displaysWithStates.get( displayId); assertEquals(originalDisplayStates.first, restoredDisplayStates.first); assertEquals(originalDisplayStates.second, restoredDisplayStates.second); } assertEquals(original.animate, restored.animate); } }