免aidl调用绑定服务

/*
     *
     *NTP同步成功,则获取当前系统时间存入RTC
     *
     */
    private void setRTCTime(){
        Log.i(TAG, "setRTCTime start");
        long currentTime = System.currentTimeMillis();
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd-HHmmss");  
        Date d = new Date(currentTime);  
        String t = format.format(d);
        int date = Integer.parseInt(t.split("-")[0]) * 10;
        int time = Integer.parseInt(t.split("-")[1]);
        android.os.Parcel _data = android.os.Parcel.obtain();
        android.os.Parcel _reply = android.os.Parcel.obtain();
        try{
            int _result;
            final int TRANSACTION_setRTCTime = (android.os.IBinder.FIRST_CALL_TRANSACTION + 57);
            final String DESCRIPTOR = "net.sunniwell.ISWRootService";
            android.os.IBinder rootService = android.os.ServiceManager.getService("SWRootService");
            _data.writeInterfaceToken(DESCRIPTOR);
            _data.writeInt(date);
            _data.writeInt(time);
            rootService.transact(TRANSACTION_setRTCTime, _data, _reply, 0);
            _reply.readException();
            _result = _reply.readInt();
        }catch(Exception e){
            e.printStackTrace();
        }finally{
            _reply.recycle();
            _data.recycle();
        }   
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值