Android App sharedUserId=”android.uid.system”

I want to get screen pixels information, while we can not get it directly from /dev/graphics/fb0 when we use nexus 4/galaxy s4 Android 4.3.  I googled it seems the file is abandoned, the screen is not render from that file, even I get root permission, I still can not read data, all returned value is 0.

So I want to know how the screenshot gets the photo. The analysis is read from http://my.eoe.cn/viver120/archive/5448.html.  The Surface.screenshot() is the key function. So I write the code according to http://blog.csdn.net/hk_256/article/details/7306590.

In the implement process, there are several problems that cost me some time to solve.

1. There is no Surface.screenshot(), in the latest android source code, the function is changed to SurfaceControl.screenshot(). If use the old, eclipse will tell there is no function. Actually, the first one in early android version is hidden api, the latter is hidden class. The hidden api and internal api used in eclipse: http://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-1-introduction/

2. If we run the app, it will give null results. That may caused by the hidden class. Although it goes through eclipse, it is not actually works. We need add system permission to the app.   a.) Add android:sharedUserId=”android.uid.system”  in manifest attribute AndroidManifest.xml.
To make sure it works. There are two ways as listed in http://hi.baidu.com/eastream/item/8b86140df304f0f5a1103448. I took first which works. The key is that it is ROM related, you need to compile your app in the same Android source code that compile your custom ROM.
b.) In Android.mk,add LOCAL_CERTIFICATE := platform
c.) Move your app folder to Android source code  /packages/apps/yourApp
d.) Run . build/envsetup.sh  then cd yourApp folder Run mm
e.) After compile, it shows the .apk path, then you can install it from adb
adb install -r testscreenshotactivity.apk  use -r if you reinstall the app, if not, just ignore -r.

If your ROM is not same with your android source code, the installation may not success, otherwise, it shows SUCCESS on your terminal.

Code: https://github.com/lyhz/AndroidScreenShot.git

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s