Monday, February 24, 2014

android framebuffer operations (I admit that this question makes a loss, the time when I was bruised and battered, still put their hopes in the final wire csdn)


I want to operate android phones framebuffer, phones have gained root privileges. On see similar code, download, specification writing follow jni c program, and then compiled by ndk call in java. The whole process is run over the. In the previous few days, I have been can open framebuffer, and can mmap data inside. But yesterday, after turning on the computer, I can not open my phone's framebuffer, code execution returns to the first step failed. I checked all the code and rewritten several times, delete other operations, leaving open the framebuffer operations still fail. I have changed the root of the board to test the program, still open failed. After more than a day to repeat some code, check the error, I despair. Code is as follows, please correct me master. Grateful!
 # include  
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include "pixelflinger.h"

static GGLSurface gr_framebuffer [2];
/ / Handler
static int gr_fb_fd = -1;
/ / V screen info
static struct fb_var_screeninfo vi;
/ / F screen info
struct fb_fix_screeninfo fi;
static int get_framebuffer (GGLSurface * fb) / / fb is defined in another header file saved framebuffer data structure
{
int fd;
void * bits;

fd = open ("/ dev/graphics/fb0", O_RDWR); / / execution failed to open here
if (fd <0) {
perror ("cannot open fb0");
return -1;
}

if (ioctl (fd, FBIOGET_FSCREENINFO, & fi) <0) {
perror ("failed to get fb0 info");
return -1;
}

if (ioctl (fd, FBIOGET_VSCREENINFO, & vi) <0) {
perror ("failed to get fb0 info");
return -1;
}


bits = mmap (0, fi.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (bits == MAP_FAILED) {
perror ("failed to mmap framebuffer");
return -1;
}

fb-> version = sizeof (* fb);
fb-> width = vi.xres;
fb-> height = vi.yres;
fb-> stride = fi.line_length / (vi.bits_per_pixel >> 3);
fb-> data = bits;
fb-> format = GGL_PIXEL_FORMAT_RGB_565;

fb + +;

fb-> version = sizeof (* fb);
fb-> width = vi.xres;
fb-> height = vi.yres;
fb-> stride = fi.line_length / (vi.bits_per_pixel >> 3);
fb-> data = (void *) (((unsigned) bits) + vi.yres * vi.xres * 2);
fb-> format = GGL_PIXEL_FORMAT_RGB_565;

return fd;
}

jstring Java_com_liuqiang_NDKScreenShot2Activity_ScreenShot (JNIEnv * env, jobject thiz) / / I deleted all the other operations, but the implementation of open frame buffer, has been "open failed"! !
{
gr_fb_fd = get_framebuffer (gr_framebuffer);
if (gr_fb_fd <0)
{
return (* env) -> NewStringUTF (env, "open failed");
}
else
{
return (* env) -> NewStringUTF (env, "open succeed");
}

}

<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
/ / Execute failed to open here
You mean the program hung up? Or wrong, if it is wrong that errno is how much?

Two days ago still open, indicating that altered anything among you?
Reply:
cited a floor oyq_yangy reply:
/ / execution failed to open here
You mean the program hung up? Or wrong, if it is wrong that errno is how much?

Two days ago still open, indicating that altered anything among you?

Is a program error. I passed: if (gr_fb_fd <0)
{
char * s = NULL;
sprintf (s, "% d", errno);
return (* env) -> NewStringUTF (env, s);
}
Print error number, the program directly linked to it.
A few days ago has been able to use. Yesterday I mmap data, always get data due jni call ndk compiled package, can not breakpoint debugging, so I did not start has been found to be open to fail. Later check out, framebuffer open failed. After no open succeeded. I put the code after all deleted, but the implementation of the open operation, but also without success. Will the above code there is a problem? Or need to pay attention to what place. Thank

Reply:
Your landlord is being given Shaa, framebuffer is generally more difficult to handle
Reply:
reference to the third floor lieri111 reply:
your landlord error is Shaa, framebuffer is generally more difficult to handle

I just printed the error in the implementation of the open when the error signal output is:. 13
In fact, the problem is not only open up before me framebuffer, but also to get to the data, and now use the same code, open the ah, framebuffer is not open, the back of the expansion method did not work. I changed the board to test, still not open. Code is rewritten several times. Depressed ah
Reply:
13 is no authority ah. . . You're a java program, you should not have permission to read and write fb0, I do not understand how you can succeed before it.
Reply:
My part is to get up in the java permission. When the program is running, the phone will prompt the application already has the highest authority.
 setContentView (R.layout.main); 
String apkRoot = "chmod 777" + getPackageCodePath ();
RootCommand (apkRoot);
public static boolean RootCommand (String command) / / application root privileges
{
Process process = null;
DataOutputStream os = null;
try
{
process = Runtime.getRuntime () exec ("su");.
os = new DataOutputStream (process.getOutputStream ());
os.writeBytes (command + "\ n");
os.writeBytes ("exit \ n");
os.flush ();
process.waitFor ();
} Catch (Exception e)
{
Log.d ("*** DEBUG ***", "ROOT REE" + e.getMessage ());
return false;
} Finally
{
try
{
if (os! = null)
{
os.close ();
}
process.destroy ();
} Catch (Exception e)
{
}
}
Log.d ("*** DEBUG ***", "Root SUC");
return true;
}

Reply:
I have also checked the error list linux, and 13 really is not meant permission. But on the phone, suggesting that the procedure for obtaining the highest authority, and the list of the highest authority inside my application.
Reply:
reference to the 7th floor love_gg reply:
I have also checked the error list linux, and 13 really is not meant permission. But on the phone, suggesting that the procedure for obtaining the highest authority, and the list of the highest authority inside my application.

"Tip of the procedure for obtaining the highest authority, and the authority which has the highest list of my application."
Who tips? Where's the list of the highest authority it?

Anyway, to get 13, it shows that your application UID is not root.
Reply:
reference to the 8th floor oyq_yangy reply:
reference to the 7th floor love_gg reply:

I have also checked the error list linux, and 13 really is not meant permission. But on the phone, suggesting that the procedure for obtaining the highest authority, and the list of the highest authority inside my application.

"Tip of the procedure for obtaining the highest authority, and the authority which has the highest list of my application."
Who tips? Where's the list of the highest authority it?

Anyway, to get 13, it shows that your application UID is not root.

On the phone or cracked board, if the application requires root privileges apply, an application box will pop up, tips are allowed or denied. If allowed, the system will pop up a prompt: ** application has access to the highest authority.
On the phone with root privileges to install a manager, you can see the current applications with root privileges.
When I saw the 13, I will be more depressed, at root privileges viewer, obviously have my application, and the system also prompts the application to have the root privileges, but returned errno is 13.
Reply:
reference to the 6th floor love_gg reply:
my java part is to get the permission. When the program is running, the phone will prompt the application already has the highest authority.
Java code
setContentView (R.layout.main);
String apkRoot = "chmod 777" + getPackageCodePath ();
RootCommand (apkRoot);
public static boolea ......


My understanding is: process = Runtime.getRuntime () exec ("su"); initiated a new process, if successful, this new process is now the root, but this is your java process and nothing like it.

Reply:
The landlord can leave a QQ exchange under it?
Reply:
In ndk framebuffer can get it? If you can read, then there can be a depth value of it? I think the landlord is framebuffer in colorbuffer, basically did not see and depthbuffer related operations ah, QQ: 826323843@qq.com
Reply:
reference to the 10th floor oyq_yangy reply:
reference to the 6th floor love_gg reply:

My part is to get up in the java permission. When the program is running, the phone will prompt the application already has the highest authority.
Java code
setContentView (R.layout.main);
String apkRoot = "chmod 777" + getPackageCodePath ();
RootCommand (apkRoot);
public static ......
I pass parameters are: String apkRoot = "chmod 777" + getPackageCodePath (); namely the application's directory. The code to get root privileges I also found online, we are using this method. And every time I run my program, you can see the system prompt, *** program has received the highest authority.
Reply:
My QQ:. 634804266 hope that we can communicate, help
Reply:
Phone prompts whether to authorize, I choose "Allow", with SuperUser view, my application has super powers inside. But still failed to open the framebuffer. On the android operating over the framebuffer great God who, to the point of help and advice, thank you
Reply:
Learn new techniques
Reply:
Mark.
Reply:
Light has permission to run when ROOT is not enough, when the APK installation package installed also apply for other permissions:
1 store permissions (modify, delete the contents of a USB device)
2 system tools (mount and unmount file systems)
3 Network Communication (full internet access)

In addition there is an Android Market application: ROOT screenshot, author JOHN ZHENG, you can look down

Reply:
cited 18 floor viperchaos reply:
light has a run time of ROOT privileges is not enough, when the APK installation package installed also apply for other permissions:
1 store permissions (modify, delete the contents of a USB device)
2 system tools (mount and unmount file systems)
3 Network Communication (full internet access)

In addition there is an Android Market application: ROOT screenshot, author JOHN ZHENG, you can look down

Positive solution! ! ! Light has root privileges, is not enough. Thank you! Troubled for a long time! ! ! ! ! ! !
Reply:
reference to the 9th floor love_gg reply:
reference to the 8th floor oyq_yangy reply:

References to the 7th floor love_gg reply:

I have also checked the error list linux, and 13 really is not meant permission. But on the phone, suggesting that the procedure for obtaining the highest authority, and the list of the highest authority inside my application.

"Tip of the procedure for obtaining the highest authority, and the authority which has the highest list of my application."
Who tips? Where's the list of the highest authority it?

Anyway, to get 13, it shows that your application UID is not root ......


Why my process = Runtime.getRuntime () exec ("su") executed always reported su: uid 1000 not allowed to su error? ? ?
Reply:
cited 20 floor csusunxgg reply:
reference to the 9th floor love_gg reply:

References to the 8th floor oyq_yangy reply:

References to the 7th floor love_gg reply:

I have also checked the error list linux, and 13 really is not meant permission. But on the phone, suggesting that the procedure for obtaining the highest authority, and the list of the highest authority inside my application.

"Tip of the procedure for obtaining the highest authority, and the authority which has the highest list of my application."
Who tips? Where's the list of the highest authority it?

Anyway, ......

How do you write? I am here can ah!
Reply:
Specific needs which permissions can be said about it?
Reply:
cited 22 floor lq244817652 reply:
specific needs which permissions can be said about it?

1 store permissions (modify, delete the contents of a USB device)
2 system tools (mount and unmount file systems)
3 Network Communication (full internet access)
Reply:
The reply was deleted at 2011-12-06 11:46:48 moderator

Reply:
cited 23 F reply:
cited 22 floor lq244817652 reply:

Specific needs which permissions can be said about it?

1 store permissions (modify, delete the contents of a USB device)
2 system tools (mount and unmount file systems)
3 Network Communication (full internet access)

Corrected with permission of everyone, without these permissions, you only need two points, the first application for permission fb0 second application java program
Reply:
The landlord Hello, I would like to extract data fb0 under you succeed or not. My code is as follows:
void * mapadd;
int fd;


fd = open ("/ dev/graphics/fb0", O_RDWR);

if (ioctl (fd, FBIOGET_VSCREENINFO, & vi) <0) {
perror ("failed to get fb0 info");
}
int w = vi.xres;
int h = vi.yres;
int d = vi.bits_per_pixel; / / bit number of each pixel
long int _ScreenByte = total number of bytes w * h * d / 8 ;/ / calculate the screen (bytes)

mapadd = mmap (0, _ScreenByte, PROT_READ |
PROT_WRITE, MAP_SHARED, fd, 0);
jbyteArray re = (* env) -> NewByteArray (env, _ScreenByte);

unsigned char a [_ScreenByte];
memcpy (a, mapadd, _ScreenByte);
(* Env) -> SetByteArrayRegion (env, re, 0, _ScreenByte, a);
munmap (mapadd, _ScreenByte);

close (_fb);
return re;



However, print out the array returned data is all in java -1 is not an assignment where an error?
Reply:
reference to the 25th floor of the reply:
cited 23 F reply:

Cited 22 floor lq244817652 reply:

Specific needs which permissions can be said about it?

1 store permissions (modify, delete the contents of a USB device)
2 system tools (mount and unmount file systems)
3 Network Communication (full internet access)

We corrected with the next, does not require these permissions, you only need two points, the first application for permission fb0 second application java program permissions

Hello, may I ask permission to apply java program What is meant, specifically how to achieve. . .
I added the three permissions, add the root privileges, you can still fb <0
Reply:
reference to the 25th floor of the reply:
cited 23 F reply:

Cited 22 floor lq244817652 reply:

Specific needs which permissions can be said about it?

1 store permissions (modify, delete the contents of a USB device)
2 system tools (mount and unmount file systems)
3 Network Communication (full internet access)

We corrected with the next, does not require these permissions, you only need two points, the first application for permission fb0 second application java program permissions


Landlord, you framebuffer this operation did not solve the problem? Resolved, way to share, I also do something in this regard, is the old framebuffer data can not be read. Please enlighten me, thank you.
Reply:
I phone up and down a terminal emulator, enter su in terminal emulator, after obtaining permission, then enter chmod 777 / dev/graphics/fb0 set permissions, and then get root privileges when you can open the app software opens fb0

No comments:

Post a Comment