openstf / STFService.apk

Monitor and perform various actions on your Android device. Not meant for actual user devices.
Other
242 stars 207 forks source link

[questions]Envelope::MergeFromCodedStream return some unknow_data #50

Closed lfjking closed 4 years ago

lfjking commented 4 years ago

The protobuff version is 2.6.0. After starting the service, After reading the data from "forward localabstract:stfservice": buff, len. Envelope lope; if (lope.ParseFromArray(buff, len)){ Dg("Event Type:%d \n", lope.type()); }

ParseFromArray always returns false. Is the buff length a problem? How do I adjust?


ok, ParseFromArray using from the group data. the non-group data, using MergeFromCodedStream. now , I from the MergeFromCodedStream get the type . but, also have some buffer can't Parse, alway, the data size 44.

I don't know it is my lost or it is the Envelope get the non-group data.

Can you provide some examples of receiving data of unknown length and parsing successfully?

lfjking commented 4 years ago

I get the info for each packet form remote:

setting connection_state to CS_DEVICE
Connect_to_remote call RS(100)'shell'
Connect_to_remote call RS(101)'forward'
Command connect:100!'shell connect'
Server connect! 'forward connect'
Command id:100
buffer: Starting service: Intent { act=jp.co.cyberagent.stf.ACTION_START cmp=jp.co.cyberagent.stf/.Service }
Command Close:100!  `the shell close,but forward is not stop`
forward get un_know buffer(100):
+x10\x0e\x1a\'x0a\x04\fullx12\x04\goodx1a\x03\usb d(d1xffffff9a\xffffff99\xffffff99\xffffff99\xffffff99\x19\8@9Hxffffffe1\zx14\xffffffae\Gx11\@x12\x10\x0f\x1a\x0e\x08\x01\x12\x04\WIFIx1a\x00\ x00\(x00\x16\x10\x10\x1a\x12\x0a\x0e\out_of_servicex10\x00\x06\x10\x11\x1a\x02\x08\Zx06\x10\x0d\x1a\x02\x08\x00\
forward get un_know buffer(62):
=x10\x12\x1a\9x08\x01\x12\5x0a\x09\xffffffe6\xffffffb5\xffffff8f\xffffffe8\xffffffa7\xffffff88\xffffffe5\xffffff99\xffffffa8\x12\$com.android.browser/.BrowserActivityx18\x01\ x01\
forward get un_know buffer(1):
x07\
Event Type:EVENT_ROTATION(17) 
Device Rotation:270
forward get un_know buffer(51):
2x10\x0e\x1a\.x0a\x0b\dischargingx12\x04\goodx1a\x03\usb d(d1xffffff9a\xffffff99\xffffff99\xffffff99\xffffff99\x19\8@9xffffffc3\xfffffff5\(\xffffff8f\Bx11\@
forward get un_know buffer(1):
x06\
Event Type:EVENT_ROTATION(17) 
Device Rotation:0
forward get un_know buffer(1):
x06\
Event Type:EVENT_ROTATION(17) 
Device Rotation:90
forward get un_know buffer(51):
2x10\x0e\x1a\.x0a\x0b\dischargingx12\x04\goodx1a\x03\usb d(d1xffffff9a\xffffff99\xffffff99\xffffff99\xffffff99\x19\8@9X9xffffffb4\xffffffc8\v>x11\@
forward get un_know buffer(1):
x06\
Event Type:EVENT_ROTATION(17) 
Device Rotation:0
forward get un_know buffer(44):
+x10\x0e\x1a\'x0a\x04\fullx12\x04\goodx1a\x03\usb d(d1xffffff9a\xffffff99\xffffff99\xffffff99\xffffff99\x19\8@9Hxffffffe1\zx14\xffffffae\Gx11\@
forward get un_know buffer(44):
+x10\x0e\x1a\'x0a\x04\fullx12\x04\goodx1a\x03\usb d(d1xffffff9a\xffffff99\xffffff99\xffffff99\xffffff99\x19\8@9-xffffffb2\xffffff9d\xffffffef\xffffffa7\Fx11\@
forward get un_know buffer(44):
+x10\x0e\x1a\'x0a\x04\fullx12\x04\goodx1a\x03\usb d(d1xffffff9a\xffffff99\xffffff99\xffffff99\xffffff99\x19\8@9Hxffffffe1\zx14\xffffffae\Gx11\@
forward get un_know buffer(51):
2x10\x0e\x1a\.x0a\x0b\dischargingx12\x04\goodx1a\x03\usb d(d13333338@9Hxffffffe1\zx14\xffffffae\Gx11\@

I don't know why...... I use the fun :ParseFromArray to parse the packet. There is no operation on my phone, why do I keep receiving this message?

lfjking commented 4 years ago

Now, I changed my code like it:

    Envelope &lope = mEnvelope;
        bool isok = false;
        io::CodedInputStream stream(data, len);
        while (!stream.ConsumedEntireMessage())
        {
            if (lope.MergeFromCodedStream(&stream)){
                ParseMessage(lope);
                isok = true;
            }
        }
        if (!isok){
            Dg("forward get un_know buffer(%d):\n", len);
            for (size_t i = 0; i < len; i++){
                char c = data[i];
                if (c > 31 && c < 127){
                    Dg("%c", c);
                }
                else{
                    Dg("x%02x\\", c);
                }
            }
            Dg("\n");
        }

---------------the output here:--------------------------

setting connection_state to CS_DEVICE
Connect_to_remote call RS(100)
Connect_to_remote call RS(101)
Command connect:100!
Server connect!
Command id:100
buffer: Starting service: Intent { act=jp.co.cyberagent.stf.ACTION_START cmp=jp.co.cyberagent.stf/.Service }
Command Close:100!

Event Type:EVENT_AIRPLANE_MODE(13) 
Air plane is Open:false

forward get un_know buffer(44):
+x10\x0e\x1a\'x0a\x04\fullx12\x04\goodx1a\x03\usb d(d13333336@9X9xffffffb4\xffffffc8\v>x11\@
forward get un_know buffer(44):
+x10\x0e\x1a\'x0a\x04\fullx12\x04\goodx1a\x03\usb d(d13333336@9shxffffff91\xffffffed\|?x11\@
forward get un_know buffer(44):
+x10\x0e\x1a\'x0a\x04\fullx12\x04\goodx1a\x03\usb d(d13333336@9X9xffffffb4\xffffffc8\v>x11\@
forward get un_know buffer(44):
+x10\x0e\x1a\'x0a\x04\fullx12\x04\goodx1a\x03\usb d(d1xffffff9a\xffffff99\xffffff99\xffffff99\xffffff99\x19\6@9X9xffffffb4\xffffffc8\v>x11\@

forward get un_know buffer(44):
+x10\x0e\x1a\'x0a\x04\fullx12\x04\goodx1a\x03\usb d(d1x00\x00\x00\x00\x00\x00\6@9X9xffffffb4\xffffffc8\v>x11\@

forward get un_know buffer(44):
+x10\x0e\x1a\'x0a\x04\fullx12\x04\goodx1a\x03\usb d(d1fffffxffffffe6\5@9X9xffffffb4\xffffffc8\v>x11\@

Event Type:EVENT_AIRPLANE_MODE(13) 
Air plane is Open:false
Event Type:EVENT_CONNECTIVITY(15) 
ConnectivityEvent:connected:true
ConnectivityEvent:type:WIFI
ConnectivityEvent:subtype:
ConnectivityEvent:failover:false
ConnectivityEvent:roaming:false
Event Type:EVENT_CONNECTIVITY(15) 
ConnectivityEvent:connected:true
ConnectivityEvent:type:WIFI
ConnectivityEvent:subtype:
ConnectivityEvent:failover:false
ConnectivityEvent:roaming:false
Event Type:EVENT_CONNECTIVITY(15) 
ConnectivityEvent:connected:true
ConnectivityEvent:type:WIFI
ConnectivityEvent:subtype:
ConnectivityEvent:failover:false
ConnectivityEvent:roaming:false
forward get un_know buffer(44):
+x10\x0e\x1a\'x0a\x04\fullx12\x04\goodx1a\x03\usb d(d1xffffffcd\xffffffcc\xffffffcc\xffffffcc\xffffffcc\xffffffcc\5@9X9xffffffb4\xffffffc8\v>x11\@
forward get un_know buffer(44):
+x10\x0e\x1a\'x0a\x04\fullx12\x04\goodx1a\x03\usb d(d133333xffffffb3\5@9=x0a\xffffffd7\xffffffa3\p=x11\@
forward get un_know buffer(44):
+x10\x0e\x1a\'x0a\x04\fullx12\x04\goodx1a\x03\usb d(d1xffffff9a\xffffff99\xffffff99\xffffff99\xffffff99\xffffff99\5@9=x0a\xffffffd7\xffffffa3\p=x11\@
forward get un_know buffer(44):
+x10\x0e\x1a\'x0a\x04\fullx12\x04\goodx1a\x03\usb d(d1x00\x00\x00\x00\x00\xffffff80\5@9=x0a\xffffffd7\xffffffa3\p=x11\@

I use the MergeFromCodedStream. It can parse more data from the received to the data. But there are still parts of the data that cannot be parsed. All data has to go through here, so there is no data loss.

As you can see from the wire message, the data information that cannot be parsed should be: EVENT_BATTERY

lfjking commented 4 years ago

It's exploding! After r rebooting my phone, I was able to parse the EVENT_BATTERY data.

Event Type:EVENT_BATTERY(14) 
Battery:health:good
Battery:level:100
Battery:scale:100
Battery:source:usb
Battery:status:charging

What an experience!