Merge changes from topics "display-dump", "presentation-dump"
* changes: Add TouchSpotController to PointerController dump. s/displayID/displayId Add viewports to PointerController dump Add dump for PointerController. Rename pointer-related members to be more specific. Use IndentingPrintWriter instead of manually prefixing dumpsys.
This commit is contained in:
committed by
Android (Google) Code Review
commit
25926239d6
@@ -22,10 +22,18 @@
|
||||
#include <SkBlendMode.h>
|
||||
#include <SkCanvas.h>
|
||||
#include <SkColor.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <android-base/thread_annotations.h>
|
||||
#include <ftl/enum.h>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "PointerControllerContext.h"
|
||||
|
||||
#define INDENT " "
|
||||
#define INDENT2 " "
|
||||
#define INDENT3 " "
|
||||
|
||||
namespace android {
|
||||
|
||||
namespace {
|
||||
@@ -223,7 +231,7 @@ void PointerController::clearSpots() {
|
||||
}
|
||||
|
||||
void PointerController::clearSpotsLocked() {
|
||||
for (auto& [displayID, spotController] : mLocked.spotControllers) {
|
||||
for (auto& [displayId, spotController] : mLocked.spotControllers) {
|
||||
spotController.clearSpots();
|
||||
}
|
||||
}
|
||||
@@ -235,7 +243,7 @@ void PointerController::setInactivityTimeout(InactivityTimeout inactivityTimeout
|
||||
void PointerController::reloadPointerResources() {
|
||||
std::scoped_lock lock(getLock());
|
||||
|
||||
for (auto& [displayID, spotController] : mLocked.spotControllers) {
|
||||
for (auto& [displayId, spotController] : mLocked.spotControllers) {
|
||||
spotController.reloadSpotResources();
|
||||
}
|
||||
|
||||
@@ -286,13 +294,13 @@ void PointerController::onDisplayViewportsUpdated(std::vector<DisplayViewport>&
|
||||
|
||||
std::scoped_lock lock(getLock());
|
||||
for (auto it = mLocked.spotControllers.begin(); it != mLocked.spotControllers.end();) {
|
||||
int32_t displayID = it->first;
|
||||
if (!displayIdSet.count(displayID)) {
|
||||
int32_t displayId = it->first;
|
||||
if (!displayIdSet.count(displayId)) {
|
||||
/*
|
||||
* Ensures that an in-progress animation won't dereference
|
||||
* a null pointer to TouchSpotController.
|
||||
*/
|
||||
mContext.removeAnimationCallback(displayID);
|
||||
mContext.removeAnimationCallback(displayId);
|
||||
it = mLocked.spotControllers.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
@@ -313,4 +321,20 @@ const ui::Transform& PointerController::getTransformForDisplayLocked(int display
|
||||
return it != di.end() ? it->transform : kIdentityTransform;
|
||||
}
|
||||
|
||||
void PointerController::dump(std::string& dump) {
|
||||
dump += INDENT "PointerController:\n";
|
||||
std::scoped_lock lock(getLock());
|
||||
dump += StringPrintf(INDENT2 "Presentation: %s\n",
|
||||
ftl::enum_string(mLocked.presentation).c_str());
|
||||
dump += StringPrintf(INDENT2 "Pointer Display ID: %" PRIu32 "\n", mLocked.pointerDisplayId);
|
||||
dump += StringPrintf(INDENT2 "Viewports:\n");
|
||||
for (const auto& info : mLocked.mDisplayInfos) {
|
||||
info.dump(dump, INDENT3);
|
||||
}
|
||||
dump += INDENT2 "Spot Controllers:\n";
|
||||
for (const auto& [_, spotController] : mLocked.spotControllers) {
|
||||
spotController.dump(dump, INDENT3);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "MouseCursorController.h"
|
||||
@@ -75,6 +76,8 @@ public:
|
||||
void onDisplayInfosChangedLocked(const std::vector<gui::DisplayInfo>& displayInfos)
|
||||
REQUIRES(getLock());
|
||||
|
||||
void dump(std::string& dump);
|
||||
|
||||
protected:
|
||||
using WindowListenerConsumer =
|
||||
std::function<void(const sp<android::gui::WindowInfosListener>&)>;
|
||||
|
||||
@@ -21,8 +21,15 @@
|
||||
|
||||
#include "TouchSpotController.h"
|
||||
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <input/PrintTools.h>
|
||||
#include <log/log.h>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#define INDENT " "
|
||||
#define INDENT2 " "
|
||||
|
||||
namespace {
|
||||
// Time to spend fading out the spot completely.
|
||||
const nsecs_t SPOT_FADE_DURATION = 200 * 1000000LL; // 200 ms
|
||||
@@ -53,6 +60,12 @@ void TouchSpotController::Spot::updateSprite(const SpriteIcon* icon, float x, fl
|
||||
}
|
||||
}
|
||||
|
||||
void TouchSpotController::Spot::dump(std::string& out, const char* prefix) const {
|
||||
out += prefix;
|
||||
base::StringAppendF(&out, "Spot{id=%" PRIx32 ", alpha=%f, scale=%f, pos=[%f, %f]}\n", id, alpha,
|
||||
scale, x, y);
|
||||
}
|
||||
|
||||
// --- TouchSpotController ---
|
||||
|
||||
TouchSpotController::TouchSpotController(int32_t displayId, PointerControllerContext& context)
|
||||
@@ -255,4 +268,22 @@ void TouchSpotController::startAnimationLocked() REQUIRES(mLock) {
|
||||
mContext.addAnimationCallback(mDisplayId, func);
|
||||
}
|
||||
|
||||
void TouchSpotController::dump(std::string& out, const char* prefix) const {
|
||||
using base::StringAppendF;
|
||||
out += prefix;
|
||||
out += "SpotController:\n";
|
||||
out += prefix;
|
||||
StringAppendF(&out, INDENT "DisplayId: %" PRId32 "\n", mDisplayId);
|
||||
std::scoped_lock lock(mLock);
|
||||
out += prefix;
|
||||
StringAppendF(&out, INDENT "Animating: %s\n", toString(mLocked.animating));
|
||||
out += prefix;
|
||||
out += INDENT "Spots:\n";
|
||||
std::string spotPrefix = prefix;
|
||||
spotPrefix += INDENT2;
|
||||
for (const auto& spot : mLocked.displaySpots) {
|
||||
spot->dump(out, spotPrefix.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
|
||||
@@ -38,6 +38,8 @@ public:
|
||||
void reloadSpotResources();
|
||||
bool doAnimations(nsecs_t timestamp);
|
||||
|
||||
void dump(std::string& out, const char* prefix = "") const;
|
||||
|
||||
private:
|
||||
struct Spot {
|
||||
static const uint32_t INVALID_ID = 0xffffffff;
|
||||
@@ -58,6 +60,7 @@ private:
|
||||
mLastIcon(nullptr) {}
|
||||
|
||||
void updateSprite(const SpriteIcon* icon, float x, float y, int32_t displayId);
|
||||
void dump(std::string& out, const char* prefix = "") const;
|
||||
|
||||
private:
|
||||
const SpriteIcon* mLastIcon;
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.os.SystemClock;
|
||||
import android.os.UEventObserver;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.ArraySet;
|
||||
import android.util.IndentingPrintWriter;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
import android.view.InputDevice;
|
||||
@@ -382,24 +383,28 @@ final class BatteryController {
|
||||
}
|
||||
}
|
||||
|
||||
public void dump(PrintWriter pw, String prefix) {
|
||||
public void dump(PrintWriter pw) {
|
||||
IndentingPrintWriter ipw = new IndentingPrintWriter(pw);
|
||||
synchronized (mLock) {
|
||||
final String indent = prefix + " ";
|
||||
final String indent2 = indent + " ";
|
||||
|
||||
pw.println(prefix + TAG + ":");
|
||||
pw.println(indent + "State: Polling = " + mIsPolling
|
||||
ipw.println(TAG + ":");
|
||||
ipw.increaseIndent();
|
||||
ipw.println("State: Polling = " + mIsPolling
|
||||
+ ", Interactive = " + mIsInteractive);
|
||||
|
||||
pw.println(indent + "Listeners: " + mListenerRecords.size() + " battery listeners");
|
||||
ipw.println("Listeners: " + mListenerRecords.size() + " battery listeners");
|
||||
ipw.increaseIndent();
|
||||
for (int i = 0; i < mListenerRecords.size(); i++) {
|
||||
pw.println(indent2 + i + ": " + mListenerRecords.valueAt(i));
|
||||
ipw.println(i + ": " + mListenerRecords.valueAt(i));
|
||||
}
|
||||
ipw.decreaseIndent();
|
||||
|
||||
pw.println(indent + "Device Monitors: " + mDeviceMonitors.size() + " monitors");
|
||||
ipw.println("Device Monitors: " + mDeviceMonitors.size() + " monitors");
|
||||
ipw.increaseIndent();
|
||||
for (int i = 0; i < mDeviceMonitors.size(); i++) {
|
||||
pw.println(indent2 + i + ": " + mDeviceMonitors.valueAt(i));
|
||||
ipw.println(i + ": " + mDeviceMonitors.valueAt(i));
|
||||
}
|
||||
ipw.decreaseIndent();
|
||||
ipw.decreaseIndent();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ import android.provider.Settings;
|
||||
import android.provider.Settings.SettingNotFoundException;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.IndentingPrintWriter;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
@@ -302,9 +303,9 @@ public class InputManagerService extends IInputManager.Stub
|
||||
private final AdditionalDisplayInputProperties mCurrentDisplayProperties =
|
||||
new AdditionalDisplayInputProperties();
|
||||
@GuardedBy("mAdditionalDisplayInputPropertiesLock")
|
||||
private int mIconType = PointerIcon.TYPE_NOT_SPECIFIED;
|
||||
private int mPointerIconType = PointerIcon.TYPE_NOT_SPECIFIED;
|
||||
@GuardedBy("mAdditionalDisplayInputPropertiesLock")
|
||||
private PointerIcon mIcon;
|
||||
private PointerIcon mPointerIcon;
|
||||
|
||||
// Holds all the registered gesture monitors that are implemented as spy windows. The spy
|
||||
// windows are mapped by their InputChannel tokens.
|
||||
@@ -2325,12 +2326,12 @@ public class InputManagerService extends IInputManager.Stub
|
||||
throw new IllegalArgumentException("Use setCustomPointerIcon to set custom pointers");
|
||||
}
|
||||
synchronized (mAdditionalDisplayInputPropertiesLock) {
|
||||
mIcon = null;
|
||||
mIconType = iconType;
|
||||
mPointerIcon = null;
|
||||
mPointerIconType = iconType;
|
||||
|
||||
if (!mCurrentDisplayProperties.pointerIconVisible) return;
|
||||
|
||||
mNative.setPointerIconType(mIconType);
|
||||
mNative.setPointerIconType(mPointerIconType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2339,12 +2340,12 @@ public class InputManagerService extends IInputManager.Stub
|
||||
public void setCustomPointerIcon(PointerIcon icon) {
|
||||
Objects.requireNonNull(icon);
|
||||
synchronized (mAdditionalDisplayInputPropertiesLock) {
|
||||
mIconType = PointerIcon.TYPE_CUSTOM;
|
||||
mIcon = icon;
|
||||
mPointerIconType = PointerIcon.TYPE_CUSTOM;
|
||||
mPointerIcon = icon;
|
||||
|
||||
if (!mCurrentDisplayProperties.pointerIconVisible) return;
|
||||
|
||||
mNative.setCustomPointerIcon(mIcon);
|
||||
mNative.setCustomPointerIcon(mPointerIcon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2689,74 +2690,78 @@ public class InputManagerService extends IInputManager.Stub
|
||||
@Override
|
||||
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
|
||||
IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ");
|
||||
|
||||
pw.println("INPUT MANAGER (dumpsys input)\n");
|
||||
ipw.println("INPUT MANAGER (dumpsys input)\n");
|
||||
String dumpStr = mNative.dump();
|
||||
if (dumpStr != null) {
|
||||
pw.println(dumpStr);
|
||||
}
|
||||
|
||||
pw.println("Input Manager Service (Java) State:");
|
||||
dumpAssociations(pw, " " /*prefix*/);
|
||||
dumpSpyWindowGestureMonitors(pw, " " /*prefix*/);
|
||||
dumpDisplayInputPropertiesValues(pw, " " /*prefix*/);
|
||||
mBatteryController.dump(pw, " " /*prefix*/);
|
||||
mKeyboardBacklightController.dump(pw, " " /*prefix*/);
|
||||
ipw.println("Input Manager Service (Java) State:");
|
||||
ipw.increaseIndent();
|
||||
dumpAssociations(ipw);
|
||||
dumpSpyWindowGestureMonitors(ipw);
|
||||
dumpDisplayInputPropertiesValues(ipw);
|
||||
mBatteryController.dump(ipw);
|
||||
mKeyboardBacklightController.dump(ipw);
|
||||
}
|
||||
|
||||
private void dumpAssociations(PrintWriter pw, String prefix) {
|
||||
private void dumpAssociations(IndentingPrintWriter pw) {
|
||||
if (!mStaticAssociations.isEmpty()) {
|
||||
pw.println(prefix + "Static Associations:");
|
||||
pw.println("Static Associations:");
|
||||
mStaticAssociations.forEach((k, v) -> {
|
||||
pw.print(prefix + " port: " + k);
|
||||
pw.print(" port: " + k);
|
||||
pw.println(" display: " + v);
|
||||
});
|
||||
}
|
||||
|
||||
synchronized (mAssociationsLock) {
|
||||
if (!mRuntimeAssociations.isEmpty()) {
|
||||
pw.println(prefix + "Runtime Associations:");
|
||||
pw.println("Runtime Associations:");
|
||||
mRuntimeAssociations.forEach((k, v) -> {
|
||||
pw.print(prefix + " port: " + k);
|
||||
pw.print(" port: " + k);
|
||||
pw.println(" display: " + v);
|
||||
});
|
||||
}
|
||||
if (!mUniqueIdAssociations.isEmpty()) {
|
||||
pw.println(prefix + "Unique Id Associations:");
|
||||
pw.println("Unique Id Associations:");
|
||||
mUniqueIdAssociations.forEach((k, v) -> {
|
||||
pw.print(prefix + " port: " + k);
|
||||
pw.print(" port: " + k);
|
||||
pw.println(" uniqueId: " + v);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dumpSpyWindowGestureMonitors(PrintWriter pw, String prefix) {
|
||||
private void dumpSpyWindowGestureMonitors(IndentingPrintWriter pw) {
|
||||
synchronized (mInputMonitors) {
|
||||
if (mInputMonitors.isEmpty()) return;
|
||||
pw.println(prefix + "Gesture Monitors (implemented as spy windows):");
|
||||
pw.println("Gesture Monitors (implemented as spy windows):");
|
||||
int i = 0;
|
||||
for (final GestureMonitorSpyWindow monitor : mInputMonitors.values()) {
|
||||
pw.append(prefix + " " + i++ + ": ").println(monitor.dump());
|
||||
pw.append(" " + i++ + ": ").println(monitor.dump());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dumpDisplayInputPropertiesValues(PrintWriter pw, String prefix) {
|
||||
private void dumpDisplayInputPropertiesValues(IndentingPrintWriter pw) {
|
||||
synchronized (mAdditionalDisplayInputPropertiesLock) {
|
||||
if (mAdditionalDisplayInputProperties.size() != 0) {
|
||||
pw.println(prefix + "mAdditionalDisplayInputProperties:");
|
||||
pw.println("mAdditionalDisplayInputProperties:");
|
||||
pw.increaseIndent();
|
||||
for (int i = 0; i < mAdditionalDisplayInputProperties.size(); i++) {
|
||||
pw.println(prefix + " displayId: "
|
||||
pw.println("displayId: "
|
||||
+ mAdditionalDisplayInputProperties.keyAt(i));
|
||||
final AdditionalDisplayInputProperties properties =
|
||||
mAdditionalDisplayInputProperties.valueAt(i);
|
||||
pw.println(prefix + " pointerAcceleration: " + properties.pointerAcceleration);
|
||||
pw.println(prefix + " pointerIconVisible: " + properties.pointerIconVisible);
|
||||
pw.println("pointerAcceleration: " + properties.pointerAcceleration);
|
||||
pw.println("pointerIconVisible: " + properties.pointerIconVisible);
|
||||
}
|
||||
pw.decreaseIndent();
|
||||
}
|
||||
if (mOverriddenPointerDisplayId != Display.INVALID_DISPLAY) {
|
||||
pw.println(prefix + "mOverriddenPointerDisplayId: " + mOverriddenPointerDisplayId);
|
||||
pw.println("mOverriddenPointerDisplayId: " + mOverriddenPointerDisplayId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3841,11 +3846,11 @@ public class InputManagerService extends IInputManager.Stub
|
||||
if (properties.pointerIconVisible != mCurrentDisplayProperties.pointerIconVisible) {
|
||||
mCurrentDisplayProperties.pointerIconVisible = properties.pointerIconVisible;
|
||||
if (properties.pointerIconVisible) {
|
||||
if (mIconType == PointerIcon.TYPE_CUSTOM) {
|
||||
Objects.requireNonNull(mIcon);
|
||||
mNative.setCustomPointerIcon(mIcon);
|
||||
if (mPointerIconType == PointerIcon.TYPE_CUSTOM) {
|
||||
Objects.requireNonNull(mPointerIcon);
|
||||
mNative.setCustomPointerIcon(mPointerIcon);
|
||||
} else {
|
||||
mNative.setPointerIconType(mIconType);
|
||||
mNative.setPointerIconType(mPointerIconType);
|
||||
}
|
||||
} else {
|
||||
mNative.setPointerIconType(PointerIcon.TYPE_NULL);
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.hardware.lights.Light;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.util.IndentingPrintWriter;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
@@ -216,12 +217,14 @@ final class KeyboardBacklightController implements InputManager.InputDeviceListe
|
||||
return null;
|
||||
}
|
||||
|
||||
void dump(PrintWriter pw, String prefix) {
|
||||
pw.println(prefix + TAG + ": " + mKeyboardBacklights.size() + " keyboard backlights");
|
||||
void dump(PrintWriter pw) {
|
||||
IndentingPrintWriter ipw = new IndentingPrintWriter(pw);
|
||||
ipw.println(TAG + ": " + mKeyboardBacklights.size() + " keyboard backlights");
|
||||
ipw.increaseIndent();
|
||||
for (int i = 0; i < mKeyboardBacklights.size(); i++) {
|
||||
Light light = mKeyboardBacklights.get(i);
|
||||
pw.println(prefix + " " + i + ": { id: " + light.getId() + ", name: " + light.getName()
|
||||
+ " }");
|
||||
ipw.println(i + ": { id: " + light.getId() + ", name: " + light.getName() + " }");
|
||||
}
|
||||
ipw.decreaseIndent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,6 +450,10 @@ void NativeInputManager::dump(std::string& dump) {
|
||||
dump += StringPrintf(INDENT "Pointer Capture: %s, seq=%" PRIu32 "\n",
|
||||
mLocked.pointerCaptureRequest.enable ? "Enabled" : "Disabled",
|
||||
mLocked.pointerCaptureRequest.seq);
|
||||
auto pointerController = mLocked.pointerController.lock();
|
||||
if (pointerController != nullptr) {
|
||||
pointerController->dump(dump);
|
||||
}
|
||||
}
|
||||
dump += "\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user