Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
C:/Program Files/Git/info/rotation support auto get rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Jan 23, 2018
1 parent 110f05d commit 3be2f5b
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,16 +538,22 @@ func ServeHTTP(lis net.Listener, tunnel *TunnelProxy) error {
}).Methods("POST")

m.HandleFunc("/info/rotation", func(w http.ResponseWriter, r *http.Request) {
var direction int // 0,1,2,3
json.NewDecoder(r.Body).Decode(&direction)
deviceRotation = direction * 90
log.Println("rotation change received:", deviceRotation)
var direction int // 0,1,2,3
err := json.NewDecoder(r.Body).Decode(&direction) // TODO: auto get rotation
if err == nil {
deviceRotation = direction * 90
log.Println("rotation change received:", deviceRotation)
} else {
rotation, er := androidutils.Rotation()
if er != nil {
log.Println("rotation auto get err:", er)
http.Error(w, "Failure", 500)
return
}
deviceRotation = rotation
}
updateMinicapRotation(deviceRotation)
// devInfo := getDeviceInfo()
// width, height := devInfo.Display.Width, devInfo.Display.Height
// go service.UpdateArgs("minicap", "/data/local/tmp/minicap", "-S", "-P",
// fmt.Sprintf("%dx%d@%dx%d/%d", width, height, displayMaxWidthHeight, displayMaxWidthHeight, deviceRotation))
io.WriteString(w, "Success")
fmt.Fprintf(w, "rotation change to %d", deviceRotation)
})

m.HandleFunc("/upload/{target:.*}", func(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit 3be2f5b

Please sign in to comment.