In Progress
Status Update
Comments
ra...@google.com <ra...@google.com> #2
Hi there, thank you for the question. We will add it to the work pipeline and get back to you.
st...@deliveroo.co.uk <st...@deliveroo.co.uk> #3
I think you can set the zoom ratio right after cameraController.bindToLifecycle(this)
This should achieve what you want.
da...@google.com <da...@google.com> #4
I've tried that as well, but didn't worked.
ra...@google.com <ra...@google.com> #5
I request u 2 please resolve my problem I m very tired
st...@deliveroo.co.uk <st...@deliveroo.co.uk> #6
The setting has only one msg in it that "setting has stopped" please resolve this problem also
st...@deliveroo.co.uk <st...@deliveroo.co.uk> #7
Please try the the snippet below. It should work.
cameraController.getInitializationFuture().addListener({
cameraController.bindToLifecycle(activity)
cameraController.setZoomRatio(1.5f)
// The following codes are needed if you want to keep the zoom ratio 1.5x after stop/start the activity or fragment.
cameraController.cameraInfo!!.cameraState.removeObservers(activity)
cameraController.cameraInfo!!.cameraState.observe(activity) {
if (it.type == CameraState.Type.OPEN || it.type == CameraState.Type.OPEN) {
cameraController.setZoomRatio(1.5f)
}
}
}, ContextCompat.getMainExecutor(applicationContext))
+Xi to see if there is a better approach.
va...@gmail.com <va...@gmail.com> #8
The above solution is working as expected. Thanks!
da...@google.com <da...@google.com> #9
Project: platform/frameworks/support
Branch: androidx-main
commit 19a88266d210181cd3ee7fa742eebdb4d57a678b
Author: Xi Zhang <xizh@google.com>
Date: Wed Jan 04 10:38:27 2023
Cleanup: remove unused code in CameraController.
The Display object and the TapToFocusStates annotation are no longer used.
Bug: 264157663
Test: manual test and ./gradlew bOS
Change-Id: I4d20d52e6e0e7bac1ae5e7cce3d358f24800c024
M camera/camera-view/src/androidTest/java/androidx/camera/view/PreviewViewDeviceTest.kt
M camera/camera-view/src/main/java/androidx/camera/view/CameraController.java
M camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
https://android-review.googlesource.com/2376060
Branch: androidx-main
commit 19a88266d210181cd3ee7fa742eebdb4d57a678b
Author: Xi Zhang <xizh@google.com>
Date: Wed Jan 04 10:38:27 2023
Cleanup: remove unused code in CameraController.
The Display object and the TapToFocusStates annotation are no longer used.
Bug: 264157663
Test: manual test and ./gradlew bOS
Change-Id: I4d20d52e6e0e7bac1ae5e7cce3d358f24800c024
M camera/camera-view/src/androidTest/java/androidx/camera/view/PreviewViewDeviceTest.kt
M camera/camera-view/src/main/java/androidx/camera/view/CameraController.java
M camera/camera-view/src/main/java/androidx/camera/view/PreviewView.java
ap...@google.com <ap...@google.com> #10
Project: platform/frameworks/support
Branch: androidx-main
commit 0a95adb75d68ecc43e27640e913ee876193b9b09
Author: Xi Zhang <xizh@google.com>
Date: Wed Jan 04 11:49:16 2023
Cleanup: create a wrapper interface for ProcessCameraProvider for injecting dependencies in unit tests.
It's hard to fake ProcessCameraProvider in unit tests. This CL creates a wrapper interface for ProcessCameraProvider so that it can be faked. This allows us to test initialization related code with unit tests.
- Create a ProcessCameraProviderWrapper with all the methods needed by CameraController.
- Create a ProcessCameraProviderWrapperImpl that wraps the real object.
- Add two tests for delayed initialization.
Bug: 264157663
Test: manual test and ./gradlew bOS
Change-Id: I1848135d58550ee1f1628f50075fff73e42896e5
M camera/camera-view/src/main/java/androidx/camera/view/CameraController.java
M camera/camera-view/src/main/java/androidx/camera/view/LifecycleCameraController.java
A camera/camera-view/src/main/java/androidx/camera/view/ProcessCameraProviderWrapper.java
A camera/camera-view/src/main/java/androidx/camera/view/ProcessCameraProviderWrapperImpl.java
M camera/camera-view/src/test/java/androidx/camera/view/CameraControllerTest.kt
A camera/camera-view/src/test/java/androidx/camera/view/FakeProcessCameraProviderWrapper.kt
https://android-review.googlesource.com/2376067
Branch: androidx-main
commit 0a95adb75d68ecc43e27640e913ee876193b9b09
Author: Xi Zhang <xizh@google.com>
Date: Wed Jan 04 11:49:16 2023
Cleanup: create a wrapper interface for ProcessCameraProvider for injecting dependencies in unit tests.
It's hard to fake ProcessCameraProvider in unit tests. This CL creates a wrapper interface for ProcessCameraProvider so that it can be faked. This allows us to test initialization related code with unit tests.
- Create a ProcessCameraProviderWrapper with all the methods needed by CameraController.
- Create a ProcessCameraProviderWrapperImpl that wraps the real object.
- Add two tests for delayed initialization.
Bug: 264157663
Test: manual test and ./gradlew bOS
Change-Id: I1848135d58550ee1f1628f50075fff73e42896e5
M camera/camera-view/src/main/java/androidx/camera/view/CameraController.java
M camera/camera-view/src/main/java/androidx/camera/view/LifecycleCameraController.java
A camera/camera-view/src/main/java/androidx/camera/view/ProcessCameraProviderWrapper.java
A camera/camera-view/src/main/java/androidx/camera/view/ProcessCameraProviderWrapperImpl.java
M camera/camera-view/src/test/java/androidx/camera/view/CameraControllerTest.kt
A camera/camera-view/src/test/java/androidx/camera/view/FakeProcessCameraProviderWrapper.kt
ap...@google.com <ap...@google.com> #11
Project: platform/frameworks/support
Branch: androidx-main
commit 1bd96bc31127f262b206dcf15b3897b79dc5a039
Author: Xi Zhang <xizh@google.com>
Date: Fri Jan 06 09:58:01 2023
In CameraController, allow setting CameraControl values before init
Save pending values and wait for the init to complete before setting them.
- Create a PendingValue class. This represents a pending CameraControl value set before init.
- In CameraController, if setting CameraControl values before init, set the PendingValue instead.
- In CameraController, once init completes, propagate the pending values. If init/bindToLifecycle fails, no-op and continue to wait.
- Updated FakeCameraControl to track the latest zoom and torch values.
Relnote: when setting torch/zoom prior before camera initialization compelets, e.g. calling CameraController#enableTorch, the pending action is cached and submitted once the initialization compeltes.
Bug: 264157663
Test: manual test and ./gradlew bOS
Change-Id: I11e926246983a760b0e65652abe89c67f6434cff
M camera/camera-testing/src/main/java/androidx/camera/testing/fakes/FakeCamera.java
M camera/camera-testing/src/main/java/androidx/camera/testing/fakes/FakeCameraControl.java
M camera/camera-view/src/main/java/androidx/camera/view/CameraController.java
A camera/camera-view/src/main/java/androidx/camera/view/PendingValue.java
M camera/camera-view/src/test/java/androidx/camera/view/CameraControllerTest.kt
M camera/camera-view/src/test/java/androidx/camera/view/FakeProcessCameraProviderWrapper.kt
A camera/camera-view/src/test/java/androidx/camera/view/PendingValueTest.kt
https://android-review.googlesource.com/2375805
Branch: androidx-main
commit 1bd96bc31127f262b206dcf15b3897b79dc5a039
Author: Xi Zhang <xizh@google.com>
Date: Fri Jan 06 09:58:01 2023
In CameraController, allow setting CameraControl values before init
Save pending values and wait for the init to complete before setting them.
- Create a PendingValue class. This represents a pending CameraControl value set before init.
- In CameraController, if setting CameraControl values before init, set the PendingValue instead.
- In CameraController, once init completes, propagate the pending values. If init/bindToLifecycle fails, no-op and continue to wait.
- Updated FakeCameraControl to track the latest zoom and torch values.
Relnote: when setting torch/zoom prior before camera initialization compelets, e.g. calling CameraController#enableTorch, the pending action is cached and submitted once the initialization compeltes.
Bug: 264157663
Test: manual test and ./gradlew bOS
Change-Id: I11e926246983a760b0e65652abe89c67f6434cff
M camera/camera-testing/src/main/java/androidx/camera/testing/fakes/FakeCamera.java
M camera/camera-testing/src/main/java/androidx/camera/testing/fakes/FakeCameraControl.java
M camera/camera-view/src/main/java/androidx/camera/view/CameraController.java
A camera/camera-view/src/main/java/androidx/camera/view/PendingValue.java
M camera/camera-view/src/test/java/androidx/camera/view/CameraControllerTest.kt
M camera/camera-view/src/test/java/androidx/camera/view/FakeProcessCameraProviderWrapper.kt
A camera/camera-view/src/test/java/androidx/camera/view/PendingValueTest.kt
rw...@gmail.com <rw...@gmail.com> #12
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.camera:camera-view:1.3.0-alpha03
Description
Version used: 2.9.0
Devices/Android versions reproduced on: API 34
When we target API 34, WorkManager is crashing our application on startup if the "location" permissions are removed whilst the application is running.
Everything works fine whilst the application has the "location" permissions. When the "location" permissions are removed (whilst the application is running), the OS is killing the application (OS behaviour) and because SystemForegroundService is a STICKY service, the OS tries to restart the service which causes a security exception because the "location" permissions are no longer present.
This is a realistic user scenario which will happen many times in our production app. We can not prevent our application from crashing as this relates to the STICKY SystemForegroundService. Our application, can check the "location" permissions before scheduling the "worker", but we have no control over the user removing the "location" permissions after the "worker" has been scheduled by the WorkManager.
This behaviour only happens with WorkManager when targeting API 34 as per the restrictions documented here:
Here is the crash we are seeing on application startup:
Java.lang.SecurityException: Starting FGS with type location callerApp=ProcessRecord{34bbf76 32120:com.deliveroo.driverapp.test/u0a190} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION] and the app must be in the eligible state/exemptions to access the foreground only permission
We are using the WorkManager to run a CoroutineWorker which accesses the device location. We are scheduling the Worker as follows:
val request = OneTimeWorkRequest.Builder(worker.java)
.setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
.build()
WorkManager.getInstance(context).enqueueUniqueWork(
ExistingWorkPolicy.KEEP,
request,
)
We are specifying FOREGROUND_SERVICE_TYPE_LOCATION in the ForegroundInfo:
ForegroundInfo(ONLINE_NOTIFICATION_ID, notificationsManager.onlineNotification, ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION)
Our Android manifest specifies the "location" foregroundServiceType:
<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="location"/>
As stated above, everything works fine until the user removes the "location" permissions after the "worker" has started. Then the OS kills our application and the OS tries to recover the STICKY SystemForegroundService which crashes because the app no longer as "location" permissions.
Please can you advise how we can avoid WorkManager crashing our application in the above scenario.