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;
mDeviceClasses= 0;
mAxisFlags =0;
mKeyboardType = KEYBOARD_TYPE_NONE;
InputGetDeviceInfo(fdev,&devInfos);
di.name = devInfos.name;
@ -143,6 +145,7 @@ InputDevice::InputDevice(int fdev){
mDeviceClasses |= INPUT_DEVICE_CLASS_KEYBOARD;
}
}
mCorrectedDeviceClasses = mDeviceClasses;
kmap = nullptr;
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());

View File

@ -14,7 +14,7 @@
namespace cdroid{
struct 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.
std::string name;

View File

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

View File

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

View File

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

View File

@ -324,7 +324,6 @@ static void setPatternByTileMode(RefPtr<SurfacePattern>pat,int tileMode){
}
static int getRotateAngle(Canvas&canvas){
double xx, yx, xy, yy, x0, y0;
Cairo::Matrix ctx=canvas.get_matrix();
double radians = atan2(ctx.yy, ctx.xy);
return int(radians*180.f/M_PI);
@ -394,7 +393,6 @@ void BitmapDrawable::draw(Canvas&canvas){
if ( (mBounds.width !=mBitmapWidth) || (mBounds.height != mBitmapHeight) ) {
canvas.scale(dw/sw,dh/sh);
dx /= fx; dy /= fy;
dw /= fx; dh /= fy;
#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),
"%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);
d->setGravity(gravity);
d->setTileModeXY(tileModeX,tileModeY);
d->setAntiAlias(antialias);
return d;
}

View File

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

View File

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

View File

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