├── .gitignore ├── AndroidManifest.xml ├── README.md ├── artworks ├── apptoolkit.ai ├── drawable-hdpi │ ├── ic_launcher.png │ └── icon.png ├── drawable-mdpi │ ├── ic_launcher.png │ └── icon.png ├── drawable-xhdpi │ ├── ic_launcher.png │ └── icon.png ├── ic_launcher.png ├── ic_launcher.psd ├── icon.psd └── screenshots │ ├── Screenshot_2013-06-22-18-43-27.png │ ├── Screenshot_2013-06-22-18-43-51.png │ ├── Screenshot_2013-06-22-18-44-10.png │ ├── Screenshot_2013-06-22-18-44-22.png │ ├── Screenshot_2013-06-22-18-44-28.png │ ├── Screenshot_2013-06-22-18-44-37.png │ ├── Screenshot_2013-06-22-18-44-53.png │ └── Screenshot_2013-06-22-18-45-01.png ├── jni └── android_os_FileUtils.cpp ├── mcxiaoke.keystore ├── pom.xml ├── release └── apptoolkit.apk ├── res ├── anim │ ├── fade_out_long.xml │ ├── zoom_enter.xml │ ├── zoom_enter_2.xml │ ├── zoom_exit.xml │ └── zoom_exit_2.xml ├── color │ ├── text_primary_selectable.xml │ └── text_secondary_selectable.xml ├── drawable-hdpi │ ├── ic_action_about.png │ ├── ic_action_help.png │ ├── ic_action_search.png │ ├── ic_action_settings.png │ ├── ic_av_replay.png │ ├── ic_collections_view_as_list.png │ ├── ic_content_attachment.png │ ├── ic_content_copy.png │ ├── ic_content_cut.png │ ├── ic_content_discard.png │ ├── ic_content_remove.png │ ├── ic_content_select_all.png │ ├── ic_device_access_storage.png │ ├── ic_launcher.png │ ├── ic_navigation_accept.png │ ├── ic_navigation_cancel.png │ ├── ic_navigation_refresh.png │ ├── ic_social_send_now.png │ ├── ic_social_share.png │ ├── icon.png │ ├── spinner_48_inner_holo.png │ └── spinner_48_outer_holo.png ├── drawable-mdpi │ ├── ic_action_about.png │ ├── ic_action_help.png │ ├── ic_action_search.png │ ├── ic_action_settings.png │ ├── ic_av_replay.png │ ├── ic_collections_view_as_list.png │ ├── ic_content_attachment.png │ ├── ic_content_copy.png │ ├── ic_content_cut.png │ ├── ic_content_discard.png │ ├── ic_content_remove.png │ ├── ic_device_access_storage.png │ ├── ic_launcher.png │ ├── ic_navigation_accept.png │ ├── ic_navigation_cancel.png │ ├── ic_navigation_refresh.png │ ├── ic_social_send_now.png │ ├── ic_social_share.png │ ├── icon.png │ ├── spinner_48_inner_holo.png │ └── spinner_48_outer_holo.png ├── drawable-xhdpi │ ├── ic_action_about.png │ ├── ic_action_help.png │ ├── ic_action_search.png │ ├── ic_action_settings.png │ ├── ic_av_replay.png │ ├── ic_collections_view_as_list.png │ ├── ic_content_attachment.png │ ├── ic_content_copy.png │ ├── ic_content_cut.png │ ├── ic_content_discard.png │ ├── ic_content_remove.png │ ├── ic_content_select_all.png │ ├── ic_device_access_storage.png │ ├── ic_fso_default.png │ ├── ic_fso_folder.png │ ├── ic_launcher.png │ ├── ic_navigation_accept.png │ ├── ic_navigation_cancel.png │ ├── ic_navigation_refresh.png │ ├── ic_social_send_now.png │ ├── ic_social_share.png │ ├── icon.png │ ├── spinner_48_inner_holo.png │ └── spinner_48_outer_holo.png ├── drawable │ ├── app_item_label.xml │ ├── background_transparent.xml │ ├── list_item_activated.xml │ ├── progress_medium_holo.xml │ ├── progress_small_holo.xml │ ├── selector.xml │ ├── selector_drawer_menu.xml │ ├── selector_drawer_menu_checked.xml │ ├── selector_drawer_menu_light_checked.xml │ ├── selector_drawer_menu_light_pressed.xml │ ├── selector_pressed.xml │ ├── spinner_32_inner_holo.png │ └── spinner_32_outer_holo.png ├── layout │ ├── action_bar_indeterminate_progress.xml │ ├── appdetail_header.xml │ ├── fm_appactions.xml │ ├── fm_appdetail.xml │ ├── fm_applist.xml │ ├── fm_menu.xml │ ├── list_item_action.xml │ ├── list_item_app.xml │ ├── list_item_menu.xml │ └── main.xml ├── menu │ ├── menu_home.xml │ └── menu_mode_applist.xml ├── raw │ ├── aid.properties │ ├── changelog │ └── mime_types.properties ├── values-v14 │ └── themes.xml ├── values-zh-rCN │ ├── arrays.xml │ └── strings.xml ├── values │ ├── analytics.xml │ ├── arrays.xml │ ├── colors.xml │ ├── dimens.xml │ ├── ids.xml │ ├── strings.xml │ ├── styles.xml │ └── themes.xml └── xml │ └── settings.xml └── src └── com └── mcxiaoke ├── apptoolkit ├── AppConfig.java ├── AppContext.java ├── Intents.java ├── adapter │ ├── AppActionsAdapter.java │ ├── AppListAdapter.java │ ├── ArrayAdapterCompat.java │ ├── BaseArrayAdapter.java │ └── MultiChoiceArrayAdapter.java ├── app │ ├── UIBaseSupport.java │ ├── UIHome.java │ ├── UISettings.java │ └── UIWelcome.java ├── cache │ └── CacheManager.java ├── callback │ └── IPackageMonitor.java ├── compress │ ├── Compress.java │ ├── Decompress.java │ ├── ZipFolder.java │ └── ZipUtils.java ├── db │ └── Database.java ├── exception │ └── NoPermissionException.java ├── fragment │ ├── AlertDialogFragment.java │ ├── BaseDialogFragment.java │ ├── BaseFragment.java │ ├── PackageListFragment.java │ └── Refreshable.java ├── menu │ ├── MenuCallback.java │ ├── MenuFragment.java │ ├── MenuItemResource.java │ ├── PopupMenuFragment.java │ └── PopupMenuItem.java ├── model │ ├── AppInfo.java │ └── BaseModel.java ├── preference │ └── MultipleChoicePreference.java ├── receiver │ └── PackageMonitor.java ├── service │ ├── BackgroundService.java │ ├── BaseService.java │ └── ExtendedRunnable.java ├── task │ ├── AsyncTaskBase.java │ ├── AsyncTaskCallback.java │ ├── BackupAppsApkTask.java │ ├── BackupAppsDataTask.java │ ├── LoadAppsTask.java │ ├── LoadRunningProcessTask.java │ ├── SimpleAsyncTask.java │ ├── SimpleAsyncTaskCallback.java │ ├── SimpleCommandTask.java │ ├── TaskMessage.java │ └── ThreadPool.java └── util │ ├── AppUtils.java │ ├── DeviceUtils.java │ ├── DialogUtils.java │ ├── IOHelper.java │ ├── StringHelper.java │ └── Utils.java ├── shell ├── Shell.java ├── model │ ├── ErrorCode.java │ ├── Mount.java │ ├── Permissions.java │ ├── Symlink.java │ └── fso │ │ ├── AID.java │ │ ├── BlockDevice.java │ │ ├── CharacterDevice.java │ │ ├── Directory.java │ │ ├── DiskUsage.java │ │ ├── DomainSocket.java │ │ ├── FileSystemObject.java │ │ ├── Group.java │ │ ├── GroupPermission.java │ │ ├── Identity.java │ │ ├── MountPoint.java │ │ ├── NamedPipe.java │ │ ├── OthersPermission.java │ │ ├── ParentDirectory.java │ │ ├── Permission.java │ │ ├── Permissions.java │ │ ├── Query.java │ │ ├── RegularFile.java │ │ ├── SearchResult.java │ │ ├── Symlink.java │ │ ├── SystemFile.java │ │ ├── User.java │ │ └── UserPermission.java ├── others │ ├── ApkUtils.java │ ├── BusyboxUtils.java │ ├── CacheUtils.java │ ├── ComponentUtils.java │ ├── Compress.java │ ├── DIPairUtils.java │ ├── DalvikUtils.java │ ├── Decompress.java │ ├── DeviceUtils.java │ ├── FileBrowser.java │ ├── HostsUtils.java │ ├── MemorySpecialList.java │ ├── MemoryUtils.java │ ├── ProcessUtils.java │ ├── RemoteAdbd.java │ └── ShellInterface.java └── utils │ ├── AIDHelper.java │ ├── FileHelper.java │ ├── ParseHelper.java │ └── Remounter.java └── view └── ABSListView.java /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.ap_ 3 | 4 | # files for the dex VM 5 | *.dex 6 | 7 | # Java class files 8 | *.class 9 | 10 | # generated files 11 | bin/ 12 | gen/ 13 | target/ 14 | gen-external-apklibs/ 15 | 16 | # Local configuration file (sdk path, etc) 17 | local.properties 18 | project.properties 19 | 20 | # Eclipse project files 21 | .classpath 22 | .project 23 | .idea 24 | *.iml 25 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 35 | 36 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/README.md -------------------------------------------------------------------------------- /artworks/apptoolkit.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/apptoolkit.ai -------------------------------------------------------------------------------- /artworks/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /artworks/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /artworks/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /artworks/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /artworks/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /artworks/drawable-xhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/drawable-xhdpi/icon.png -------------------------------------------------------------------------------- /artworks/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/ic_launcher.png -------------------------------------------------------------------------------- /artworks/ic_launcher.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/ic_launcher.psd -------------------------------------------------------------------------------- /artworks/icon.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/icon.psd -------------------------------------------------------------------------------- /artworks/screenshots/Screenshot_2013-06-22-18-43-27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/screenshots/Screenshot_2013-06-22-18-43-27.png -------------------------------------------------------------------------------- /artworks/screenshots/Screenshot_2013-06-22-18-43-51.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/screenshots/Screenshot_2013-06-22-18-43-51.png -------------------------------------------------------------------------------- /artworks/screenshots/Screenshot_2013-06-22-18-44-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/screenshots/Screenshot_2013-06-22-18-44-10.png -------------------------------------------------------------------------------- /artworks/screenshots/Screenshot_2013-06-22-18-44-22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/screenshots/Screenshot_2013-06-22-18-44-22.png -------------------------------------------------------------------------------- /artworks/screenshots/Screenshot_2013-06-22-18-44-28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/screenshots/Screenshot_2013-06-22-18-44-28.png -------------------------------------------------------------------------------- /artworks/screenshots/Screenshot_2013-06-22-18-44-37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/screenshots/Screenshot_2013-06-22-18-44-37.png -------------------------------------------------------------------------------- /artworks/screenshots/Screenshot_2013-06-22-18-44-53.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/screenshots/Screenshot_2013-06-22-18-44-53.png -------------------------------------------------------------------------------- /artworks/screenshots/Screenshot_2013-06-22-18-45-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/artworks/screenshots/Screenshot_2013-06-22-18-45-01.png -------------------------------------------------------------------------------- /mcxiaoke.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/mcxiaoke.keystore -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.mcxiaoke.apptoolkit 6 | apptoolkit 7 | 1.0.0-SNAPSHOT 8 | apk 9 | App Toolkit 10 | 11 | 12 | UTF-8 13 | UTF-8 14 | 1.6 15 | 4.1.1.4 16 | 17 17 | r13 18 | 3.6.0 19 | 4.3.1 20 | 21 | 22 | 23 | 24 | github-repo 25 | github-repo 26 | https://raw.github.com/mcxiaoke/mavenrepo/master/repository/ 27 | 28 | 29 | 30 | 31 | 32 | com.google.android 33 | android 34 | ${android.version} 35 | provided 36 | 37 | 38 | 39 | com.google.android 40 | support-v4 41 | ${android-support.version} 42 | 43 | 44 | 45 | com.google.android.analytics 46 | analytics 47 | 3 48 | 49 | 50 | 51 | com.google.code.gson 52 | gson 53 | 2.2.4 54 | 55 | 56 | 57 | com.actionbarsherlock 58 | actionbarsherlock 59 | ${actionbarsherlock.version} 60 | apklib 61 | 62 | 63 | 64 | de.psdev.licensesdialog 65 | licensesdialog 66 | 1.1.0 67 | apklib 68 | 69 | 70 | 71 | 72 | 73 | 74 | ${project.artifactId} 75 | src 76 | 77 | 78 | 79 | com.jayway.maven.plugins.android.generation2 80 | android-maven-plugin 81 | ${android-maven.version} 82 | true 83 | 84 | 85 | 86 | 87 | 88 | com.jayway.maven.plugins.android.generation2 89 | android-maven-plugin 90 | 91 | 92 | ${android.platform} 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /release/apptoolkit.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/release/apptoolkit.apk -------------------------------------------------------------------------------- /res/anim/fade_out_long.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /res/anim/zoom_enter.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 18 | 20 | 21 | 29 | 30 | -------------------------------------------------------------------------------- /res/anim/zoom_enter_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 24 | 33 | 34 | 38 | -------------------------------------------------------------------------------- /res/anim/zoom_exit.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 26 | 29 | 30 | 38 | 39 | 43 | 44 | -------------------------------------------------------------------------------- /res/anim/zoom_exit_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 18 | 20 | 21 | 29 | 30 | 35 | 36 | -------------------------------------------------------------------------------- /res/color/text_primary_selectable.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /res/color/text_secondary_selectable.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_action_about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_action_about.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_action_help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_action_help.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_action_search.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_action_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_action_settings.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_av_replay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_av_replay.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_collections_view_as_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_collections_view_as_list.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_content_attachment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_content_attachment.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_content_copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_content_copy.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_content_cut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_content_cut.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_content_discard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_content_discard.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_content_remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_content_remove.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_content_select_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_content_select_all.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_device_access_storage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_device_access_storage.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_navigation_accept.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_navigation_accept.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_navigation_cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_navigation_cancel.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_navigation_refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_navigation_refresh.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_social_send_now.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_social_send_now.png -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_social_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/ic_social_share.png -------------------------------------------------------------------------------- /res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /res/drawable-hdpi/spinner_48_inner_holo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/spinner_48_inner_holo.png -------------------------------------------------------------------------------- /res/drawable-hdpi/spinner_48_outer_holo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-hdpi/spinner_48_outer_holo.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_action_about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_action_about.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_action_help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_action_help.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_action_search.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_action_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_action_settings.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_av_replay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_av_replay.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_collections_view_as_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_collections_view_as_list.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_content_attachment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_content_attachment.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_content_copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_content_copy.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_content_cut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_content_cut.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_content_discard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_content_discard.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_content_remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_content_remove.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_device_access_storage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_device_access_storage.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_navigation_accept.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_navigation_accept.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_navigation_cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_navigation_cancel.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_navigation_refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_navigation_refresh.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_social_send_now.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_social_send_now.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_social_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/ic_social_share.png -------------------------------------------------------------------------------- /res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /res/drawable-mdpi/spinner_48_inner_holo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/spinner_48_inner_holo.png -------------------------------------------------------------------------------- /res/drawable-mdpi/spinner_48_outer_holo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-mdpi/spinner_48_outer_holo.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_action_about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_action_about.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_action_help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_action_help.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_action_search.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_action_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_action_settings.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_av_replay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_av_replay.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_collections_view_as_list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_collections_view_as_list.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_content_attachment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_content_attachment.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_content_copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_content_copy.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_content_cut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_content_cut.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_content_discard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_content_discard.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_content_remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_content_remove.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_content_select_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_content_select_all.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_device_access_storage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_device_access_storage.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_fso_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_fso_default.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_fso_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_fso_folder.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_navigation_accept.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_navigation_accept.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_navigation_cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_navigation_cancel.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_navigation_refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_navigation_refresh.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_social_send_now.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_social_send_now.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_social_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/ic_social_share.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/icon.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/spinner_48_inner_holo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/spinner_48_inner_holo.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/spinner_48_outer_holo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable-xhdpi/spinner_48_outer_holo.png -------------------------------------------------------------------------------- /res/drawable/app_item_label.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 28 | 33 | 34 | -------------------------------------------------------------------------------- /res/drawable/background_transparent.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /res/drawable/list_item_activated.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /res/drawable/progress_medium_holo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /res/drawable/progress_small_holo.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 25 | 26 | 27 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /res/drawable/selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /res/drawable/selector_drawer_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /res/drawable/selector_drawer_menu_checked.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /res/drawable/selector_drawer_menu_light_checked.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /res/drawable/selector_drawer_menu_light_pressed.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /res/drawable/selector_pressed.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /res/drawable/spinner_32_inner_holo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable/spinner_32_inner_holo.png -------------------------------------------------------------------------------- /res/drawable/spinner_32_outer_holo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcxiaoke/apptoolkit/1887ad22890c83d13c4f2ebfc727b3f886e9126c/res/drawable/spinner_32_outer_holo.png -------------------------------------------------------------------------------- /res/layout/action_bar_indeterminate_progress.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | -------------------------------------------------------------------------------- /res/layout/appdetail_header.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /res/layout/fm_appactions.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /res/layout/fm_appdetail.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /res/layout/fm_applist.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /res/layout/fm_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | 20 | 21 | 22 | 28 | 29 | -------------------------------------------------------------------------------- /res/layout/list_item_action.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 20 | 21 | -------------------------------------------------------------------------------- /res/layout/list_item_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 22 | 23 | -------------------------------------------------------------------------------- /res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 14 | 15 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /res/menu/menu_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /res/menu/menu_mode_applist.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 16 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /res/raw/aid.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2012 The CyanogenMod 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 | # 18 | # Android ID list (from system/core/include/private/android_filesystem_config.h) 19 | # 20 | # Format: 21 | # = 22 | # 23 | 24 | 0 = root 25 | 1000 = system 26 | 1001 = radio 27 | 1002 = bluetooth 28 | 1003 = graphics 29 | 1004 = input 30 | 1005 = audio 31 | 1006 = camera 32 | 1007 = log 33 | 1008 = compass 34 | 1009 = mount 35 | 1010 = wifi 36 | 1011 = adb 37 | 1012 = install 38 | 1013 = media 39 | 1014 = dhcp 40 | 1015 = sdcard_rw 41 | 1016 = vpn 42 | 1017 = keystore 43 | 1018 = usb 44 | 1019 = drm 45 | 1020 = mdnsr 46 | 1021 = gps 47 | 1023 = media_rw 48 | 1024 = mtp 49 | 1026 = drmrpc 50 | 1027 = nfc 51 | 1028 = sdcard_r 52 | 2000 = shell 53 | 2001 = cache 54 | 2002 = diag 55 | 3001 = net_bt_admin 56 | 3002 = net_bt 57 | 3003 = inet 58 | 3004 = net_raw 59 | 3005 = net_admin 60 | 3006 = net_bw_stats 61 | 3007 = net_bw_acct 62 | 3008 = qcom_oncrpc 63 | 3009 = qcom_diag 64 | 9998 = misc 65 | 9999 = nobody 66 | 67 | -------------------------------------------------------------------------------- /res/raw/changelog: -------------------------------------------------------------------------------- 1 | CyanogenMod File Manager 2 | ======================== 3 | 4 | Version 1.0.1 5 | ------------- 6 | * NFC support 7 | * Themes support 8 | 9 | Version 1.0.0 10 | ------------- 11 | Initial release. 12 | 13 | Features: 14 | 15 | * 3 navigation modes: 16 | · Safe mode (by default) 17 | · Prompt user mode 18 | · Root mode 19 | * History 20 | * Bookmarks 21 | * Search 22 | * Pick browsing 23 | * Breadcrumb browsing 24 | * Multiple selection 25 | * Layout view selection 26 | * Sort order selection 27 | * Show/Hide system files 28 | * Compression and uncompression 29 | * Add shortcuts to desktop 30 | * Mount and unmount file systems 31 | * Change file permissions 32 | * File system information 33 | * File information 34 | * Open and Open With 35 | * Send to 36 | * Internal editor 37 | 38 | -------------------------------------------------------------------------------- /res/values-v14/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 | 23 | 24 | -------------------------------------------------------------------------------- /res/values-zh-rCN/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 应用管理 6 | 进程管理 7 | 服务管理 8 | 自启动管理 9 | 10 | -------------------------------------------------------------------------------- /res/values-zh-rCN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | App Toolkit 4 | 获取ROOT权限成功 5 | 获取ROOT权限失败 6 | 刷新 7 | 设置 8 | 备份 9 | 10 | 11 | 选择应用 12 | 已选择%1$d项 13 | 选择全部 14 | 取消选择 15 | 卸载应用 16 | 备份应用 17 | 备份数据 18 | 19 | 正在备份 20 | 21 | 备份应用 22 | 备份数据 23 | 确定备份所选应用的安装文件到存储卡? 24 | 确定备份所选应用的数据到存储卡? 25 | 26 | 应用备份完成 27 | 应用已全部备份到%1$s,备份应用总数:%2$d,本次新增: %3$d 28 | 数据备份完成 29 | 数据已全部备份到%1$s,备份应用数据总数:%2$d,本次新增: %3$d 30 | 31 | %1$s的安装文件已成功备份到%2$s 32 | %1$s的数据已成功备份到%2$s 33 | %1$s数据已从备份中恢复 34 | Root权限获取失败,无法备份数据. 35 | 36 | 37 | 进入应用管理 38 | 查看应用详情 39 | 备份安装文件 40 | 备份应用数据 41 | 从备份恢复数据 42 | 显示应用数据 43 | 清除应用数据 44 | 清除应用缓存 45 | 安装应用 46 | 卸载应用 47 | 静默安装 48 | 静默卸载 49 | 禁用此应用 50 | 启用此应用 51 | 结束应用 52 | 结束进程 53 | 安装为系统应用 54 | 删除系统应用 55 | 市场信息 56 | 复制包名 57 | 查看清单文件 58 | 查看资源文件 59 | 60 | 61 | 应用管理 62 | 备份管理 63 | 进程管理 64 | 组件管理 65 | 启动管理 66 | 服务管理 67 | 文件管理 68 | 缓存清理 69 | 网络防火墙 70 | 工具箱 71 | 关于应用 72 | 73 | 选择操作 74 | 75 | 76 | 版本信息 77 | 当前版本: %1$s 78 | 79 | 项目地址 80 | 81 | 82 | -------------------------------------------------------------------------------- /res/values/analytics.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | UA-41944843-1 5 | 6 | 7 | true 8 | 9 | 10 | true 11 | -------------------------------------------------------------------------------- /res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Apps 6 | Processes 7 | Services 8 | Receivers 9 | 10 | -------------------------------------------------------------------------------- /res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #FFFFFFFF 5 | #FF000000 6 | #FFFFFFFF 7 | #FF000000 8 | #FF999999 9 | #FF333333 10 | #FFCCCCCC 11 | #FF333333 12 | #FF666666 13 | #FF999999 14 | 15 | 16 | #FFCC0000 17 | 18 | 19 | 20 | #20999999 21 | 22 | #66CCCCCC 23 | 24 | #C0000000 25 | 26 | #33666666 27 | #66666666 28 | #CC269926 29 | #FF269926 30 | 31 | #FF101010 32 | #FF666666 33 | 34 | #FFF0F0F0 35 | #FFE0E0E0 36 | 37 | 38 | #ff0099cc 39 | #800099cc 40 | #200099cc 41 | #ff28a5c0 42 | 43 | #ffb2cb39 44 | #80b2cb39 45 | #20b2cb39 46 | #ff96aa39 47 | 48 | #ff3f9fe0 49 | #803f9fe0 50 | #203f9fe0 51 | #ff3687bf 52 | 53 | #ffc74b46 54 | #80c74b46 55 | #20c74b46 56 | #ff943c39 57 | 58 | #fff4842d 59 | #80f4842d 60 | #20f4842d 61 | #ffd77428 62 | 63 | #ff5161bc 64 | #805161bc 65 | #205161bc 66 | #ff384c9e 67 | 68 | #ff585858 69 | #80585858 70 | #20585858 71 | #ff4d4d4d 72 | 73 | #FF33B5E5 74 | 75 | #FFE0E0E0 76 | #6633B5E5 77 | 78 | #FFE0E0E0 79 | #8033B5E5 80 | 81 | -------------------------------------------------------------------------------- /res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10dp 6 | 12dp 7 | 14dp 8 | 16dp 9 | 18dp 10 | 20dp 11 | 24dp 12 | 13 | 48dp 14 | 48dp 15 | 48dp 16 | 17 | -------------------------------------------------------------------------------- /res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | -------------------------------------------------------------------------------- /res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 14 | 15 | 17 | 18 | 25 | 26 | 27 | 31 | 32 | 35 | 36 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /res/xml/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 12 | 13 | 14 | 18 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit; 2 | 3 | /** 4 | * Project: filemanager 5 | * Package: com.com.mcxiaoke.appmanager 6 | * User: com.mcxiaoke 7 | * Date: 13-6-11 8 | * Time: 下午1:20 9 | */ 10 | public class AppConfig { 11 | 12 | public static final String APP_TOOL_DIR = "AppToolkit"; 13 | public static final String BACKUP_APPS_DIR = "apps"; 14 | public static final String BACKUP_DATA_DIR = "data"; 15 | 16 | public static final String EXTRA_APPINFO = "extra_appinfo"; 17 | public static final String EXTRA_ID = "extra_ID"; 18 | public static final String EXTRA_TYPE = "extra_type"; 19 | public static final String EXTRA_TEXT = "extra_text"; 20 | public static final String EXTRA_COUNT = "extra_count"; 21 | public static final String EXTRA_FLAG = "extra_flag"; 22 | public static final String EXTRA_ADVANCED = "extra_advanced"; 23 | public static final String EXTRA_SYSTEM = "extra_system"; 24 | public static final String EXTRA_PACKAGE = "extra_package"; 25 | public static final String EXTRA_STRING_LIST = "extra_string_list"; 26 | public static final String EXTRA_CACHE_ID = "extra_cache_id"; 27 | 28 | public static final int TYPE_USER_APP_MANAGER = 0; 29 | public static final int TYPE_SYSTEM_APP_MANAGER = 2; 30 | public static final int TYPE_PROCESS_MANAGER = 4; 31 | public static final int TYPE_DATA_MANAGER = 6; 32 | public static final int TYPE_CACHE_MANAGER = 8; 33 | public static final int TYPE_COMPONENT_MANAGER = 10; 34 | public static final int TYPE_FILE_MANAGER = 12; 35 | 36 | public static final int CMD_BACKUP_APP_ONE = 50; 37 | public static final int CMD_BACKUP_DATA_ONE = 52; 38 | public static final int CMD_SILENT_INSTAlL_ONE = 54; 39 | public static final int CMD_SILENT_UNINSTALL_ONE = 56; 40 | public static final int CMD_CLEAR_CACHE_ONE = 58; 41 | public static final int CMD_CLEAR_DATA_ONE = 60; 42 | public static final int CMD_INSTALL_SYSTEM_APP_ONE = 62; 43 | public static final int CMD_UNINSTALL_SYSTEM_APP_ONE = 64; 44 | 45 | public static final int CMD_RESTORE_APP_ONE = 70; 46 | public static final int CMD_RESTORE_DATA_ONE = 71; 47 | 48 | public static final int DOMAIN_ANDROID = 101; 49 | public static final int DOMAIN_GOOGLE = 102; 50 | public static final int DOMAIN_WHITELIST = 103; 51 | public static final int DOMAIN_BLACKLIST = 104; 52 | public static final int DOMAIN_NORMAL = 105; 53 | 54 | public static final String DOMAIN_NAME_ANDROID = "Android"; 55 | public static final String DOMAIN_NAME_GOOGLE = "Google"; 56 | public static final String DOMAIN_NAME_WHITELIST = "Whitelist"; 57 | public static final String DOMAIN_NAME_BLACKLIST = "Blacklist"; 58 | public static final String DOMAIN_NAME_NORMAL = "Normal"; 59 | 60 | 61 | public static final String APK_MIME_TYPE = "application/vnd.android.package-archive"; 62 | /** 63 | * The patch for some android version and devices. Install may fail without 64 | * this patch. 65 | */ 66 | public static final String COMMAND_INSTALL_PATCH = "LD_LIBRARY_PATH=/vendor/lib:/system/lib "; 67 | 68 | public static final String SETTINGS_PACKAGE = "com.android.settings"; 69 | 70 | public static final String SYSTEM_APP_PATH = "/system/app"; 71 | public static final String USER_APP_PATH = "/data/app"; 72 | public static final String APP_DATA_PATH = "/data/data"; 73 | public static final String BUSYBOX_PATH = "/system/xbin/busybox"; 74 | public static final String ANDROID_APP_PACKAGE_PREFIX = "com.android."; 75 | public static final String GOOGLE_APP_PACKAGE_PREFIX = "com.google.android"; 76 | 77 | public static final int UID_ROOT = 0; 78 | public static final int UID_SYSTEM = 1000; 79 | } 80 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/Intents.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit; 2 | 3 | /** 4 | * Project: apptoolkit 5 | * Package: com.mcxiaoke 6 | * User: mcxiaoke 7 | * Date: 13-6-16 8 | * Time: 下午1:50 9 | */ 10 | public class Intents { 11 | } 12 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/adapter/AppActionsAdapter.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.TextView; 7 | import com.mcxiaoke.apptoolkit.R; 8 | import com.mcxiaoke.apptoolkit.menu.PopupMenuItem; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * Project: filemanager 14 | * Package: com.mcxiaoke.appmanager.adapter 15 | * User: mcxiaoke 16 | * Date: 13-6-12 17 | * Time: 下午11:00 18 | */ 19 | public class AppActionsAdapter extends BaseArrayAdapter { 20 | 21 | public AppActionsAdapter(Context context, List objects) { 22 | super(context, objects); 23 | } 24 | 25 | @Override 26 | public View getView(int position, View convertView, ViewGroup parent) { 27 | ViewHolder holder; 28 | if (convertView == null) { 29 | convertView = mInflater.inflate(R.layout.list_item_action, null); 30 | holder = new ViewHolder(); 31 | holder.textView = (TextView) convertView.findViewById(R.id.action); 32 | convertView.setTag(holder); 33 | } else { 34 | holder = (ViewHolder) convertView.getTag(); 35 | } 36 | 37 | holder.textView.setText(getItem(position).name); 38 | return convertView; 39 | } 40 | 41 | private static class ViewHolder { 42 | TextView textView; 43 | } 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/adapter/BaseArrayAdapter.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.adapter; 2 | 3 | import android.content.Context; 4 | import android.os.Handler; 5 | import android.os.Looper; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * Project: filemanager 14 | * Package: com.mcxiaoke.appmanager.adapter 15 | * User: mcxiaoke 16 | * Date: 13-6-12 17 | * Time: 下午11:00 18 | */ 19 | public abstract class BaseArrayAdapter extends ArrayAdapterCompat { 20 | protected Context mContext; 21 | protected LayoutInflater mInflater; 22 | protected Handler mUiHandler; 23 | 24 | public BaseArrayAdapter(Context context, List objects) { 25 | super(context, objects); 26 | initialize(context); 27 | } 28 | 29 | private void initialize(Context context) { 30 | mContext = context; 31 | mInflater = LayoutInflater.from(context); 32 | mUiHandler = new Handler(Looper.getMainLooper()); 33 | } 34 | 35 | @Override 36 | public abstract View getView(int position, View convertView, ViewGroup parent); 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/app/UIBaseSupport.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.app; 2 | 3 | import android.os.Bundle; 4 | import android.os.Looper; 5 | import com.actionbarsherlock.app.SherlockFragmentActivity; 6 | import com.actionbarsherlock.view.MenuItem; 7 | import com.actionbarsherlock.view.Window; 8 | import com.mcxiaoke.apptoolkit.AppContext; 9 | 10 | /** 11 | * Project: DoubanShuo 12 | * User: com.mcxiaoke 13 | * Date: 13-5-30 14 | * Time: 上午9:58 15 | */ 16 | public class UIBaseSupport extends SherlockFragmentActivity { 17 | 18 | protected static final boolean DEBUG = AppContext.isDebug(); 19 | 20 | protected void debug(String message) { 21 | AppContext.v(message); 22 | } 23 | 24 | protected void error(String message) { 25 | AppContext.e(message); 26 | } 27 | 28 | @Override 29 | protected void onCreate(Bundle savedInstanceState) { 30 | super.onCreate(savedInstanceState); 31 | requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); 32 | } 33 | 34 | @Override 35 | protected void onResume() { 36 | super.onResume(); 37 | } 38 | 39 | 40 | @Override 41 | protected void onPause() { 42 | super.onPause(); 43 | } 44 | 45 | @Override 46 | protected void onPostResume() { 47 | super.onPostResume(); 48 | } 49 | 50 | 51 | @Override 52 | protected void onStop() { 53 | super.onStop(); 54 | } 55 | 56 | @Override 57 | protected void onStart() { 58 | super.onStart(); 59 | } 60 | 61 | 62 | @Override 63 | protected void onDestroy() { 64 | super.onDestroy(); 65 | } 66 | 67 | 68 | @Override 69 | public void onBackPressed() { 70 | super.onBackPressed(); 71 | } 72 | 73 | 74 | @Override 75 | protected void onRestoreInstanceState(Bundle savedInstanceState) { 76 | super.onRestoreInstanceState(savedInstanceState); 77 | } 78 | 79 | @Override 80 | protected void onSaveInstanceState(Bundle outState) { 81 | super.onSaveInstanceState(outState); 82 | } 83 | 84 | @Override 85 | protected void onTitleChanged(CharSequence title, int color) { 86 | super.onTitleChanged(title, color); 87 | } 88 | 89 | 90 | @Override 91 | public void onContentChanged() { 92 | super.onContentChanged(); 93 | } 94 | 95 | @Override 96 | public boolean onOptionsItemSelected(MenuItem item) { 97 | if (android.R.id.home == item.getItemId()) { 98 | onHomeClick(); 99 | return true; 100 | } 101 | return super.onOptionsItemSelected(item); 102 | } 103 | 104 | protected void onHomeClick() { 105 | onBackPressed(); 106 | } 107 | 108 | private boolean mRefreshing; 109 | 110 | public boolean isRefreshing() { 111 | return mRefreshing; 112 | } 113 | 114 | private void showActionBarProgress() { 115 | ensureMainThread(); 116 | mRefreshing = true; 117 | invalidateOptionsMenu(); 118 | } 119 | 120 | private void hideActionBarProgress() { 121 | ensureMainThread(); 122 | mRefreshing = false; 123 | invalidateOptionsMenu(); 124 | } 125 | 126 | protected void showProgressIndicator() { 127 | setSupportProgressBarIndeterminateVisibility(true); 128 | } 129 | 130 | protected void hideProgressIndicator() { 131 | setSupportProgressBarIndeterminateVisibility(false); 132 | } 133 | 134 | 135 | public void showProgress() { 136 | if (hasRefreshAction()) { 137 | showActionBarProgress(); 138 | } else { 139 | showProgressIndicator(); 140 | } 141 | } 142 | 143 | public void hideProgress() { 144 | if (hasRefreshAction()) { 145 | hideActionBarProgress(); 146 | } else { 147 | hideProgressIndicator(); 148 | } 149 | } 150 | 151 | protected void ensureMainThread() { 152 | Looper looper = Looper.myLooper(); 153 | if (looper != null && looper != getMainLooper()) { 154 | throw new IllegalStateException("Only call this from your main thread."); 155 | } 156 | } 157 | 158 | protected boolean hasRefreshAction() { 159 | return false; 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/app/UISettings.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.app; 2 | 3 | import android.os.Bundle; 4 | import android.preference.Preference; 5 | import com.actionbarsherlock.app.SherlockPreferenceActivity; 6 | import com.actionbarsherlock.view.MenuItem; 7 | import com.mcxiaoke.apptoolkit.AppContext; 8 | import com.mcxiaoke.apptoolkit.R; 9 | 10 | /** 11 | * Project: apptoolkit 12 | * Package: com.mcxiaoke.apptoolkit.app 13 | * User: mcxiaoke 14 | * Date: 13-6-22 15 | * Time: 下午6:02 16 | */ 17 | public class UISettings extends SherlockPreferenceActivity { 18 | 19 | @Override 20 | protected void onCreate(Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | 23 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 24 | addPreferencesFromResource(R.xml.settings); 25 | 26 | StringBuilder builder = new StringBuilder(); 27 | builder.append("v").append(AppContext.getVersionName()).append(" Build").append(AppContext.getVersionCode()); 28 | String versionInfo = String.format(getString(R.string.pref_version_summary, builder.toString())); 29 | Preference version = findPreference(getString(R.string.pref_version_key)); 30 | version.setSummary(versionInfo); 31 | } 32 | 33 | @Override 34 | public boolean onOptionsItemSelected(MenuItem item) { 35 | if (android.R.id.home == item.getItemId()) { 36 | onBackPressed(); 37 | return true; 38 | } 39 | return super.onOptionsItemSelected(item); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/app/UIWelcome.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.app; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | 6 | public class UIWelcome extends UIBaseSupport { 7 | 8 | @Override 9 | protected void onCreate(Bundle savedInstanceState) { 10 | super.onCreate(savedInstanceState); 11 | startActivity(new Intent(this, UIHome.class)); 12 | finish(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/cache/CacheManager.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.cache; 2 | 3 | import android.graphics.drawable.Drawable; 4 | import com.mcxiaoke.apptoolkit.model.AppInfo; 5 | 6 | import java.util.Collection; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.concurrent.CopyOnWriteArrayList; 10 | 11 | /** 12 | * Project: apptoolkit 13 | * Package: com.mcxiaoke.apptoolkit.cache 14 | * User: com.mcxiaoke 15 | * Date: 13-6-11 16 | * Time: 上午12:09 17 | */ 18 | public class CacheManager { 19 | private static CacheManager sInstance = new CacheManager(); 20 | 21 | private final Object mLock = new Object(); 22 | 23 | private HashMap mIconCache; 24 | private List mAppInfoCache; 25 | 26 | public static CacheManager getInstance() { 27 | return sInstance; 28 | } 29 | 30 | private CacheManager() { 31 | mIconCache = new HashMap(); 32 | mAppInfoCache = new CopyOnWriteArrayList(); 33 | } 34 | 35 | public boolean addAll(Collection apps) { 36 | if (apps == null || apps.isEmpty()) { 37 | return false; 38 | } 39 | synchronized (mLock) { 40 | mAppInfoCache.addAll(apps); 41 | } 42 | return true; 43 | } 44 | 45 | public List getAll() { 46 | return mAppInfoCache; 47 | } 48 | 49 | public boolean remove(AppInfo app) { 50 | synchronized (mLock) { 51 | return mAppInfoCache.remove(app); 52 | } 53 | } 54 | 55 | public boolean putIcon(String key, Drawable drawable) { 56 | if (key == null || drawable == null) { 57 | return false; 58 | } 59 | synchronized (mLock) { 60 | mIconCache.put(key, drawable); 61 | } 62 | return true; 63 | } 64 | 65 | public Drawable getIcon(String key) { 66 | if (key == null) { 67 | return null; 68 | } 69 | Drawable drawable = mIconCache.get(key); 70 | if (drawable == null) { 71 | synchronized (mLock) { 72 | mIconCache.remove(key); 73 | } 74 | } 75 | return drawable; 76 | } 77 | 78 | public synchronized void clear() { 79 | synchronized (mLock) { 80 | mIconCache.clear(); 81 | mAppInfoCache.clear(); 82 | } 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/callback/IPackageMonitor.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.callback; 2 | 3 | /** 4 | * Project: appmanager 5 | * User: mcxiaoke 6 | * Date: 13-6-13 7 | * Time: 下午3:22 8 | */ 9 | public interface IPackageMonitor { 10 | 11 | public void onPackageAdded(String packageName, int uid); 12 | 13 | public void onPackageRemoved(String packageName, int uid); 14 | 15 | public void onPackageModified(String packageName); 16 | 17 | public void onPackageChanged(String packageName, int uid, String[] components); 18 | 19 | public void onUidRemoved(int uid); 20 | } 21 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/compress/Compress.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.compress; 2 | 3 | import android.util.Log; 4 | 5 | import java.io.BufferedInputStream; 6 | import java.io.BufferedOutputStream; 7 | import java.io.FileInputStream; 8 | import java.io.FileOutputStream; 9 | import java.util.zip.ZipEntry; 10 | import java.util.zip.ZipOutputStream; 11 | 12 | 13 | public class Compress { 14 | 15 | private static final int BUFFER = 4096; 16 | 17 | private String[] files; 18 | private String zipFile; 19 | 20 | public Compress(String[] files, String zipFile) { 21 | this.files = files; 22 | this.zipFile = zipFile; 23 | } 24 | 25 | public void zip(String location) { 26 | try { 27 | BufferedInputStream origin = null; 28 | FileOutputStream dest = new FileOutputStream(zipFile); 29 | 30 | ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest)); 31 | 32 | byte data[] = new byte[BUFFER]; 33 | 34 | for (int i = 0; i < files.length; i++) { 35 | Log.v("Compress", "Adding: " + files[i]); 36 | FileInputStream fi = new FileInputStream(files[i]); 37 | origin = new BufferedInputStream(fi, BUFFER); 38 | ZipEntry entry = new ZipEntry(files[i].substring(files[i].lastIndexOf(location) + 1)); 39 | out.putNextEntry(entry); 40 | int count; 41 | while ((count = origin.read(data, 0, BUFFER)) != -1) { 42 | out.write(data, 0, count); 43 | } 44 | origin.close(); 45 | } 46 | 47 | out.close(); 48 | } catch (Exception e) { 49 | e.printStackTrace(); 50 | } 51 | 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/compress/Decompress.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.compress; 2 | 3 | import android.util.Log; 4 | 5 | import java.io.BufferedInputStream; 6 | import java.io.BufferedOutputStream; 7 | import java.io.File; 8 | import java.io.FileOutputStream; 9 | import java.io.IOException; 10 | import java.util.Enumeration; 11 | import java.util.zip.ZipEntry; 12 | import java.util.zip.ZipFile; 13 | 14 | public class Decompress { 15 | private String zipFile; 16 | private String location; 17 | 18 | public Decompress(String zipFile, String location) { 19 | this.zipFile = zipFile; 20 | this.location = location; 21 | } 22 | 23 | public void unzip() { 24 | try { 25 | 26 | File fSourceZip = new File(zipFile); 27 | String zipPath = zipFile.substring(0, zipFile.length() - 4); 28 | //File temp = new File(zipPath); 29 | //temp.mkdir(); 30 | Log.v("Decompress", zipPath + " created"); 31 | 32 | /* 33 | * Extract entries while creating required sub-directories 34 | */ 35 | ZipFile zipFile = new ZipFile(fSourceZip); 36 | Enumeration e = zipFile.entries(); 37 | 38 | while (e.hasMoreElements()) { 39 | ZipEntry entry = (ZipEntry) e.nextElement(); 40 | File destinationFilePath = new File(location, entry.getName()); 41 | 42 | // create directories if required. 43 | destinationFilePath.getParentFile().mkdirs(); 44 | 45 | // if the entry is directory, leave it. Otherwise extract it. 46 | if (entry.isDirectory()) { 47 | continue; 48 | } else { 49 | Log.v("Decompress", "Unzipping " + entry.getName()); 50 | 51 | /* 52 | * Get the InputStream for current entry of the zip file 53 | * using 54 | * 55 | * InputStream getInputStream(Entry entry) method. 56 | */ 57 | BufferedInputStream bis = new BufferedInputStream( 58 | zipFile.getInputStream(entry)); 59 | 60 | int b; 61 | byte buffer[] = new byte[1024]; 62 | 63 | /* 64 | * read the current entry from the zip file, extract it and 65 | * write the extracted file. 66 | */ 67 | FileOutputStream fos = new FileOutputStream(destinationFilePath); 68 | BufferedOutputStream bos = new BufferedOutputStream(fos, 69 | 1024); 70 | 71 | while ((b = bis.read(buffer, 0, 1024)) != -1) { 72 | bos.write(buffer, 0, b); 73 | } 74 | 75 | // flush the output stream and close it. 76 | bos.flush(); 77 | bos.close(); 78 | 79 | // close the input stream. 80 | bis.close(); 81 | } 82 | } 83 | } catch (IOException ioe) { 84 | Log.e("Decompress", "unzip", ioe); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/compress/ZipFolder.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.compress; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.util.zip.ZipEntry; 6 | import java.util.zip.ZipOutputStream; 7 | 8 | public class ZipFolder { 9 | // here is the code for the method 10 | public void zipDir(String dir2zip, ZipOutputStream zos) { 11 | try { 12 | // create a new File object based on the directory we 13 | // have to zip File 14 | File zipDir = new File(dir2zip); 15 | // getIcon a listing of the directory content 16 | String[] dirList = zipDir.list(); 17 | byte[] readBuffer = new byte[2156]; 18 | int bytesIn = 0; 19 | // loop through dirList, and zip the files 20 | for (int i = 0; i < dirList.length; i++) { 21 | File f = new File(zipDir, dirList[i]); 22 | if (f.isDirectory()) { 23 | // if the File object is a directory, call this 24 | // function again to add its content recursively 25 | String filePath = f.getPath(); 26 | zipDir(filePath, zos); 27 | // loop again 28 | continue; 29 | } 30 | // if we reached here, the File object f was not 31 | // a directory 32 | // create a FileInputStream on top of f 33 | FileInputStream fis = new FileInputStream(f); 34 | // create a new zip entry 35 | ZipEntry anEntry = new ZipEntry(f.getPath()); 36 | // place the zip entry in the ZipOutputStream object 37 | zos.putNextEntry(anEntry); 38 | // now write the content of the file to the ZipOutputStream 39 | while ((bytesIn = fis.read(readBuffer)) != -1) { 40 | zos.write(readBuffer, 0, bytesIn); 41 | } 42 | // close the Stream 43 | fis.close(); 44 | } 45 | } catch (Exception e) { 46 | // handle exception 47 | } 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/exception/NoPermissionException.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.exception; 2 | 3 | /** 4 | * Project: apptoolkit 5 | * Package: com.mcxiaoke.apptoolkit.exception 6 | * User: mcxiaoke 7 | * Date: 13-6-22 8 | * Time: 下午7:43 9 | */ 10 | public class NoPermissionException extends Exception { 11 | 12 | public NoPermissionException() { 13 | } 14 | 15 | public NoPermissionException(String detailMessage) { 16 | super(detailMessage); 17 | } 18 | 19 | public NoPermissionException(String detailMessage, Throwable throwable) { 20 | super(detailMessage, throwable); 21 | } 22 | 23 | public NoPermissionException(Throwable throwable) { 24 | super(throwable); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/fragment/BaseDialogFragment.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.fragment; 2 | 3 | import com.actionbarsherlock.app.SherlockDialogFragment; 4 | 5 | /** 6 | * Project: filemanager 7 | * Package: com.mcxiaoke.appmanager.fragment 8 | * User: mcxiaoke 9 | * Date: 13-6-12 10 | * Time: 下午10:57 11 | */ 12 | public class BaseDialogFragment extends SherlockDialogFragment { 13 | } 14 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/fragment/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.fragment; 2 | 3 | import android.app.Activity; 4 | import com.actionbarsherlock.app.SherlockFragment; 5 | import com.mcxiaoke.apptoolkit.app.UIBaseSupport; 6 | 7 | /** 8 | * Project: filemanager 9 | * Package: com.com.mcxiaoke.appmanager.fragment 10 | * User: com.mcxiaoke 11 | * Date: 13-6-11 12 | * Time: 上午10:51 13 | */ 14 | public abstract class BaseFragment extends SherlockFragment implements Refreshable { 15 | private UIBaseSupport mBaseSupport; 16 | 17 | @Override 18 | public void onAttach(Activity activity) { 19 | super.onAttach(activity); 20 | mBaseSupport = (UIBaseSupport) activity; 21 | } 22 | 23 | protected UIBaseSupport getBaseSupport() { 24 | return mBaseSupport; 25 | } 26 | 27 | @Override 28 | public void hideProgress() { 29 | mBaseSupport.hideProgress(); 30 | } 31 | 32 | @Override 33 | public void showProgress() { 34 | mBaseSupport.showProgress(); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/fragment/Refreshable.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.fragment; 2 | 3 | /** 4 | * Project: filemanager 5 | * Package: com.com.mcxiaoke.appmanager.fragment 6 | * User: com.mcxiaoke 7 | * Date: 13-6-11 8 | * Time: 上午10:53 9 | */ 10 | public interface Refreshable { 11 | 12 | public void refresh(); 13 | 14 | public void showProgress(); 15 | 16 | public void hideProgress(); 17 | } 18 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/menu/MenuCallback.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.mcxiaoke.apptoolkit.menu; 5 | 6 | /** 7 | * @author mcxiaoke 8 | * 9 | */ 10 | public interface MenuCallback { 11 | 12 | public void onMenuItemSelected(int position, MenuItemResource menuItem); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/menu/MenuItemResource.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.mcxiaoke.apptoolkit.menu; 5 | 6 | /** 7 | * @author mcxiaoke 8 | * 9 | */ 10 | public class MenuItemResource { 11 | public final int id; 12 | public final int type; 13 | public final String text; 14 | public final int iconId; 15 | public boolean selected; 16 | public boolean highlight;// 如果是activity跳转就不需要高亮,本界面的fragment切换需要高亮 17 | 18 | public MenuItemResource(Builder builder) { 19 | this.id = builder.id; 20 | this.type = builder.type; 21 | this.text = builder.text; 22 | this.iconId = builder.iconId; 23 | this.selected = builder.selected; 24 | this.highlight = builder.highlight; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | StringBuilder builder2 = new StringBuilder(); 30 | builder2.append("MenuItemResource [id="); 31 | builder2.append(id); 32 | builder2.append(", type="); 33 | builder2.append(type); 34 | builder2.append(", text="); 35 | builder2.append(text); 36 | builder2.append(", iconId="); 37 | builder2.append(iconId); 38 | builder2.append(", selected="); 39 | builder2.append(selected); 40 | builder2.append(", highlight="); 41 | builder2.append(highlight); 42 | builder2.append("]"); 43 | return builder2.toString(); 44 | } 45 | 46 | public static Builder newBuilder() { 47 | return new Builder(); 48 | } 49 | 50 | public static class Builder { 51 | private int id; 52 | private int type; 53 | private String text; 54 | private int iconId; 55 | private boolean selected; 56 | private boolean highlight; 57 | 58 | public Builder() { 59 | } 60 | 61 | public MenuItemResource build() { 62 | return new MenuItemResource(this); 63 | } 64 | 65 | public Builder id(int id) { 66 | this.id = id; 67 | return this; 68 | } 69 | 70 | public Builder type(int type) { 71 | this.type = type; 72 | return this; 73 | } 74 | 75 | public Builder text(String text) { 76 | this.text = text; 77 | return this; 78 | } 79 | 80 | public Builder iconId(int iconId) { 81 | this.iconId = iconId; 82 | return this; 83 | } 84 | 85 | public Builder selected(boolean selected) { 86 | this.selected = selected; 87 | return this; 88 | } 89 | 90 | public Builder highlight(boolean highlight) { 91 | this.highlight = highlight; 92 | return this; 93 | } 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/menu/PopupMenuItem.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.menu; 2 | 3 | /** 4 | * Project: filemanager 5 | * Package: com.mcxiaoke.appmanager.model 6 | * User: mcxiaoke 7 | * Date: 13-6-12 8 | * Time: 下午11:01 9 | */ 10 | public class PopupMenuItem { 11 | 12 | public int id; 13 | public int type; 14 | public String name; 15 | public boolean enabled; 16 | public boolean root; 17 | public boolean advanced; 18 | 19 | public PopupMenuItem(int id, String name) { 20 | this.id = id; 21 | this.name = name; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/model/BaseModel.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.model; 2 | 3 | import android.os.Parcelable; 4 | import com.mcxiaoke.apptoolkit.AppContext; 5 | 6 | /** 7 | * Project: filemanager 8 | * Package: com.com.mcxiaoke.appmanager.model 9 | * User: com.mcxiaoke 10 | * Date: 13-6-10 11 | * Time: 下午9:21 12 | */ 13 | public abstract class BaseModel implements Parcelable { 14 | 15 | public long getId() { 16 | return 0; 17 | } 18 | 19 | @Override 20 | public int describeContents() { 21 | return 0; 22 | } 23 | 24 | public String jsonString() { 25 | return AppContext.getApp().getGson().toJson(this); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/preference/MultipleChoicePreference.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.preference; 2 | 3 | import android.app.AlertDialog.Builder; 4 | import android.content.Context; 5 | import android.content.DialogInterface; 6 | import android.preference.ListPreference; 7 | import android.util.AttributeSet; 8 | 9 | import java.util.Arrays; 10 | import java.util.HashSet; 11 | import java.util.Set; 12 | 13 | /** 14 | * Similar to a ListPreference, but uses a multi-choice list and saves the value as a comma-separated string. 15 | * 16 | * @author nlawson 17 | */ 18 | public class MultipleChoicePreference extends ListPreference { 19 | 20 | public static final String DELIMITER = ","; 21 | boolean[] checkedDialogEntryIndexes; 22 | 23 | public MultipleChoicePreference(Context context, AttributeSet attrs) { 24 | super(context, attrs); 25 | } 26 | 27 | public MultipleChoicePreference(Context context) { 28 | super(context); 29 | } 30 | 31 | @Override 32 | protected void onPrepareDialogBuilder(Builder builder) { 33 | 34 | // convert comma-separated list to boolean array 35 | 36 | String value = getValue(); 37 | Set commaSeparated = new HashSet(Arrays.asList(value.split(DELIMITER))); 38 | 39 | CharSequence[] entryValues = getEntryValues(); 40 | final boolean[] checked = new boolean[entryValues.length]; 41 | for (int i = 0; i < entryValues.length; i++) { 42 | checked[i] = commaSeparated.contains(entryValues[i]); 43 | } 44 | 45 | builder.setMultiChoiceItems(getEntries(), checked, new DialogInterface.OnMultiChoiceClickListener() { 46 | 47 | @Override 48 | public void onClick(DialogInterface dialog, int which, boolean isChecked) { 49 | checked[which] = isChecked; 50 | } 51 | }); 52 | builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { 53 | 54 | @Override 55 | public void onClick(DialogInterface dialog, int which) { 56 | 57 | checkedDialogEntryIndexes = checked; 58 | 59 | /* 60 | * Clicking on an item simulates the positive button 61 | * click, and dismisses the dialog. 62 | */ 63 | MultipleChoicePreference.this.onClick(dialog, DialogInterface.BUTTON_POSITIVE); 64 | dialog.dismiss(); 65 | 66 | } 67 | }); 68 | } 69 | 70 | @Override 71 | protected void onDialogClosed(boolean positiveResult) { 72 | 73 | if (positiveResult && checkedDialogEntryIndexes != null) { 74 | String value = createValueAsString(checkedDialogEntryIndexes); 75 | if (callChangeListener(value)) { 76 | setValue(value); 77 | } 78 | } 79 | } 80 | 81 | private String createValueAsString(boolean[] checked) { 82 | StringBuilder sb = new StringBuilder(); 83 | 84 | for (int i = 0; i < checked.length; i++) { 85 | if (checked[i]) { 86 | sb.append(getEntryValues()[i]).append(DELIMITER); 87 | } 88 | } 89 | return sb.length() == 0 ? "" : sb.substring(0, sb.length() - 1); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/service/BackgroundService.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.service; 2 | 3 | import android.content.Intent; 4 | 5 | /** 6 | * Project: apptoolkit 7 | * Package: com.mcxiaoke.apptoolkit.service 8 | * User: mcxiaoke 9 | * Date: 13-6-15 10 | * Time: 下午5:57 11 | */ 12 | public final class BackgroundService extends BaseService { 13 | public static final int CMD_BACKUP_APPS = 1001; // 备份应用 14 | public static final int CMD_BACKUP_DATA = 1002; // 备份数据 ROOT 15 | 16 | public static final int CMD_RESTORE_APPS = 1011; // 恢复应用 ROOT 17 | public static final int CMD_RESTORE_DATA = 1012; // 恢复数据 ROOT 18 | 19 | public static final int CMD_INSTALL_APPS = 1021; // 批量安装 ROOT 20 | public static final int CMD_UNINSTALL_APPS = 1022;// 批量卸载 ROOT 21 | 22 | public static final int CMD_CLEAR_APPCACHE = 1031; // 清除缓存 ROOT 23 | public static final int CMD_CLEAR_APPDATA = 1032; // 清除数据 ROOT 24 | 25 | public static final int CMD_COPY_FILES = 1041; // 复制文件 ROOT* 26 | public static final int CMD_MOVE_FILES = 1042; // 移动文件 ROOT* 27 | public static final int CMD_DELETE_FILES = 1043; // 删除文件 ROOT* 28 | 29 | 30 | @Override 31 | public void onCreate() { 32 | super.onCreate(); 33 | } 34 | 35 | @Override 36 | protected void onHandleIntent(long taskId, Intent intent) { 37 | } 38 | 39 | @Override 40 | protected boolean isDebug() { 41 | return false; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/service/ExtendedRunnable.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.service; 2 | 3 | /** 4 | * Project: apptoolkit 5 | * Package: com.mcxiaoke.apptoolkit.task 6 | * User: mcxiaoke 7 | * Date: 13-6-15 8 | * Time: 下午6:59 9 | */ 10 | public abstract class ExtendedRunnable implements Runnable { 11 | private String mName; 12 | private boolean mCancelled; 13 | 14 | public ExtendedRunnable(String name) { 15 | mName = name; 16 | mCancelled = false; 17 | } 18 | 19 | public void cancel() { 20 | mCancelled = true; 21 | } 22 | 23 | public boolean isCancelled() { 24 | return mCancelled; 25 | } 26 | 27 | public String getName() { 28 | return mName; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/task/AsyncTaskBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 - 2013, all rights reserved 3 | */ 4 | 5 | package com.mcxiaoke.apptoolkit.task; 6 | 7 | import android.os.AsyncTask; 8 | import android.os.Build; 9 | import android.util.Pair; 10 | 11 | public abstract class AsyncTaskBase 12 | extends AsyncTask> { 13 | 14 | private AsyncTaskCallback mCallback; 15 | protected volatile boolean mCancelled; 16 | 17 | public AsyncTaskBase(AsyncTaskCallback callback) { 18 | this.mCallback = callback; 19 | this.mCancelled = false; 20 | } 21 | 22 | /** 23 | * 设置结果回调监听器 24 | * 25 | * @param callback 26 | */ 27 | public void setCallback(AsyncTaskCallback callback) { 28 | this.mCallback = callback; 29 | } 30 | 31 | @Override 32 | protected void onProgressUpdate(Progress... values) { 33 | super.onProgressUpdate(values); 34 | if (mCallback != null) { 35 | mCallback.onTaskProgress(0, values[0]); 36 | } 37 | } 38 | 39 | @Override 40 | protected final Pair doInBackground(Params... params) { 41 | Result res = null; 42 | Throwable ex = null; 43 | try { 44 | res = onExecute(params); 45 | } catch (Throwable e) { 46 | ex = e; 47 | } 48 | return new Pair(res, ex); 49 | } 50 | 51 | @Override 52 | protected final void onPostExecute(Pair result) { 53 | if (mCancelled) { 54 | return; 55 | } 56 | try { 57 | if (result.first != null) { 58 | onPostExecuteSuccess(result.first); 59 | } else { 60 | onPostExecuteFailure(result.second); 61 | } 62 | } catch (Throwable t) { 63 | t.printStackTrace(); 64 | } 65 | } 66 | 67 | /** 68 | * 继承这个方法来实现线程调用 69 | * 70 | * @param params 71 | * @return 72 | * @throws Exception 73 | */ 74 | protected abstract Result onExecute(Params... params) throws Exception; 75 | 76 | /** 77 | * 调用成功 78 | * 79 | * @param result 80 | */ 81 | protected void onPostExecuteSuccess(Result result) { 82 | if (mCallback != null) { 83 | mCallback.onTaskSuccess(0, result); 84 | } 85 | } 86 | 87 | /** 88 | * 失败 并返回异常 89 | * 90 | * @param exception 91 | */ 92 | protected void onPostExecuteFailure(Throwable exception) { 93 | if (mCallback != null) { 94 | mCallback.onTaskFailure(0, exception); 95 | } 96 | } 97 | 98 | /** 99 | * 取消任务 100 | */ 101 | public void stop() { 102 | mCancelled = true; 103 | super.cancel(true); 104 | } 105 | 106 | protected boolean isUserCancelled() { 107 | return mCancelled; 108 | } 109 | 110 | 111 | /** 112 | * @param params 113 | */ 114 | public void start(Params... params) { 115 | if (Build.VERSION.SDK_INT > 10) { 116 | super.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params); 117 | } else { 118 | super.execute(params); 119 | } 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/task/AsyncTaskCallback.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.task; 2 | 3 | /** 4 | * Project: DoubanShuo 5 | * User: com.mcxiaoke 6 | * Date: 13-6-4 7 | * Time: 下午12:08 8 | */ 9 | public interface AsyncTaskCallback { 10 | public void onTaskProgress(int code, Progress progress); 11 | 12 | public void onTaskSuccess(int code, Result result); 13 | 14 | public void onTaskFailure(int code, Throwable e); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/task/BackupAppsApkTask.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.task; 2 | 3 | import android.content.Context; 4 | import com.mcxiaoke.apptoolkit.model.AppInfo; 5 | import com.mcxiaoke.apptoolkit.util.Utils; 6 | 7 | import java.io.File; 8 | import java.util.List; 9 | 10 | /** 11 | * 批量备份应用安装包,不需要ROOT 12 | * Project: filemanager 13 | * Package: com.com.mcxiaoke.appmanager.task 14 | * User: com.mcxiaoke 15 | * Date: 13-6-11 16 | * Time: 下午1:24 17 | */ 18 | public class BackupAppsApkTask extends AsyncTaskBase, AppInfo, Integer> { 19 | private Context mContext; 20 | 21 | 22 | public BackupAppsApkTask(Context context, AsyncTaskCallback callback) { 23 | super(callback); 24 | mContext = context; 25 | } 26 | 27 | @Override 28 | protected void onPreExecute() { 29 | super.onPreExecute(); 30 | } 31 | 32 | @Override 33 | protected void onProgressUpdate(AppInfo... values) { 34 | super.onProgressUpdate(values); 35 | } 36 | 37 | @Override 38 | protected void onPostExecuteSuccess(Integer integer) { 39 | super.onPostExecuteSuccess(integer); 40 | } 41 | 42 | @Override 43 | protected void onPostExecuteFailure(Throwable exception) { 44 | super.onPostExecuteFailure(exception); 45 | } 46 | 47 | @Override 48 | protected Integer onExecute(List... params) throws Exception { 49 | if (params == null || params.length == 0) { 50 | throw new NullPointerException("params is null"); 51 | } 52 | if (!Utils.isSdcardMounted()) { 53 | throw new NullPointerException("sdcard is not mounted"); 54 | } 55 | 56 | List apps = params[0]; 57 | File backupDir = checkBackupDir(); 58 | int backupCount = 0; 59 | for (AppInfo app : apps) { 60 | if (isUserCancelled()) { 61 | break; 62 | } 63 | String fileName = Utils.buildApkName(app); 64 | File src = new File(app.sourceDir); 65 | File dest = new File(backupDir, fileName); 66 | if (src.exists() && src.canRead()) { 67 | if (!dest.exists()) { 68 | boolean success = Utils.copyFile(src, dest); 69 | if (success) { 70 | backupCount++; 71 | } 72 | } 73 | app.apkBackup = true; 74 | } 75 | publishProgress(app); 76 | } 77 | return backupCount; 78 | } 79 | 80 | private File checkBackupDir() { 81 | return Utils.getBackupAppsDir(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/task/BackupAppsDataTask.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.task; 2 | 3 | import android.content.Context; 4 | import com.mcxiaoke.apptoolkit.AppContext; 5 | import com.mcxiaoke.apptoolkit.db.Database; 6 | import com.mcxiaoke.apptoolkit.exception.NoPermissionException; 7 | import com.mcxiaoke.apptoolkit.model.AppInfo; 8 | import com.mcxiaoke.apptoolkit.util.Utils; 9 | import com.mcxiaoke.shell.Shell; 10 | 11 | import java.io.File; 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * 批量备份应用数据,需要ROOT 17 | * Project: filemanager 18 | * Package: com.com.mcxiaoke.appmanager.task 19 | * User: com.mcxiaoke 20 | * Date: 13-6-11 21 | * Time: 下午1:24 22 | */ 23 | public class BackupAppsDataTask extends AsyncTaskBase, AppInfo, Integer> { 24 | private Context mContext; 25 | 26 | 27 | public BackupAppsDataTask(Context context, AsyncTaskCallback callback) { 28 | super(callback); 29 | mContext = context; 30 | } 31 | 32 | @Override 33 | protected void onPreExecute() { 34 | super.onPreExecute(); 35 | } 36 | 37 | @Override 38 | protected void onProgressUpdate(AppInfo... values) { 39 | super.onProgressUpdate(values); 40 | } 41 | 42 | @Override 43 | protected void onPostExecuteSuccess(Integer integer) { 44 | super.onPostExecuteSuccess(integer); 45 | } 46 | 47 | @Override 48 | protected void onPostExecuteFailure(Throwable exception) { 49 | super.onPostExecuteFailure(exception); 50 | } 51 | 52 | @Override 53 | protected Integer onExecute(List... params) throws Exception { 54 | if (params == null || params.length == 0) { 55 | throw new NullPointerException("params is null"); 56 | } 57 | 58 | if (!Shell.isRootAccessAvailable()) { 59 | throw new NoPermissionException(); 60 | } 61 | 62 | List apps = params[0]; 63 | List backupPackages = new ArrayList(); 64 | File backupDir = Utils.getBackupDataDir(); 65 | int backupCount = 0; 66 | for (AppInfo app : apps) { 67 | if (isUserCancelled()) { 68 | break; 69 | } 70 | AppContext.v("BackupAppsDataTask processing name=" + app.appName); 71 | File src = new File(app.dataDir); 72 | File dest = new File(backupDir, app.packageName); 73 | boolean success = Shell.backupAppData(src.getPath(), dest.getPath(), false, true); 74 | if (success) { 75 | app.dataBackup=true; 76 | backupPackages.add(app.packageName); 77 | backupCount++; 78 | } else { 79 | AppContext.e("BackupAppsDataTask processing backup failed app: name=" + app.appName + " src=" + src); 80 | // break; 81 | } 82 | publishProgress(app); 83 | } 84 | Database db = AppContext.getApp().getDB(); 85 | db.addBackups(backupPackages); 86 | return backupCount; 87 | } 88 | 89 | private String buildProgressText(AppInfo app) { 90 | return new StringBuilder().append(app.appName).append(" v").append(app.versionName).append("\n").append(app.sourceDir).toString(); 91 | 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/task/LoadAppsTask.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.task; 2 | 3 | import android.content.Context; 4 | import android.content.pm.PackageInfo; 5 | import android.content.pm.PackageManager; 6 | import android.graphics.drawable.Drawable; 7 | import android.util.Pair; 8 | import com.mcxiaoke.apptoolkit.AppConfig; 9 | import com.mcxiaoke.apptoolkit.AppContext; 10 | import com.mcxiaoke.apptoolkit.cache.CacheManager; 11 | import com.mcxiaoke.apptoolkit.db.Database; 12 | import com.mcxiaoke.apptoolkit.model.AppInfo; 13 | import com.mcxiaoke.apptoolkit.util.Utils; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | /** 19 | * Project: filemanager 20 | * Package: com.com.mcxiaoke.appmanager.task 21 | * User: com.mcxiaoke 22 | * Date: 13-6-11 23 | * Time: 上午10:58 24 | */ 25 | public class LoadAppsTask extends AsyncTaskBase, List> { 26 | private Context mContext; 27 | private PackageManager mPackageManager; 28 | 29 | public LoadAppsTask(Context context, AsyncTaskCallback, List> callback) { 30 | super(callback); 31 | this.mContext = context; 32 | this.mPackageManager = context.getPackageManager(); 33 | AppContext.v("LoadAppsTask()"); 34 | } 35 | 36 | @Override 37 | protected void onPreExecute() { 38 | super.onPreExecute(); 39 | } 40 | 41 | @Override 42 | protected List onExecute(TaskMessage... params) throws Exception { 43 | TaskMessage param = params[0]; 44 | int type = param.type; 45 | boolean includeSystemApp = param.flag; 46 | 47 | AppContext.v("LoadAppsTask.onExecute() type=" + type + " includeSystemApp=" + includeSystemApp); 48 | 49 | int flags = PackageManager.GET_META_DATA; 50 | List apps = null; 51 | List installedPackages = mPackageManager.getInstalledPackages(flags); 52 | if (installedPackages != null && installedPackages.size() > 0) { 53 | apps = new ArrayList(installedPackages.size()); 54 | List backupDatas = new ArrayList(); 55 | 56 | Database db = AppContext.getApp().getDB(); 57 | List dbBackupDatas = db.getBackupApps(); 58 | if (dbBackupDatas != null) { 59 | for (String packageName : dbBackupDatas) { 60 | if (Utils.isBackupDataExists(packageName)) { 61 | backupDatas.add(packageName); 62 | } else { 63 | db.removeBackup(packageName); 64 | } 65 | } 66 | } 67 | List backupApks = Utils.getBackupApkFiles(); 68 | 69 | if (AppConfig.TYPE_USER_APP_MANAGER == type) { 70 | for (PackageInfo info : installedPackages) { 71 | if (includeSystemApp || !Utils.isSystemApp(info)) { 72 | AddToApps(apps, backupDatas, backupApks, info); 73 | } 74 | } 75 | } else if (AppConfig.TYPE_SYSTEM_APP_MANAGER == type) { 76 | for (PackageInfo info : installedPackages) { 77 | if (Utils.isSystemApp(info)) { 78 | AddToApps(apps, backupDatas, backupApks, info); 79 | } 80 | } 81 | } 82 | } 83 | return apps; 84 | } 85 | 86 | private void AddToApps(List apps, List backupDatas, List backupApks, PackageInfo info) { 87 | AppInfo app = Utils.convert(mPackageManager, info); 88 | app.apkBackup = backupApks.contains(Utils.buildApkName(app)); 89 | app.dataBackup = backupDatas.contains(app.packageName); 90 | apps.add(app); 91 | Drawable icon = info.applicationInfo.loadIcon(mPackageManager); 92 | CacheManager.getInstance().putIcon(info.packageName, icon); 93 | } 94 | 95 | @Override 96 | protected void onProgressUpdate(Pair... values) { 97 | super.onProgressUpdate(values); 98 | } 99 | 100 | @Override 101 | protected void onPostExecuteSuccess(List appInfos) { 102 | super.onPostExecuteSuccess(appInfos); 103 | } 104 | 105 | @Override 106 | protected void onPostExecuteFailure(Throwable exception) { 107 | super.onPostExecuteFailure(exception); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/task/LoadRunningProcessTask.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.task; 2 | 3 | import android.app.ActivityManager; 4 | import android.app.ActivityManager.RunningAppProcessInfo; 5 | import android.content.Context; 6 | import com.mcxiaoke.apptoolkit.AppContext; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Project: apptoolkit 12 | * Package: com.mcxiaoke.apptoolkit.task 13 | * User: mcxiaoke 14 | * Date: 13-6-22 15 | * Time: 下午10:17 16 | */ 17 | public class LoadRunningProcessTask extends AsyncTaskBase> { 18 | private static final String TAG = LoadRunningProcessTask.class.getSimpleName(); 19 | private Context mContext; 20 | 21 | public LoadRunningProcessTask(Context context, AsyncTaskCallback> callback) { 22 | super(callback); 23 | mContext = context; 24 | } 25 | 26 | @Override 27 | protected List onExecute(TaskMessage... params) throws Exception { 28 | TaskMessage tm = params[0]; 29 | ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); 30 | List processes = am.getRunningAppProcesses(); 31 | for (int i = 0; i < processes.size(); i++) { 32 | RunningAppProcessInfo info = processes.get(i); 33 | AppContext.v(TAG, "Process: " + info.processName + " pkg: " + info.pkgList[0] + " pid: " + info.pid); 34 | } 35 | return null; 36 | } 37 | 38 | @Override 39 | protected void onPostExecuteSuccess(List runningAppProcessInfos) { 40 | super.onPostExecuteSuccess(runningAppProcessInfos); 41 | } 42 | 43 | @Override 44 | protected void onPostExecuteFailure(Throwable exception) { 45 | super.onPostExecuteFailure(exception); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/task/SimpleAsyncTask.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.task; 2 | 3 | /** 4 | * Project: apptoolkit 5 | * Package: com.mcxiaoke.apptoolkit.task 6 | * User: mcxiaoke 7 | * Date: 13-6-16 8 | * Time: 下午6:23 9 | */ 10 | public abstract class SimpleAsyncTask extends AsyncTaskBase { 11 | 12 | public SimpleAsyncTask() { 13 | super(null); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/task/SimpleAsyncTaskCallback.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.task; 2 | 3 | /** 4 | * Project: filemanager 5 | * Package: com.com.mcxiaoke.appmanager.task 6 | * User: com.mcxiaoke 7 | * Date: 13-6-11 8 | * Time: 下午1:51 9 | */ 10 | public class SimpleAsyncTaskCallback implements AsyncTaskCallback { 11 | 12 | @Override 13 | public void onTaskFailure(int code, Throwable e) { 14 | } 15 | 16 | @Override 17 | public void onTaskProgress(int code, Void aVoid) { 18 | } 19 | 20 | @Override 21 | public void onTaskSuccess(int code, Result result) { 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/task/TaskMessage.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.task; 2 | 3 | import android.os.Bundle; 4 | import android.os.Parcel; 5 | import android.os.Parcelable; 6 | 7 | /** 8 | * Project: apptoolkit 9 | * Package: com.mcxiaoke.apptoolkit.task 10 | * User: mcxiaoke 11 | * Date: 13-6-16 12 | * Time: 下午1:58 13 | */ 14 | public final class TaskMessage implements Parcelable { 15 | public int id; 16 | public int type; 17 | public int arg1; 18 | public int arg2; 19 | public boolean flag; 20 | public String message; 21 | public Bundle extras; 22 | public Object object; 23 | 24 | public TaskMessage() { 25 | } 26 | 27 | public TaskMessage(Parcel in) { 28 | this.id = in.readInt(); 29 | this.type = in.readInt(); 30 | this.arg1 = in.readInt(); 31 | this.arg2 = in.readInt(); 32 | this.flag = (in.readInt() == 1); 33 | this.message = in.readString(); 34 | this.extras = in.readBundle(); 35 | 36 | if (in.readInt() != 0) { 37 | object = in.readParcelable(getClass().getClassLoader()); 38 | } 39 | 40 | } 41 | 42 | public TaskMessage(int type, boolean flag) { 43 | this.type = type; 44 | this.flag = flag; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | final StringBuilder sb = new StringBuilder("AsyncTaskParam{"); 50 | sb.append(", id=").append(id); 51 | sb.append(", type=").append(type); 52 | sb.append(", flag=").append(flag); 53 | sb.append(", arg1=").append(arg1); 54 | sb.append(", arg2=").append(arg2); 55 | sb.append(", message='").append(message).append('\''); 56 | sb.append('}'); 57 | return sb.toString(); 58 | } 59 | 60 | @Override 61 | public int describeContents() { 62 | return 0; 63 | } 64 | 65 | @Override 66 | public void writeToParcel(Parcel dest, int flags) { 67 | dest.writeInt(this.id); 68 | dest.writeInt(this.type); 69 | dest.writeInt(this.arg1); 70 | dest.writeInt(this.arg2); 71 | dest.writeInt(this.flag ? 1 : 0); 72 | dest.writeString(this.message); 73 | dest.writeBundle(this.extras); 74 | 75 | if (object != null) { 76 | try { 77 | Parcelable p = (Parcelable) object; 78 | dest.writeInt(1); 79 | dest.writeParcelable(p, flags); 80 | } catch (ClassCastException e) { 81 | throw new RuntimeException( 82 | "Can't marshal non-Parcelable objects across processes."); 83 | } 84 | } else { 85 | dest.writeInt(0); 86 | } 87 | } 88 | 89 | public static final Creator CREATOR = new Creator() { 90 | @Override 91 | public TaskMessage createFromParcel(Parcel source) { 92 | return new TaskMessage(source); 93 | } 94 | 95 | @Override 96 | public TaskMessage[] newArray(int size) { 97 | return new TaskMessage[size]; 98 | } 99 | }; 100 | } 101 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/util/AppUtils.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.util; 2 | 3 | import android.content.Context; 4 | import com.mcxiaoke.apptoolkit.model.AppInfo; 5 | import com.mcxiaoke.shell.Shell; 6 | 7 | import java.io.File; 8 | import java.io.IOException; 9 | 10 | /** 11 | * Project: filemanager 12 | * Package: com.mcxiaoke.appmanager.util 13 | * User: mcxiaoke 14 | * Date: 13-6-11 15 | * Time: 下午10:53 16 | */ 17 | public final class AppUtils { 18 | 19 | public static void installApp(Context context, AppInfo app) { 20 | 21 | } 22 | 23 | public static void installAsSystemApp(Context context, AppInfo app) { 24 | 25 | } 26 | 27 | public static void moveToSystem(Context context, AppInfo app) { 28 | 29 | } 30 | 31 | public static void clearAppData(Context context, AppInfo app) { 32 | 33 | } 34 | 35 | public static void uninstallApp(Context context, AppInfo app) { 36 | 37 | } 38 | 39 | public static void showDetail(Context context, AppInfo app) { 40 | 41 | } 42 | 43 | public static void copyPackageName(Context context, AppInfo app) { 44 | 45 | } 46 | 47 | public static void killAppProcess(Context context, AppInfo app) { 48 | 49 | } 50 | 51 | public static void showApp(Context context, AppInfo app) { 52 | 53 | 54 | } 55 | 56 | public static boolean backupAppApk(AppInfo app) throws IOException { 57 | boolean result = false; 58 | File src = new File(app.sourceDir); 59 | File dest = new File(Utils.getBackupAppsDir(), Utils.buildApkName(app)); 60 | if (src.exists() && !dest.exists()) { 61 | result = IOHelper.copyFile(src, dest); 62 | } 63 | return result; 64 | } 65 | 66 | public static boolean backupAppData(AppInfo app) throws Exception { 67 | String src = app.dataDir; 68 | String dest = new File(Utils.getBackupDataDir(), app.packageName).getPath(); 69 | return Shell.backupAppData(src, dest, false, true); 70 | 71 | } 72 | 73 | public static boolean restoreAppData(AppInfo app) throws Exception { 74 | File backupDataFile = new File(Utils.getBackupDataDir(), app.packageName); 75 | String src = backupDataFile.getPath(); 76 | String dest = app.dataDir; 77 | return Shell.restoreAppData(String.valueOf(app.uid), src, dest, false, false); 78 | } 79 | 80 | public static void showDataDir(Context context, AppInfo app) { 81 | 82 | } 83 | 84 | public static void createShortcut(Context context, AppInfo app) { 85 | 86 | } 87 | 88 | public static void viewManifestFile(Context context, AppInfo app) { 89 | 90 | } 91 | 92 | public static void gotoPlayStore(Context context, AppInfo app) { 93 | 94 | } 95 | 96 | // TODO todos 97 | // show services/providers/receivers/permissions/activities 98 | // kill process, show memory, show cpuinfo 99 | // install binary, move to system, uninstall system 100 | // apkBackup app data, batch install /uninstall 101 | // shutdown, restart, remount, screenshot 102 | // kill notifications, kill auto start 103 | // disable component 104 | // restart package / real kill: kill process 105 | //Process.sendSignal(pid, Process.SIGNAL_KILL); 106 | //ActivityManager.killBackgroundProcesses(PackageName) 107 | 108 | // android:name="android.permission.GET_TASKS" 109 | //android:name="android.permission.KILL_BACKGROUND_PROCESSES" 110 | 111 | // 删除系统程序,三步:删除apk/odex,删除数据,删除dalvikcache 112 | 113 | 114 | } 115 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/util/DeviceUtils.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.util; 2 | 3 | import android.content.Context; 4 | 5 | import java.io.File; 6 | import java.io.FileOutputStream; 7 | import java.io.IOException; 8 | import java.io.RandomAccessFile; 9 | import java.util.UUID; 10 | 11 | /** 12 | * Project: apptoolkit 13 | * Package: com.mcxiaoke.apptoolkit.util 14 | * User: mcxiaoke 15 | * Date: 13-6-22 16 | * Time: 下午7:31 17 | */ 18 | public class DeviceUtils { 19 | private static String sID = null; 20 | private static final String INSTALLATION = "INSTALLATION"; 21 | 22 | public synchronized static String id(Context context) { 23 | if (sID == null) { 24 | File installation = new File(context.getFilesDir(), INSTALLATION); 25 | try { 26 | if (!installation.exists()) 27 | writeInstallationFile(installation); 28 | sID = readInstallationFile(installation); 29 | } catch (Exception e) { 30 | throw new RuntimeException(e); 31 | } 32 | } 33 | return sID; 34 | } 35 | 36 | private static String readInstallationFile(File installation) throws IOException { 37 | RandomAccessFile f = new RandomAccessFile(installation, "r"); 38 | byte[] bytes = new byte[(int) f.length()]; 39 | f.readFully(bytes); 40 | f.close(); 41 | return new String(bytes); 42 | } 43 | 44 | private static void writeInstallationFile(File installation) throws IOException { 45 | FileOutputStream out = new FileOutputStream(installation); 46 | String id = UUID.randomUUID().toString(); 47 | out.write(id.getBytes()); 48 | out.close(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/apptoolkit/util/DialogUtils.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.apptoolkit.util; 2 | 3 | import android.app.Activity; 4 | import android.app.AlertDialog; 5 | import com.mcxiaoke.apptoolkit.model.AppInfo; 6 | 7 | /** 8 | * Project: filemanager 9 | * Package: com.mcxiaoke.appmanager.util 10 | * User: mcxiaoke 11 | * Date: 13-6-12 12 | * Time: 下午8:51 13 | */ 14 | public class DialogUtils { 15 | 16 | 17 | public static AlertDialog createAppActionDialog(Activity context, AppInfo app) { 18 | return null; 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/ErrorCode.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.shell.model; 2 | 3 | /** 4 | * Copyright 2012 by Ronald Ammann (ramdroid) 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | /** 20 | * Global list of all error codes used by the RootToolsEx classes. 21 | */ 22 | public class ErrorCode { 23 | 24 | public static final int OK = 0; 25 | public static final int NO_ROOT_ACCESS = 1; 26 | public static final int NO_BUSYBOX = 2; 27 | public static final int NO_STORAGE = 3; 28 | public static final int NO_SPACE = 4; 29 | public static final int NO_PERMISSION = 5; 30 | public static final int TIMEOUT = 6; 31 | public static final int UNKNOWN = 7; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/Mount.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the RootKit Project: http://code.google.com/p/RootKit/ 3 | * Copyright (c) 2012 Stephen Erickson, Chris Ravenscroft, Dominik Schuermann, Adam Shanks 4 | * This code is dual-licensed under the terms of the Apache License Version 2.0 and 5 | * the terms of the General Public License (GPL) Version 2. 6 | * You may use this code according to either of these licenses as is most appropriate 7 | * for your project on a case-by-case basis. 8 | * The terms of each license can be found in the root directory of this project's repository as well 9 | * as at: 10 | * * http://www.apache.org/licenses/LICENSE-2.0 11 | * * http://www.gnu.org/licenses/gpl-2.0.txt 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under these Licenses is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See each License for the specific language governing permissions and 16 | * limitations under that License. 17 | */ 18 | 19 | package com.mcxiaoke.shell.model; 20 | 21 | import java.io.File; 22 | import java.util.Arrays; 23 | import java.util.HashSet; 24 | import java.util.Set; 25 | 26 | public class Mount { 27 | final File mDevice; 28 | final File mMountPoint; 29 | final String mType; 30 | final Set mFlags; 31 | 32 | public Mount(File device, File path, String type, String flagsStr) { 33 | mDevice = device; 34 | mMountPoint = path; 35 | mType = type; 36 | mFlags = new HashSet(Arrays.asList(flagsStr.split(","))); 37 | } 38 | 39 | public File getDevice() { 40 | return mDevice; 41 | } 42 | 43 | public File getMountPoint() { 44 | return mMountPoint; 45 | } 46 | 47 | public String getType() { 48 | return mType; 49 | } 50 | 51 | public Set getFlags() { 52 | return mFlags; 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return String.format("%s on %s type %s %s", mDevice, mMountPoint, mType, mFlags); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/Symlink.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the RootTools Project: http://code.google.com/p/roottools/ 3 | * 4 | * Copyright (c) 2012 Stephen Erickson, Chris Ravenscroft, Dominik Schuermann, Adam Shanks 5 | * 6 | * This code is dual-licensed under the terms of the Apache License Version 2.0 and 7 | * the terms of the General Public License (GPL) Version 2. 8 | * You may use this code according to either of these licenses as is most appropriate 9 | * for your project on a case-by-case basis. 10 | * 11 | * The terms of each license can be found in the root directory of this project's repository as well as at: 12 | * 13 | * * http://www.apache.org/licenses/LICENSE-2.0 14 | * * http://www.gnu.org/licenses/gpl-2.0.txt 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under these Licenses is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See each License for the specific language governing permissions and 20 | * limitations under that License. 21 | */ 22 | 23 | package com.mcxiaoke.shell.model; 24 | 25 | import com.mcxiaoke.shell.Shell; 26 | 27 | import java.io.File; 28 | import java.io.FileReader; 29 | import java.io.IOException; 30 | import java.io.LineNumberReader; 31 | import java.util.ArrayList; 32 | import java.util.List; 33 | 34 | public class Symlink { 35 | protected final File file; 36 | protected final File symlinkPath; 37 | 38 | public Symlink(File file, File path) { 39 | this.file = file; 40 | symlinkPath = path; 41 | } 42 | 43 | public File getFile() { 44 | return this.file; 45 | } 46 | 47 | public File getSymlinkPath() { 48 | return symlinkPath; 49 | } 50 | 51 | 52 | public static ArrayList getSymLinks() throws IOException { 53 | LineNumberReader lnr = null; 54 | try { 55 | lnr = new LineNumberReader(new FileReader( 56 | "/data/local/symlinks.txt")); 57 | String line; 58 | ArrayList symlink = new ArrayList(); 59 | while ((line = lnr.readLine()) != null) { 60 | 61 | // RootTools.log(line); 62 | 63 | String[] fields = line.split(" "); 64 | symlink.add(new Symlink(new File(fields[fields.length - 3]), // file 65 | new File(fields[fields.length - 1]) // SymlinkPath 66 | )); 67 | } 68 | return symlink; 69 | } finally { 70 | // no need to do anything here. 71 | } 72 | } 73 | 74 | /** 75 | * This will return an ArrayList of the class Symlink. The class Symlink contains the following 76 | * property's: path SymplinkPath 77 | *

