code checks

This commit is contained in:
侯歌 2024-07-11 16:44:53 +08:00
parent 727e249614
commit d677392217
10 changed files with 54 additions and 51 deletions

View File

@ -41,6 +41,8 @@ InputDevice::InputDevice(int fdev){
mSeqID = 0; mSeqID = 0;
mDeviceClasses= 0; mDeviceClasses= 0;
mAxisFlags =0;
mKeyboardType = KEYBOARD_TYPE_NONE; mKeyboardType = KEYBOARD_TYPE_NONE;
InputGetDeviceInfo(fdev,&devInfos); InputGetDeviceInfo(fdev,&devInfos);
di.name = devInfos.name; di.name = devInfos.name;
@ -143,6 +145,7 @@ InputDevice::InputDevice(int fdev){
mDeviceClasses |= INPUT_DEVICE_CLASS_KEYBOARD; mDeviceClasses |= INPUT_DEVICE_CLASS_KEYBOARD;
} }
} }
mCorrectedDeviceClasses = mDeviceClasses;
kmap = nullptr; kmap = nullptr;
LOGI("%d:[%s] Props=%02x%02x%02x%02x[%s]",fdev,devInfos.name,devInfos.propBitMask[0], LOGI("%d:[%s] Props=%02x%02x%02x%02x[%s]",fdev,devInfos.name,devInfos.propBitMask[0],
devInfos.propBitMask[1],devInfos.propBitMask[2],devInfos.propBitMask[3],oss.str().c_str()); devInfos.propBitMask[1],devInfos.propBitMask[2],devInfos.propBitMask[3],oss.str().c_str());

View File

