Merge "Refine getIndex and getType of InsetsSource" into udc-dev am: f34371cb12

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23127421

Change-Id: I7d9b95347f2dea6e999176e9d4112b8e526aac82
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Tiger Huang
2023-05-11 02:05:23 +00:00
committed by Automerger Merge Worker

View File

@@ -293,16 +293,23 @@ public class InsetsSource implements Parcelable {
* @see #createId(Object, int, int)
*/
public static int getIndex(int id) {
return (id % (1 << 16)) >> 5;
// start: ????????????????***********?????
// & 65535: 0000000000000000***********?????
// >> 5: 000000000000000000000***********
return (id & 65535) >> 5;
}
/**
* Gets the {@link InsetsType} from the ID.
*
* @see #createId(Object, int, int)
* @see WindowInsets.Type#indexOf(int)
*/
public static int getType(int id) {
return 1 << (id % 32);
// start: ???????????????????????????*****
// & 31: 000000000000000000000000000*****
// 1 <<: See WindowInsets.Type#indexOf
return 1 << (id & 31);
}
public static String flagsToString(@Flags int flags) {