Introduce nt-fwk
Used by Hotword Enrollment. Change-Id: I65f5da0ba6dcd2e83a6bbc5a14567474686beedc Signed-off-by: cjh1249131356 <cjh1249131356@gmail.com> Signed-off-by: chandu078 <chandudyavanapelli03@gmail.com>
This commit is contained in:
committed by
Wiktor Rudzki
parent
5b11e7851e
commit
9444409ad2
14
nt-fwk/Android.bp
Normal file
14
nt-fwk/Android.bp
Normal file
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Copyright (C) 2024 The LineageOS Project
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
java_library {
|
||||
name: "nt-fwk",
|
||||
installable: true,
|
||||
|
||||
srcs: [
|
||||
"src/**/*.java",
|
||||
],
|
||||
}
|
||||
8
nt-fwk/nt-fwk.mk
Normal file
8
nt-fwk/nt-fwk.mk
Normal file
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# Copyright (C) 2024 The LineageOS Project
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
PRODUCT_PACKAGES += nt-fwk
|
||||
PRODUCT_BOOT_JARS += nt-fwk
|
||||
60
nt-fwk/src/com/nothing/NtFeaturesUtils.java
Normal file
60
nt-fwk/src/com/nothing/NtFeaturesUtils.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The LineageOS Project
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.nothing;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.SystemProperties;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
public class NtFeaturesUtils {
|
||||
|
||||
private static final BitSet sFeatures = new BitSet(38);
|
||||
|
||||
static {
|
||||
final String fullProp = SystemProperties.get("ro.build.nothing.feature.base", "0");
|
||||
final String productDiffProp = SystemProperties.get("ro.build.nothing.feature.diff.product." + Build.PRODUCT, "0");
|
||||
final String deviceDiffProp = SystemProperties.get("ro.build.nothing.feature.diff.device." + Build.DEVICE, "0");
|
||||
|
||||
base(Long.decode(fullProp).longValue());
|
||||
change(Long.decode(productDiffProp).longValue());
|
||||
change(Long.decode(deviceDiffProp).longValue());
|
||||
}
|
||||
|
||||
public static boolean isSupport(int... features) {
|
||||
for (int feature : features) {
|
||||
if (feature < 0 || feature > 37) {
|
||||
return false;
|
||||
}
|
||||
if (!sFeatures.get(feature)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void base(long full) {
|
||||
int index = 0;
|
||||
while (full != 0) {
|
||||
if (full % 2 != 0) {
|
||||
sFeatures.set(index);
|
||||
}
|
||||
index++;
|
||||
full >>>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static void change(long diff) {
|
||||
int index = 0;
|
||||
while (diff != 0) {
|
||||
if (diff % 2 != 0) {
|
||||
sFeatures.flip(index);
|
||||
}
|
||||
index++;
|
||||
diff >>>= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user