Loading services/core/java/com/android/server/display/DisplayManagerService.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -758,7 +758,8 @@ public final class DisplayManagerService extends SystemService { mContext.registerReceiver(mIdleModeReceiver, filter); mContext.registerReceiver(mIdleModeReceiver, filter); mSmallAreaDetectionController = SmallAreaDetectionController.create(mContext); mSmallAreaDetectionController = (mFlags.isSmallAreaDetectionEnabled()) ? SmallAreaDetectionController.create(mContext) : null; } } @VisibleForTesting @VisibleForTesting Loading services/core/java/com/android/server/display/SmallAreaDetectionController.java +32 −41 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.content.Context; import android.content.Context; import android.content.pm.PackageManagerInternal; import android.content.pm.PackageManagerInternal; import android.os.UserHandle; import android.provider.DeviceConfig; import android.provider.DeviceConfig; import android.provider.DeviceConfigInterface; import android.provider.DeviceConfigInterface; import android.util.ArrayMap; import android.util.ArrayMap; Loading @@ -30,15 +31,14 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.os.BackgroundThread; import com.android.internal.os.BackgroundThread; import com.android.server.LocalServices; import com.android.server.LocalServices; import com.android.server.pm.UserManagerInternal; import com.android.server.pm.pkg.PackageStateInternal; import java.io.PrintWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.Map; import java.util.Map; final class SmallAreaDetectionController { final class SmallAreaDetectionController { private static native void nativeUpdateSmallAreaDetection(int[] uids, float[] thresholds); private static native void nativeUpdateSmallAreaDetection(int[] appIds, float[] thresholds); private static native void nativeSetSmallAreaDetectionThreshold(int uid, float threshold); private static native void nativeSetSmallAreaDetectionThreshold(int appId, float threshold); // TODO(b/281720315): Move this to DeviceConfig once server side ready. // TODO(b/281720315): Move this to DeviceConfig once server side ready. private static final String KEY_SMALL_AREA_DETECTION_ALLOWLIST = private static final String KEY_SMALL_AREA_DETECTION_ALLOWLIST = Loading @@ -47,12 +47,8 @@ final class SmallAreaDetectionController { private final Object mLock = new Object(); private final Object mLock = new Object(); private final Context mContext; private final Context mContext; private final PackageManagerInternal mPackageManager; private final PackageManagerInternal mPackageManager; private final UserManagerInternal mUserManager; @GuardedBy("mLock") @GuardedBy("mLock") private final Map<String, Float> mAllowPkgMap = new ArrayMap<>(); private final Map<String, Float> mAllowPkgMap = new ArrayMap<>(); // TODO(b/298722189): Update allowlist when user changes @GuardedBy("mLock") private int[] mUserIds; static SmallAreaDetectionController create(@NonNull Context context) { static SmallAreaDetectionController create(@NonNull Context context) { final SmallAreaDetectionController controller = final SmallAreaDetectionController controller = Loading @@ -67,7 +63,6 @@ final class SmallAreaDetectionController { SmallAreaDetectionController(Context context, DeviceConfigInterface deviceConfig) { SmallAreaDetectionController(Context context, DeviceConfigInterface deviceConfig) { mContext = context; mContext = context; mPackageManager = LocalServices.getService(PackageManagerInternal.class); mPackageManager = LocalServices.getService(PackageManagerInternal.class); mUserManager = LocalServices.getService(UserManagerInternal.class); deviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_DISPLAY_MANAGER, deviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_DISPLAY_MANAGER, BackgroundThread.getExecutor(), BackgroundThread.getExecutor(), new SmallAreaDetectionController.OnPropertiesChangedListener()); new SmallAreaDetectionController.OnPropertiesChangedListener()); Loading @@ -76,6 +71,7 @@ final class SmallAreaDetectionController { @VisibleForTesting @VisibleForTesting void updateAllowlist(@Nullable String property) { void updateAllowlist(@Nullable String property) { final Map<String, Float> allowPkgMap = new ArrayMap<>(); synchronized (mLock) { synchronized (mLock) { mAllowPkgMap.clear(); mAllowPkgMap.clear(); if (property != null) { if (property != null) { Loading @@ -86,8 +82,11 @@ final class SmallAreaDetectionController { .getStringArray(R.array.config_smallAreaDetectionAllowlist); .getStringArray(R.array.config_smallAreaDetectionAllowlist); for (String defaultMapString : defaultMapStrings) putToAllowlist(defaultMapString); for (String defaultMapString : defaultMapStrings) putToAllowlist(defaultMapString); } } updateSmallAreaDetection(); if (mAllowPkgMap.isEmpty()) return; allowPkgMap.putAll(mAllowPkgMap); } } updateSmallAreaDetection(allowPkgMap); } } @GuardedBy("mLock") @GuardedBy("mLock") Loading @@ -105,43 +104,32 @@ final class SmallAreaDetectionController { } } } } @GuardedBy("mLock") private void updateSmallAreaDetection(Map<String, Float> allowPkgMap) { private void updateUidListForAllUsers(SparseArray<Float> list, String pkg, float threshold) { final SparseArray<Float> appIdThresholdList = new SparseArray(allowPkgMap.size()); for (int i = 0; i < mUserIds.length; i++) { for (String pkg : allowPkgMap.keySet()) { final int userId = mUserIds[i]; final float threshold = allowPkgMap.get(pkg); final int uid = mPackageManager.getPackageUid(pkg, 0, userId); final PackageStateInternal stage = mPackageManager.getPackageStateInternal(pkg); if (uid > 0) list.put(uid, threshold); if (stage != null) { } appIdThresholdList.put(stage.getAppId(), threshold); } } @GuardedBy("mLock") private void updateSmallAreaDetection() { if (mAllowPkgMap.isEmpty()) return; mUserIds = mUserManager.getUserIds(); final SparseArray<Float> uidThresholdList = new SparseArray<>(); for (String pkg : mAllowPkgMap.keySet()) { final float threshold = mAllowPkgMap.get(pkg); updateUidListForAllUsers(uidThresholdList, pkg, threshold); } } final int[] uids = new int[uidThresholdList.size()]; final int[] appIds = new int[appIdThresholdList.size()]; final float[] thresholds = new float[uidThresholdList.size()]; final float[] thresholds = new float[appIdThresholdList.size()]; for (int i = 0; i < uidThresholdList.size(); i++) { for (int i = 0; i < appIdThresholdList.size(); i++) { uids[i] = uidThresholdList.keyAt(i); appIds[i] = appIdThresholdList.keyAt(i); thresholds[i] = uidThresholdList.valueAt(i); thresholds[i] = appIdThresholdList.valueAt(i); } } updateSmallAreaDetection(uids, thresholds); updateSmallAreaDetection(appIds, thresholds); } } @VisibleForTesting @VisibleForTesting void updateSmallAreaDetection(int[] uids, float[] thresholds) { void updateSmallAreaDetection(int[] appIds, float[] thresholds) { nativeUpdateSmallAreaDetection(uids, thresholds); nativeUpdateSmallAreaDetection(appIds, thresholds); } } void setSmallAreaDetectionThreshold(int uid, float threshold) { void setSmallAreaDetectionThreshold(int appId, float threshold) { nativeSetSmallAreaDetectionThreshold(uid, threshold); nativeSetSmallAreaDetectionThreshold(appId, threshold); } } void dump(PrintWriter pw) { void dump(PrintWriter pw) { Loading @@ -151,7 +139,6 @@ final class SmallAreaDetectionController { for (String pkg : mAllowPkgMap.keySet()) { for (String pkg : mAllowPkgMap.keySet()) { pw.println(" " + pkg + " threshold = " + mAllowPkgMap.get(pkg)); pw.println(" " + pkg + " threshold = " + mAllowPkgMap.get(pkg)); } } pw.println(" mUserIds=" + Arrays.toString(mUserIds)); } } } } Loading @@ -167,10 +154,14 @@ final class SmallAreaDetectionController { private final class PackageReceiver implements PackageManagerInternal.PackageListObserver { private final class PackageReceiver implements PackageManagerInternal.PackageListObserver { @Override @Override public void onPackageAdded(@NonNull String packageName, int uid) { public void onPackageAdded(@NonNull String packageName, int uid) { float threshold = 0.0f; synchronized (mLock) { synchronized (mLock) { if (mAllowPkgMap.containsKey(packageName)) { if (mAllowPkgMap.containsKey(packageName)) { setSmallAreaDetectionThreshold(uid, mAllowPkgMap.get(packageName)); threshold = mAllowPkgMap.get(packageName); } } } if (threshold > 0.0f) { setSmallAreaDetectionThreshold(UserHandle.getAppId(uid), threshold); } } } } } } Loading services/core/java/com/android/server/display/feature/DisplayManagerFlags.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -71,6 +71,10 @@ public class DisplayManagerFlags { Flags.FLAG_ENABLE_POWER_THROTTLING_CLAMPER, Flags.FLAG_ENABLE_POWER_THROTTLING_CLAMPER, Flags::enablePowerThrottlingClamper); Flags::enablePowerThrottlingClamper); private final FlagState mSmallAreaDetectionFlagState = new FlagState( Flags.FLAG_ENABLE_SMALL_AREA_DETECTION, Flags::enableSmallAreaDetection); /** Returns whether connected display management is enabled or not. */ /** Returns whether connected display management is enabled or not. */ public boolean isConnectedDisplayManagementEnabled() { public boolean isConnectedDisplayManagementEnabled() { return mConnectedDisplayManagementFlagState.isEnabled(); return mConnectedDisplayManagementFlagState.isEnabled(); Loading Loading @@ -147,6 +151,10 @@ public class DisplayManagerFlags { return mBackUpSmoothDisplayAndForcePeakRefreshRateFlagState.isEnabled(); return mBackUpSmoothDisplayAndForcePeakRefreshRateFlagState.isEnabled(); } } public boolean isSmallAreaDetectionEnabled() { return mSmallAreaDetectionFlagState.isEnabled(); } private static class FlagState { private static class FlagState { private final String mName; private final String mName; Loading services/core/java/com/android/server/display/feature/display_flags.aconfig +9 −0 Original line number Original line Diff line number Diff line Loading @@ -104,3 +104,12 @@ flag { bug: "211737588" bug: "211737588" is_fixed_read_only: true is_fixed_read_only: true } } flag { name: "enable_small_area_detection" namespace: "display_manager" description: "Feature flag for SmallAreaDetection" bug: "298722189" is_fixed_read_only: true } services/core/jni/com_android_server_display_SmallAreaDetectionController.cpp +12 −12 Original line number Original line Diff line number Diff line Loading @@ -24,33 +24,33 @@ #include "utils/Log.h" #include "utils/Log.h" namespace android { namespace android { static void nativeUpdateSmallAreaDetection(JNIEnv* env, jclass clazz, jintArray juids, static void nativeUpdateSmallAreaDetection(JNIEnv* env, jclass clazz, jintArray jappIds, jfloatArray jthresholds) { jfloatArray jthresholds) { if (juids == nullptr || jthresholds == nullptr) return; if (jappIds == nullptr || jthresholds == nullptr) return; ScopedIntArrayRO uids(env, juids); ScopedIntArrayRO appIds(env, jappIds); ScopedFloatArrayRO thresholds(env, jthresholds); ScopedFloatArrayRO thresholds(env, jthresholds); if (uids.size() != thresholds.size()) { if (appIds.size() != thresholds.size()) { ALOGE("uids size exceeds thresholds size!"); ALOGE("appIds size exceeds thresholds size!"); return; return; } } std::vector<int32_t> uidVector; std::vector<int32_t> appIdVector; std::vector<float> thresholdVector; std::vector<float> thresholdVector; size_t size = uids.size(); size_t size = appIds.size(); uidVector.reserve(size); appIdVector.reserve(size); thresholdVector.reserve(size); thresholdVector.reserve(size); for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) { uidVector.push_back(static_cast<int32_t>(uids[i])); appIdVector.push_back(static_cast<int32_t>(appIds[i])); thresholdVector.push_back(static_cast<float>(thresholds[i])); thresholdVector.push_back(static_cast<float>(thresholds[i])); } } SurfaceComposerClient::updateSmallAreaDetection(uidVector, thresholdVector); SurfaceComposerClient::updateSmallAreaDetection(appIdVector, thresholdVector); } } static void nativeSetSmallAreaDetectionThreshold(JNIEnv* env, jclass clazz, jint uid, static void nativeSetSmallAreaDetectionThreshold(JNIEnv* env, jclass clazz, jint appId, jfloat threshold) { jfloat threshold) { SurfaceComposerClient::setSmallAreaDetectionThreshold(uid, threshold); SurfaceComposerClient::setSmallAreaDetectionThreshold(appId, threshold); } } static const JNINativeMethod gMethods[] = { static const JNINativeMethod gMethods[] = { Loading Loading
services/core/java/com/android/server/display/DisplayManagerService.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -758,7 +758,8 @@ public final class DisplayManagerService extends SystemService { mContext.registerReceiver(mIdleModeReceiver, filter); mContext.registerReceiver(mIdleModeReceiver, filter); mSmallAreaDetectionController = SmallAreaDetectionController.create(mContext); mSmallAreaDetectionController = (mFlags.isSmallAreaDetectionEnabled()) ? SmallAreaDetectionController.create(mContext) : null; } } @VisibleForTesting @VisibleForTesting Loading
services/core/java/com/android/server/display/SmallAreaDetectionController.java +32 −41 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.content.Context; import android.content.Context; import android.content.pm.PackageManagerInternal; import android.content.pm.PackageManagerInternal; import android.os.UserHandle; import android.provider.DeviceConfig; import android.provider.DeviceConfig; import android.provider.DeviceConfigInterface; import android.provider.DeviceConfigInterface; import android.util.ArrayMap; import android.util.ArrayMap; Loading @@ -30,15 +31,14 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.os.BackgroundThread; import com.android.internal.os.BackgroundThread; import com.android.server.LocalServices; import com.android.server.LocalServices; import com.android.server.pm.UserManagerInternal; import com.android.server.pm.pkg.PackageStateInternal; import java.io.PrintWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.Map; import java.util.Map; final class SmallAreaDetectionController { final class SmallAreaDetectionController { private static native void nativeUpdateSmallAreaDetection(int[] uids, float[] thresholds); private static native void nativeUpdateSmallAreaDetection(int[] appIds, float[] thresholds); private static native void nativeSetSmallAreaDetectionThreshold(int uid, float threshold); private static native void nativeSetSmallAreaDetectionThreshold(int appId, float threshold); // TODO(b/281720315): Move this to DeviceConfig once server side ready. // TODO(b/281720315): Move this to DeviceConfig once server side ready. private static final String KEY_SMALL_AREA_DETECTION_ALLOWLIST = private static final String KEY_SMALL_AREA_DETECTION_ALLOWLIST = Loading @@ -47,12 +47,8 @@ final class SmallAreaDetectionController { private final Object mLock = new Object(); private final Object mLock = new Object(); private final Context mContext; private final Context mContext; private final PackageManagerInternal mPackageManager; private final PackageManagerInternal mPackageManager; private final UserManagerInternal mUserManager; @GuardedBy("mLock") @GuardedBy("mLock") private final Map<String, Float> mAllowPkgMap = new ArrayMap<>(); private final Map<String, Float> mAllowPkgMap = new ArrayMap<>(); // TODO(b/298722189): Update allowlist when user changes @GuardedBy("mLock") private int[] mUserIds; static SmallAreaDetectionController create(@NonNull Context context) { static SmallAreaDetectionController create(@NonNull Context context) { final SmallAreaDetectionController controller = final SmallAreaDetectionController controller = Loading @@ -67,7 +63,6 @@ final class SmallAreaDetectionController { SmallAreaDetectionController(Context context, DeviceConfigInterface deviceConfig) { SmallAreaDetectionController(Context context, DeviceConfigInterface deviceConfig) { mContext = context; mContext = context; mPackageManager = LocalServices.getService(PackageManagerInternal.class); mPackageManager = LocalServices.getService(PackageManagerInternal.class); mUserManager = LocalServices.getService(UserManagerInternal.class); deviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_DISPLAY_MANAGER, deviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_DISPLAY_MANAGER, BackgroundThread.getExecutor(), BackgroundThread.getExecutor(), new SmallAreaDetectionController.OnPropertiesChangedListener()); new SmallAreaDetectionController.OnPropertiesChangedListener()); Loading @@ -76,6 +71,7 @@ final class SmallAreaDetectionController { @VisibleForTesting @VisibleForTesting void updateAllowlist(@Nullable String property) { void updateAllowlist(@Nullable String property) { final Map<String, Float> allowPkgMap = new ArrayMap<>(); synchronized (mLock) { synchronized (mLock) { mAllowPkgMap.clear(); mAllowPkgMap.clear(); if (property != null) { if (property != null) { Loading @@ -86,8 +82,11 @@ final class SmallAreaDetectionController { .getStringArray(R.array.config_smallAreaDetectionAllowlist); .getStringArray(R.array.config_smallAreaDetectionAllowlist); for (String defaultMapString : defaultMapStrings) putToAllowlist(defaultMapString); for (String defaultMapString : defaultMapStrings) putToAllowlist(defaultMapString); } } updateSmallAreaDetection(); if (mAllowPkgMap.isEmpty()) return; allowPkgMap.putAll(mAllowPkgMap); } } updateSmallAreaDetection(allowPkgMap); } } @GuardedBy("mLock") @GuardedBy("mLock") Loading @@ -105,43 +104,32 @@ final class SmallAreaDetectionController { } } } } @GuardedBy("mLock") private void updateSmallAreaDetection(Map<String, Float> allowPkgMap) { private void updateUidListForAllUsers(SparseArray<Float> list, String pkg, float threshold) { final SparseArray<Float> appIdThresholdList = new SparseArray(allowPkgMap.size()); for (int i = 0; i < mUserIds.length; i++) { for (String pkg : allowPkgMap.keySet()) { final int userId = mUserIds[i]; final float threshold = allowPkgMap.get(pkg); final int uid = mPackageManager.getPackageUid(pkg, 0, userId); final PackageStateInternal stage = mPackageManager.getPackageStateInternal(pkg); if (uid > 0) list.put(uid, threshold); if (stage != null) { } appIdThresholdList.put(stage.getAppId(), threshold); } } @GuardedBy("mLock") private void updateSmallAreaDetection() { if (mAllowPkgMap.isEmpty()) return; mUserIds = mUserManager.getUserIds(); final SparseArray<Float> uidThresholdList = new SparseArray<>(); for (String pkg : mAllowPkgMap.keySet()) { final float threshold = mAllowPkgMap.get(pkg); updateUidListForAllUsers(uidThresholdList, pkg, threshold); } } final int[] uids = new int[uidThresholdList.size()]; final int[] appIds = new int[appIdThresholdList.size()]; final float[] thresholds = new float[uidThresholdList.size()]; final float[] thresholds = new float[appIdThresholdList.size()]; for (int i = 0; i < uidThresholdList.size(); i++) { for (int i = 0; i < appIdThresholdList.size(); i++) { uids[i] = uidThresholdList.keyAt(i); appIds[i] = appIdThresholdList.keyAt(i); thresholds[i] = uidThresholdList.valueAt(i); thresholds[i] = appIdThresholdList.valueAt(i); } } updateSmallAreaDetection(uids, thresholds); updateSmallAreaDetection(appIds, thresholds); } } @VisibleForTesting @VisibleForTesting void updateSmallAreaDetection(int[] uids, float[] thresholds) { void updateSmallAreaDetection(int[] appIds, float[] thresholds) { nativeUpdateSmallAreaDetection(uids, thresholds); nativeUpdateSmallAreaDetection(appIds, thresholds); } } void setSmallAreaDetectionThreshold(int uid, float threshold) { void setSmallAreaDetectionThreshold(int appId, float threshold) { nativeSetSmallAreaDetectionThreshold(uid, threshold); nativeSetSmallAreaDetectionThreshold(appId, threshold); } } void dump(PrintWriter pw) { void dump(PrintWriter pw) { Loading @@ -151,7 +139,6 @@ final class SmallAreaDetectionController { for (String pkg : mAllowPkgMap.keySet()) { for (String pkg : mAllowPkgMap.keySet()) { pw.println(" " + pkg + " threshold = " + mAllowPkgMap.get(pkg)); pw.println(" " + pkg + " threshold = " + mAllowPkgMap.get(pkg)); } } pw.println(" mUserIds=" + Arrays.toString(mUserIds)); } } } } Loading @@ -167,10 +154,14 @@ final class SmallAreaDetectionController { private final class PackageReceiver implements PackageManagerInternal.PackageListObserver { private final class PackageReceiver implements PackageManagerInternal.PackageListObserver { @Override @Override public void onPackageAdded(@NonNull String packageName, int uid) { public void onPackageAdded(@NonNull String packageName, int uid) { float threshold = 0.0f; synchronized (mLock) { synchronized (mLock) { if (mAllowPkgMap.containsKey(packageName)) { if (mAllowPkgMap.containsKey(packageName)) { setSmallAreaDetectionThreshold(uid, mAllowPkgMap.get(packageName)); threshold = mAllowPkgMap.get(packageName); } } } if (threshold > 0.0f) { setSmallAreaDetectionThreshold(UserHandle.getAppId(uid), threshold); } } } } } } Loading
services/core/java/com/android/server/display/feature/DisplayManagerFlags.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -71,6 +71,10 @@ public class DisplayManagerFlags { Flags.FLAG_ENABLE_POWER_THROTTLING_CLAMPER, Flags.FLAG_ENABLE_POWER_THROTTLING_CLAMPER, Flags::enablePowerThrottlingClamper); Flags::enablePowerThrottlingClamper); private final FlagState mSmallAreaDetectionFlagState = new FlagState( Flags.FLAG_ENABLE_SMALL_AREA_DETECTION, Flags::enableSmallAreaDetection); /** Returns whether connected display management is enabled or not. */ /** Returns whether connected display management is enabled or not. */ public boolean isConnectedDisplayManagementEnabled() { public boolean isConnectedDisplayManagementEnabled() { return mConnectedDisplayManagementFlagState.isEnabled(); return mConnectedDisplayManagementFlagState.isEnabled(); Loading Loading @@ -147,6 +151,10 @@ public class DisplayManagerFlags { return mBackUpSmoothDisplayAndForcePeakRefreshRateFlagState.isEnabled(); return mBackUpSmoothDisplayAndForcePeakRefreshRateFlagState.isEnabled(); } } public boolean isSmallAreaDetectionEnabled() { return mSmallAreaDetectionFlagState.isEnabled(); } private static class FlagState { private static class FlagState { private final String mName; private final String mName; Loading
services/core/java/com/android/server/display/feature/display_flags.aconfig +9 −0 Original line number Original line Diff line number Diff line Loading @@ -104,3 +104,12 @@ flag { bug: "211737588" bug: "211737588" is_fixed_read_only: true is_fixed_read_only: true } } flag { name: "enable_small_area_detection" namespace: "display_manager" description: "Feature flag for SmallAreaDetection" bug: "298722189" is_fixed_read_only: true }
services/core/jni/com_android_server_display_SmallAreaDetectionController.cpp +12 −12 Original line number Original line Diff line number Diff line Loading @@ -24,33 +24,33 @@ #include "utils/Log.h" #include "utils/Log.h" namespace android { namespace android { static void nativeUpdateSmallAreaDetection(JNIEnv* env, jclass clazz, jintArray juids, static void nativeUpdateSmallAreaDetection(JNIEnv* env, jclass clazz, jintArray jappIds, jfloatArray jthresholds) { jfloatArray jthresholds) { if (juids == nullptr || jthresholds == nullptr) return; if (jappIds == nullptr || jthresholds == nullptr) return; ScopedIntArrayRO uids(env, juids); ScopedIntArrayRO appIds(env, jappIds); ScopedFloatArrayRO thresholds(env, jthresholds); ScopedFloatArrayRO thresholds(env, jthresholds); if (uids.size() != thresholds.size()) { if (appIds.size() != thresholds.size()) { ALOGE("uids size exceeds thresholds size!"); ALOGE("appIds size exceeds thresholds size!"); return; return; } } std::vector<int32_t> uidVector; std::vector<int32_t> appIdVector; std::vector<float> thresholdVector; std::vector<float> thresholdVector; size_t size = uids.size(); size_t size = appIds.size(); uidVector.reserve(size); appIdVector.reserve(size); thresholdVector.reserve(size); thresholdVector.reserve(size); for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) { uidVector.push_back(static_cast<int32_t>(uids[i])); appIdVector.push_back(static_cast<int32_t>(appIds[i])); thresholdVector.push_back(static_cast<float>(thresholds[i])); thresholdVector.push_back(static_cast<float>(thresholds[i])); } } SurfaceComposerClient::updateSmallAreaDetection(uidVector, thresholdVector); SurfaceComposerClient::updateSmallAreaDetection(appIdVector, thresholdVector); } } static void nativeSetSmallAreaDetectionThreshold(JNIEnv* env, jclass clazz, jint uid, static void nativeSetSmallAreaDetectionThreshold(JNIEnv* env, jclass clazz, jint appId, jfloat threshold) { jfloat threshold) { SurfaceComposerClient::setSmallAreaDetectionThreshold(uid, threshold); SurfaceComposerClient::setSmallAreaDetectionThreshold(appId, threshold); } } static const JNINativeMethod gMethods[] = { static const JNINativeMethod gMethods[] = { Loading