blob: 6ce5b86482a1324841537599d14b7cb946e52c44 [file] [log] [blame]
Mathias Agopian88a5df92010-09-26 18:49:45 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <unistd.h>
18#include <fcntl.h>
19
20#include <utils/Log.h>
21
22#include <binder/IPCThreadState.h>
23#include <binder/ProcessState.h>
24#include <binder/IServiceManager.h>
25
26#include <binder/IMemory.h>
27#include <surfaceflinger/ISurfaceComposer.h>
28
29using namespace android;
30
31int main(int argc, char** argv)
32{
33 const String16 name("SurfaceFlinger");
34 sp<ISurfaceComposer> composer;
35 if (getService(name, &composer) != NO_ERROR)
36 return 0;
37
38 sp<IMemoryHeap> heap;
39 uint32_t w, h;
40 PixelFormat f;
41 status_t err = composer->captureScreen(0, &heap, &w, &h, &f);
42 if (err != NO_ERROR)
43 return 0;
44
45 uint8_t* base = (uint8_t*)heap->getBase();
46 int fd = dup(STDOUT_FILENO);
47 write(fd, &w, 4);
48 write(fd, &h, 4);
49 write(fd, &f, 4);
50 write(fd, base, w*h*4);
51 close(fd);
52 return 0;
53}