FORUMS

[SCRIPT][ROM][DEV] deptree - Dependency tracking tool for apk/jar/so/bin (ROM mngmt)

106 posts
Thanks Meter: 41
 
By romanr, Senior Member on 2nd February 2012, 09:48 AM
Post Reply Email Thread
There are lot of cases, when we're trying to remove system library or apk and device becomes malfunctioning or stops booting at all.

Average ROM has ~500 system packages/jars/libraries/binaries and ~20000 dependencies, which, frankly speaking, most human beings are unable to apprehend using only own mind.

The idea is to track the dependencies using some sort of automation.

Libraries depend on other libraries.
Binaries depend on libraries.
Jars depend on other jars and libraries.
APKs depend on other APKs, jars and libraries.

Library and binary dependencies may be gathered by arm-eabi-readelf tool (option -d).
Jars and APKs may be deodexed (if needed), decompiled; "System.loadLibrary(...)", "import ...", "package ...", "class ...", "new Intent(...)" code lines may be grepped to gather dependencies.

All this is done by deptree tool I'm offering.

Use cases:
Code:
Reset/init database (test.sqlite). If you don't do this - database will be updated.
$ ./init_db.sh
... (output)

Parsing. Specify "system" filesystem tree. system/bin/*, system/xbin/* should be executables (chmod a+x bin/* xbin/*).
$ ./parse_rom_dir.sh /path/to/unpacked/rom/system
... (too long output, duration ~15-35min)

List binaries/jars/apks, which names contain "adrenaline".
$ ./list_objects.sh adrenaline
Asphalt6_AdrenalineHD_SamsungSCH-i927_ML_IGP_ATT_MP_GLLive_DEMO_104.apk 139 dependencies 7 providings
$ ./list_objects.sh ext2
libext2_blkid.so 2 dependencies 1 providings
libext2_com_err.so 3 dependencies 1 providings
libext2_e2p.so 1 dependencies 1 providings
libext2_uuid.so 3 dependencies 1 providings
libext2fs.so 5 dependencies 1 providings

Calculate objects that should be removed also if this one is removed.
$ ./remove_object.sh Asphalt6_AdrenalineHD_SamsungSCH-i927_ML_IGP_ATT_MP_GLLive_DEMO_104.apk
libasphalt6.so not_needed
Asphalt6_AdrenalineHD_SamsungSCH-i927_ML_IGP_ATT_MP_GLLive_DEMO_104.apk dependency
$ ./remove_object.sh libext2fs.so
libext2_uuid.so not_needed
libext2_blkid.so not_needed
libext2_com_err.so not_needed
libdiskconfig.so not_needed
libext2fs.so dependency
libext2_e2p.so not_needed
vold dependency
$ ./remove_object.sh ext.jar
LiveWallpapers.apk dependency
MobileTrackerEngineTwo.apk dependency
libandroid_servers.so not_needed
SnsImageCache.apk dependency
libmobiletag-decoder.so not_needed
...
secmediarecorder.jar dependency
android.test.runner.jar dependency
PhoneErrService.apk dependency
att_code_scanner_v2_0_45_aligned.apk dependency
$ ./remove_object.sh ATTNavigator.apk Asphalt6_AdrenalineHD_SamsungSCH-i927_ML_IGP_ATT_MP_GLLive_DEMO_104.apk Vending.apk
libasphalt6.so not_needed
Asphalt6_AdrenalineHD_SamsungSCH-i927_ML_IGP_ATT_MP_GLLive_DEMO_104.apk dependency
Vending.apk dependency
MarketUpdater.apk dependency
ATTNavigator.apk dependency

List symbols and objects, which provide/require them. Substring may be specified.
$ ./list_symbols.sh libext2fs.so
symbol libext2fs.so
required_by vold
provided_by libext2fs.so
$ ./list_symbols.sh iqclient
symbol com.carrieriq.iqagent.client.IQClient
required_by android.policy.jar ext.jar framework.jar services.jar
provided_by ext.jar
symbol com.android.internal.policy.impl.IQClientThreadRunnable
required_by
provided_by android.policy.jar

List symbols/objects, which the object provides and on which depends.
$ ./list_dependencies.sh ext2
object libext2_blkid.so
depends_on_symbols libc.so libext2_uuid.so
provides_symbols libext2_blkid.so
depends_on_objects libc.so libext2_uuid.so
dependent_objects libext2fs.so
object libext2_com_err.so
depends_on_symbols libc.so libstdc++.so libm.so
provides_symbols libext2_com_err.so
depends_on_objects libc.so libm.so libstdc++.so
dependent_objects libext2fs.so
object libext2_e2p.so
depends_on_symbols libc.so
provides_symbols libext2_e2p.so
depends_on_objects libc.so
dependent_objects libext2fs.so
object libext2_uuid.so
depends_on_symbols libc.so libstdc++.so libm.so
provides_symbols libext2_uuid.so
depends_on_objects libc.so libm.so libstdc++.so
dependent_objects libext2_blkid.so libext2fs.so
object libext2fs.so
depends_on_symbols libc.so libext2_blkid.so libext2_uuid.so libext2_com_err.so libext2_e2p.so
provides_symbols libext2fs.so
depends_on_objects libc.so libext2_blkid.so libext2_com_err.so libext2_e2p.so libext2_uuid.so
dependent_objects vold
$ ./list_dependencies.sh asphalt6
object libasphalt6.so
depends_on_symbols libc.so libstdc++.so libm.so liblog.so libdl.so libGLESv1_CM.so libGLESv2.so
provides_symbols libasphalt6.so
depends_on_objects libGLESv1_CM.so libGLESv2.so libc.so libdl.so liblog.so libm.so libstdc++.so
dependent_objects Asphalt6_AdrenalineHD_SamsungSCH-i927_ML_IGP_ATT_MP_GLLive_DEMO_104.apk
object Asphalt6_AdrenalineHD_SamsungSCH-i927_ML_IGP_ATT_MP_GLLive_DEMO_104.apk
depends_on_symbols libasphalt6.so android.os.Bundle java.io.PrintStream java.util.Iterator android.content.Intent java.io android.net.Uri android.os android.content.Context android.widget.EditText android.widget.TextView java.io.IOException android.app.ProgressDialog android.content.res.Configuration android.content.res.Resources android.graphics.Rect android.view android.util.AttributeSet android.util.Log android.content java.util android.view.KeyEvent android.view.View android.widget.Button java.util.Date android.widget.RelativeLayout android.content.DialogInterface android.app.AlertDialog android.view.MotionEvent android.graphics.Bitmap android.graphics.BitmapFactory java.io.FileNotFoundException java.io.InputStream android.media.AudioManager java.util.ArrayList android.net.ConnectivityManager android.telephony.TelephonyManager java.io.File android.view.Window java.util.List android.text.Editable android.text.TextWatcher android.view.inputmethod.InputMethodManager java.util.HashMap java.util.Locale android.app.NotificationManager android.app.Activity java.util.zip.ZipEntry java.util.zip.ZipFile android.content.res.AssetManager android.content.res.AssetFileDescriptor java.util.Random android.os.Environment java.util.Enumeration java.util.Vector java.net.URL java.security.SecureRandom javax.crypto javax.crypto.spec.SecretKeySpec java.io.ByteArrayInputStream java.security.cert.X509Certificate android.app.PendingIntent android.net.NetworkInfo java.util.zip.GZIPInputStream java.util.zip org.apache.http.impl.client.DefaultHttpClient android.os.Build java.nio.charset.Charset java.io.FileOutputStream java.io.DataInputStream java.net java.nio java.util.zip.GZIPOutputStream java.util.Timer java.net.SocketException java.net.SocketTimeoutException javax.net.ssl org.xml.sax.Attributes javax.xml.parsers.SAXParser javax.net.ssl.SSLSession javax.net.ssl.X509TrustManager org.xml.sax.helpers.DefaultHandler org.xml.sax.XMLReader org.xml.sax.InputSource java.net.HttpURLConnection java.util.TimerTask org.apache.http.client.entity.UrlEncodedFormEntity org.apache.http.client.methods.HttpPost org.apache.http.message.BasicNameValuePair org.apache.http.HttpConnection android.os.Looper android.os.Process android.content.BroadcastReceiver android.os.StatFs android.content.IntentFilter android.view.Display android.text.TextPaint android.content.SharedPreferences android.net.wifi.WifiManager android.widget.ProgressBar android.graphics.Typeface android.webkit.WebView android.hardware javax.microedition.khronos.egl android.widget.AbsoluteLayout android.widget.ImageButton android.media.MediaPlayer android.view.SurfaceHolder android.graphics.drawable.PaintDrawable android.view.WindowManager android.telephony.SmsManager android.telephony.SmsMessage javax.net.ssl.HostnameVerifier android.net.wifi.WifiInfo android.opengl.GLES20 javax.microedition.khronos.opengles.GL10 android.opengl.GLSurfaceView android.opengl.GLUtils android.webkit.WebSettings android.webkit.WebViewClient android.permission.INTERNET android.permission.ACCESS_WIFI_STATE android.permission.CHANGE_WIFI_STATE android.permission.DEVICE_POWER android.permission.WAKE_LOCK android.permission.READ_PHONE_STATE android.permission.RECEIVE_SMS android.permission.ACCESS_NETWORK_STATE android.permission.WRITE_EXTERNAL_STORAGE android.permission.VIBRATE android.permission.CHANGE_NETWORK_STATE android.permission.RESTART_PACKAGES android.permission.WRITE_SETTINGS android.permission.SEND_SMS android.permission.WRITE_SMS android.permission.READ_SMS javax.xml.parsers.SAXParserFactory org.apache.http.client.HttpClient javax.microedition.khronos.egl.EGL10
provides_symbols com.gameloft.android.ATT.GloftA6HP.asphalt6.installer.GameInstaller com.gameloft.android.ATT.GloftA6HP.asphalt6.MyVideoView com.gameloft.android.ATT.GloftA6HP.asphalt6.GLGame com.gameloft.android.ATT.GloftA6HP.asphalt6.GLiveMain com.gameloft.android.ATT.GloftA6HP.asphalt6.IGPMain com.gameloft.android.ATT.GloftA6HP.asphalt6.Billing.AndroidBilling com.gameloft.android.ATT.GloftA6HP.asphalt6.Billing.SmsReceiver
depends_on_objects libasphalt6.so core.jar ext.jar framework.jar SystemInfo.apk
dependent_objects
$ ./list_dependencies.sh SystemInfo.apk
object SystemInfo.apk
depends_on_symbols android.os.Bundle java.io android.os android.content.Context android.util.AttributeSet android.util.Log android.os.Handler android.content android.os.Message android.view.View android.os.SystemProperties android.graphics.Canvas android.text.TextUtils java.util.List android.app.Service android.os.Build android.graphics.Paint android.app.ActivityManager android.view.WindowManager android.permission.RECORD_AUDIO android.permission.ACCESS_FINE_LOCATION android.permission.WAKE_LOCK android.permission.WRITE_EXTERNAL_STORAGE android.permission.RECEIVE_BOOT_COMPLETED android.permission.GET_TASKS android.permission.SET_WALLPAPER android.permission.CAMERA android.permission.READ_OWNER_DATA android.permission.WRITE_OWNER_DATA
provides_symbols android.permission.WRITE_EXTERNAL_STORAGE android.samsung.SystemInfo.SystemInfoService android.samsung.SystemInfo.SystemInfoReceiver
depends_on_objects core.jar framework.jar SystemInfo.apk
dependent_objects ATTNavigator.apk Asphalt6_AdrenalineHD_SamsungSCH-i927_ML_IGP_ATT_MP_GLLive_DEMO_104.apk BluetoothOpp.apk BluetoothPbap.apk BooksPhone.apk Browser.apk CallSetting.apk Camera.apk CertInstaller.apk CityID-release.apk ClockPackage.apk Contacts.apk DataCreate.apk DefaultContainerService.apk Dlna.apk DownloadProvider.apk Email.apk FTC.apk FTM.apk FTS.apk Gallery3D.apk GenieWidget.apk Gmail.apk InputEventApp.apk JobManager.apk Kobo.apk Maps.apk MediaHub.apk MediaProvider.apk Memo.apk MiniDiary.apk Mms.apk MobilePrint.apk MtpApplication.apk MusicPlayer.apk MyFiles.apk NetworkLocation.apk PopupuiReceiver.apk PressReader.apk QuickView.apk Quickoffice.apk SamsungWidget_News.apk ScreenCaptureService.apk SecDownloadProvider.apk SecretWallpaper1.apk SecretWallpaper2.apk SelfTestMode.apk SocialHub.apk SoundPlayer.apk Superuser.apk SystemInfo.apk Talk2.apk Tasks.apk TelephonyProvider.apk TouchWiz30Launcher.apk TouchWizCalculator.apk TouchWizCalendar.apk TrimApp.apk TtsService.apk Vending.apk VideoPlayer.apk VoiceRecorder.apk VoiceSearch.apk Zinio.apk att_featuredapp.apk wssyncmldm.apk wssyncmlnps.apk
Grab the latest version here: http://romanr.info/android/deptree-0.1.1.zip
Sources/git: http://romanr.info/android/deptree.git

References/regards:
AXMLPrinter - http://code.google.com/p/android4me/downloads/list
arm-eabi-toolchain - https://www.codeaurora.org/git/proje...eabi-4.4.0/bin
dex2jar - http://code.google.com/p/dex2jar/downloads/list
jad - http://www.varaneckas.com/jad
smali - http://code.google.com/p/smali/downloads/list
The Following 19 Users Say Thank You to romanr For This Useful Post: [ View ] Gift romanr Ad-Free
16th June 2012, 08:15 PM |#2  
Nice tool man, but under windows 7 with cygwin i get DBI.pm missing error, and i cannot solve this problem at all. Any help?

Thank you.
16th June 2012, 08:30 PM |#3  
OP Senior Member
Flag Moscow
Thanks Meter: 41
 
More
Quote:
Originally Posted by mrbenbiz

under cygwin i get DBI.pm missing error

Try search & install for your cygwin something like libdbi-perl or libperl-dbi or dbi-perl. dbi-sqlite also needed.
26th August 2012, 01:03 PM |#4  
gade12's Avatar
Senior Member
Flag Salamanca
Thanks Meter: 76
 
More
When i try to path system rom dir, i get this message with all apks, libs...
error: DBD:SQLite:db selectrow_array failed: no such table: objects at xApp.pl

I am very interesting on that. thank!!
26th August 2012, 02:50 PM |#5  
OP Senior Member
Flag Moscow
Thanks Meter: 41
 
More
selectrow_array failed
Quote:
Originally Posted by gade12

error: DBD:SQLite:db selectrow_array failed: no such table: objects at xApp.pl

Try to remove all *.db files and run init_db.sh again.
27th August 2012, 01:29 PM |#6  
gade12's Avatar
Senior Member
Flag Salamanca
Thanks Meter: 76
 
More
Very nice/usefull tool!! it's work perfect!!
It's perfect for delete apps or port roms.
Thank for share it!
21st September 2012, 02:20 PM |#7  
_polimorph_'s Avatar
Senior Member
Flag Jibou, Transilvania
Thanks Meter: 1,130
 
Donate to Me
More
Looks like a very nice tool, but links are down. Anyone cares to share a working download link? Thanks.
21st September 2012, 02:27 PM |#8  
OP Senior Member
Flag Moscow
Thanks Meter: 41
 
More
Everything works!
Quote:
Originally Posted by _polimorph_

Anyone cares to share a working download link?

I've just checked every link - all links work.
Which exactly link doesn't work?
20th February 2013, 01:44 AM |#9  
Senior Member
Flag Chennai
Thanks Meter: 2,329
 
More
Hey , can you teach me how to use it ?
maybe edit ur post and add a guide on how to use it ?
thanks
20th February 2013, 07:59 AM |#10  
OP Senior Member
Flag Moscow
Thanks Meter: 41
 
More
Quote:
Originally Posted by monish1995

Hey , can you teach me how to use it ?
maybe edit ur post and add a guide on how to use it ?

Can u tell me what r u gonna do with it?
Why do you need this tool? What info in your development are you looking for?
23rd March 2013, 01:45 AM |#11  
Senior Member
Thanks Meter: 639
 
Donate to Me
More
Edit: should have read the readme first!
had to install the following packages to get it working on ubuntu: sqlite3 libdbi-perl libdigest-perl libdigest-crc-perl libdbd-sqlite3-perl

seems like an awesome tool, thanks a ton!
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes