From f87d80fabed7ca96268d76daaa2e5d5341227322 Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Mon, 17 Oct 2011 10:56:12 -0700 Subject: [PATCH 1/5] Updated the Monkey runner to reflect changes to some private APIs it uses. bug:5382859 Change-Id: I67f8e4c7604d5466621e4655218e24f663d9efe6 --- .../com/android/commands/monkey/MonkeySourceNetworkViews.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetworkViews.java b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetworkViews.java index b6b08a926..806187558 100644 --- a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetworkViews.java +++ b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetworkViews.java @@ -345,7 +345,7 @@ public class MonkeySourceNetworkViews { if (command.size() == 2) { String text = command.get(1); List nodes = AccessibilityInteractionClient.getInstance() - .findAccessibilityNodeInfosByViewTextInActiveWindow(sConnection, text); + .findAccessibilityNodeInfosByTextInActiveWindow(sConnection, text); ViewIntrospectionCommand idGetter = new GetAccessibilityIds(); List emptyArgs = new ArrayList(); StringBuilder ids = new StringBuilder(); From 12c0b21abeea8f07cdcab3bf9a79b0791590f537 Mon Sep 17 00:00:00 2001 From: Christine Chen Date: Tue, 18 Oct 2011 17:43:52 -0700 Subject: [PATCH 2/5] Added white balance settings to the camera Emulator. - Added the white balance control to the fake camera. Change-Id: I5ada253a3ae7195ca5625a3601c9e4ed819fa2cc --- .../emulator/system/camera/EmulatedCamera.cpp | 49 +++++++++++++++---- .../system/camera/EmulatedCameraDevice.cpp | 45 ++++++++++++++++- .../system/camera/EmulatedCameraDevice.h | 46 ++++++++++++++++- .../system/camera/EmulatedFakeCamera.cpp | 27 ++++++++++ .../camera/EmulatedFakeCameraDevice.cpp | 17 ++++--- .../system/camera/EmulatedFakeCameraDevice.h | 5 +- 6 files changed, 165 insertions(+), 24 deletions(-) diff --git a/tools/emulator/system/camera/EmulatedCamera.cpp b/tools/emulator/system/camera/EmulatedCamera.cpp index 02b4683f6..f7f6eea56 100755 --- a/tools/emulator/system/camera/EmulatedCamera.cpp +++ b/tools/emulator/system/camera/EmulatedCamera.cpp @@ -28,7 +28,7 @@ #include #include #include "EmulatedCamera.h" -#include "EmulatedFakeCameraDevice.h" +//#include "EmulatedFakeCameraDevice.h" #include "Converters.h" /* Defines whether we should trace parameter changes. */ @@ -99,12 +99,8 @@ status_t EmulatedCamera::Initialize() * Fake required parameters. */ - mParameters.set(CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES, - "320x240,0x0"); - mParameters.set(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, "6"); - mParameters.set(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, "-6"); - mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP, "0.5"); - mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, "0"); + mParameters.set(CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES, "320x240,0x0"); + mParameters.set(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, "512"); mParameters.set(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, "384"); mParameters.set(CameraParameters::KEY_JPEG_QUALITY, "90"); @@ -137,10 +133,22 @@ status_t EmulatedCamera::Initialize() CameraParameters::PIXEL_FORMAT_JPEG); mParameters.setPictureFormat(CameraParameters::PIXEL_FORMAT_JPEG); - /* - * Not supported features - */ + /* Sets the default exposure compensation support to be disabled. */ + mParameters.set(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, "0"); + mParameters.set(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, "0"); + /* Sets auto white balance as default. */ + getCameraDevice()->initializeWhiteBalanceModes( + CameraParameters::WHITE_BALANCE_AUTO, 1.0f, 1.0f); + mParameters.set(CameraParameters::KEY_SUPPORTED_WHITE_BALANCE, + CameraParameters::WHITE_BALANCE_AUTO); + mParameters.set(CameraParameters::KEY_WHITE_BALANCE, + CameraParameters::WHITE_BALANCE_AUTO); + getCameraDevice()->setWhiteBalanceMode( + mParameters.get(CameraParameters::KEY_WHITE_BALANCE)); + + /* Not supported features + */ mParameters.set(CameraParameters::KEY_SUPPORTED_FOCUS_MODES, CameraParameters::FOCUS_MODE_FIXED); mParameters.set(CameraParameters::KEY_FOCUS_MODE, @@ -408,6 +416,9 @@ status_t EmulatedCamera::setParameters(const char* parms) String8 str8_param(parms); new_param.unflatten(str8_param); + /* + * Check for new exposure compensation parameter. + */ int new_exposure_compensation = new_param.getInt( CameraParameters::KEY_EXPOSURE_COMPENSATION); const int min_exposure_compensation = new_param.getInt( @@ -435,6 +446,24 @@ status_t EmulatedCamera::setParameters(const char* parms) exposure_value); } } + + const char* new_white_balance = new_param.get( + CameraParameters::KEY_WHITE_BALANCE); + const char* supported_white_balance = new_param.get( + CameraParameters::KEY_SUPPORTED_WHITE_BALANCE); + + if ((supported_white_balance != NULL) && (new_white_balance != NULL) && + (strstr(supported_white_balance, new_white_balance) != NULL)) { + + const char* current_white_balance = mParameters.get( + CameraParameters::KEY_WHITE_BALANCE); + if ((current_white_balance == NULL) || + (strcmp(current_white_balance, new_white_balance) != 0)) { + LOGV("Setting white balance to %s", new_white_balance); + getCameraDevice()->setWhiteBalanceMode(new_white_balance); + } + } + mParameters = new_param; return NO_ERROR; diff --git a/tools/emulator/system/camera/EmulatedCameraDevice.cpp b/tools/emulator/system/camera/EmulatedCameraDevice.cpp index 71464d201..eab169c67 100755 --- a/tools/emulator/system/camera/EmulatedCameraDevice.cpp +++ b/tools/emulator/system/camera/EmulatedCameraDevice.cpp @@ -29,25 +29,33 @@ #include #include #include "EmulatedCameraDevice.h" -#include "Converters.h" namespace android { +const float GAMMA_CORRECTION = 2.2f; EmulatedCameraDevice::EmulatedCameraDevice(EmulatedCamera* camera_hal) : mObjectLock(), mCurFrameTimestamp(0), mCameraHAL(camera_hal), mCurrentFrame(NULL), mExposureCompensation(1.0f), + mWhiteBalanceScale(NULL), + mSupportedWhiteBalanceScale(), mState(ECDS_CONSTRUCTED) { } EmulatedCameraDevice::~EmulatedCameraDevice() { + LOGV("EmulatedCameraDevice destructor"); if (mCurrentFrame != NULL) { delete[] mCurrentFrame; } + for (int i = 0; i < mSupportedWhiteBalanceScale.size(); ++i) { + if (mSupportedWhiteBalanceScale.valueAt(i) != NULL) { + delete[] mSupportedWhiteBalanceScale.valueAt(i); + } + } } /**************************************************************************** @@ -110,10 +118,43 @@ void EmulatedCameraDevice::setExposureCompensation(const float ev) { LOGW("%s: Fake camera device is not started.", __FUNCTION__); } - mExposureCompensation = std::pow(2.0f, ev); + mExposureCompensation = std::pow(2.0f, ev / GAMMA_CORRECTION); LOGV("New exposure compensation is %f", mExposureCompensation); } +void EmulatedCameraDevice::initializeWhiteBalanceModes(const char* mode, + const float r_scale, + const float b_scale) { + LOGV("%s with %s, %f, %f", __FUNCTION__, mode, r_scale, b_scale); + float* value = new float[3]; + value[0] = r_scale; value[1] = 1.0f; value[2] = b_scale; + mSupportedWhiteBalanceScale.add(String8(mode), value); +} + +void EmulatedCameraDevice::setWhiteBalanceMode(const char* mode) { + LOGV("%s with white balance %s", __FUNCTION__, mode); + mWhiteBalanceScale = + mSupportedWhiteBalanceScale.valueFor(String8(mode)); +} + +/* Computes the pixel value after adjusting the white balance to the current + * one. The input the y, u, v channel of the pixel and the adjusted value will + * be stored in place. The adjustment is done in RGB space. + */ +void EmulatedCameraDevice::changeWhiteBalance(uint8_t& y, + uint8_t& u, + uint8_t& v) const { + float r_scale = mWhiteBalanceScale[0]; + float b_scale = mWhiteBalanceScale[2]; + int r = static_cast(YUV2R(y, u, v)) / r_scale; + int g = YUV2G(y, u, v); + int b = static_cast(YUV2B(y, u, v)) / b_scale; + + y = RGB2Y(r, g, b); + u = RGB2U(r, g, b); + v = RGB2V(r, g, b); +} + status_t EmulatedCameraDevice::getCurrentPreviewFrame(void* buffer) { if (!isStarted()) { diff --git a/tools/emulator/system/camera/EmulatedCameraDevice.h b/tools/emulator/system/camera/EmulatedCameraDevice.h index 357c9e6dd..b0999063b 100755 --- a/tools/emulator/system/camera/EmulatedCameraDevice.h +++ b/tools/emulator/system/camera/EmulatedCameraDevice.h @@ -27,7 +27,10 @@ */ #include +#include +#include #include "EmulatedCameraCommon.h" +#include "Converters.h" namespace android { @@ -116,6 +119,21 @@ public: */ virtual status_t Initialize(); + /* Initializes the white balance modes parameters. + * The parameters are passed by each individual derived camera API to + * represent that different camera manufacturers may have different + * preferences on the white balance parameters. Green channel in the RGB + * color space is fixed to keep the luminance to be reasonably constant. + * + * Param: + * mode the text describing the current white balance mode + * r_scale the scale factor for the R channel in RGB space + * b_scale the scale factor for the B channel in RGB space. + */ + void initializeWhiteBalanceModes(const char* mode, + const float r_scale, + const float b_scale); + /* Starts delivering frames captured from the camera device. * This method will start the worker thread that would be pulling frames from * the camera device, and will deliver the pulled frames back to the emulated @@ -145,7 +163,11 @@ public: /* Sets the exposure compensation for the camera device. */ - virtual void setExposureCompensation(const float ev); + void setExposureCompensation(const float ev); + + /* Sets the white balance mode for the device. + */ + void setWhiteBalanceMode(const char* mode); /* Gets current framebuffer, converted into preview frame format. * This method must be called on a connected instance of this class with a @@ -269,6 +291,24 @@ protected: */ virtual void commonStopDevice(); + /** Computes a luminance value after taking the exposure compensation. + * value into account. + * + * Param: + * inputY - The input luminance value. + * Return: + * The luminance value after adjusting the exposure compensation. + */ + inline uint8_t changeExposure(const uint8_t& inputY) const { + return static_cast(clamp(static_cast(inputY) * + mExposureCompensation)); + } + + /** Computes the pixel value in YUV space after adjusting to the current + * white balance mode. + */ + void changeWhiteBalance(uint8_t& y, uint8_t& u, uint8_t& v) const; + /**************************************************************************** * Worker thread management. * Typicaly when emulated camera device starts capturing frames from the @@ -478,6 +518,10 @@ protected: /* Exposure compensation value */ float mExposureCompensation; + float* mWhiteBalanceScale; + + DefaultKeyedVector mSupportedWhiteBalanceScale; + /* Defines possible states of the emulated camera device object. */ enum EmulatedCameraDeviceState { diff --git a/tools/emulator/system/camera/EmulatedFakeCamera.cpp b/tools/emulator/system/camera/EmulatedFakeCamera.cpp index d82fd787f..9d54f3884 100755 --- a/tools/emulator/system/camera/EmulatedFakeCamera.cpp +++ b/tools/emulator/system/camera/EmulatedFakeCamera.cpp @@ -61,6 +61,33 @@ status_t EmulatedFakeCamera::Initialize() gEmulatedCameraFactory.getFakeCameraOrientation()); res = EmulatedCamera::Initialize(); + + mParameters.set(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, "6"); + mParameters.set(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, "-6"); + mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP, "0.5"); + mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, "0"); + LOGV("Set camera supported exposure values"); + + // Sets the white balance modes and the device-dependent scale factors. + mFakeCameraDevice.initializeWhiteBalanceModes( + CameraParameters::WHITE_BALANCE_INCANDESCENT, 1.38f, 0.60f); + mFakeCameraDevice.initializeWhiteBalanceModes( + CameraParameters::WHITE_BALANCE_DAYLIGHT, 1.09f, 0.92f); + mFakeCameraDevice.initializeWhiteBalanceModes( + CameraParameters::WHITE_BALANCE_TWILIGHT, 0.92f, 1.22f); + + char supported_white_balance[1024]; + snprintf(supported_white_balance, sizeof(supported_white_balance), + "%s,%s,%s,%s", + mParameters.get(CameraParameters::KEY_SUPPORTED_WHITE_BALANCE), + CameraParameters::WHITE_BALANCE_INCANDESCENT, + CameraParameters::WHITE_BALANCE_DAYLIGHT, + CameraParameters::WHITE_BALANCE_TWILIGHT); + mParameters.set(CameraParameters::KEY_SUPPORTED_WHITE_BALANCE, + supported_white_balance); + + LOGV("Set camera supported white balance modes"); + if (res != NO_ERROR) { return res; } diff --git a/tools/emulator/system/camera/EmulatedFakeCameraDevice.cpp b/tools/emulator/system/camera/EmulatedFakeCameraDevice.cpp index 36668272e..1e1a01210 100755 --- a/tools/emulator/system/camera/EmulatedFakeCameraDevice.cpp +++ b/tools/emulator/system/camera/EmulatedFakeCameraDevice.cpp @@ -46,11 +46,11 @@ EmulatedFakeCameraDevice::EmulatedFakeCameraDevice(EmulatedFakeCamera* camera_ha { // Makes the image with the original exposure compensation darker. // So the effects of changing the exposure compensation can be seen. - mBlackYUV.Y = mBlackYUV.Y / 4; - mWhiteYUV.Y = mWhiteYUV.Y / 4; - mRedYUV.Y = mRedYUV.Y / 4; - mGreenYUV.Y = mGreenYUV.Y / 4; - mBlueYUV.Y = mBlueYUV.Y / 4; + mBlackYUV.Y = mBlackYUV.Y / 2; + mWhiteYUV.Y = mWhiteYUV.Y / 2; + mRedYUV.Y = mRedYUV.Y / 2; + mGreenYUV.Y = mGreenYUV.Y / 2; + mBlueYUV.Y = mBlueYUV.Y / 2; } EmulatedFakeCameraDevice::~EmulatedFakeCameraDevice() @@ -256,6 +256,9 @@ void EmulatedFakeCameraDevice::drawCheckerboard() uint8_t* U = U_pos; uint8_t* V = V_pos; + YUVPixel adjustedWhite = YUVPixel(mWhiteYUV); + changeWhiteBalance(adjustedWhite.Y, adjustedWhite.U, adjustedWhite.V); + for(int y = 0; y < mFrameHeight; y++) { int countx = checkxremainder; bool current = black; @@ -263,7 +266,7 @@ void EmulatedFakeCameraDevice::drawCheckerboard() if (current) { mBlackYUV.get(Y, U, V); } else { - mWhiteYUV.get(Y, U, V); + adjustedWhite.get(Y, U, V); } *Y = changeExposure(*Y); Y[1] = *Y; @@ -407,7 +410,7 @@ int EmulatedFakeCameraDevice::rotateFrame() } } else if (mCurrentFrameType == 0) { LOGD("********** Rotated to the CHECKERBOARD frame **********"); - } else { + } else if (mCurrentFrameType == 1) { LOGD("********** Rotated to the STRIPED frame **********"); } } diff --git a/tools/emulator/system/camera/EmulatedFakeCameraDevice.h b/tools/emulator/system/camera/EmulatedFakeCameraDevice.h index 0920be7a2..6f6d4f715 100755 --- a/tools/emulator/system/camera/EmulatedFakeCameraDevice.h +++ b/tools/emulator/system/camera/EmulatedFakeCameraDevice.h @@ -99,6 +99,7 @@ protected: ***************************************************************************/ private: + /* Draws a black and white checker board in the current frame buffer. */ void drawCheckerboard(); @@ -110,10 +111,6 @@ private: */ void drawSquare(int x, int y, int size, const YUVPixel* color); - inline uint8_t changeExposure(uint8_t inputY) { - return static_cast(static_cast(inputY) * - mExposureCompensation); - } #if EFCD_ROTATE_FRAME void drawSolid(YUVPixel* color); void drawStripes(); From 94a55ddf0b12940c019b8275cbc5413616e7f1ae Mon Sep 17 00:00:00 2001 From: Raphael Date: Sat, 22 Oct 2011 23:41:13 -0700 Subject: [PATCH 3/5] SDK: package fastboot in platform-tools on 3 OSes. SDK Bug: 21115 Change-Id: I0a5ded5ac085dce15f53d012c2ea33d82ede908b --- build/sdk-windows-x86.atree | 2 ++ build/sdk.atree | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build/sdk-windows-x86.atree b/build/sdk-windows-x86.atree index 68105a2d0..3144b2711 100644 --- a/build/sdk-windows-x86.atree +++ b/build/sdk-windows-x86.atree @@ -27,7 +27,9 @@ # rm platform-tools/adb +rm platform-tools/fastboot bin/adb.exe strip platform-tools/adb.exe +bin/fastboot.exe strip platform-tools/fastboot.exe bin/AdbWinUsbApi.dll platform-tools/AdbWinUsbApi.dll bin/AdbWinApi.dll platform-tools/AdbWinApi.dll diff --git a/build/sdk.atree b/build/sdk.atree index 5996c9ccb..ab7ab5c6b 100644 --- a/build/sdk.atree +++ b/build/sdk.atree @@ -43,6 +43,7 @@ development/sdk/plat_tools_source.properties platform-tools/source.properties bin/adb strip platform-tools/adb bin/aapt strip platform-tools/aapt bin/aidl strip platform-tools/aidl +bin/fastboot strip platform-tools/fastboot bin/llvm-rs-cc strip platform-tools/llvm-rs-cc # dx @@ -50,7 +51,6 @@ bin/dx platform-tools/dx bin/dexdump platform-tools/dexdump framework/dx.jar platform-tools/lib/dx.jar - # Framework include for Renderscript frameworks/base/libs/rs/scriptc platform-tools/renderscript/include external/clang/lib/Headers platform-tools/renderscript/clang-include From 7d9558522d0a3dc8004b05d97e043a5e8896e193 Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Mon, 24 Oct 2011 16:07:34 -0700 Subject: [PATCH 4/5] Adding a code sample for using AccessibilityNodeProvider to report virtual Views. Note: This is a sample and does *not* affect the system image, rather only the SDK. bug:5508317 Change-Id: I62bbef4b2a4c2789ddfa128e94ae37246d244ac0 --- samples/ApiDemos/AndroidManifest.xml | 10 + samples/ApiDemos/_index.html | 1 + .../layout/accessibility_node_provider.xml | 34 ++ samples/ApiDemos/res/values/strings.xml | 9 + .../AccessibilityNodeProviderActivity.java | 484 ++++++++++++++++++ .../android/apis/accessibility/_index.html | 9 + 6 files changed, 547 insertions(+) create mode 100644 samples/ApiDemos/res/layout/accessibility_node_provider.xml create mode 100644 samples/ApiDemos/src/com/example/android/apis/accessibility/AccessibilityNodeProviderActivity.java create mode 100644 samples/ApiDemos/src/com/example/android/apis/accessibility/_index.html diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml index 2449e062e..3ee5e5e4d 100644 --- a/samples/ApiDemos/AndroidManifest.xml +++ b/samples/ApiDemos/AndroidManifest.xml @@ -834,6 +834,16 @@ + + + + + + + + diff --git a/samples/ApiDemos/_index.html b/samples/ApiDemos/_index.html index 9466c95b5..ee230a930 100644 --- a/samples/ApiDemos/_index.html +++ b/samples/ApiDemos/_index.html @@ -36,6 +36,7 @@ fragment animations
  • Stylus and hover support
  • Switch widget
  • +
  • Accessibility Node Provider
  • diff --git a/samples/ApiDemos/res/layout/accessibility_node_provider.xml b/samples/ApiDemos/res/layout/accessibility_node_provider.xml new file mode 100644 index 000000000..cc10c9cd2 --- /dev/null +++ b/samples/ApiDemos/res/layout/accessibility_node_provider.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml index 5a7183c6d..90855007b 100644 --- a/samples/ApiDemos/res/values/strings.xml +++ b/samples/ApiDemos/res/values/strings.xml @@ -1286,4 +1286,13 @@ Dismiss Share + + + + + + Accessibility/Accessibility Node Provider + Enable TalkBack and Explore-by-touch from accessibility + settings. Then touch the colored squares. + diff --git a/samples/ApiDemos/src/com/example/android/apis/accessibility/AccessibilityNodeProviderActivity.java b/samples/ApiDemos/src/com/example/android/apis/accessibility/AccessibilityNodeProviderActivity.java new file mode 100644 index 000000000..16914c7ac --- /dev/null +++ b/samples/ApiDemos/src/com/example/android/apis/accessibility/AccessibilityNodeProviderActivity.java @@ -0,0 +1,484 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.android.apis.accessibility; + +import com.example.android.apis.R; + +import android.app.Activity; +import android.app.Service; +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Rect; +import android.os.Bundle; +import android.text.TextUtils; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.View; +import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityManager; +import android.view.accessibility.AccessibilityNodeInfo; +import android.view.accessibility.AccessibilityNodeProvider; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * This sample demonstrates how a View can expose a virtual view sub-tree + * rooted at it. A virtual sub-tree is composed of imaginary Views + * that are reported as a part of the view hierarchy for accessibility + * purposes. This enables custom views that draw complex content to report + * them selves as a tree of virtual views, thus conveying their logical + * structure. + *

    + * For example, a View may draw a monthly calendar as a grid of days while + * each such day may contains some events. From a perspective of the View + * hierarchy the calendar is composed of a single View but an accessibility + * service would benefit of traversing the logical structure of the calendar + * by examining each day and each event on that day. + *

    + */ +public class AccessibilityNodeProviderActivity extends Activity { + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.accessibility_node_provider); + } + + /** + * This class presents a View that is composed of three virtual children + * each of which is drawn with a different color and represents a region + * of the View that has different semantics compared to other such regions. + * While the virtual view tree exposed by this class is one level deep + * for simplicity, there is no bound on the complexity of that virtual + * sub-tree. + */ + public static class VirtualSubtreeRootView extends View { + + /** Paint object for drawing the virtual sub-tree */ + private final Paint mPaint = new Paint(); + + /** Temporary rectangle to minimize object creation. */ + private final Rect mTempRect = new Rect(); + + /** Handle to the system accessibility service. */ + private final AccessibilityManager mAccessibilityManager; + + /** The virtual children of this View. */ + private final List mChildren = new ArrayList(); + + /** The instance of the node provider for the virtual tree - lazily instantiated. */ + private AccessibilityNodeProvider mAccessibilityNodeProvider; + + /** The last hovered child used for event dispatching. */ + private VirtualView mLastHoveredChild; + + public VirtualSubtreeRootView(Context context, AttributeSet attrs) { + super(context, attrs); + mAccessibilityManager = (AccessibilityManager) context.getSystemService( + Service.ACCESSIBILITY_SERVICE); + createVirtualChildren(); + } + + /** + * {@inheritDoc} + */ + @Override + public AccessibilityNodeProvider getAccessibilityNodeProvider() { + // Instantiate the provide only when requested. Since the system + // will call this method multiple times it is a good practice to + // cache the provider instance. + if (mAccessibilityNodeProvider == null) { + mAccessibilityNodeProvider = new VirtualDescendantsProvider(); + } + return mAccessibilityNodeProvider; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean dispatchHoverEvent(MotionEvent event) { + // This implementation assumes that the virtual children + // cannot overlap and are always visible. Do NOT use this + // code as a reference of how to implement hover event + // dispatch. Instead, refer to ViewGroup#dispatchHoverEvent. + boolean handled = false; + List children = mChildren; + final int childCount = children.size(); + for (int i = 0; i < childCount; i++) { + VirtualView child = children.get(i); + Rect childBounds = child.mBounds; + final int childCoordsX = (int) event.getX() + getScrollX(); + final int childCoordsY = (int) event.getY() + getScrollY(); + if (!childBounds.contains(childCoordsX, childCoordsY)) { + continue; + } + final int action = event.getAction(); + switch (action) { + case MotionEvent.ACTION_HOVER_ENTER: { + mLastHoveredChild = child; + handled |= onHoverVirtualView(child, event); + event.setAction(action); + } break; + case MotionEvent.ACTION_HOVER_MOVE: { + if (child == mLastHoveredChild) { + handled |= onHoverVirtualView(child, event); + event.setAction(action); + } else { + MotionEvent eventNoHistory = event.getHistorySize() > 0 + ? MotionEvent.obtainNoHistory(event) : event; + eventNoHistory.setAction(MotionEvent.ACTION_HOVER_EXIT); + onHoverVirtualView(mLastHoveredChild, eventNoHistory); + eventNoHistory.setAction(MotionEvent.ACTION_HOVER_ENTER); + onHoverVirtualView(child, eventNoHistory); + mLastHoveredChild = child; + eventNoHistory.setAction(MotionEvent.ACTION_HOVER_MOVE); + handled |= onHoverVirtualView(child, eventNoHistory); + if (eventNoHistory != event) { + eventNoHistory.recycle(); + } else { + event.setAction(action); + } + } + } break; + case MotionEvent.ACTION_HOVER_EXIT: { + mLastHoveredChild = null; + handled |= onHoverVirtualView(child, event); + event.setAction(action); + } break; + } + } + if (!handled) { + handled |= onHoverEvent(event); + } + return handled; + } + + /** + * {@inheritDoc} + */ + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + // The virtual children are ordered horizontally next to + // each other and take the entire space of this View. + int offsetX = 0; + List children = mChildren; + final int childCount = children.size(); + for (int i = 0; i < childCount; i++) { + VirtualView child = children.get(i); + Rect childBounds = child.mBounds; + childBounds.set(offsetX, 0, offsetX + childBounds.width(), childBounds.height()); + offsetX += childBounds.width(); + } + } + + /** + * {@inheritDoc} + */ + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + // The virtual children are ordered horizontally next to + // each other and take the entire space of this View. + int width = 0; + int height = 0; + List children = mChildren; + final int childCount = children.size(); + for (int i = 0; i < childCount; i++) { + VirtualView child = children.get(i); + width += child.mBounds.width(); + height = Math.max(height, child.mBounds.height()); + } + setMeasuredDimension(width, height); + } + + /** + * {@inheritDoc} + */ + @Override + protected void onDraw(Canvas canvas) { + // Draw the virtual children with the reusable Paint object + // and with the bounds and color which are child specific. + Rect drawingRect = mTempRect; + List children = mChildren; + final int childCount = children.size(); + for (int i = 0; i < childCount; i++) { + VirtualView child = children.get(i); + drawingRect.set(child.mBounds); + mPaint.setColor(child.mColor); + mPaint.setAlpha(child.mAlpha); + canvas.drawRect(drawingRect, mPaint); + } + } + + /** + * Creates the virtual children of this View. + */ + private void createVirtualChildren() { + // The virtual portion of the tree is one level deep. Note + // that implementations can use any way of representing and + // drawing virtual view. + VirtualView firstChild = new VirtualView(0, new Rect(0, 0, 150, 150), Color.RED, + "Virtual view 1"); + mChildren.add(firstChild); + VirtualView secondChild = new VirtualView(1, new Rect(0, 0, 150, 150), Color.GREEN, + "Virtual view 2"); + mChildren.add(secondChild); + VirtualView thirdChild = new VirtualView(2, new Rect(0, 0, 150, 150), Color.BLUE, + "Virtual view 3"); + mChildren.add(thirdChild); + } + + /** + * Set the selected state of a virtual view. + * + * @param virtualView The virtual view whose selected state to set. + * @param selected Whether the virtual view is selected. + */ + private void setVirtualViewSelected(VirtualView virtualView, boolean selected) { + virtualView.mAlpha = selected ? VirtualView.ALPHA_SELECTED : VirtualView.ALPHA_NOT_SELECTED; + } + + /** + * Handle a hover over a virtual view. + * + * @param virtualView The virtual view over which is hovered. + * @param event The event to dispatch. + * @return Whether the event was handled. + */ + private boolean onHoverVirtualView(VirtualView virtualView, MotionEvent event) { + // The implementation of hover event dispatch can be implemented + // in any way that is found suitable. However, each virtual View + // should fire a corresponding accessibility event whose source + // is that virtual view. Accessibility services get the event source + // as the entry point of the APIs for querying the window content. + final int action = event.getAction(); + switch (action) { + case MotionEvent.ACTION_HOVER_ENTER: { + sendAccessibilityEventForVirtualView(virtualView, + AccessibilityEvent.TYPE_VIEW_HOVER_ENTER); + } break; + case MotionEvent.ACTION_HOVER_EXIT: { + sendAccessibilityEventForVirtualView(virtualView, + AccessibilityEvent.TYPE_VIEW_HOVER_EXIT); + } break; + } + return true; + } + + /** + * Sends a properly initialized accessibility event for a virtual view.. + * + * @param virtualView The virtual view. + * @param eventType The type of the event to send. + */ + private void sendAccessibilityEventForVirtualView(VirtualView virtualView, int eventType) { + // If touch exploration, i.e. the user gets feedback while touching + // the screen, is enabled we fire accessibility events. + if (mAccessibilityManager.isTouchExplorationEnabled()) { + AccessibilityEvent event = AccessibilityEvent.obtain(eventType); + event.setPackageName(getContext().getPackageName()); + event.setClassName(virtualView.getClass().getName()); + event.setSource(VirtualSubtreeRootView.this, virtualView.mId); + event.getText().add(virtualView.mText); + getParent().requestSendAccessibilityEvent(VirtualSubtreeRootView.this, event); + } + } + + /** + * Finds a virtual view given its id. + * + * @param id The virtual view id. + * @return The found virtual view. + */ + private VirtualView findVirtualViewById(int id) { + List children = mChildren; + final int childCount = children.size(); + for (int i = 0; i < childCount; i++) { + VirtualView child = children.get(i); + if (child.mId == id) { + return child; + } + } + return null; + } + + /** + * Represents a virtual View. + */ + private class VirtualView { + public static final int ALPHA_SELECTED = 255; + public static final int ALPHA_NOT_SELECTED = 127; + + public final int mId; + public final int mColor; + public final Rect mBounds; + public final String mText; + public int mAlpha; + + public VirtualView(int id, Rect bounds, int color, String text) { + mId = id; + mColor = color; + mBounds = bounds; + mText = text; + mAlpha = ALPHA_NOT_SELECTED; + } + } + + /** + * This is the provider that exposes the virtual View tree to accessibility + * services. From the perspective of an accessibility service the + * {@link AccessibilityNodeInfo}s it receives while exploring the sub-tree + * rooted at this View will be the same as the ones it received while + * exploring a View containing a sub-tree composed of real Views. + */ + private class VirtualDescendantsProvider extends AccessibilityNodeProvider { + + /** + * {@inheritDoc} + */ + @Override + public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) { + AccessibilityNodeInfo info = null; + if (virtualViewId == View.NO_ID) { + // We are requested to create an AccessibilityNodeInfo describing + // this View, i.e. the root of the virtual sub-tree. Note that the + // host View has an AccessibilityNodeProvider which means that this + // provider is responsible for creating the node info for that root. + info = AccessibilityNodeInfo.obtain(VirtualSubtreeRootView.this); + onInitializeAccessibilityNodeInfo(info); + // Add the virtual children of the root View. + List children = mChildren; + final int childCount = children.size(); + for (int i = 0; i < childCount; i++) { + VirtualView child = children.get(i); + info.addChild(VirtualSubtreeRootView.this, child.mId); + } + } else { + // Find the view that corresponds to the given id. + VirtualView virtualView = findVirtualViewById(virtualViewId); + if (virtualView == null) { + return null; + } + // Obtain and initialize an AccessibilityNodeInfo with + // information about the virtual view. + info = AccessibilityNodeInfo.obtain(); + info.addAction(AccessibilityNodeInfo.ACTION_SELECT); + info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_SELECTION); + info.setPackageName(getContext().getPackageName()); + info.setClassName(virtualView.getClass().getName()); + info.setSource(VirtualSubtreeRootView.this, virtualViewId); + info.setBoundsInParent(virtualView.mBounds); + info.setParent(VirtualSubtreeRootView.this); + info.setText(virtualView.mText); + } + return info; + } + + /** + * {@inheritDoc} + */ + @Override + public List findAccessibilityNodeInfosByText(String searched, + int virtualViewId) { + if (TextUtils.isEmpty(searched)) { + return Collections.emptyList(); + } + String searchedLowerCase = searched.toLowerCase(); + List result = null; + if (virtualViewId == View.NO_ID) { + // If the search is from the root, i.e. this View, go over the virtual + // children and look for ones that contain the searched string since + // this View does not contain text itself. + List children = mChildren; + final int childCount = children.size(); + for (int i = 0; i < childCount; i++) { + VirtualView child = children.get(i); + String textToLowerCase = child.mText.toLowerCase(); + if (textToLowerCase.contains(searchedLowerCase)) { + if (result == null) { + result = new ArrayList(); + } + result.add(createAccessibilityNodeInfo(child.mId)); + } + } + } else { + // If the search is from a virtual view, find the view. Since the tree + // is one level deep we add a node info for the child to the result if + // the child contains the searched text. + VirtualView virtualView = findVirtualViewById(virtualViewId); + if (virtualView != null) { + String textToLowerCase = virtualView.mText.toLowerCase(); + if (textToLowerCase.contains(searchedLowerCase)) { + result = new ArrayList(); + result.add(createAccessibilityNodeInfo(virtualViewId)); + } + } + } + if (result == null) { + return Collections.emptyList(); + } + return result; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean performAccessibilityAction(int action, int virtualViewId) { + if (virtualViewId == View.NO_ID) { + // Perform the action on the host View. + switch (action) { + case AccessibilityNodeInfo.ACTION_SELECT: + if (!isSelected()) { + setSelected(true); + return isSelected(); + } + break; + case AccessibilityNodeInfo.ACTION_CLEAR_SELECTION: + if (isSelected()) { + setSelected(false); + return !isSelected(); + } + break; + } + } else { + // Find the view that corresponds to the given id. + VirtualView child = findVirtualViewById(virtualViewId); + if (child == null) { + return false; + } + // Perform the action on a virtual view. + switch (action) { + case AccessibilityNodeInfo.ACTION_SELECT: + setVirtualViewSelected(child, true); + invalidate(); + return true; + case AccessibilityNodeInfo.ACTION_CLEAR_SELECTION: + setVirtualViewSelected(child, false); + invalidate(); + return true; + } + } + return false; + } + } + } +} diff --git a/samples/ApiDemos/src/com/example/android/apis/accessibility/_index.html b/samples/ApiDemos/src/com/example/android/apis/accessibility/_index.html new file mode 100644 index 000000000..87aea08ca --- /dev/null +++ b/samples/ApiDemos/src/com/example/android/apis/accessibility/_index.html @@ -0,0 +1,9 @@ +

    Accessibility

    +
    +
    Accessibility Node Provider
    +
    Demonstrates how to develop an accessibility node provider which manages a virtual + View tree reported to accessibility services. The virtual subtree is rooted at a View + that draws complex content and reports itself as a tree of virtual views, thus conveying + its logical structure. +
    +
    From 629719e390ce66be822c3563bbd248ce15eaae7b Mon Sep 17 00:00:00 2001 From: Steve Block Date: Thu, 20 Oct 2011 11:55:55 +0100 Subject: [PATCH 5/5] Rename LOGV(_IF) to ALOGV(_IF) DO NOT MERGE See https://android-git.corp.google.com/g/#/c/143865 Bug: 5449033 Change-Id: Iad3a485eed0dc273d66607d30a7b9b79b02c03b6 --- .../system/camera/CallbackNotifier.cpp | 16 +++++----- .../emulator/system/camera/EmulatedCamera.cpp | 28 ++++++++--------- .../system/camera/EmulatedCameraCommon.h | 4 +-- .../system/camera/EmulatedCameraDevice.cpp | 30 +++++++++---------- .../system/camera/EmulatedCameraFactory.cpp | 6 ++-- .../system/camera/EmulatedFakeCamera.cpp | 4 +-- .../camera/EmulatedFakeCameraDevice.cpp | 10 +++---- .../system/camera/EmulatedQemuCamera.cpp | 4 +-- .../camera/EmulatedQemuCameraDevice.cpp | 20 ++++++------- .../emulator/system/camera/JpegCompressor.cpp | 4 +-- .../emulator/system/camera/PreviewWindow.cpp | 8 ++--- tools/emulator/system/camera/QemuClient.cpp | 16 +++++----- 12 files changed, 75 insertions(+), 75 deletions(-) diff --git a/tools/emulator/system/camera/CallbackNotifier.cpp b/tools/emulator/system/camera/CallbackNotifier.cpp index f974b8673..f908e15c7 100755 --- a/tools/emulator/system/camera/CallbackNotifier.cpp +++ b/tools/emulator/system/camera/CallbackNotifier.cpp @@ -80,7 +80,7 @@ static void PrintMessages(uint32_t msg) const char* strs[lCameraMessagesNum]; const int translated = GetMessageStrings(msg, strs, lCameraMessagesNum); for (int n = 0; n < translated; n++) { - LOGV(" %s", strs[n]); + ALOGV(" %s", strs[n]); } } @@ -113,7 +113,7 @@ void CallbackNotifier::setCallbacks(camera_notify_callback notify_cb, camera_request_memory get_memory, void* user) { - LOGV("%s: %p, %p, %p, %p (%p)", + ALOGV("%s: %p, %p, %p, %p (%p)", __FUNCTION__, notify_cb, data_cb, data_cb_timestamp, get_memory, user); Mutex::Autolock locker(&mObjectLock); @@ -126,29 +126,29 @@ void CallbackNotifier::setCallbacks(camera_notify_callback notify_cb, void CallbackNotifier::enableMessage(uint msg_type) { - LOGV("%s: msg_type = 0x%x", __FUNCTION__, msg_type); + ALOGV("%s: msg_type = 0x%x", __FUNCTION__, msg_type); PrintMessages(msg_type); Mutex::Autolock locker(&mObjectLock); mMessageEnabler |= msg_type; - LOGV("**** Currently enabled messages:"); + ALOGV("**** Currently enabled messages:"); PrintMessages(mMessageEnabler); } void CallbackNotifier::disableMessage(uint msg_type) { - LOGV("%s: msg_type = 0x%x", __FUNCTION__, msg_type); + ALOGV("%s: msg_type = 0x%x", __FUNCTION__, msg_type); PrintMessages(msg_type); Mutex::Autolock locker(&mObjectLock); mMessageEnabler &= ~msg_type; - LOGV("**** Currently enabled messages:"); + ALOGV("**** Currently enabled messages:"); PrintMessages(mMessageEnabler); } status_t CallbackNotifier::enableVideoRecording(int fps) { - LOGV("%s: FPS = %d", __FUNCTION__, fps); + ALOGV("%s: FPS = %d", __FUNCTION__, fps); Mutex::Autolock locker(&mObjectLock); mVideoRecEnabled = true; @@ -160,7 +160,7 @@ status_t CallbackNotifier::enableVideoRecording(int fps) void CallbackNotifier::disableVideoRecording() { - LOGV("%s:", __FUNCTION__); + ALOGV("%s:", __FUNCTION__); Mutex::Autolock locker(&mObjectLock); mVideoRecEnabled = false; diff --git a/tools/emulator/system/camera/EmulatedCamera.cpp b/tools/emulator/system/camera/EmulatedCamera.cpp index f7f6eea56..25847a4e2 100755 --- a/tools/emulator/system/camera/EmulatedCamera.cpp +++ b/tools/emulator/system/camera/EmulatedCamera.cpp @@ -180,7 +180,7 @@ void EmulatedCamera::onCameraDeviceError(int err) status_t EmulatedCamera::connectCamera(hw_device_t** device) { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); status_t res = EINVAL; EmulatedCameraDevice* const camera_dev = getCameraDevice(); @@ -199,14 +199,14 @@ status_t EmulatedCamera::connectCamera(hw_device_t** device) status_t EmulatedCamera::closeCamera() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); return cleanupCamera(); } status_t EmulatedCamera::getCameraInfo(struct camera_info* info) { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); const char* valstr = NULL; @@ -309,7 +309,7 @@ void EmulatedCamera::releaseRecordingFrame(const void* opaque) status_t EmulatedCamera::setAutoFocus() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); /* TODO: Future enhancements. */ return NO_ERROR; @@ -317,7 +317,7 @@ status_t EmulatedCamera::setAutoFocus() status_t EmulatedCamera::cancelAutoFocus() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); /* TODO: Future enhancements. */ return NO_ERROR; @@ -325,7 +325,7 @@ status_t EmulatedCamera::cancelAutoFocus() status_t EmulatedCamera::takePicture() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); status_t res; int width, height; @@ -402,14 +402,14 @@ status_t EmulatedCamera::takePicture() status_t EmulatedCamera::cancelPicture() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); return NO_ERROR; } status_t EmulatedCamera::setParameters(const char* parms) { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); PrintParamDiff(mParameters, parms); CameraParameters new_param; @@ -459,7 +459,7 @@ status_t EmulatedCamera::setParameters(const char* parms) CameraParameters::KEY_WHITE_BALANCE); if ((current_white_balance == NULL) || (strcmp(current_white_balance, new_white_balance) != 0)) { - LOGV("Setting white balance to %s", new_white_balance); + ALOGV("Setting white balance to %s", new_white_balance); getCameraDevice()->setWhiteBalanceMode(new_white_balance); } } @@ -498,7 +498,7 @@ void EmulatedCamera::putParameters(char* params) status_t EmulatedCamera::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) { - LOGV("%s: cmd = %d, arg1 = %d, arg2 = %d", __FUNCTION__, cmd, arg1, arg2); + ALOGV("%s: cmd = %d, arg1 = %d, arg2 = %d", __FUNCTION__, cmd, arg1, arg2); /* TODO: Future enhancements. */ return 0; @@ -506,14 +506,14 @@ status_t EmulatedCamera::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) void EmulatedCamera::releaseCamera() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); cleanupCamera(); } status_t EmulatedCamera::dumpCamera(int fd) { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); /* TODO: Future enhancements. */ return -EINVAL; @@ -525,7 +525,7 @@ status_t EmulatedCamera::dumpCamera(int fd) status_t EmulatedCamera::doStartPreview() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); EmulatedCameraDevice* camera_dev = getCameraDevice(); if (camera_dev->isStarted()) { @@ -613,7 +613,7 @@ status_t EmulatedCamera::doStartPreview() status_t EmulatedCamera::doStopPreview() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); status_t res = NO_ERROR; if (mPreviewWindow.isPreviewEnabled()) { diff --git a/tools/emulator/system/camera/EmulatedCameraCommon.h b/tools/emulator/system/camera/EmulatedCameraCommon.h index 907985aec..c1d575c93 100755 --- a/tools/emulator/system/camera/EmulatedCameraCommon.h +++ b/tools/emulator/system/camera/EmulatedCameraCommon.h @@ -34,12 +34,12 @@ public: /* Constructor that prints an "entry" trace message. */ explicit HWERoutineTracker(const char* name) : mName(name) { - LOGV("Entering %s", mName); + ALOGV("Entering %s", mName); } /* Destructor that prints a "leave" trace message. */ ~HWERoutineTracker() { - LOGV("Leaving %s", mName); + ALOGV("Leaving %s", mName); } private: diff --git a/tools/emulator/system/camera/EmulatedCameraDevice.cpp b/tools/emulator/system/camera/EmulatedCameraDevice.cpp index eab169c67..c6338922c 100755 --- a/tools/emulator/system/camera/EmulatedCameraDevice.cpp +++ b/tools/emulator/system/camera/EmulatedCameraDevice.cpp @@ -47,7 +47,7 @@ EmulatedCameraDevice::EmulatedCameraDevice(EmulatedCamera* camera_hal) EmulatedCameraDevice::~EmulatedCameraDevice() { - LOGV("EmulatedCameraDevice destructor"); + ALOGV("EmulatedCameraDevice destructor"); if (mCurrentFrame != NULL) { delete[] mCurrentFrame; } @@ -84,7 +84,7 @@ status_t EmulatedCameraDevice::Initialize() status_t EmulatedCameraDevice::startDeliveringFrames(bool one_burst) { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); if (!isStarted()) { LOGE("%s: Device is not started", __FUNCTION__); @@ -99,7 +99,7 @@ status_t EmulatedCameraDevice::startDeliveringFrames(bool one_burst) status_t EmulatedCameraDevice::stopDeliveringFrames() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); if (!isStarted()) { LOGW("%s: Device is not started", __FUNCTION__); @@ -112,27 +112,27 @@ status_t EmulatedCameraDevice::stopDeliveringFrames() } void EmulatedCameraDevice::setExposureCompensation(const float ev) { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); if (!isStarted()) { LOGW("%s: Fake camera device is not started.", __FUNCTION__); } mExposureCompensation = std::pow(2.0f, ev / GAMMA_CORRECTION); - LOGV("New exposure compensation is %f", mExposureCompensation); + ALOGV("New exposure compensation is %f", mExposureCompensation); } void EmulatedCameraDevice::initializeWhiteBalanceModes(const char* mode, const float r_scale, const float b_scale) { - LOGV("%s with %s, %f, %f", __FUNCTION__, mode, r_scale, b_scale); + ALOGV("%s with %s, %f, %f", __FUNCTION__, mode, r_scale, b_scale); float* value = new float[3]; value[0] = r_scale; value[1] = 1.0f; value[2] = b_scale; mSupportedWhiteBalanceScale.add(String8(mode), value); } void EmulatedCameraDevice::setWhiteBalanceMode(const char* mode) { - LOGV("%s with white balance %s", __FUNCTION__, mode); + ALOGV("%s with white balance %s", __FUNCTION__, mode); mWhiteBalanceScale = mSupportedWhiteBalanceScale.valueFor(String8(mode)); } @@ -223,7 +223,7 @@ status_t EmulatedCameraDevice::commonStartDevice(int width, LOGE("%s: Unable to allocate framebuffer", __FUNCTION__); return ENOMEM; } - LOGV("%s: Allocated %p %d bytes for %d pixels in %.4s[%dx%d] frame", + ALOGV("%s: Allocated %p %d bytes for %d pixels in %.4s[%dx%d] frame", __FUNCTION__, mCurrentFrame, mFrameBufferSize, mTotalPixels, reinterpret_cast(&mPixelFormat), mFrameWidth, mFrameHeight); return NO_ERROR; @@ -246,7 +246,7 @@ void EmulatedCameraDevice::commonStopDevice() status_t EmulatedCameraDevice::startWorkerThread(bool one_burst) { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); if (!isInitialized()) { LOGE("%s: Emulated camera device is not initialized", __FUNCTION__); @@ -260,7 +260,7 @@ status_t EmulatedCameraDevice::startWorkerThread(bool one_burst) status_t EmulatedCameraDevice::stopWorkerThread() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); if (!isInitialized()) { LOGE("%s: Emulated camera device is not initialized", __FUNCTION__); @@ -285,7 +285,7 @@ bool EmulatedCameraDevice::inWorkerThread() status_t EmulatedCameraDevice::WorkerThread::readyToRun() { - LOGV("Starting emulated camera device worker thread..."); + ALOGV("Starting emulated camera device worker thread..."); LOGW_IF(mThreadControl >= 0 || mControlFD >= 0, "%s: Thread control FDs are opened", __FUNCTION__); @@ -294,7 +294,7 @@ status_t EmulatedCameraDevice::WorkerThread::readyToRun() if (pipe(thread_fds) == 0) { mThreadControl = thread_fds[1]; mControlFD = thread_fds[0]; - LOGV("Emulated device's worker thread has been started."); + ALOGV("Emulated device's worker thread has been started."); return NO_ERROR; } else { LOGE("%s: Unable to create thread control FDs: %d -> %s", @@ -305,7 +305,7 @@ status_t EmulatedCameraDevice::WorkerThread::readyToRun() status_t EmulatedCameraDevice::WorkerThread::stopThread() { - LOGV("Stopping emulated camera device's worker thread..."); + ALOGV("Stopping emulated camera device's worker thread..."); status_t res = EINVAL; if (mThreadControl >= 0) { @@ -326,7 +326,7 @@ status_t EmulatedCameraDevice::WorkerThread::stopThread() close(mControlFD); mControlFD = -1; } - LOGV("Emulated camera device's worker thread has been stopped."); + ALOGV("Emulated camera device's worker thread has been stopped."); } else { LOGE("%s: requestExitAndWait failed: %d -> %s", __FUNCTION__, res, strerror(-res)); @@ -380,7 +380,7 @@ EmulatedCameraDevice::WorkerThread::Select(int fd, int timeout) } /* THREAD_STOP is the only message expected here. */ if (msg == THREAD_STOP) { - LOGV("%s: THREAD_STOP message is received", __FUNCTION__); + ALOGV("%s: THREAD_STOP message is received", __FUNCTION__); return EXIT_THREAD; } else { LOGE("Unknown worker thread message %d", msg); diff --git a/tools/emulator/system/camera/EmulatedCameraFactory.cpp b/tools/emulator/system/camera/EmulatedCameraFactory.cpp index 5c5c5dec1..dc84357b1 100755 --- a/tools/emulator/system/camera/EmulatedCameraFactory.cpp +++ b/tools/emulator/system/camera/EmulatedCameraFactory.cpp @@ -86,7 +86,7 @@ EmulatedCameraFactory::EmulatedCameraFactory() LOGD("Fake camera emulation is disabled."); } - LOGV("%d cameras are being emulated. Fake camera ID is %d", + ALOGV("%d cameras are being emulated. Fake camera ID is %d", mEmulatedCameraNum, mFakeCameraID); mConstructedOK = true; @@ -114,7 +114,7 @@ EmulatedCameraFactory::~EmulatedCameraFactory() int EmulatedCameraFactory::cameraDeviceOpen(int camera_id, hw_device_t** device) { - LOGV("%s: id = %d", __FUNCTION__, camera_id); + ALOGV("%s: id = %d", __FUNCTION__, camera_id); *device = NULL; @@ -134,7 +134,7 @@ int EmulatedCameraFactory::cameraDeviceOpen(int camera_id, hw_device_t** device) int EmulatedCameraFactory::getCameraInfo(int camera_id, struct camera_info* info) { - LOGV("%s: id = %d", __FUNCTION__, camera_id); + ALOGV("%s: id = %d", __FUNCTION__, camera_id); if (!isConstructedOK()) { LOGE("%s: EmulatedCameraFactory has failed to initialize", __FUNCTION__); diff --git a/tools/emulator/system/camera/EmulatedFakeCamera.cpp b/tools/emulator/system/camera/EmulatedFakeCamera.cpp index 9d54f3884..7549ddf6d 100755 --- a/tools/emulator/system/camera/EmulatedFakeCamera.cpp +++ b/tools/emulator/system/camera/EmulatedFakeCamera.cpp @@ -66,7 +66,7 @@ status_t EmulatedFakeCamera::Initialize() mParameters.set(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, "-6"); mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP, "0.5"); mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, "0"); - LOGV("Set camera supported exposure values"); + ALOGV("Set camera supported exposure values"); // Sets the white balance modes and the device-dependent scale factors. mFakeCameraDevice.initializeWhiteBalanceModes( @@ -86,7 +86,7 @@ status_t EmulatedFakeCamera::Initialize() mParameters.set(CameraParameters::KEY_SUPPORTED_WHITE_BALANCE, supported_white_balance); - LOGV("Set camera supported white balance modes"); + ALOGV("Set camera supported white balance modes"); if (res != NO_ERROR) { return res; diff --git a/tools/emulator/system/camera/EmulatedFakeCameraDevice.cpp b/tools/emulator/system/camera/EmulatedFakeCameraDevice.cpp index 1e1a01210..051c28aa6 100755 --- a/tools/emulator/system/camera/EmulatedFakeCameraDevice.cpp +++ b/tools/emulator/system/camera/EmulatedFakeCameraDevice.cpp @@ -63,7 +63,7 @@ EmulatedFakeCameraDevice::~EmulatedFakeCameraDevice() status_t EmulatedFakeCameraDevice::connectDevice() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); Mutex::Autolock locker(&mObjectLock); if (!isInitialized()) { @@ -83,7 +83,7 @@ status_t EmulatedFakeCameraDevice::connectDevice() status_t EmulatedFakeCameraDevice::disconnectDevice() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); Mutex::Autolock locker(&mObjectLock); if (!isConnected()) { @@ -105,7 +105,7 @@ status_t EmulatedFakeCameraDevice::startDevice(int width, int height, uint32_t pix_fmt) { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); Mutex::Autolock locker(&mObjectLock); if (!isConnected()) { @@ -170,7 +170,7 @@ status_t EmulatedFakeCameraDevice::startDevice(int width, status_t EmulatedFakeCameraDevice::stopDevice() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); Mutex::Autolock locker(&mObjectLock); if (!isStarted()) { @@ -195,7 +195,7 @@ bool EmulatedFakeCameraDevice::inWorkerThread() WorkerThread::SelectRes res = getWorkerThread()->Select(-1, 1000000 / mEmulatedFPS); if (res == WorkerThread::EXIT_THREAD) { - LOGV("%s: Worker thread has been terminated.", __FUNCTION__); + ALOGV("%s: Worker thread has been terminated.", __FUNCTION__); return false; } diff --git a/tools/emulator/system/camera/EmulatedQemuCamera.cpp b/tools/emulator/system/camera/EmulatedQemuCamera.cpp index 611b6b54e..d1b2b7866 100755 --- a/tools/emulator/system/camera/EmulatedQemuCamera.cpp +++ b/tools/emulator/system/camera/EmulatedQemuCamera.cpp @@ -45,7 +45,7 @@ status_t EmulatedQemuCamera::Initialize(const char* device_name, const char* frame_dims, const char* facing_dir) { - LOGV("%s:\n Name=%s\n Facing '%s'\n Dimensions=%s", + ALOGV("%s:\n Name=%s\n Facing '%s'\n Dimensions=%s", __FUNCTION__, device_name, facing_dir, frame_dims); /* Save dimensions. */ mFrameDims = frame_dims; @@ -105,7 +105,7 @@ status_t EmulatedQemuCamera::Initialize(const char* device_name, mParameters.setPreviewSize(x, y); mParameters.setPictureSize(x, y); - LOGV("%s: Qemu camera %s is initialized. Current frame is %dx%d", + ALOGV("%s: Qemu camera %s is initialized. Current frame is %dx%d", __FUNCTION__, device_name, x, y); return NO_ERROR; diff --git a/tools/emulator/system/camera/EmulatedQemuCameraDevice.cpp b/tools/emulator/system/camera/EmulatedQemuCameraDevice.cpp index 57dbc987f..d95307db9 100755 --- a/tools/emulator/system/camera/EmulatedQemuCameraDevice.cpp +++ b/tools/emulator/system/camera/EmulatedQemuCameraDevice.cpp @@ -58,7 +58,7 @@ status_t EmulatedQemuCameraDevice::Initialize(const char* device_name) /* Initialize base class. */ res = EmulatedCameraDevice::Initialize(); if (res == NO_ERROR) { - LOGV("%s: Connected to the emulated camera service '%s'", + ALOGV("%s: Connected to the emulated camera service '%s'", __FUNCTION__, device_name); mDeviceName = device_name; } else { @@ -74,7 +74,7 @@ status_t EmulatedQemuCameraDevice::Initialize(const char* device_name) status_t EmulatedQemuCameraDevice::connectDevice() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); Mutex::Autolock locker(&mObjectLock); if (!isInitialized()) { @@ -90,7 +90,7 @@ status_t EmulatedQemuCameraDevice::connectDevice() /* Connect to the camera device via emulator. */ const status_t res = mQemuClient.queryConnect(); if (res == NO_ERROR) { - LOGV("%s: Connected to device '%s'", + ALOGV("%s: Connected to device '%s'", __FUNCTION__, (const char*)mDeviceName); mState = ECDS_CONNECTED; } else { @@ -103,7 +103,7 @@ status_t EmulatedQemuCameraDevice::connectDevice() status_t EmulatedQemuCameraDevice::disconnectDevice() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); Mutex::Autolock locker(&mObjectLock); if (!isConnected()) { @@ -120,7 +120,7 @@ status_t EmulatedQemuCameraDevice::disconnectDevice() /* Disconnect from the camera device via emulator. */ const status_t res = mQemuClient.queryDisconnect(); if (res == NO_ERROR) { - LOGV("%s: Disonnected from device '%s'", + ALOGV("%s: Disonnected from device '%s'", __FUNCTION__, (const char*)mDeviceName); mState = ECDS_INITIALIZED; } else { @@ -135,7 +135,7 @@ status_t EmulatedQemuCameraDevice::startDevice(int width, int height, uint32_t pix_fmt) { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); Mutex::Autolock locker(&mObjectLock); if (!isConnected()) { @@ -168,7 +168,7 @@ status_t EmulatedQemuCameraDevice::startDevice(int width, /* Start the actual camera device. */ res = mQemuClient.queryStart(mPixelFormat, mFrameWidth, mFrameHeight); if (res == NO_ERROR) { - LOGV("%s: Qemu camera device '%s' is started for %.4s[%dx%d] frames", + ALOGV("%s: Qemu camera device '%s' is started for %.4s[%dx%d] frames", __FUNCTION__, (const char*)mDeviceName, reinterpret_cast(&mPixelFormat), mFrameWidth, mFrameHeight); @@ -184,7 +184,7 @@ status_t EmulatedQemuCameraDevice::startDevice(int width, status_t EmulatedQemuCameraDevice::stopDevice() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); Mutex::Autolock locker(&mObjectLock); if (!isStarted()) { @@ -202,7 +202,7 @@ status_t EmulatedQemuCameraDevice::stopDevice() } EmulatedCameraDevice::commonStopDevice(); mState = ECDS_CONNECTED; - LOGV("%s: Qemu camera device '%s' is stopped", + ALOGV("%s: Qemu camera device '%s' is stopped", __FUNCTION__, (const char*)mDeviceName); } else { LOGE("%s: Unable to stop device '%s'", @@ -237,7 +237,7 @@ bool EmulatedQemuCameraDevice::inWorkerThread() WorkerThread::SelectRes res = getWorkerThread()->Select(-1, 1000000 / mEmulatedFPS); if (res == WorkerThread::EXIT_THREAD) { - LOGV("%s: Worker thread has been terminated.", __FUNCTION__); + ALOGV("%s: Worker thread has been terminated.", __FUNCTION__); return false; } diff --git a/tools/emulator/system/camera/JpegCompressor.cpp b/tools/emulator/system/camera/JpegCompressor.cpp index 0e538a165..ebcd91520 100644 --- a/tools/emulator/system/camera/JpegCompressor.cpp +++ b/tools/emulator/system/camera/JpegCompressor.cpp @@ -44,7 +44,7 @@ status_t NV21JpegCompressor::compressRawImage(const void* image, int height, int quality) { - LOGV("%s: %p[%dx%d]", __FUNCTION__, image, width, height); + ALOGV("%s: %p[%dx%d]", __FUNCTION__, image, width, height); void* pY = const_cast(image); int offsets[2]; offsets[0] = 0; @@ -52,7 +52,7 @@ status_t NV21JpegCompressor::compressRawImage(const void* image, mStrides[0] = width; mStrides[1] = width; if (encode(&mStream, pY, width, height, offsets, quality)) { - LOGV("%s: Compressed JPEG: %d[%dx%d] -> %d bytes", + ALOGV("%s: Compressed JPEG: %d[%dx%d] -> %d bytes", __FUNCTION__, (width * height * 12) / 8, width, height, mStream.getOffset()); return NO_ERROR; } else { diff --git a/tools/emulator/system/camera/PreviewWindow.cpp b/tools/emulator/system/camera/PreviewWindow.cpp index fb708d598..db48b1065 100755 --- a/tools/emulator/system/camera/PreviewWindow.cpp +++ b/tools/emulator/system/camera/PreviewWindow.cpp @@ -49,7 +49,7 @@ PreviewWindow::~PreviewWindow() status_t PreviewWindow::setPreviewWindow(struct preview_stream_ops* window, int preview_fps) { - LOGV("%s: current: %p -> new: %p", __FUNCTION__, mPreviewWindow, window); + ALOGV("%s: current: %p -> new: %p", __FUNCTION__, mPreviewWindow, window); status_t res = NO_ERROR; Mutex::Autolock locker(&mObjectLock); @@ -81,7 +81,7 @@ status_t PreviewWindow::setPreviewWindow(struct preview_stream_ops* window, status_t PreviewWindow::startPreview() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); Mutex::Autolock locker(&mObjectLock); mPreviewEnabled = true; @@ -91,7 +91,7 @@ status_t PreviewWindow::startPreview() void PreviewWindow::stopPreview() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); Mutex::Autolock locker(&mObjectLock); mPreviewEnabled = false; @@ -117,7 +117,7 @@ void PreviewWindow::onNextFrameAvailable(const void* frame, /* Need to set / adjust buffer geometry for the preview window. * Note that in the emulator preview window uses only RGB for pixel * formats. */ - LOGV("%s: Adjusting preview windows %p geometry to %dx%d", + ALOGV("%s: Adjusting preview windows %p geometry to %dx%d", __FUNCTION__, mPreviewWindow, mPreviewFrameWidth, mPreviewFrameHeight); res = mPreviewWindow->set_buffers_geometry(mPreviewWindow, diff --git a/tools/emulator/system/camera/QemuClient.cpp b/tools/emulator/system/camera/QemuClient.cpp index fd4958585..fe761b08d 100755 --- a/tools/emulator/system/camera/QemuClient.cpp +++ b/tools/emulator/system/camera/QemuClient.cpp @@ -212,7 +212,7 @@ QemuClient::~QemuClient() status_t QemuClient::connectClient(const char* param) { - LOGV("%s: '%s'", __FUNCTION__, param ? param : ""); + ALOGV("%s: '%s'", __FUNCTION__, param ? param : ""); /* Make sure that client is not connected already. */ if (mPipeFD >= 0) { @@ -247,7 +247,7 @@ status_t QemuClient::connectClient(const char* param) void QemuClient::disconnectClient() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); if (mPipeFD >= 0) { close(mPipeFD); @@ -386,7 +386,7 @@ FactoryQemuClient::~FactoryQemuClient() status_t FactoryQemuClient::listCameras(char** list) { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); QemuQuery query(mQueryList); if (doQuery(&query) || !query.isQuerySucceeded()) { @@ -445,7 +445,7 @@ CameraQemuClient::~CameraQemuClient() status_t CameraQemuClient::queryConnect() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); QemuQuery query(mQueryConnect); doQuery(&query); @@ -458,7 +458,7 @@ status_t CameraQemuClient::queryConnect() status_t CameraQemuClient::queryDisconnect() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); QemuQuery query(mQueryDisconnect); doQuery(&query); @@ -473,7 +473,7 @@ status_t CameraQemuClient::queryStart(uint32_t pixel_format, int width, int height) { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); char query_str[256]; snprintf(query_str, sizeof(query_str), "%s dim=%dx%d pix=%d", @@ -489,7 +489,7 @@ status_t CameraQemuClient::queryStart(uint32_t pixel_format, status_t CameraQemuClient::queryStop() { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); QemuQuery query(mQueryStop); doQuery(&query); @@ -505,7 +505,7 @@ status_t CameraQemuClient::queryFrame(void* vframe, size_t vframe_size, size_t pframe_size) { - LOGV("%s", __FUNCTION__); + ALOGV("%s", __FUNCTION__); char query_str[256]; snprintf(query_str, sizeof(query_str), "%s video=%d preview=%d",