החל מ-27 במרץ 2025, מומלץ להשתמש ב-android-latest-release
במקום ב-aosp-main
כדי ליצור תרומות ל-AOSP. מידע נוסף זמין במאמר שינויים ב-AOSP.
בקרת עוצמת הפנס
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
במכשירים עם Android מגרסה 13 ואילך, מסגרת Android מספקת שליטה ברמות שונות בעוצמת הפנס. ב-Android 12 וגרסאות ישנות יותר, המסגרת מאפשרת רק להפעיל או לכבות את מצב הפנס. התמיכה בשליטה ברמות שונות בעוצמת הפנס מאפשרת למכשירים לאפשר תרחישי שימוש כמו שליטה בהירות הפנס על סמך תנאי התאורה ושליחת אותות לעזרה באמצעות אפקט סטרבו באמצעות שליחת פולסים מהירים של אור ברצף. יתרון נוסף של התכונה הזו הוא שהיא יכולה לשפר את חיי הסוללה ואת הביצועים, כי לא תמיד צריך להפעיל את מצב הפנס בעוצמה המקסימלית, דבר שעלול להוביל לתנאי 'האטה תרמית'.
ממשקי API ציבוריים
אפליקציות יכולות להשתמש בתכונה של בקרת עוצמת הפנס באמצעות ממשקי ה-API הציבוריים הבאים ומפתחות המאפיינים של המצלמה. לא נדרשות הרשאות מצלמה לממשקי ה-API האלה כי אין גישה למצלמה.
ממשקי CameraManager API
מפתחות של CameraCharacteristics
הטמעה
כדי לתמוך בתכונה של בקרת עוצמת הפנס במכשיר, צריך להשתמש בממשקי ה-HAL הבאים של המצלמה:
מיקום: /camera/device/aidl/android/hardware/camera/device/ICameraDevice.aidl
כדי לתמוך בתכונה של בקרת הבהירות של הפנס, צריך לוודא שההטמעה של HAL מפרסמת את מפתחות המאפיינים הבאים של המצלמה:
להטמעה לדוגמה של HAL של מצלמה שתומכת בשליטה בעוצמת הפנס, ראו EmulatedCameraDeviceHWLImpl.cpp
.
אימות
כדי לאמת את ההטמעה של תכונת בקרת עוצמת הפנס, מריצים את בדיקות ה-VTS וה-CTS הבאות:
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-26 (שעון UTC).
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-07-26 (שעון UTC)."],[],[],null,["# Torch strength control\n\nFor devices running Android 13 or higher, the Android\nframework provides a multilevel control for torch strength. In\nAndroid 12 and lower, the framework allows only for\nturning the torch mode on or off. By supporting multilevel torch strength\ncontrol, devices can enable use cases such as controlling the brightness of the\nflashlight based on lighting conditions and sending signals for assistance\nusing a strobe effect by sending quick pulses of light in a row. Another\nbenefit of this feature is that it can improve battery life and performance as\nthe torch mode doesn't always need to be turned on at the maximum strength,\nwhich can lead to thermal throttling conditions.\n\nPublic APIs\n-----------\n\nApps can use the torch strength control feature through the following public\nAPIs and camera characteristics keys. No camera permissions are required for\nthese APIs because the camera isn't accessed.\n\n#### CameraManager APIs\n\n- [`public void turnOnTorchWithStrengthLevel (String cameraId, int torchStrength)`](https://developer.android.com/reference/android/hardware/camera2/CameraManager#turnOnTorchWithStrengthLevel(java.lang.String,%20int)): Sets the brightness level of the flashlight associated with the given `cameraId` value in torch mode. If torch mode is off and `torchStrength` is greater than or equal to `1`, the torch turns on with the strength level specified in `torchStrength`.\n- [`public int getTorchStrengthLevel (String cameraId)`](https://developer.android.com/reference/android/hardware/camera2/CameraManager#getTorchStrengthLevel(java.lang.String)): Returns the brightness level of the flash unit associated with `cameraId`.\n\n#### CameraCharacteristics keys\n\n- [`FLASH_INFO_STRENGTH_MAXIMUM_LEVEL`](https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#FLASH_INFO_STRENGTH_MAXIMUM_LEVEL): Maximum brightness level. The camera HAL advertises this feature by setting a value greater than `1`.\n- [`FLASH_INFO_STRENGTH_DEFAULT_LEVEL`](https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#FLASH_INFO_STRENGTH_DEFAULT_LEVEL): Default flashlight brightness level.\n\nImplementation\n--------------\n\nTo support the torch strength control feature on your device, use the following\ncamera AIDL HAL interfaces:\n\nLocation: `/camera/device/aidl/android/hardware/camera/device/ICameraDevice.aidl`\n\n- [`void turnOnTorchWithStrengthLevel(int torchStrength)`](https://cs.android.com/android/platform/superproject/+/android-latest-release:hardware/interfaces/camera/device/aidl/android/hardware/camera/device/ICameraDevice.aidl?q=turnOnTorchWithStrengthLevel)\n- [`int getTorchStrengthLevel()`](https://cs.android.com/android/platform/superproject/+/android-latest-release:hardware/interfaces/camera/device/aidl/android/hardware/camera/device/ICameraDevice.aidl?q=getTorchStrengthLevel)\n\nEnsure your HAL implementation advertises the following camera characteristics\nkeys to support the torch brightness control feature:\n\n- [`FLASH_INFO_STRENGTH_MAXIMUM_LEVEL`](https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#FLASH_INFO_STRENGTH_MAXIMUM_LEVEL)\n- [`FLASH_INFO_STRENGTH_DEFAULT_LEVEL`](https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#FLASH_INFO_STRENGTH_DEFAULT_LEVEL)\n\nFor a reference Camera HAL implementation supporting torch strength control,\nsee\n[`EmulatedCameraDeviceHWLImpl.cpp`](https://cs.android.com/android/platform/superproject/+/android-latest-release:hardware/google/camera/devices/EmulatedCamera/hwl/EmulatedCameraDeviceHWLImpl.cpp).\n\nValidation\n----------\n\nTo validate your implementation of the torch strength control feature, run the\nfollowing VTS and CTS tests:\n\n- VTS: [`/camera/provider/aidl/vts/VtsAidlHalCameraProvider\\_TargetTest.cpp`](https://cs.android.com/android/platform/superproject/+/android-latest-release:hardware/interfaces/camera/provider/aidl/vts/VtsAidlHalCameraProvider_TargetTest.cpp)\n- CTS: [`/platform/cts/tests/camera/src/android/hardware/camera2/cts/FlashlightTest.java`](https://cs.android.com/android/platform/superproject/+/android-latest-release:cts/tests/camera/src/android/hardware/camera2/cts/FlashlightTest.java)"]]