Skip to content

Commit 28f19fa

Browse files
committed
core: Dynamically inject Tensor features for Play Store compatibility
Inject Tensor-specific features dynamically via getSystemAvailableFeatures() to ensure Play Store and other services recognize them as system-declared features instead of relying solely on hasSystemFeature() overrides. This improves compatibility with Tensor-targeted GApps and allows updates to appear correctly in Play Store. Also expose invalidateHasSystemFeatureCache() to allow cache refresh when spoofing state changes. - Inject FEATURES_TENSOR into system feature list when enabled - Keep hasSystemFeature() override for runtime checks - Add cache invalidation support for immediate effect Note: Play Store may still require a reboot or process restart due to server-side and process-level caching.
1 parent b1a5832 commit 28f19fa

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

core/java/android/app/ApplicationPackageManager.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -792,12 +792,32 @@ public FeatureInfo[] getSystemAvailableFeatures() {
792792
if (parceledList == null) {
793793
return new FeatureInfo[0];
794794
}
795-
final List<FeatureInfo> list = parceledList.getList();
796-
final FeatureInfo[] res = new FeatureInfo[list.size()];
797-
for (int i = 0; i < res.length; i++) {
798-
res[i] = list.get(i);
795+
final List<FeatureInfo> list = new ArrayList<>(parceledList.getList());
796+
797+
// Inject Tensor features when toggle is enabled
798+
final boolean forceTensor = SystemProperties.getBoolean(
799+
"persist.sys.pp.tensor", false);
800+
801+
if (forceTensor && !IS_TENSOR_DEVICE) {
802+
for (String feature : FEATURES_TENSOR) {
803+
boolean exists = false;
804+
805+
for (FeatureInfo fi : list) {
806+
if (feature.equals(fi.name)) {
807+
exists = true;
808+
break;
809+
}
810+
}
811+
812+
if (!exists) {
813+
FeatureInfo fi = new FeatureInfo();
814+
fi.name = feature;
815+
fi.version = 0;
816+
list.add(fi);
817+
}
818+
}
799819
}
800-
return res;
820+
return list.toArray(new FeatureInfo[0]);
801821
} catch (RemoteException e) {
802822
throw e.rethrowFromSystemServer();
803823
}

0 commit comments

Comments
 (0)