diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2021-10-18 20:18:02 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-10-18 20:18:02 +0000 |
| commit | ac0da15643306311d196fe3ac059bd7fbf8ce1e6 (patch) | |
| tree | 786f1886f5a79b6567c9896279128a65244b3033 /core/java | |
| parent | 59bd397aac86495701c7bb7a28055a6bfff9ef72 (diff) | |
| parent | 22314d89a330835c4695fb9a43c8c19fd34b7da6 (diff) | |
Merge "Update DozeSensors and DozeBrightnessSensor on posture changes" into sc-v2-dev am: 22314d89a3
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15983468
Change-Id: I2513907077181517855ec80de4dad9e53ade562a
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/hardware/display/AmbientDisplayConfiguration.java | 51 |
1 files changed, 19 insertions, 32 deletions
diff --git a/core/java/android/hardware/display/AmbientDisplayConfiguration.java b/core/java/android/hardware/display/AmbientDisplayConfiguration.java index f5b2ac586bd1..2b52e967ce54 100644 --- a/core/java/android/hardware/display/AmbientDisplayConfiguration.java +++ b/core/java/android/hardware/display/AmbientDisplayConfiguration.java @@ -22,11 +22,9 @@ import android.os.Build; import android.os.SystemProperties; import android.provider.Settings; import android.text.TextUtils; -import android.util.Log; - -import java.util.Arrays; import com.android.internal.R; +import com.android.internal.util.ArrayUtils; /** * AmbientDisplayConfiguration encapsulates reading access to the configuration of ambient display. @@ -90,7 +88,12 @@ public class AmbientDisplayConfiguration { /** {@hide} */ public boolean tapSensorAvailable() { - return !TextUtils.isEmpty(tapSensorType()); + for (String tapType : tapSensorTypeMapping()) { + if (!TextUtils.isEmpty(tapType)) { + return true; + } + } + return false; } /** {@hide} */ @@ -143,18 +146,18 @@ public class AmbientDisplayConfiguration { return mContext.getResources().getString(R.string.config_dozeDoubleTapSensorType); } - /** {@hide} */ - private String tapSensorType() { - return mContext.getResources().getString(R.string.config_dozeTapSensorType); - } - - /** {@hide} */ - public String tapSensorType(int posture) { - return getSensorFromPostureMapping( - mContext.getResources().getStringArray(R.array.config_dozeTapSensorPostureMapping), - tapSensorType(), - posture - ); + /** {@hide} + * May support multiple postures. + */ + public String[] tapSensorTypeMapping() { + String[] postureMapping = + mContext.getResources().getStringArray(R.array.config_dozeTapSensorPostureMapping); + if (ArrayUtils.isEmpty(postureMapping)) { + return new String[] { + mContext.getResources().getString(R.string.config_dozeTapSensorType) + }; + } + return postureMapping; } /** {@hide} */ @@ -253,20 +256,4 @@ public class AmbientDisplayConfiguration { private boolean boolSetting(String name, int user, int def) { return Settings.Secure.getIntForUser(mContext.getContentResolver(), name, def, user) != 0; } - - /** {@hide} */ - public static String getSensorFromPostureMapping( - String[] postureMapping, - String defaultValue, - int posture) { - String sensorType = defaultValue; - if (postureMapping != null && posture < postureMapping.length) { - sensorType = postureMapping[posture]; - } else { - Log.e(TAG, "Unsupported doze posture " + posture - + " postureMapping=" + Arrays.toString(postureMapping)); - } - - return TextUtils.isEmpty(sensorType) ? defaultValue : sensorType; - } } |
