How can I disable ARCore logs for Android? - android

ArCore spams each frame the following error before it detects surfaces (trackables)
=== Source Location Trace: ===
third_party/arcore/ar/perception/feature_track_ml_depth_provider_utils.cc:402
third_party/arcore/ar/perception/feature_track_ml_depth_provider.cc:209
E0000 00:00:1675437554.648981 30783 motion_tracking_context.cc:1879] NOT_FOUND: Not able to find any depth measurements on feature measurements at timestamp 28971862451376
or
E0000 00:00:1675437708.212223 30553 hit_test.cc:428] INTERNAL: No
point hit.
How can I disable such logs?

You must follow these steps to disable ARCore API call logging:
Open the AR experience in your app so that there is an active ARCore session running. Your app must be in AR mode to receive the broadcast that disables logging. The AR camera preview images should be visible on the device screen.
Then use the following adb command to disable call logging for your app:
adb shell am broadcast -a com.google.ar.core.DISABLE_API_CALL_LOGGING

Related

Camera2 cameraManager.openCamera exception from time to time on some devices

I have an app which records videos, it has about 80K current installations (more than 100K downloads), Crashlytics statistics seems to be good - Crash-free users 99.66% and rating on Google Play is also OK - 4.5
But still for some of my users can happen the next errors (it may happened for such user once or a couple of times by now, so not often, but still happens from time to time):
android.hardware.camera2.CameraAccessException: CAMERA_DISABLED (1): connectHelper:1578: Camera "0" disabled by policy
android.hardware.camera2.CameraAccessException: CAMERA_DISCONNECTED (2): Camera service is currently unavailable
java.lang.IllegalArgumentException: supportsCameraApi:2096: Unknown camera ID 0
android.hardware.camera2.CameraAccessException: CAMERA_DISABLED (1): validateClientPermissionsLocked:1066: Caller "com.MY_APP_PACKAGE" (PID 10237, UID 21433) cannot open camera "1" when sensor privacy is enabled
on opening camera using camera2 API:
...
cameraManager.openCamera(cameraId, stateCallback, mainHandler)`
} catch (e: Exception) {
e.printStackTrace()
openReportErrorDialog(e) // so a user could report this issue
...
Reported devices:
Vivo 1906
Wheatek BV5500Plus
Samsung SM-N975F
Samsung SM-G988W
Samsung SM-A520F
Motorola REVVLRY
HUAWEI VOG-L09
HUAWEI STK-LX1
HUAWEI MRD-LX1
HUAWEI FIG-LX1
Coolpad CP3669AS
Infinix X655C
Android versions: from 8 to 11 (app min SDK is 6)
So basically it can work fine for a specific user for some time, no issues when opening camera, but from time to time this exception can occur for such user
I don't have any idea why it happens. I can't reproduce this issue on my own devices (two Samsung, one Lenovo, one Huawei and one Xiaomi devices), only users can report such issue from time to time...
The most nonsense exception here is Unknown camera ID 0, because before opening camera I get list of available cameras, so it's not hardcoded, it's not possible that such camera id doesn't exist, and a user said that before this error that camera was working ok
UPDATE
Found this
https://developer.android.com/guide/components/foreground-services#bg-access-restrictions
So it seems if a foreground service was started by system (on BOOT_COMPLETED broadcast, declared in manifest) and not by app (if a user launch app) then it can't access camera and microphone.
So basically after rebooting a device we can't automatically start camera anymore without user interaction.
Really bad for dashboard camera applications for car drivers...
They added ACCESS_BACKGROUND_LOCATION, but there is no ACCESS_BACKGROUND_CAMERA and ACCESS_BACKGROUND_RECORD_AUDIO...
android.hardware.camera2.CameraAccessException: CAMERA_DISABLED (1): connectHelper:1578: Camera "0" disabled by policy
That either means the device has an enterprise policy installed that disables cameras for example (employers that don't want employees photographing stuff at work), or your app is trying to open the camera in the background, on more recent Android releases.
If it's the policy, there's nothing you can do besides to tell the user that there's a policy in place and to complain to their admins.
android.hardware.camera2.CameraAccessException: CAMERA_DISCONNECTED (2): Camera service is currently unavailable
java.lang.IllegalArgumentException: supportsCameraApi:2096: Unknown camera ID 0
These usually mean something has crashed in the camera stack - until things restart (takes a few seconds usually), all cameras will be reported as unknown.
Ideally that'll never happen, but bugs unfortunately exist even on the best devices. A retry a few seconds later will probably work, unless the camera hardware on the phone is failing in some way that leads to a persistent crash.
android.hardware.camera2.CameraAccessException: CAMERA_DISABLED (1): validateClientPermissionsLocked:1066: Caller "com.MY_APP_PACKAGE" (PID 10237, UID 21433) cannot open camera "1" when sensor privacy is enabled
This means the OEM has some kind of 'shut off all cameras' feature like airplane mode is for radios. Like the enterprise policy above, this is something out of your control - the user needs to re-enable camera access, so all you can do is put up a dialog saying "cameras are disabled, sorry".
If your app targets Android 10 (API level 29) or higher and accesses location information in a foreground service, declare the location foreground service type as an attribute of your component.
<manifest>
...
<service ... android:foregroundServiceType="location|camera" />
At runtime, if the foreground service only needs access to a subset of the types declared in the manifest, you can limit the service's access using the logic in the following code snippet:
Notification notification = ...;
Service.startForeground(notification, FOREGROUND_SERVICE_TYPE_LOCATION| FOREGROUND_SERVICE_TYPE_CAMERA);
This is how you will be able to use camera in the background.

Calibration server not working on ARToolKit5 . Unable to fetch calibration file on Android device

When ever I run ARToolKit5 android project , it takes hell lot of time to open up camera and I am getting this log -
E/libar: Error performing CURL operation: Error (7). Failed to connect to omega.artoolworks.com port 443: Connection timed out.
E/libar: Error -4 returned from cparamSearch.
E/nftSimpleNative: Unable to automatically determine camera parameters. Using default.
Is there is any other way to get calibration file for different device , because using default calibration file causes problem when I change the resolution of the device.
P.S. - Turning off internet is not an option, I need calibration file specific to each device.
The calibration service previously provided by DAQRI is offline as of October 2017. A new project named artoolkitX is now providing a calibration service which can be used by ARToolKit 5. See https://github.com/artoolkitx/artoolkit5/commit/47e0100441e211cfc4496d5599de0f8fe5531131 and http://www.artoolkitx.org/docs/downloads/

About Android Init Language to start a daemon dynamically after devices was added when phone booting process

I want to start a native service daemon, when my device is decteded(i.e. the devices is create at boot time). I saw the android init.rc document and got this grammer:
device-removed-<path> Triggers of these forms occur when a device node is added or removed.
So I think I can use this grammer to start my daemon. Then I modify init.rc as below,
on device-added-/dev/fp_dev
setprop fp.hardware.vendor llc
start fpDaemon
#Finger Feature for llc
service fpDaemon /system/bin/gxFpDaemon
disabled
user system
group system
Above grammer means, when my device name (fp_dev for example) was added when booting time, I start the native service daemon. But, the problem is the device is added when booted, but the daemon is not started as required. what's wrong with this? Many thinks.

Cannot record screen on Android 4.4.2

I am trying to record my device screen using the shell command as outlined here:
http://developer.android.com/tools/help/adb.html#screenrecord
Using the verbose flag, I am getting a Permission Denial that I think is connected to the fact there is an Owner profile on the device, as it references User 0 and User 1 in the error message.
Does anyone know how I can remove the Owner profile (can't see any options to do so) or how I can set the Owner to user 0?
EDIT - clarification, the error states "broadcast asks to run as user -1 but is calling from user 0"
I got the recording to work.
It seems that for whatever reason, you need to do this via adb shell.
Whilst adb shell is running shell commands on the connected device, running the screenrecord commands directly on the device just doesn't want to work.

Disable native logcat outputs in Android

I am using a Samsung Galaxy S3 device for development and my app is using the camera.
In the logcat, there is an output made by the native system with the tag Camera-JNI that is written to logcat like 20 times per second, causing the logcat to clean the oldest entries very fast.
Is it possible to disable logs from already installed apps or system logs to prevent this? Filters doesn't work, as the logcat is still filled and lines are still being clared.
Thank you.
EDIT
The documentation says this:
You can change the default level by setting a system property: setprop log.tag.<YOUR_LOG_TAG> <LEVEL>. You can also create a local.prop file that with the following in it:
log.tag.<YOUR_LOG_TAG>=<LEVEL> and place that in /data/local.prop.
EDIT 2
I already did this (rooting the device, pushing the local.prop file to /data and rebooting) but the tag is still appearing
I can see the following by examining the android source code (2.3.x):
Executing
shell setprop log.tag.XYZ
will not work here (frameworks/base/core/jni/android_hardware_Camera.cpp), as logging is being done using the LOGV() macro. This method of logging does not use properties to detect if some component wishes to disable logging. That is as far as I am able to trace the calls trough the android code.
So using setprop(...) will not work for disabling logging from an android system component but it should work when the logs come from user apps etc. written in Java which use base/core/java/android/util/Log.java and frameworks/base/core/jni/android_util_Log.cpp to log. My guess is that android_util_Log_isLoggable() is what is being used to filter.
IMHO I see no other alternative than building from source for your device and disabling the LOGV macros in the camera code you are using.
You can try something like adb shell setprop log.tag.Camera-JNI ERROR. If it doesn't work simply filter the log or dump it to a file and use grep to find the lines you are interested or filter out the camera with grep -v Camera-JNI.
If you want to see specific tags use:
logcat -s YourTag:* SecondTag:* ThirdTag:* ...
You can also use adb logcat
Just specify <TAG>:* as many times as you want to filter the tags you need.
Example: adb logcat -s AndroidRuntime:* MyApp:* filters AndroidRuntime and MyApp tags. So you see all uncaught exceptions (crashes) and also all logs of your application.

Categories

Resources