@ -14,7 +14,7 @@
namespace cdroid{ namespace cdroid{
struct InputDeviceIdentifier { struct InputDeviceIdentifier {
InputDeviceIdentifier() : InputDeviceIdentifier() :
bus(0), vendor(0), product(0), version(0) { bus(0), vendor(0), product(0), version(0), nonce(0){
} }
// Information provided by the kernel. // Information provided by the kernel.
std::string name; std::string name;

View File

@ -63,6 +63,9 @@ Keyboard::Key::Key(void*p){
edgeFlags = row->rowEdgeFlags; edgeFlags = row->rowEdgeFlags;
on = false; on = false;
pressed = false; pressed = false;
repeatable = false;
icon = nullptr;
iconPreview = nullptr;
} }
void Keyboard::Key::onPressed() { void Keyboard::Key::onPressed() {

View File

@ -119,7 +119,7 @@ void Looper::setForThread(Looper* looper){
} }
Looper*Looper::getForThread(){ Looper*Looper::getForThread(){
int result = pthread_once(&gTLSOnce,initTLSKey); const int result = pthread_once(&gTLSOnce,initTLSKey);
LOGW_IF(result!=0,"pthread_once failed"); LOGW_IF(result!=0,"pthread_once failed");
Looper*looper =(Looper*)pthread_getspecific(gTLSKey); Looper*looper =(Looper*)pthread_getspecific(gTLSKey);
return looper; return looper;
@ -203,7 +203,7 @@ int Looper::pollEvents(int timeoutMillis){
mResponses.clear(); mResponses.clear();
mResponseIndex = 0; mResponseIndex = 0;
mPolling = true; mPolling = true;
int j,eventCount; int eventCount;
struct epoll_event eventItems[EPOLL_MAX_EVENTS]; struct epoll_event eventItems[EPOLL_MAX_EVENTS];
#if USED_POLL == EPOLL #if USED_POLL == EPOLL
eventCount = epoll_wait(mEpollFd, eventItems, EPOLL_MAX_EVENTS, timeoutMillis); eventCount = epoll_wait(mEpollFd, eventItems, EPOLL_MAX_EVENTS, timeoutMillis);
@ -216,7 +216,7 @@ int Looper::pollEvents(int timeoutMillis){
pollfds.push_back(pfd); pollfds.push_back(pfd);
} }
eventCount = poll(pollfds.data(),pollfds.size(),timeoutMillis); eventCount = poll(pollfds.data(),pollfds.size(),timeoutMillis);
j = 0; int j = 0;
for(auto f:pollfds){ for(auto f:pollfds){
if(f.revents==0)continue; if(f.revents==0)continue;
eventItems[j].data.fd= f.fd; eventItems[j].data.fd= f.fd;
@ -613,7 +613,7 @@ void Looper::sendMessageAtTime(nsecs_t uptime, const MessageHandler* handler,
{ // acquire lock { // acquire lock
std::lock_guard<std::recursive_mutex> _l(mLock); std::lock_guard<std::recursive_mutex> _l(mLock);
std::list<MessageEnvelope>::iterator it; std::list<MessageEnvelope>::const_iterator it;
for(it=mMessageEnvelopes.begin();it!=mMessageEnvelopes.end();it++){ for(it=mMessageEnvelopes.begin();it!=mMessageEnvelopes.end();it++){
if(it->uptime>=uptime)break; if(it->uptime>=uptime)break;
i+=1; i+=1;

View File

@ -74,9 +74,7 @@ void Preferences::load(const char*buf,size_t len){
void Preferences::load(std::istream&istream){ void Preferences::load(std::istream&istream){
XML_Parser parser=XML_ParserCreate(nullptr); XML_Parser parser=XML_ParserCreate(nullptr);
std::string curKey; int len = 0;
std::string curValue;
int len=0;
PREFPARSER kvp; PREFPARSER kvp;
kvp.pref=this; kvp.pref=this;
XML_SetUserData(parser,&kvp); XML_SetUserData(parser,&kvp);
@ -195,62 +193,60 @@ std::string Preferences::getString(const std::string&section,const std::string&k
void Preferences::setValue(const std::string&section,const std::string&key,bool v){ void Preferences::setValue(const std::string&section,const std::string&key,bool v){
auto sec=mPrefs.find(section); auto sec=mPrefs.find(section);
if(sec==mPrefs.end()){ if(sec==mPrefs.end()){
std::map<std::string,std::string>ss; sec = mPrefs.insert({section,std::map<std::string,std::string>()}).first;
sec=mPrefs.insert({section,std::map<std::string,std::string>()}).first;
} }
auto kv=sec->second.find(key); auto kv = sec->second.find(key);
if(kv==sec->second.end()) if(kv == sec->second.end())
sec->second.insert({key,(v?"true":"false")}); sec->second.insert({key,(v?"true":"false")});
else kv->second=(v?"true":"false"); else kv->second = (v?"true":"false");
updates++; updates++;
} }
void Preferences::setValue(const std::string&section,const std::string&key,int v){ void Preferences::setValue(const std::string&section,const std::string&key,int v){
auto sec=mPrefs.find(section); auto sec = mPrefs.find(section);
if(sec==mPrefs.end()){ if(sec == mPrefs.end()){
std::string vs=std::to_string(v); sec = mPrefs.insert({section,std::map<std::string,std::string>()}).first;
sec=mPrefs.insert({section,std::map<std::string,std::string>()}).first;
} }
auto kv=sec->second.find(key); auto kv = sec->second.find(key);
if(kv==sec->second.end()) if(kv == sec->second.end())
sec->second.insert({key,std::to_string(v)}); sec->second.insert({key,std::to_string(v)});
else kv->second=std::to_string(v); else kv->second = std::to_string(v);
LOGV("%s %s %d",section.c_str(),key.c_str(),v); LOGV("%s %s %d",section.c_str(),key.c_str(),v);
updates++; updates++;
} }
void Preferences::setValue(const std::string&section,const std::string&key,float v){ void Preferences::setValue(const std::string&section,const std::string&key,float v){
auto sec=mPrefs.find(section); auto sec = mPrefs.find(section);
if(sec==mPrefs.end()) if(sec == mPrefs.end())
sec=mPrefs.insert({section,std::map<std::string,std::string>()}).first; sec = mPrefs.insert({section,std::map<std::string,std::string>()}).first;
auto kv=sec->second.find(key); auto kv = sec->second.find(key);
if(kv==sec->second.end()) if(kv == sec->second.end())
sec->second.insert({key,std::to_string(v)}); sec->second.insert({key,std::to_string(v)});
else kv->second=std::to_string(v); else kv->second = std::to_string(v);
LOGV("%s %s %f",section.c_str(),key.c_str(),v); LOGV("%s %s %f",section.c_str(),key.c_str(),v);
updates++; updates++;
} }
void Preferences::setValue(const std::string&section,const std::string&key,const std::string&v){ void Preferences::setValue(const std::string&section,const std::string&key,const std::string&v){
auto sec=mPrefs.find(section); auto sec = mPrefs.find(section);
if(sec==mPrefs.end()) if(sec == mPrefs.end())
sec=mPrefs.insert({section,std::map<std::string,std::string>()}).first; sec = mPrefs.insert({section,std::map<std::string,std::string>()}).first;
auto kv=sec->second.find(key); auto kv = sec->second.find(key);
if(kv==sec->second.end()) if(kv == sec->second.end())
sec->second.insert({key,v}); sec->second.insert({key,v});
else kv->second=v; else kv->second = v;
LOGV("%s %s %s",section.c_str(),key.c_str(),v.c_str()); LOGV("%s %s %s",section.c_str(),key.c_str(),v.c_str());
updates++; updates++;
} }
void Preferences::setValue(const std::string&section,const std::string&key,double v){ void Preferences::setValue(const std::string&section,const std::string&key,double v){
auto sec=mPrefs.find(section); auto sec = mPrefs.find(section);
if(sec==mPrefs.end()) if(sec==mPrefs.end())
sec=mPrefs.insert({section,std::map<std::string,std::string>()}).first; sec = mPrefs.insert({section,std::map<std::string,std::string>()}).first;
auto kv=sec->second.find(key); auto kv = sec->second.find(key);
if(kv==sec->second.end()) if(kv == sec->second.end())
sec->second.insert({key,std::to_string(v)}); sec->second.insert({key,std::to_string(v)});
else kv->second=std::to_string(v); else kv->second = std::to_string(v);
LOGV("%s %s %f",section.c_str(),key.c_str(),v); LOGV("%s %s %f",section.c_str(),key.c_str(),v);
updates++; updates++;
} }

View File

@ -324,7 +324,6 @@ static void setPatternByTileMode(RefPtr<SurfacePattern>pat,int tileMode){
} }
static int getRotateAngle(Canvas&canvas){ static int getRotateAngle(Canvas&canvas){
double xx, yx, xy, yy, x0, y0;
Cairo::Matrix ctx=canvas.get_matrix(); Cairo::Matrix ctx=canvas.get_matrix();
double radians = atan2(ctx.yy, ctx.xy); double radians = atan2(ctx.yy, ctx.xy);
return int(radians*180.f/M_PI); return int(radians*180.f/M_PI);
@ -394,7 +393,6 @@ void BitmapDrawable::draw(Canvas&canvas){
if ( (mBounds.width !=mBitmapWidth) || (mBounds.height != mBitmapHeight) ) { if ( (mBounds.width !=mBitmapWidth) || (mBounds.height != mBitmapHeight) ) {
canvas.scale(dw/sw,dh/sh); canvas.scale(dw/sw,dh/sh);
dx /= fx; dy /= fy; dx /= fx; dy /= fy;
dw /= fx; dh /= fy;
#if defined(__x86_64__)||defined(__amd64__)||defined(__i386__) #if defined(__x86_64__)||defined(__amd64__)||defined(__i386__)
LOGD_IF((mBitmapWidth*mBitmapHeight>=512*512)||(std::min(fx,fy)<0.1f)||(std::max(fx,fy)>10.f), LOGD_IF((mBitmapWidth*mBitmapHeight>=512*512)||(std::min(fx,fy)<0.1f)||(std::max(fx,fy)>10.f),
"%p bitmap %s scaled %dx%d->%d,%d",this,mBitmapState->mResource.c_str() ,mBitmapWidth,mBitmapHeight,mBounds.width,mBounds.height); "%p bitmap %s scaled %dx%d->%d,%d",this,mBitmapState->mResource.c_str() ,mBitmapWidth,mBitmapHeight,mBounds.width,mBounds.height);
@ -445,6 +443,7 @@ Drawable*BitmapDrawable::inflate(Context*ctx,const AttributeSet&atts){
LOGD("bitmap=%p",d); LOGD("bitmap=%p",d);
d->setGravity(gravity); d->setGravity(gravity);
d->setTileModeXY(tileModeX,tileModeY); d->setTileModeXY(tileModeX,tileModeY);
d->setAntiAlias(antialias);
return d; return d;
} }

View File

@ -696,9 +696,10 @@ bool GradientDrawable::ensureValidRect() {
const std::vector<int>&gradientColors = st.mGradientColors; const std::vector<int>&gradientColors = st.mGradientColors;
if (gradientColors.size()) { if (gradientColors.size()) {
const RectF r = mRect; const RectF r = mRect;
float x0, x1, y0, y1; float x0, y0;
if (st.mGradient == LINEAR_GRADIENT) { if (st.mGradient == LINEAR_GRADIENT) {
float x1,y1;
const float level = st.mUseLevel ? getLevel() / 10000.0f : 1.0f; const float level = st.mUseLevel ? getLevel() / 10000.0f : 1.0f;
switch (st.mOrientation) { switch (st.mOrientation) {
case TOP_BOTTOM: case TOP_BOTTOM:

View File

@ -36,7 +36,6 @@ NinePatch::~NinePatch() {
} }
static int getRotateAngle(Canvas&canvas){ static int getRotateAngle(Canvas&canvas){
double xx, yx, xy, yy, x0, y0;
Cairo::Matrix ctx=canvas.get_matrix(); Cairo::Matrix ctx=canvas.get_matrix();
double radians = atan2(ctx.yy, ctx.xy); double radians = atan2(ctx.yy, ctx.xy);
return int(radians*180.f/M_PI); return int(radians*180.f/M_PI);

View File

@ -8,9 +8,9 @@ namespace cdroid{
DECLARE_WIDGET(FrameLayout) DECLARE_WIDGET(FrameLayout)
FrameLayout::FrameLayout(int w,int h):ViewGroup(w,h){ FrameLayout::FrameLayout(int w,int h):ViewGroup(w,h){
mMeasureAllChildren=false; mMeasureAllChildren = false;
mForegroundPaddingLeft=mForegroundPaddingRight=0; mForegroundPaddingLeft= mForegroundPaddingRight = 0;
mForegroundPaddingTop =mForegroundPaddingBottom=0; mForegroundPaddingTop = mForegroundPaddingBottom= 0;
} }
FrameLayout::FrameLayout(Context* context,const AttributeSet& attrs) FrameLayout::FrameLayout(Context* context,const AttributeSet& attrs)

View File

@ -8,6 +8,7 @@ DECLARE_WIDGET(ViewAnimator)
ViewAnimator::ViewAnimator(int w,int h):FrameLayout(w,h){ ViewAnimator::ViewAnimator(int w,int h):FrameLayout(w,h){
mInAnimation = nullptr; mInAnimation = nullptr;
mOutAnimation= nullptr; mOutAnimation= nullptr;
setMeasureAllChildren(true);
} }
ViewAnimator::ViewAnimator(Context* context,const AttributeSet& attrs) ViewAnimator::ViewAnimator(Context* context,const AttributeSet& attrs)
@ -21,11 +22,9 @@ ViewAnimator::~ViewAnimator(){
} }
void ViewAnimator::initViewAnimator(Context* context, const AttributeSet& attrs) { void ViewAnimator::initViewAnimator(Context* context, const AttributeSet& attrs) {
//mMeasureAllChildren = true;
// For compatibility, default to measure children, but allow XML // For compatibility, default to measure children, but allow XML
// attribute to override. // attribute to override.
bool measureAllChildren = attrs.getBoolean("measureAllChildren", true); setMeasureAllChildren(attrs.getBoolean("measureAllChildren", true));
setMeasureAllChildren(measureAllChildren);
mInAnimation = nullptr; mInAnimation = nullptr;
mOutAnimation = nullptr; mOutAnimation = nullptr;
} }
@ -57,7 +56,7 @@ void ViewAnimator::showPrevious() {
} }
void ViewAnimator::showOnly(int childIndex, bool animate) { void ViewAnimator::showOnly(int childIndex, bool animate) {
int count = getChildCount(); const int count = getChildCount();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
View* child = getChildAt(i); View* child = getChildAt(i);
if (i == childIndex) { if (i == childIndex) {
@ -151,12 +150,15 @@ View* ViewAnimator::getCurrentView() {
Animation* ViewAnimator::getInAnimation(){ Animation* ViewAnimator::getInAnimation(){
return mInAnimation; return mInAnimation;
} }
void ViewAnimator::setInAnimation(Animation* inAnimation){ void ViewAnimator::setInAnimation(Animation* inAnimation){
mInAnimation=inAnimation; mInAnimation=inAnimation;
} }
Animation* ViewAnimator::getOutAnimation(){ Animation* ViewAnimator::getOutAnimation(){
return mOutAnimation; return mOutAnimation;
} }
void ViewAnimator::setOutAnimation(Animation* outAnimation){ void ViewAnimator::setOutAnimation(Animation* outAnimation){
mOutAnimation = outAnimation; mOutAnimation = outAnimation;
} }