opp分析(BluetoothOppService的启动)

      1)注册了database的改变监控。

      2)通知栏信息的刷新

      3)清理数据库

      4)注册ACTION_STATE_CHANGEDreceiver

      5)开始rfcommsocket的监听

      6)启动updatethread,在传输过程中根据传输的情况进行不断地刷新。



void BluetoothOppService::onCreate() {

    GLOGENTRY();
    Service::onCreate();
    GLOGI("Service onCreate");

    mHandler = new BtoppServiceHandler(this);
    GLOGD("BluetoothOppService:: BtoppServiceHandler count %d", getStrongCount());


//注册ACTION_STATE_CHANGED的receiver,用于处理蓝牙文件传输过程中的蓝牙开关操作

    mBluetoothReceiver = new BtoppServiceBroadcastReceiver(this);
    GLOGD("BluetoothOppService:: BtoppServiceBroadcastReceiver count %d", getStrongCount());
    sp<IntentFilter> filter = new IntentFilter(BluetoothAdapter::ACTION_STATE_CHANGED());
    registerReceiver(mBluetoothReceiver, filter);

    GLOGD("BluetoothOppService:: count %d", getStrongCount());


    mAdapter = BluetoothAdapter::getDefaultAdapter();

    GLOGD("BluetoothOppService:: count %d", getStrongCount());


    mSocketListener = new BluetoothOppRfcommListener(mAdapter);

    GLOGD("BluetoothOppService:: count %d", getStrongCount());

    mShares = new GArrayList<BluetoothOppShareInfo>();

    GLOGD("BluetoothOppService:: count %d", getStrongCount());

    mBatchs = new GArrayList<BluetoothOppBatch>();

    GLOGD("BluetoothOppService:: count %d", getStrongCount());

    mObserver = new BluetoothShareContentObserver(this);
    GLOGD("BluetoothOppService:: BluetoothShareContentObserver count %d", getStrongCount());
    getContentResolver()->registerContentObserver(BluetoothShare::CONTENT_URI(), true, mObserver);
    GLOGD("BluetoothOppService:: BluetoothShareContentObserver count %d", getStrongCount());
    mBatchId = 1;
    mNotifier = new BluetoothOppNotification(this);
    GLOGD("BluetoothOppService:: BluetoothOppNotification count %d", getStrongCount());
    mNotifier->mNotificationMgr->cancelAll();
    mNotifier->updateNotification();

    // sp<ContentResolver> contentResolver = getContentResolver();
    sp<GThread> thread = new onCreateThread(this);
    GLOGD("BluetoothOppService:: onCreateThread count %d", getStrongCount());
    thread->run("trimDatabase");

    {
        RecursiveMutex::Autolock _l(mBluetoothOppServiceMutex);
        if (mAdapter == NULL) {
            GLOGW("Local BT device is not enabled");
        } else {
            startListener();
        }
    }
    updateFromProvider();
    GLOGD("BluetoothOppService:: count %d", getStrongCount());
}



void BluetoothOppNotification::updateNotification() {
    GLOGENTRY();
    Mutex::Autolock autoLock(mOppNotificationMutex);

    mPendingUpdate++;
    if (mPendingUpdate > 1) {
        GLOGI("update too frequent, put in queue");
        return;
    }
    if (!mHandler->hasMessages(NOTIFY)) {
        GLOGI("send message");
        mHandler->sendMessage(mHandler->obtainMessage(NOTIFY));
    }
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值