2013年6月4日星期二

Get IMountService by reflection

Please see these codes in src/com/android/settings/deviceinfo/Memory.java

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);

没有评论:

发表评论