开发者

Add Server classes to android.jar

Right now I am able to get access to the hidden and internal android APIs, but now I want access to things like AlarmManagerService which is in server. I used adb pull system/framework/services.jar changed services.jar to services.zip which unpacked a directory of all the server classes (including AlarmManagerService which I was looking for). My question now is how can I add those server classes to my android.jar file which I can then use in Eclipse?

I hope that makes sense the way I worded it. Let me know if there is any confusion I can clear up.

EDIT: Essentially, when all is said and done, I want to be able to do something like below without any errors:

import com.android.server.AlarmManagerService;

public class TestActivity extends Activity {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        AlarmManagerService ams = new AlarmManagerService(this.getApplicationContext());
        ams.setTime(1313);
    }
}

ANOTHER EDIT:

I figured this out after looking at all the source code.

Classes like AlarmManagerService just have package visibility which is why it cannot be imported. Some classes are public, but many other com.android.server classes have package constructors so they can't be instantiated.

Here are the com.android.server.* I was able to import and successfully create an object of:

import com.android.server.AttributeCache;                   
import com.android.server.BootReceiver;                     
import com.android.server.BrickReceiver;                    
import com.android.server.ClipboardService;                 
import com.android.server.ConnectivityService;              
import com.android.server.DevicePolicyManagerService;       
import com.android.server.DiskStatsService;                 
import com.android.server.DropBoxManagerService;            
import com.android.server.EntropyService;                   
import com.android.server.InputMethodManagerService;        
import com.android.server.LocationManagerService;           
import com.android.server.MasterClearReceiver;              
import com.android.server.NativeDaemonConnectorException;   
import com.android.server.NetStatService;                   
import com.android.server.NotificationPlayer;               
import com.a开发者_开发技巧ndroid.server.ProcessMap;                       
import com.android.server.ProcessStats;                     
import com.android.server.SystemBackupAgent;                
import com.android.server.SystemServer;                     
import com.android.server.ThrottleService;                      
import com.android.server.TwilightCalculator;               
import com.android.server.Watchdog;                         

import com.android.server.connectivity.Tethering;           

import com.android.server.status.AnimatedImageView;
import com.android.server.status.CloseDragHandle;
import com.android.server.status.DateView;
import com.android.server.status.ExpandedView;
import com.android.server.status.IconMerger;
import com.android.server.status.LatestItemView;
import com.android.server.status.NotificationData;
import com.android.server.status.NotificationLinearLayout;
import com.android.server.status.StatusBarService;
import com.android.server.status.StatusBarView;
import com.android.server.status.StorageNotification;
import com.android.server.status.TickerView;
import com.android.server.status.TrackingPatternView;
import com.android.server.status.TrackingView;
import com.android.server.status.UsbStorageActivity;


android.jar contains only the public API's class files and I think you made changes in 'com.android' package or its internal packages. So to reflect the changes in eclipse you have to add the path explicitly to your service.jar to your project. But remeber this will not reflected at run time, since the emulator or the device you are using have not been updated your changes. And you can't update them by simply modifying the jar file, since the device or emulator uses the image 'system.img' which internally have .dex file as library not the .jar file for internal APIs. To make changes for device/emulator you have to build the whole code and for that you can refer the http://source.android.com/source/index.html.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