78 | * These will provide you with any Symlinks in the given path. 79 | * 80 | * @param path path to search for Symlinks. 81 | * @return ArrayList an ArrayList of the class Symlink. 82 | * @throws Exception if we cannot return the Symlinks. 83 | */ 84 | public ArrayList getSymlinks(String path) throws Exception { 85 | 86 | // this command needs find 87 | if (!Shell.hasFind()) { 88 | throw new Exception("find command not found"); 89 | } 90 | 91 | String findCommand = "find " + path + " -type l -exec ls -l {} \\; > /data/local/symlinks.txt;"; 92 | List outputs = Shell.runAsRoot(findCommand).output; 93 | ArrayList symlinks = getSymLinks(); 94 | return symlinks; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/fso/AID.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The CyanogenMod 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 | package com.mcxiaoke.shell.model.fso; 18 | 19 | import java.io.Serializable; 20 | 21 | /** 22 | * The base class for Android security identifiers objects. 23 | * 24 | * @see User 25 | * @see Group 26 | */ 27 | public class AID implements Serializable, Comparable { 28 | 29 | private static final long serialVersionUID = 5603819450513225452L; 30 | 31 | private final int mId; 32 | private final String mName; 33 | 34 | /** 35 | * Constructor of AID. 36 | * 37 | * @param id The identifier of the security identifier object 38 | * @param name The name of the security identifier object 39 | */ 40 | public AID(int id, String name) { 41 | super(); 42 | this.mId = id; 43 | this.mName = name; 44 | } 45 | 46 | /** 47 | * Method that returns the identifier of the security identifier object. 48 | * 49 | * @return int The identifier of the security identifier object 50 | */ 51 | public int getId() { 52 | return this.mId; 53 | } 54 | 55 | /** 56 | * Method that returns the name of the security identifier object. 57 | * 58 | * @return String The name of the security identifier object 59 | */ 60 | public String getName() { 61 | return this.mName; 62 | } 63 | 64 | /** 65 | * {@inheritDoc} 66 | */ 67 | @Override 68 | public int compareTo(AID another) { 69 | if (this.mId < another.mId) { 70 | return -1; 71 | } 72 | if (this.mId > another.mId) { 73 | return 1; 74 | } 75 | if (this.mId == -1) { 76 | return this.mName.compareTo(another.mName); 77 | } 78 | return 0; 79 | } 80 | 81 | /** 82 | * {@inheritDoc} 83 | */ 84 | @Override 85 | public int hashCode() { 86 | final int prime = 31; 87 | int result = 1; 88 | result = prime * result + this.mId; 89 | result = prime * result + ((this.mName == null) ? 0 : this.mName.hashCode()); 90 | return result; 91 | } 92 | 93 | /** 94 | * {@inheritDoc} 95 | */ 96 | @Override 97 | public boolean equals(Object obj) { 98 | if (this == obj) { 99 | return true; 100 | } 101 | if (obj == null) { 102 | return false; 103 | } 104 | if (getClass() != obj.getClass()) { 105 | return false; 106 | } 107 | AID other = (AID) obj; 108 | if (this.mId != other.mId) { 109 | return false; 110 | } 111 | if (this.mName == null) { 112 | if (other.mName != null) { 113 | return false; 114 | } 115 | } else if (!this.mName.equals(other.mName)) { 116 | return false; 117 | } 118 | return true; 119 | } 120 | 121 | /** 122 | * {@inheritDoc} 123 | */ 124 | @Override 125 | public String toString() { 126 | return "AID [id=" + this.mId + ", name=" //$NON-NLS-1$ //$NON-NLS-2$ 127 | + this.mName + "]"; //$NON-NLS-1$ 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/fso/BlockDevice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The CyanogenMod 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 | package com.mcxiaoke.shell.model.fso; 18 | 19 | import java.util.Date; 20 | 21 | /** 22 | * A class that represents a block device. 23 | * 24 | * {@link "http://en.wikipedia.org/wiki/Block_special_file#Block_devices"} 25 | */ 26 | public class BlockDevice extends SystemFile { 27 | 28 | private static final long serialVersionUID = 5938248951823805680L; 29 | 30 | /** 31 | * The unix identifier of the object. 32 | * @hide 33 | */ 34 | public static final char UNIX_ID = 'b'; 35 | 36 | /** 37 | * Constructor of BlockDevice. 38 | * 39 | * @param name The name of the object 40 | * @param parent The parent folder of the object 41 | * @param user The user proprietary of the object 42 | * @param group The group proprietary of the object 43 | * @param permissions The permissions of the object 44 | * @param lastAccessedTime The last time that the object was accessed 45 | * @param lastModifiedTime The last time that the object was modified 46 | * @param lastChangedTime The last time that the object was changed 47 | */ 48 | public BlockDevice( 49 | String name, String parent, User user, Group group, Permissions permissions, 50 | Date lastAccessedTime, Date lastModifiedTime, Date lastChangedTime) { 51 | super(name, parent, user, group, permissions, 0L, 52 | lastAccessedTime, lastModifiedTime, lastChangedTime); 53 | } 54 | 55 | /** 56 | * {@inheritDoc} 57 | */ 58 | @Override 59 | public char getUnixIdentifier() { 60 | return UNIX_ID; 61 | } 62 | 63 | /** 64 | * {@inheritDoc} 65 | */ 66 | @Override 67 | public String toString() { 68 | return "BlockDevice [type=" + super.toString() + "]"; //$NON-NLS-1$//$NON-NLS-2$ 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/fso/CharacterDevice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The CyanogenMod 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 | package com.mcxiaoke.shell.model.fso; 18 | 19 | import java.util.Date; 20 | 21 | /** 22 | * A class that represents a block device. 23 | * 24 | * {@link "http://en.wikipedia.org/wiki/Character_special_file#Character_devices"} 25 | */ 26 | public class CharacterDevice extends SystemFile { 27 | 28 | private static final long serialVersionUID = -3585051204874199619L; 29 | 30 | /** 31 | * The unix identifier of the object. 32 | * @hide 33 | */ 34 | public static final char UNIX_ID = 'c'; 35 | 36 | /** 37 | * Constructor of CharacterDevice. 38 | * 39 | * @param name The name of the object 40 | * @param parent The parent folder of the object 41 | * @param user The user proprietary of the object 42 | * @param group The group proprietary of the object 43 | * @param permissions The permissions of the object 44 | * @param lastAccessedTime The last time that the object was accessed 45 | * @param lastModifiedTime The last time that the object was modified 46 | * @param lastChangedTime The last time that the object was changed 47 | */ 48 | public CharacterDevice( 49 | String name, String parent, User user, Group group, Permissions permissions, 50 | Date lastAccessedTime, Date lastModifiedTime, Date lastChangedTime) { 51 | super(name, parent, user, group, permissions, 0L, 52 | lastAccessedTime, lastModifiedTime, lastChangedTime); 53 | } 54 | 55 | /** 56 | * {@inheritDoc} 57 | */ 58 | @Override 59 | public char getUnixIdentifier() { 60 | return UNIX_ID; 61 | } 62 | 63 | /** 64 | * {@inheritDoc} 65 | */ 66 | @Override 67 | public String toString() { 68 | return "CharacterDevice [type=" + super.toString() + "]"; //$NON-NLS-1$//$NON-NLS-2$ 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/fso/Directory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The CyanogenMod 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 | package com.mcxiaoke.shell.model.fso; 18 | 19 | import com.mcxiaoke.apptoolkit.R; 20 | 21 | import java.util.Date; 22 | 23 | /** 24 | * A class that represents a directory. 25 | */ 26 | public class Directory extends FileSystemObject { 27 | 28 | private static final long serialVersionUID = -3975569940766905884L; 29 | 30 | //Resource identifier for default icon 31 | private static final int RESOURCE_FOLDER_DEFAULT = R.drawable.ic_fso_folder; 32 | 33 | /** 34 | * The unix identifier of the object. 35 | * @hide 36 | */ 37 | public static final char UNIX_ID = 'd'; 38 | 39 | /** 40 | * Constructor of Directory. 41 | * 42 | * @param name The name of the object 43 | * @param parent The parent folder of the object 44 | * @param user The user proprietary of the object 45 | * @param group The group proprietary of the object 46 | * @param permissions The permissions of the object 47 | * @param lastAccessedTime The last time that the object was accessed 48 | * @param lastModifiedTime The last time that the object was modified 49 | * @param lastChangedTime The last time that the object was changed 50 | */ 51 | public Directory(String name, String parent, User user, Group group, Permissions permissions, 52 | Date lastAccessedTime, Date lastModifiedTime, Date lastChangedTime) { 53 | super(name, parent, user, group, permissions, 0L, 54 | lastAccessedTime, lastModifiedTime, lastChangedTime); 55 | setResourceIconId(RESOURCE_FOLDER_DEFAULT); 56 | } 57 | 58 | /** 59 | * {@inheritDoc} 60 | */ 61 | @Override 62 | public char getUnixIdentifier() { 63 | return UNIX_ID; 64 | } 65 | 66 | /** 67 | * {@inheritDoc} 68 | */ 69 | @Override 70 | public String toString() { 71 | return "Directory [type=" + super.toString() + "]"; //$NON-NLS-1$//$NON-NLS-2$ 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/fso/DomainSocket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The CyanogenMod 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 | package com.mcxiaoke.shell.model.fso; 18 | 19 | import java.util.Date; 20 | 21 | /** 22 | * A class that represents a symbolic link. 23 | * 24 | * {@link "http://en.wikipedia.org/wiki/Unix_domain_socket"} 25 | */ 26 | public class DomainSocket extends SystemFile { 27 | 28 | private static final long serialVersionUID = 7821422013567568593L; 29 | 30 | /** 31 | * The unix identifier of the object. 32 | * @hide 33 | */ 34 | public static final char UNIX_ID = 's'; 35 | 36 | /** 37 | * Constructor of DomainSocket. 38 | * 39 | * @param name The name of the object 40 | * @param parent The parent folder of the object 41 | * @param user The user proprietary of the object 42 | * @param group The group proprietary of the object 43 | * @param permissions The permissions of the object 44 | * @param lastAccessedTime The last time that the object was accessed 45 | * @param lastModifiedTime The last time that the object was modified 46 | * @param lastChangedTime The last time that the object was changed 47 | */ 48 | public DomainSocket( 49 | String name, String parent, User user, Group group, Permissions permissions, 50 | Date lastAccessedTime, Date lastModifiedTime, Date lastChangedTime) { 51 | super(name, parent, user, group, permissions, 0L, 52 | lastAccessedTime, lastModifiedTime, lastChangedTime); 53 | } 54 | 55 | /** 56 | * {@inheritDoc} 57 | */ 58 | @Override 59 | public char getUnixIdentifier() { 60 | return UNIX_ID; 61 | } 62 | 63 | /** 64 | * {@inheritDoc} 65 | */ 66 | @Override 67 | public String toString() { 68 | return "DomainSocket [type=" + super.toString() + "]"; //$NON-NLS-1$//$NON-NLS-2$ 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/fso/Group.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The CyanogenMod 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 | package com.mcxiaoke.shell.model.fso; 18 | 19 | /** 20 | * A class that represents a group of the operating system. 21 | */ 22 | public class Group extends AID { 23 | 24 | private static final long serialVersionUID = -6087834824505714560L; 25 | 26 | /** 27 | * Constructor of Group. 28 | * 29 | * @param gid The group identifier 30 | * @param name The group name 31 | */ 32 | public Group(int gid, String name) { 33 | super(gid, name); 34 | } 35 | 36 | /** 37 | * {@inheritDoc} 38 | */ 39 | @Override 40 | public String toString() { 41 | return "Group [" + super.toString() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/fso/GroupPermission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The CyanogenMod 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 | package com.mcxiaoke.shell.model.fso; 18 | 19 | /** 20 | * A class for represents a group permissions. 21 | * 22 | * @see Permission 23 | */ 24 | public class GroupPermission extends Permission { 25 | 26 | private static final long serialVersionUID = 5261938461035756626L; 27 | 28 | /** 29 | * @hide 30 | */ 31 | public static final char SETGID_E = 's'; 32 | /** 33 | * @hide 34 | */ 35 | public static final char SETGID = 'S'; 36 | 37 | private boolean mSetGid; 38 | 39 | /** 40 | * Constructor of GroupPermission. 41 | * 42 | * @param read If the object can be read 43 | * @param write If the object can be written 44 | * @param execute If the object can be executed 45 | */ 46 | public GroupPermission(boolean read, boolean write, boolean execute) { 47 | super(read, write, execute); 48 | this.mSetGid = false; 49 | } 50 | 51 | /** 52 | * Constructor of GroupPermission. 53 | * 54 | * @param read If the object can be read 55 | * @param write If the object can be written 56 | * @param execute If the object can be executed 57 | * @param setgid If the object has the setgid bit active 58 | */ 59 | public GroupPermission(boolean read, boolean write, boolean execute, boolean setgid) { 60 | super(read, write, execute); 61 | this.mSetGid = setgid; 62 | } 63 | 64 | /** 65 | * Method that returns if the object has the setgid bit active. 66 | * 67 | * @return boolean If the object has the setgid bit active 68 | */ 69 | public boolean isSetGID() { 70 | return this.mSetGid; 71 | } 72 | 73 | /** 74 | * Method that sets if the object has the setgid bit active. 75 | * 76 | * @param setgid If the object has the setgid bit active 77 | */ 78 | public void setSetGID(boolean setgid) { 79 | this.mSetGid = setgid; 80 | } 81 | 82 | /** 83 | * {@inheritDoc} 84 | */ 85 | @Override 86 | public int hashCode() { 87 | final int prime = 31; 88 | int result = super.hashCode(); 89 | result = prime * result + (this.mSetGid ? 1231 : 1237); 90 | return result; 91 | } 92 | 93 | /** 94 | * {@inheritDoc} 95 | */ 96 | @Override 97 | public boolean equals(Object obj) { 98 | if (this == obj) { 99 | return true; 100 | } 101 | if (!super.equals(obj)) { 102 | return false; 103 | } 104 | if (getClass() != obj.getClass()) { 105 | return false; 106 | } 107 | GroupPermission other = (GroupPermission) obj; 108 | if (this.mSetGid != other.mSetGid) { 109 | return false; 110 | } 111 | return true; 112 | } 113 | 114 | /** 115 | * {@inheritDoc} 116 | */ 117 | @Override 118 | public String toString() { 119 | return "GroupPermission [setgid=" + this.mSetGid //$NON-NLS-1$ 120 | + ", permission=" + super.toString() + "]"; //$NON-NLS-1$//$NON-NLS-2$ 121 | } 122 | 123 | /** 124 | * {@inheritDoc} 125 | */ 126 | @Override 127 | public String toRawString() { 128 | StringBuilder p = new StringBuilder(); 129 | p.append(isRead() ? READ : UNASIGNED); 130 | p.append(isWrite() ? WRITE : UNASIGNED); 131 | if (isSetGID()) { 132 | p.append(isExecute() ? SETGID_E : SETGID); 133 | } else { 134 | p.append(isExecute() ? EXECUTE : UNASIGNED); 135 | } 136 | return p.toString(); 137 | } 138 | 139 | } 140 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/fso/NamedPipe.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The CyanogenMod 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 | package com.mcxiaoke.shell.model.fso; 18 | 19 | import java.util.Date; 20 | 21 | /** 22 | * A class that represents a symbolic link. 23 | * 24 | * {@link "http://en.wikipedia.org/wiki/Named_pipe"} 25 | */ 26 | public class NamedPipe extends SystemFile { 27 | 28 | private static final long serialVersionUID = -5199356055601688190L; 29 | 30 | /** 31 | * The unix identifier of the object. 32 | * @hide 33 | */ 34 | public static final char UNIX_ID = 'p'; 35 | 36 | /** 37 | * Constructor of NamedPipe. 38 | * 39 | * @param name The name of the object 40 | * @param parent The parent folder of the object 41 | * @param user The user proprietary of the object 42 | * @param group The group proprietary of the object 43 | * @param permissions The permissions of the object 44 | * @param lastAccessedTime The last time that the object was accessed 45 | * @param lastModifiedTime The last time that the object was modified 46 | * @param lastChangedTime The last time that the object was changed 47 | */ 48 | public NamedPipe( 49 | String name, String parent, User user, Group group, Permissions permissions, 50 | Date lastAccessedTime, Date lastModifiedTime, Date lastChangedTime) { 51 | super(name, parent, user, group, permissions, 0L, 52 | lastAccessedTime, lastModifiedTime, lastChangedTime); 53 | } 54 | 55 | /** 56 | * {@inheritDoc} 57 | */ 58 | @Override 59 | public char getUnixIdentifier() { 60 | return UNIX_ID; 61 | } 62 | 63 | /** 64 | * {@inheritDoc} 65 | */ 66 | @Override 67 | public String toString() { 68 | return "NamedPipe [type=" + super.toString() + "]"; //$NON-NLS-1$//$NON-NLS-2$ 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/fso/OthersPermission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The CyanogenMod 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 | package com.mcxiaoke.shell.model.fso; 18 | 19 | /** 20 | * A class for represents a others permissions. 21 | * 22 | * @see Permission 23 | */ 24 | public class OthersPermission extends Permission { 25 | 26 | private static final long serialVersionUID = -8993601349099495256L; 27 | 28 | /** 29 | * @hide 30 | */ 31 | public static final char STICKY_E = 't'; 32 | /** 33 | * @hide 34 | */ 35 | public static final char STICKY = 'T'; 36 | 37 | private boolean mStickybit; 38 | 39 | /** 40 | * Constructor of OthersPermission. 41 | * 42 | * @param read If the object can be read 43 | * @param write If the object can be written 44 | * @param execute If the object can be executed 45 | */ 46 | public OthersPermission(boolean read, boolean write, boolean execute) { 47 | super(read, write, execute); 48 | this.mStickybit = false; 49 | } 50 | 51 | /** 52 | * Constructor of OthersPermission. 53 | * 54 | * @param read If the object can be read 55 | * @param write If the object can be written 56 | * @param execute If the object can be executed 57 | * @param stickybit If the object has the sticky bit active 58 | */ 59 | public OthersPermission(boolean read, boolean write, boolean execute, boolean stickybit) { 60 | super(read, write, execute); 61 | this.mStickybit = stickybit; 62 | } 63 | 64 | /** 65 | * Method that returns if the object has the sticky bit active. 66 | * 67 | * @return boolean If the object has the sticky bit active 68 | */ 69 | public boolean isStickybit() { 70 | return this.mStickybit; 71 | } 72 | 73 | /** 74 | * Method that sets if the object has the sticky bit active. 75 | * 76 | * @param stickybit If the object has the sticky bit active 77 | */ 78 | public void setStickybit(boolean stickybit) { 79 | this.mStickybit = stickybit; 80 | } 81 | 82 | /** 83 | * {@inheritDoc} 84 | */ 85 | @Override 86 | public int hashCode() { 87 | final int prime = 31; 88 | int result = super.hashCode(); 89 | result = prime * result + (this.mStickybit ? 1231 : 1237); 90 | return result; 91 | } 92 | 93 | /** 94 | * {@inheritDoc} 95 | */ 96 | @Override 97 | public boolean equals(Object obj) { 98 | if (this == obj) { 99 | return true; 100 | } 101 | if (!super.equals(obj)) { 102 | return false; 103 | } 104 | if (getClass() != obj.getClass()) { 105 | return false; 106 | } 107 | OthersPermission other = (OthersPermission) obj; 108 | if (this.mStickybit != other.mStickybit) { 109 | return false; 110 | } 111 | return true; 112 | } 113 | 114 | /** 115 | * {@inheritDoc} 116 | */ 117 | @Override 118 | public String toString() { 119 | return "OthersPermission [stickybit=" + this.mStickybit //$NON-NLS-1$ 120 | + ", permission=" + super.toString() + "]"; //$NON-NLS-1$//$NON-NLS-2$ 121 | } 122 | 123 | /** 124 | * {@inheritDoc} 125 | */ 126 | @Override 127 | public String toRawString() { 128 | StringBuilder p = new StringBuilder(); 129 | p.append(isRead() ? READ : UNASIGNED); 130 | p.append(isWrite() ? WRITE : UNASIGNED); 131 | if (isStickybit()) { 132 | p.append(isExecute() ? STICKY_E : STICKY); 133 | } else { 134 | p.append(isExecute() ? EXECUTE : UNASIGNED); 135 | } 136 | return p.toString(); 137 | } 138 | 139 | } 140 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/fso/ParentDirectory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The CyanogenMod 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 | package com.mcxiaoke.shell.model.fso; 18 | 19 | import com.mcxiaoke.shell.utils.FileHelper; 20 | 21 | 22 | /** 23 | * A class that represents a link to the parent directory. 24 | */ 25 | public class ParentDirectory extends Directory { 26 | 27 | private static final long serialVersionUID = -3818276335217197479L; 28 | 29 | /** 30 | * Constructor of ParentDirectory. 31 | * 32 | * @param parent The parent folder of the object 33 | */ 34 | public ParentDirectory(String parent) { 35 | super(FileHelper.PARENT_DIRECTORY, parent, null, null, null, null, null, null); 36 | } 37 | 38 | /** 39 | * {@inheritDoc} 40 | */ 41 | @Override 42 | public boolean isHidden() { 43 | return false; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/fso/Query.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The CyanogenMod 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 | package com.mcxiaoke.shell.model.fso; 18 | 19 | import android.text.TextUtils; 20 | 21 | import java.io.Serializable; 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | 25 | /** 26 | * A class that restrict the number of queries that can 27 | * be made to the application search system. 28 | */ 29 | public class Query implements Serializable { 30 | 31 | private static final long serialVersionUID = 3485374541081012723L; 32 | 33 | //IMP! This need to be sync which the command_list.xml resource 34 | //to have the same slots as the filled for the find command 35 | private static final int SLOTS_COUNT = 5; 36 | 37 | private final String[] mQUERIES = new String[SLOTS_COUNT]; 38 | 39 | /** 40 | * Constructor of Query. 41 | */ 42 | public Query() { 43 | super(); 44 | } 45 | 46 | /** 47 | * Method that returns the value of an slot. 48 | * 49 | * @param slot The slot number 50 | * @return String The text of the query at the slot 51 | */ 52 | public String getSlot(int slot) { 53 | return this.mQUERIES[slot]; 54 | } 55 | 56 | /** 57 | * Method that sets the value of an slot. 58 | * 59 | * @param query The text of the query at the slot 60 | * @param slot The slot number 61 | * @return Query The query reference 62 | */ 63 | public Query setSlot(String query, int slot) { 64 | this.mQUERIES[slot] = query; 65 | return this; 66 | } 67 | 68 | /** 69 | * Method that return the number of slots. 70 | * 71 | * @return int The number of slots 72 | */ 73 | public int getSlotsCount() { 74 | return this.mQUERIES.length; 75 | } 76 | 77 | /** 78 | * Method that fill all the available slots (filled from the minimum 79 | * to the maximum slot). 80 | * 81 | * @param queries The queries which fill the slots 82 | * @return Query The query reference 83 | */ 84 | public Query fillSlots(List queries) { 85 | int cc = queries.size(); 86 | for (int i = 0; i < cc; i++) { 87 | if (i > this.mQUERIES.length) { 88 | break; 89 | } 90 | this.mQUERIES[i] = queries.get(i); 91 | } 92 | return this; 93 | } 94 | 95 | /** 96 | * Method that returns the list of queries. 97 | * 98 | * @return List The list of queries 99 | */ 100 | public List getQueries() { 101 | List queries = new ArrayList(getSlotsCount()); 102 | int cc = this.mQUERIES.length; 103 | for (int i = 0; i < cc; i++) { 104 | if (this.mQUERIES[i] != null && this.mQUERIES[i].length() > 0) { 105 | queries.add(this.mQUERIES[i]); 106 | } 107 | } 108 | return queries; 109 | } 110 | 111 | /** 112 | * Method that returns the terms of the query in a single string separated by ", " string. 113 | * 114 | * @return String The terms of the query 115 | */ 116 | public String getTerms() { 117 | String terms = TextUtils.join(", ", getQueries().toArray(new String[]{})); //$NON-NLS-1$; 118 | if (terms.endsWith(", ")) { //$NON-NLS-1$; 119 | terms = ""; //$NON-NLS-1$; 120 | } 121 | return terms; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/fso/RegularFile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The CyanogenMod 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 | package com.mcxiaoke.shell.model.fso; 18 | 19 | import java.util.Date; 20 | 21 | /** 22 | * A class that represents a regular file. 23 | */ 24 | public class RegularFile extends FileSystemObject { 25 | 26 | private static final long serialVersionUID = 7113562456595400525L; 27 | 28 | /** 29 | * The unix identifier of the object. 30 | * @hide 31 | */ 32 | public static final char UNIX_ID = '-'; 33 | 34 | /** 35 | * Constructor of RegularFile. 36 | * 37 | * @param name The name of the object 38 | * @param parent The parent folder of the object 39 | * @param user The user proprietary of the object 40 | * @param group The group proprietary of the object 41 | * @param permissions The permissions of the object 42 | * @param size The size in bytes of the object 43 | * @param lastAccessedTime The last time that the object was accessed 44 | * @param lastModifiedTime The last time that the object was modified 45 | * @param lastChangedTime The last time that the object was changed 46 | */ 47 | public RegularFile(String name, String parent, User user, Group group, 48 | Permissions permissions, long size, 49 | Date lastAccessedTime, Date lastModifiedTime, Date lastChangedTime) { 50 | super(name, parent, user, group, permissions, size, 51 | lastAccessedTime, lastModifiedTime, lastChangedTime); 52 | } 53 | 54 | /** 55 | * {@inheritDoc} 56 | */ 57 | @Override 58 | public char getUnixIdentifier() { 59 | return UNIX_ID; 60 | } 61 | 62 | /** 63 | * {@inheritDoc} 64 | */ 65 | @Override 66 | public String toString() { 67 | return "RegularFile [type=" + super.toString() + "]"; //$NON-NLS-1$//$NON-NLS-2$ 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/fso/Symlink.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The CyanogenMod 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 | package com.mcxiaoke.shell.model.fso; 18 | 19 | import java.util.Date; 20 | 21 | /** 22 | * A class that represents a symbolic link. 23 | * 24 | * {@link "http://en.wikipedia.org/wiki/Symbolic_link"} 25 | */ 26 | public class Symlink extends FileSystemObject { 27 | 28 | private static final long serialVersionUID = -6411787401264288389L; 29 | 30 | /** 31 | * The unix identifier of the object. 32 | * @hide 33 | */ 34 | public static final char UNIX_ID = 'l'; 35 | 36 | private String mLink; 37 | private FileSystemObject mLinkRef; 38 | 39 | /** 40 | * Constructor of Symlink. 41 | * 42 | * @param name The name of the object 43 | * @param link The real file that this symlink is point to 44 | * @param parent The parent folder of the object 45 | * @param user The user proprietary of the object 46 | * @param group The group proprietary of the object 47 | * @param permissions The permissions of the object 48 | * @param lastAccessedTime The last time that the object was accessed 49 | * @param lastModifiedTime The last time that the object was modified 50 | * @param lastChangedTime The last time that the object was changed 51 | */ 52 | public Symlink(String name, String link, String parent, User user, 53 | Group group, Permissions permissions, 54 | Date lastAccessedTime, Date lastModifiedTime, Date lastChangedTime) { 55 | super(name, parent, user, group, permissions, 0L, 56 | lastAccessedTime, lastModifiedTime, lastChangedTime); 57 | this.mLink = link; 58 | } 59 | 60 | /** 61 | * Method that returns the real file that this symlink is point to. 62 | * 63 | * @return String The real file that this symlink is point to. 64 | */ 65 | public String getLink() { 66 | return this.mLink; 67 | } 68 | 69 | /** 70 | * Method that sets the real file that this symlink is point to. 71 | * 72 | * @param link the real file that this symlink is point to 73 | */ 74 | public void setLink(String link) { 75 | this.mLink = link; 76 | } 77 | 78 | /** 79 | * Method that returns the {@link FileSystemObject} reference of the symlink. 80 | * 81 | * @return FileSystemObject The {@link FileSystemObject} reference of the symlink 82 | */ 83 | public FileSystemObject getLinkRef() { 84 | return this.mLinkRef; 85 | } 86 | 87 | /** 88 | * Method that sets the {@link FileSystemObject} reference of the symlink. 89 | * 90 | * @param linkRef The {@link FileSystemObject} reference of the symlink 91 | */ 92 | public void setLinkRef(FileSystemObject linkRef) { 93 | this.mLinkRef = linkRef; 94 | } 95 | 96 | /** 97 | * {@inheritDoc} 98 | */ 99 | @Override 100 | public char getUnixIdentifier() { 101 | return UNIX_ID; 102 | } 103 | 104 | /** 105 | * {@inheritDoc} 106 | */ 107 | @Override 108 | public String toString() { 109 | return "Symlink [type=" + super.toString() + ", link=" //$NON-NLS-1$//$NON-NLS-2$ 110 | + this.mLink + "]"; //$NON-NLS-1$ 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/fso/SystemFile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The CyanogenMod 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 | package com.mcxiaoke.shell.model.fso; 18 | 19 | import java.util.Date; 20 | 21 | /** 22 | * A class that represents a system file (files with some system functionality). 23 | * 24 | * @see BlockDevice 25 | * @see CharacterDevice 26 | * @see NamedPipe 27 | * @see DomainSocket 28 | */ 29 | public abstract class SystemFile extends FileSystemObject { 30 | 31 | private static final long serialVersionUID = -1396396017050697459L; 32 | 33 | /** 34 | * Constructor of SystemFile. 35 | * 36 | * @param name The name of the object 37 | * @param parent The parent folder of the object 38 | * @param user The user proprietary of the object 39 | * @param group The group proprietary of the object 40 | * @param permissions The permissions of the object 41 | * @param size The size in bytes of the object 42 | * @param lastAccessedTime The last time that the object was accessed 43 | * @param lastModifiedTime The last time that the object was modified 44 | * @param lastChangedTime The last time that the object was changed 45 | */ 46 | public SystemFile( 47 | String name, String parent, User user, Group group, 48 | Permissions permissions, long size, 49 | Date lastAccessedTime, Date lastModifiedTime, Date lastChangedTime) { 50 | super(name, parent, user, group, permissions, size, 51 | lastAccessedTime, lastModifiedTime, lastChangedTime); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/fso/User.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The CyanogenMod 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 | package com.mcxiaoke.shell.model.fso; 18 | 19 | /** 20 | * A class that represents a user of the operating system. 21 | */ 22 | public class User extends AID { 23 | 24 | private static final long serialVersionUID = 8250909336356908786L; 25 | 26 | /** 27 | * Constructor of User. 28 | * 29 | * @param uid The user identifier 30 | * @param name The user name 31 | */ 32 | public User(int uid, String name) { 33 | super(uid, name); 34 | } 35 | 36 | /** 37 | * {@inheritDoc} 38 | */ 39 | @Override 40 | public String toString() { 41 | return "User [" + super.toString() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/model/fso/UserPermission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The CyanogenMod 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 | package com.mcxiaoke.shell.model.fso; 18 | 19 | /** 20 | * A class for represents a user permissions. 21 | * 22 | * @see Permission 23 | */ 24 | public class UserPermission extends Permission { 25 | 26 | private static final long serialVersionUID = -900037436267443837L; 27 | 28 | /** 29 | * @hide 30 | */ 31 | public static final char SETUID_E = 's'; 32 | /** 33 | * @hide 34 | */ 35 | public static final char SETUID = 'S'; 36 | 37 | private boolean mSetuid; 38 | 39 | /** 40 | * Constructor of UserPermission. 41 | * 42 | * @param read If the object can be read 43 | * @param write If the object can be written 44 | * @param execute If the object can be executed 45 | */ 46 | public UserPermission(boolean read, boolean write, boolean execute) { 47 | super(read, write, execute); 48 | this.mSetuid = false; 49 | } 50 | 51 | /** 52 | * Constructor of UserPermission. 53 | * 54 | * @param read If the object can be read 55 | * @param write If the object can be written 56 | * @param execute If the object can be executed 57 | * @param setuid If the object has the setuid bit active 58 | */ 59 | public UserPermission(boolean read, boolean write, boolean execute, boolean setuid) { 60 | super(read, write, execute); 61 | this.mSetuid = setuid; 62 | } 63 | 64 | /** 65 | * Method that returns if the object has the setuid bit active. 66 | * 67 | * @return boolean If the object has the setuid bit active. 68 | */ 69 | public boolean isSetUID() { 70 | return this.mSetuid; 71 | } 72 | 73 | /** 74 | * Method that sets if the object has the setuid bit active. 75 | * 76 | * @param setuid If the object has the setuid bit active 77 | */ 78 | public void setSetUID(boolean setuid) { 79 | this.mSetuid = setuid; 80 | } 81 | 82 | /** 83 | * {@inheritDoc} 84 | */ 85 | @Override 86 | public int hashCode() { 87 | final int prime = 31; 88 | int result = super.hashCode(); 89 | result = prime * result + (this.mSetuid ? 1231 : 1237); 90 | return result; 91 | } 92 | 93 | /** 94 | * {@inheritDoc} 95 | */ 96 | @Override 97 | public boolean equals(Object obj) { 98 | if (this == obj) { 99 | return true; 100 | } 101 | if (!super.equals(obj)) { 102 | return false; 103 | } 104 | if (getClass() != obj.getClass()) { 105 | return false; 106 | } 107 | UserPermission other = (UserPermission) obj; 108 | if (this.mSetuid != other.mSetuid) { 109 | return false; 110 | } 111 | return true; 112 | } 113 | 114 | /** 115 | * {@inheritDoc} 116 | */ 117 | @Override 118 | public String toString() { 119 | return "UserPermission [setuid=" + this.mSetuid + //$NON-NLS-1$ 120 | ", permission=" + super.toString() + "]"; //$NON-NLS-1$//$NON-NLS-2$ 121 | } 122 | 123 | /** 124 | * {@inheritDoc} 125 | */ 126 | @Override 127 | public String toRawString() { 128 | StringBuilder p = new StringBuilder(); 129 | p.append(isRead() ? READ : UNASIGNED); 130 | p.append(isWrite() ? WRITE : UNASIGNED); 131 | if (isSetUID()) { 132 | p.append(isExecute() ? SETUID_E : SETUID); 133 | } else { 134 | p.append(isExecute() ? EXECUTE : UNASIGNED); 135 | } 136 | return p.toString(); 137 | } 138 | 139 | } 140 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/others/BusyboxUtils.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.shell.others; 2 | 3 | public class BusyboxUtils { 4 | 5 | /*public static boolean isSuBusyboxReady() { 6 | boolean a = RootUtils.hasSu(); 7 | boolean b = RootUtils.hasSuperuser(); 8 | boolean c = RootUtils.hasBusybox(); 9 | return (a && b && c); 10 | } 11 | 12 | public static boolean installBusybox(Context context) { 13 | 14 | CommandResult result = null; 15 | boolean ret = copyBusybox(context); 16 | if (!ret) { 17 | return false; 18 | } 19 | result = RootUtils.runCommand(String.format( 20 | "cat %sbusybox > /system/xbin/busybox", DirHelper.BUSYBOX_DIR), 21 | true, null); 22 | result = RootUtils.runCommand("chmod 777 /system/xbin/busybox", true, null); 23 | result = RootUtils.runCommand( 24 | "/system/xbin/busybox --install -s /system/xbin", true, null); 25 | if (!result.error.equals("")) { 26 | return false; 27 | } 28 | return true; 29 | 30 | } 31 | 32 | public static boolean installSuperuser(Context context, boolean isICS) { 33 | 34 | CommandResult result = null; 35 | boolean ret = copySuperuser(context, (isICS ? "ics" : "old")); 36 | if (!ret) { 37 | return false; 38 | } 39 | result = RootUtils.runCommand(String.format( 40 | "cat %sSuperuser_%s.apk > /system/app/Superuser.apk", 41 | DirHelper.BUSYBOX_DIR, (isICS ? "ics" : "old")), true, null); 42 | if (!result.error.equals("")) { 43 | return false; 44 | } 45 | return true; 46 | 47 | } 48 | 49 | public static boolean removeBusybox() { 50 | 51 | CommandResult result = null; 52 | result = RootUtils 53 | .runCommand( 54 | "busybox find /system/xbin -type l | busybox xargs rm -r", 55 | true, null); 56 | result = RootUtils.runCommand("rm /system/xbin/busybox", true, null); 57 | if (!result.error.equals("")) { 58 | return false; 59 | } 60 | 61 | return true; 62 | 63 | } 64 | 65 | public static boolean removeSuperuser() { 66 | 67 | RootUtils.runCommand("rm /system/app/Superuser.*", true, null); 68 | RootUtils.runCommand("rm /system/app/SuperSU.*", true, null); 69 | RootUtils.runCommand("rm /system/app/SuperSU_Pro.*", true, null); 70 | return true; 71 | } 72 | 73 | private static boolean copyBusybox(Context context) { 74 | File fBusybox = new File(DirHelper.BUSYBOX_DIR); 75 | if (!fBusybox.exists()) { 76 | fBusybox.mkdirs(); 77 | } 78 | try { 79 | byte[] buffer = new byte[8192]; 80 | 81 | File dest = new File(DirHelper.BUSYBOX_DIR + "busybox"); 82 | 83 | if (dest.exists()) { 84 | dest.delete(); 85 | } 86 | 87 | InputStream is = context.getAssets().open("busybox"); 88 | OutputStream fos = new BufferedOutputStream(new FileOutputStream( 89 | dest)); 90 | int n; 91 | while ((n = is.read(buffer, 0, buffer.length)) != -1) 92 | fos.write(buffer, 0, n); 93 | 94 | is.close(); 95 | fos.close(); 96 | return true; 97 | } catch (Exception ex) { 98 | return false; 99 | } 100 | } 101 | 102 | private static boolean copySuperuser(Context context, String surfix) { 103 | File fBusybox = new File(DirHelper.BUSYBOX_DIR); 104 | if (!fBusybox.exists()) { 105 | fBusybox.mkdirs(); 106 | } 107 | try { 108 | byte[] buffer = new byte[8192]; 109 | 110 | File dest = new File(DirHelper.BUSYBOX_DIR + "Superuser_" + surfix 111 | + ".apk"); 112 | 113 | if (dest.exists()) { 114 | dest.delete(); 115 | } 116 | 117 | InputStream is = context.getAssets().open( 118 | "Superuser_" + surfix + ".apk"); 119 | OutputStream fos = new BufferedOutputStream(new FileOutputStream( 120 | dest)); 121 | int n; 122 | while ((n = is.read(buffer, 0, buffer.length)) != -1) 123 | fos.write(buffer, 0, n); 124 | 125 | is.close(); 126 | fos.close(); 127 | return true; 128 | } catch (Exception ex) { 129 | return false; 130 | } 131 | } 132 | */ 133 | } 134 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/others/CacheUtils.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.shell.others; 2 | 3 | public class CacheUtils { 4 | 5 | /* public static List getCacheList() { 6 | 7 | List result = null; 8 | 9 | CommandResult cmdResult = RootUtils.runCommand( 10 | "busybox find /data/data/ -name \"cache\"", true, null); 11 | if (cmdResult.error.equals("") && cmdResult.result.equals("")) { 12 | return result; 13 | } 14 | 15 | cmdResult = RootUtils 16 | .runCommand( 17 | "busybox find /data/data/ -name \"cache\" | busybox xargs du -s", 18 | true, null); 19 | if (cmdResult.error.equals("")) { 20 | String cacheString = cmdResult.result; 21 | cacheString = cacheString.replace("\t", " "); 22 | cacheString = cacheString.replace("/data/data/", "") 23 | .replace("/cache", "").replace("\n", "|"); 24 | cacheString = cacheString.replaceAll("\\s+", " "); 25 | String[] lines = cacheString.split("\\|"); 26 | 27 | if (lines != null && lines.length != 0) { 28 | result = new ArrayList(); 29 | for (String s : lines) { 30 | if (s.trim().equals("")) { 31 | continue; 32 | } 33 | CacheInfo info = CacheInfo.parseString(s); 34 | if (info != null) { 35 | result.add(info); 36 | } 37 | } 38 | } 39 | } 40 | return result; 41 | } 42 | 43 | public static boolean cleanCache(CacheInfo info) { 44 | String path = "rm -r /data/data/%s/cache"; 45 | CommandResult result = RootUtils.runCommand( 46 | String.format(path, info.namespace), true, null); 47 | return result.error.equals(""); 48 | } 49 | 50 | public static boolean cleanAllCache() { 51 | String cmd = "busybox find /data/data/ -name \"cache\" | busybox xargs rm -r"; 52 | CommandResult result = RootUtils.runCommand(cmd, true, null); 53 | return result.error.equals(""); 54 | } 55 | 56 | public static String countCache(List list) { 57 | if (list == null || list.size() == 0) { 58 | return "0.0M"; 59 | } 60 | double count = 0D; 61 | String size = ""; 62 | double sizeD = 0D; 63 | for (CacheInfo info : list) { 64 | size = info.cacheSize; 65 | try { 66 | sizeD = Double 67 | .parseDouble(size.substring(0, size.length() - 1)); 68 | } catch (Exception e) { 69 | sizeD = 0D; 70 | } 71 | 72 | count += sizeD; 73 | } 74 | 75 | count /= 1024; 76 | String ret = new DecimalFormat("#.##").format(count) + "M"; 77 | return ret; 78 | }*/ 79 | } 80 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/others/Compress.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.shell.others; 2 | 3 | import android.util.Log; 4 | 5 | import java.io.BufferedInputStream; 6 | import java.io.BufferedOutputStream; 7 | import java.io.FileInputStream; 8 | import java.io.FileOutputStream; 9 | import java.util.zip.ZipEntry; 10 | import java.util.zip.ZipOutputStream; 11 | 12 | 13 | public class Compress { 14 | 15 | private static final int BUFFER = 2048; 16 | 17 | private String[] _files; 18 | private String _zipFile; 19 | 20 | public Compress(String[] files, String zipFile) { 21 | _files = files; 22 | _zipFile = zipFile; 23 | } 24 | 25 | public void zip(String location) { 26 | try { 27 | BufferedInputStream origin = null; 28 | FileOutputStream dest = new FileOutputStream(_zipFile); 29 | 30 | ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest)); 31 | 32 | byte data[] = new byte[BUFFER]; 33 | 34 | for (int i = 0; i < _files.length; i++) { 35 | Log.v("Compress", "Adding: " + _files[i]); 36 | FileInputStream fi = new FileInputStream(_files[i]); 37 | origin = new BufferedInputStream(fi, BUFFER); 38 | ZipEntry entry = new ZipEntry(_files[i].substring(_files[i].lastIndexOf(location) + 1)); 39 | out.putNextEntry(entry); 40 | int count; 41 | while ((count = origin.read(data, 0, BUFFER)) != -1) { 42 | out.write(data, 0, count); 43 | } 44 | origin.close(); 45 | } 46 | 47 | out.close(); 48 | } catch (Exception e) { 49 | e.printStackTrace(); 50 | } 51 | 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/others/DalvikUtils.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.shell.others; 2 | 3 | public class DalvikUtils { 4 | 5 | // return -1 for failed 6 | // return 0 and more for cleaned count 7 | /* public static int cleanDalvik() { 8 | 9 | CommandResult cmdResult = RootUtils.runCommand( 10 | "ls /data/dalvik-cache/", true, null); 11 | if (!cmdResult.error.equals("")) { 12 | return -1; 13 | } 14 | 15 | String str = cmdResult.result.replace("@", "/").replace("/classes.dex", 16 | ""); 17 | String[] dalvikStr = str.split("\n"); 18 | 19 | File fClean = null; 20 | int cleanCount = 0; 21 | String dalvikName = ""; 22 | CommandResult cleanResult = null; 23 | if (dalvikStr != null && dalvikStr.length != 0) { 24 | for (String s : dalvikStr) { 25 | fClean = new File(s); 26 | if (!fClean.exists()) { 27 | dalvikName = s.replace("/", "@"); 28 | cleanResult = RootUtils.runCommand(String.format( 29 | "rm -r /data/dalvik-cache/%s*", dalvikName), true, 30 | null); 31 | if (!cleanResult.error.equals("")) { 32 | return -1; 33 | } else { 34 | cleanCount++; 35 | } 36 | 37 | } 38 | } 39 | } 40 | return cleanCount; 41 | } 42 | 43 | public static void doCleanDalvikT(final Context context, final View view, 44 | final Preference pref) { 45 | 46 | pref.setTitle(R.string.cleaning_dalvik); 47 | view.setEnabled(false); 48 | 49 | final Handler h = new Handler() { 50 | @Override 51 | public void handleMessage(Message msg) { 52 | if (msg.what == 1) { 53 | 54 | pref.setTitle(R.string.clean_dalvik); 55 | view.setEnabled(true); 56 | 57 | if (msg.arg1 == -1) { 58 | Toast.makeText(context, R.string.clean_dalvik_fail, 59 | Toast.LENGTH_LONG).show(); 60 | } else if (msg.arg1 == 0) { 61 | Toast.makeText(context, R.string.clean_dalvik_0, 62 | Toast.LENGTH_LONG).show(); 63 | } else { 64 | Toast.makeText( 65 | context, 66 | String.format(context 67 | .getString(R.string.clean_dalvik_succ), 68 | msg.arg1), Toast.LENGTH_LONG).show(); 69 | } 70 | } 71 | super.handleMessage(msg); 72 | } 73 | }; 74 | new Thread(new Runnable() { 75 | 76 | @Override 77 | public void run() { 78 | Message msg = new Message(); 79 | msg.what = 1; 80 | msg.arg1 = cleanDalvik(); 81 | h.sendMessage(msg); 82 | 83 | } 84 | }).start(); 85 | }*/ 86 | } 87 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/others/Decompress.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.shell.others; 2 | 3 | import android.util.Log; 4 | 5 | import java.io.BufferedInputStream; 6 | import java.io.BufferedOutputStream; 7 | import java.io.File; 8 | import java.io.FileOutputStream; 9 | import java.io.IOException; 10 | import java.util.Enumeration; 11 | import java.util.zip.ZipEntry; 12 | import java.util.zip.ZipFile; 13 | 14 | public class Decompress { 15 | private String _zipFile; 16 | private String _location; 17 | 18 | public Decompress(String zipFile, String location) { 19 | _zipFile = zipFile; 20 | _location = location; 21 | } 22 | 23 | public void unzip() { 24 | try { 25 | 26 | File fSourceZip = new File(_zipFile); 27 | String zipPath = _zipFile.substring(0, _zipFile.length() - 4); 28 | //File temp = new File(zipPath); 29 | //temp.mkdir(); 30 | Log.v("Decompress", zipPath + " created"); 31 | 32 | /* 33 | * Extract entries while creating required sub-directories 34 | */ 35 | ZipFile zipFile = new ZipFile(fSourceZip); 36 | Enumeration e = zipFile.entries(); 37 | 38 | while (e.hasMoreElements()) { 39 | ZipEntry entry = (ZipEntry) e.nextElement(); 40 | File destinationFilePath = new File(_location, entry.getName()); 41 | 42 | // create directories if required. 43 | destinationFilePath.getParentFile().mkdirs(); 44 | 45 | // if the entry is directory, leave it. Otherwise extract it. 46 | if (entry.isDirectory()) { 47 | continue; 48 | } else { 49 | Log.v("Decompress", "Unzipping " + entry.getName()); 50 | 51 | /* 52 | * Get the InputStream for current entry of the zip file 53 | * using 54 | * 55 | * InputStream getInputStream(Entry entry) method. 56 | */ 57 | BufferedInputStream bis = new BufferedInputStream( 58 | zipFile.getInputStream(entry)); 59 | 60 | int b; 61 | byte buffer[] = new byte[1024]; 62 | 63 | /* 64 | * read the current entry from the zip file, extract it and 65 | * write the extracted file. 66 | */ 67 | FileOutputStream fos = new FileOutputStream(destinationFilePath); 68 | BufferedOutputStream bos = new BufferedOutputStream(fos, 69 | 1024); 70 | 71 | while ((b = bis.read(buffer, 0, 1024)) != -1) { 72 | bos.write(buffer, 0, b); 73 | } 74 | 75 | // flush the output stream and close it. 76 | bos.flush(); 77 | bos.close(); 78 | 79 | // close the input stream. 80 | bis.close(); 81 | } 82 | } 83 | } catch (IOException ioe) { 84 | Log.e("Decompress", "unzip", ioe); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/others/HostsUtils.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.shell.others; 2 | 3 | public class HostsUtils { 4 | /* 5 | public static boolean copyHosts(String text, String fileName) { 6 | try { 7 | FileUtils.rewriteFile(fileName, text); 8 | String cmd = String.format("busybox cp %s /system/etc/", fileName); 9 | CommandResult result = RootUtils.runCommand(cmd, true, null); 10 | if (result.error.equals("")) { 11 | result = RootUtils.runCommand("chmod 644 /system/etc/hosts", 12 | true, null); 13 | } 14 | return result.error.equals(""); 15 | } catch (Exception e) { 16 | return false; 17 | } 18 | }*/ 19 | } 20 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/others/MemorySpecialList.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.shell.others; 2 | 3 | public class MemorySpecialList { 4 | 5 | /* private static final String PATH_LIST = DirHelper.MEM_DIR + "ignore"; 6 | private static List lstExclude = new ArrayList(); 7 | 8 | public static List getExcludeList() { 9 | return lstExclude; 10 | } 11 | 12 | public static int inExcludeList(String ns) { 13 | int ret = -1; 14 | 15 | for (int i = 0; i < lstExclude.size(); i++) { 16 | 17 | if (lstExclude.getIcon(i).namespace.equals(ns)) { 18 | ret = i; 19 | break; 20 | } 21 | } 22 | return ret; 23 | } 24 | 25 | public static boolean isExcludeLocked(String ns) { 26 | boolean ret = false; 27 | for (int i = 0; i < lstExclude.size(); i++) { 28 | if (lstExclude.getIcon(i).namespace.equals(ns)) { 29 | ret = lstExclude.getIcon(i).locked; 30 | break; 31 | } 32 | } 33 | return ret; 34 | } 35 | 36 | public static void loadExcludeList() { 37 | List list = null; 38 | try { 39 | list = FileUtils.readFile(PATH_LIST); 40 | } catch (IOException e) { 41 | 42 | } 43 | 44 | lstExclude.clear(); 45 | // self 46 | lstExclude.add(newIgnoreInfo("com.rarnu.tools.root", true)); 47 | 48 | // system 49 | lstExclude.add(newIgnoreInfo("android.process.acore", true)); 50 | lstExclude.add(newIgnoreInfo("system_server", true)); 51 | lstExclude.add(newIgnoreInfo("com.android.systemui", true)); 52 | lstExclude.add(newIgnoreInfo("com.android.phone", true)); 53 | 54 | // htc 55 | lstExclude.add(newIgnoreInfo("com.htc.launcher", true)); 56 | 57 | if (list != null && list.size() != 0) { 58 | for (String s : list) { 59 | if (inExcludeList(s) == -1) { 60 | lstExclude.add(newIgnoreInfo(s, false)); 61 | } 62 | } 63 | } 64 | 65 | } 66 | 67 | private static MemIgnoreInfo newIgnoreInfo(String ns, boolean locked) { 68 | MemIgnoreInfo info = new MemIgnoreInfo(); 69 | info.namespace = ns; 70 | info.checked = false; 71 | info.locked = locked; 72 | return info; 73 | } 74 | 75 | public static void addExclude(String ns) { 76 | if (inExcludeList(ns) == -1) { 77 | MemIgnoreInfo info = new MemIgnoreInfo(); 78 | info.namespace = ns; 79 | info.checked = false; 80 | info.locked = false; 81 | lstExclude.add(info); 82 | } 83 | } 84 | 85 | public static void removeExclude(String ns) { 86 | int idx = inExcludeList(ns); 87 | if (idx != -1) { 88 | lstExclude.remove(idx); 89 | } 90 | } 91 | 92 | public static void removeExclude(int index) { 93 | lstExclude.remove(index); 94 | } 95 | 96 | public static boolean saveExclude() { 97 | String ignore = ""; 98 | for (MemIgnoreInfo info : lstExclude) { 99 | ignore += info.namespace + "\n"; 100 | } 101 | try { 102 | FileUtils.rewriteFile(PATH_LIST, ignore); 103 | return true; 104 | } catch (Exception e) { 105 | return false; 106 | } 107 | }*/ 108 | 109 | } 110 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/others/MemoryUtils.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.shell.others; 2 | 3 | public class MemoryUtils { 4 | 5 | // public static MemoryInfo getMemoryInfo() { 6 | 7 | /* MemoryInfo ret = null; 8 | CommandResult result = RootUtils.runCommand("busybox free", false, null); 9 | if (result != null) { 10 | if (result.error.equals("")) { 11 | ret = new MemoryInfo(); 12 | 13 | String r = result.result; 14 | r = r.toLowerCase(); 15 | r = r.replace("total", "").replace("used", "") 16 | .replace("free", "").replace("shared", "") 17 | .replace("buffers", "").replace("mem:", ""); 18 | r = r.replaceAll("\\s+", " ").trim(); 19 | 20 | String[] ss = r.split(" "); 21 | ret.Total = Integer.parseInt(ss[0]) / 1024; 22 | ret.Used = Integer.parseInt(ss[1]) / 1024; 23 | ret.Free = Integer.parseInt(ss[2]) / 1024; 24 | ret.Shared = Integer.parseInt(ss[3]) / 1024; 25 | ret.Buffer = Integer.parseInt(ss[4]) / 1024; 26 | 27 | } 28 | } 29 | 30 | return ret; 31 | } 32 | 33 | public static void killProcess(int pid) { 34 | RootUtils.runCommand(String.format("kill %d", pid), true, null); 35 | } 36 | 37 | public static void dropCache() { 38 | RootUtils.runCommand("echo 3 > /proc/sys/vm/drop_caches", true, null); 39 | try { 40 | Thread.sleep(1000); 41 | } catch (InterruptedException e) { 42 | } 43 | RootUtils.runCommand("echo 0 > /proc/sys/vm/drop_caches", true, null); 44 | }*/ 45 | } 46 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/others/ProcessUtils.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.shell.others; 2 | 3 | public class ProcessUtils { 4 | 5 | /* public static List getUserProcessList() { 6 | return getProcessList(); 7 | } 8 | 9 | private static List getProcessList() { 10 | 11 | List ret = null; 12 | 13 | CommandResult result = RootUtils.runCommand("toolbox ps", false, null); 14 | int position = 0; 15 | if (result != null) { 16 | if (result.error.equals("")) { 17 | String r = result.result; 18 | r = r.toLowerCase(); 19 | // r = r.replaceAll("\\s+", " "); 20 | String[] ss = r.split("\n"); 21 | ret = new ArrayList(); 22 | for (int i = 1; i < ss.length; i++) { 23 | if (!ss[i].startsWith("root")) { 24 | MemProcessInfo info = null; 25 | try { 26 | info = MemProcessInfo.stringToProcessInfo(ss[i]); 27 | } catch (Exception e) { 28 | info = null; 29 | } 30 | 31 | if (info == null) { 32 | continue; 33 | } 34 | if (info.PID > 127) { 35 | info.position = position; 36 | ret.add(info); 37 | position++; 38 | } 39 | } 40 | } 41 | } 42 | } 43 | return ret; 44 | }*/ 45 | } 46 | -------------------------------------------------------------------------------- /src/com/mcxiaoke/shell/others/RemoteAdbd.java: -------------------------------------------------------------------------------- 1 | package com.mcxiaoke.shell.others; 2 | 3 | /** 4 | * @hide 5 | */ 6 | class RemoteAdbd { 7 | 8 | /* private static final String GET_PORT = "getprop service.adb.tcp.port"; 9 | private static final String SET_PORT = "setprop service.adb.tcp.port 5555"; 10 | private static final String SET_PORT_USB = "setprop service.adb.tcp.port -1"; 11 | 12 | private static final String STOP_ADBD = "stop adbd"; 13 | private static final String START_ADBD = "start adbd"; 14 | 15 | public static boolean isRemoteConnected() { 16 | boolean rc = false; 17 | CommandResult ret = RootUtils.runCommand(GET_PORT, true, null); 18 | if (ret.error.equals("")) { 19 | String port = ret.result; 20 | if (port.equals("5555")) { 21 | rc = true; 22 | } 23 | } 24 | return rc; 25 | } 26 | 27 | public static boolean switchAdbd(boolean isStop) { 28 | boolean r = true; 29 | CommandResult ret = RootUtils.runCommand((isStop ? SET_PORT_USB : SET_PORT), true, null); 30 | if (!ret.error.equals("")) { 31 | r = false; 32 | } 33 | if (r) { 34 | ret = RootUtils.runCommand(STOP_ADBD, true, null); 35 | if (!ret.error.equals("")) { 36 | r = false; 37 | } 38 | } 39 | if (r) { 40 | ret = RootUtils.runCommand(START_ADBD, true, null); 41 | if (!ret.error.equals("")) { 42 | r = false; 43 | } 44 | } 45 | return r; 46 | } 47 | 48 | public static String getIpAddress() { 49 | try { 50 | for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { 51 | NetworkInterface intf = en.nextElement(); 52 | for (Enumeration enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { 53 | InetAddress inetAddress = enumIpAddr.nextElement(); 54 | if (!inetAddress.isLoopbackAddress()) { 55 | return inetAddress.getHostAddress().toString(); 56 | } 57 | } 58 | } 59 | } catch (SocketException ex) { 60 | 61 | } 62 | return ""; 63 | } 64 | 65 | public static boolean isWifiActive(Context context) { 66 | Context con = context.getApplicationContext(); 67 | ConnectivityManager connectivity = (ConnectivityManager) con.getSystemService(Context.CONNECTIVITY_SERVICE); 68 | boolean ret = false; 69 | if (connectivity != null) { 70 | NetworkInfo[] info = connectivity.getAllNetworkInfo(); 71 | if (info != null) { 72 | for (int i = 0; i < info.length; i++) { 73 | String typ = info[i].getTypeName().toUpperCase(); 74 | if (typ.equals("WIFI") && info[i].isConnected()) { 75 | ret = true; 76 | } 77 | } 78 | } 79 | } 80 | return ret; 81 | }*/ 82 | } 83 | --------------------------------------------------------------------------------