String[] serviceList = (String[]) Class.forName("android.os.ServiceManager")
.getDeclaredMethod("listServices").invoke(null);
String result = "";
for(int i=0; i<serviceList.length; i++)
{
result += serviceList[i] + ",\n";
System.out.println(serviceList[i]);
}
Result:
SYSSCOPE,
iphoneinfo,
isprintextension,
sip,
phoneext,
phone,
com.orange.authentication.simcard,
isms,
iphonesubinfo,
simphonebook,
nfc,
tvoutservice,
samsung.facedetection_service,
voip,
motion_recognition,
commontime_management,
mini_mode_app_manager,
samplingprofiler,
AtCmdFwd,
diskstats,
appwidget,
backup,
uimode,
serial,
usb,
audio,
wallpaper,
dropbox,
search,
country_detector,
location,
devicestoragemonitor,
notification,
updatelock,
throttle,
servicediscovery,
connectivity,
wfd,
wifi,
wifip2p,
netpolicy,
netstats,
textservices,
network_management,
clipboardEx,
clipboard,
statusbar,
enterprise_policy,
edm_proxy,
apppermission_control_policy,
kioskmode,
remoteinjection,
date_time_policy,
browser_policy,
phone_restriction_policy,
apn_settings_policy,
enterprise_vpn_policy,
vpn_policy,
firewall_policy,
email_policy,
bluetooth_policy,
wifi_policy,
roaming_policy,
security_policy,
password_policy,
restriction_policy,
misc_policy,
location_policy,
email_account_policy,
eas_account_policy,
device_info,
application_policy,
device_policy,
lock_settings,
mount,
CustomFrequencyManagerService,
accessibility,
input_method,
bluetooth_avrcp,
bluetooth_a2dp,
bluetooth,
input,
window,
alarm,
vibrator,
battery,
hardware,
DirEncryptService,
content,
account,
permission,
cpuinfo,
dbinfo,
gfxinfo,
meminfo,
activity,
package,
scheduling_policy,
telephony.registry,
usagestats,
batteryinfo,
power,
entropy,
mdm.remotedesktop,
sensorservice,
media.gestures,
media.audio_policy,
SurfaceFlinger,
media.camera,
media.player,
media.audio_flinger,
display.hwcservice,
drm.drmManager,
TvoutService_C
2013年6月4日星期二
Get IMountService by reflection
Please see these codes in src/com/android/settings/deviceinfo/Memory.java
So you know how to get IMountService now.
Method method = Class.forName("android.os.ServiceManager").getMethod("getService", "String.class);
IBinder binder = (IBinder) method.invoke(null, "mount");
IMountService iMountService = IMountService.Stub.asInterface(binder);
116 | private synchronized IMountService getMountService() { |
117 | if (mMountService == null) { |
118 | IBinder service = ServiceManager.getService("mount"); |
119 | if (service != null) { |
120 | mMountService = IMountService.Stub.asInterface(service); |
121 | } else { |
122 | Log.e(TAG, "Can't get mount service"); |
123 | } |
124 | } |
125 | return mMountService; |
126 | } |
So you know how to get IMountService now.
Method method = Class.forName("android.os.ServiceManager").getMethod("getService", "String.class);
IBinder binder = (IBinder) method.invoke(null, "mount");
IMountService iMountService = IMountService.Stub.asInterface(binder);
订阅:
博文 (Atom)