代码来源 Pie 9.0.0_r3
通讯录存放在哪?
系统有个apk叫
ContactsProvider 里面有如下数据库,通讯录就存在数据库里 /data/data/com.android.providers.contacts/databases/calllog.db /data/data/com.android.providers.contacts/databases/contacts2.db /data/data/com.android.providers.contacts/databases/profile.db
谁去管理同步过程?
蓝牙电话同步通讯录时会去操作ContactsProvider PhonebookPullRequest.java
Handler接收消息进行同步 PbapClientConnectionHandler.java
241 case MSG_DOWNLOAD:
242 try {
243 mAccountCreated = addAccount(mAccount);
244 if (!mAccountCreated) {
245 Log.e(TAG, "Account creation failed.");
246 return;
247 }
248
249 BluetoothPbapRequestPullPhoneBook request =
250 new BluetoothPbapRequestPullPhoneBook(PB_PATH, mAccount,
251 PBAP_REQUESTED_FIELDS, VCARD_TYPE_30, 0, 1);
252 request.execute(mObexSession);
253 PhonebookPullRequest processor =
254 new PhonebookPullRequest(mPbapClientStateMachine.getContext(),
255 mAccount);
256 processor.setResults(request.getList());
257 processor.onPullComplete();
258 HashMap<String, Integer> callCounter = new HashMap<>();
259 downloadCallLog(MCH_PATH, callCounter);
260 downloadCallLog(ICH_PATH, callCounter);
261 downloadCallLog(OCH_PATH, callCounter);
262 } catch (IOException e) {
263 Log.w(TAG, "DOWNLOAD_CONTACTS Failure" + e.toString());
264 }
哪里发送的消息呢? 1.连接上PBAP后已经解除锁屏 PbapClientStateMachine.java
295 class Connected extends State {
296 @Override
297 public void enter() {
298 Log.d(TAG, "Enter Connected: " + getCurrentMessage().what);
299 onConnectionStateChanged(mCurrentDevice, mMostRecentState,
300 BluetoothProfile.STATE_CONNECTED);
301 mMostRecentState = BluetoothProfile.STATE_CONNECTED;
302 if (mUserManager.isUserUnlocked()) {
303 mConnectionHandler.obtainMessage(PbapClientConnectionHandler.MSG_DOWNLOAD)
304 .sendToTarget();
305 }
306 }
2.收到解除锁屏广播后会调用 resumeDownload
356 public void resumeDownload() {
357 sendMessage(MSG_RESUME_DOWNLOAD);
358 }
==========================
321 case MSG_RESUME_DOWNLOAD:
322 mConnectionHandler.obtainMessage(PbapClientConnectionHandler.MSG_DOWNLOAD)
323 .sendToTarget();
324 break;
那么如何获取下载状态?如何获取下载进度? Pie 9.0.0_r3 里并没有此逻辑 其他版本源码没有看
|