(final Context context)
| 1029 | } |
| 1030 | |
| 1031 | static void init(final Context context) { |
| 1032 | if (Helper.hasPermission(context, Manifest.permission.READ_CONTACTS)) { |
| 1033 | ContentObserver observer = new ContentObserver(ApplicationEx.getMainHandler()) { |
| 1034 | @Override |
| 1035 | public void onChange(boolean selfChange, Uri uri) { |
| 1036 | EntityLog.log(context, EntityLog.Type.Notification, "Contact changed uri=" + uri); |
| 1037 | Helper.getSerialExecutor().submit(new Runnable() { |
| 1038 | @Override |
| 1039 | public void run() { |
| 1040 | try { |
| 1041 | emailLookup = getEmailLookup(context); |
| 1042 | } catch (Throwable ex) { |
| 1043 | Log.e(ex); |
| 1044 | } |
| 1045 | } |
| 1046 | }); |
| 1047 | } |
| 1048 | }; |
| 1049 | |
| 1050 | Helper.getSerialExecutor().submit(new Runnable() { |
| 1051 | @Override |
| 1052 | public void run() { |
| 1053 | try { |
| 1054 | emailLookup = getEmailLookup(context); |
| 1055 | } catch (Throwable ex) { |
| 1056 | Log.e(ex); |
| 1057 | } |
| 1058 | } |
| 1059 | }); |
| 1060 | |
| 1061 | try { |
| 1062 | Uri uri = ContactsContract.CommonDataKinds.Email.CONTENT_URI; |
| 1063 | EntityLog.log(context, EntityLog.Type.Notification, "Observing uri=" + uri); |
| 1064 | context.getContentResolver().registerContentObserver(uri, true, observer); |
| 1065 | } catch (SecurityException ex) { |
| 1066 | Log.w(ex); |
| 1067 | /* |
| 1068 | Should never happen, but: |
| 1069 | Caused by: android.os.RemoteException: |
| 1070 | at com.android.server.content.ContentService.registerContentObserver (ContentService.java:340) |
| 1071 | at android.content.IContentService$Stub.onTransact (IContentService.java:76) |
| 1072 | at com.android.server.content.ContentService.onTransact (ContentService.java:262) |
| 1073 | at android.os.Binder.execTransact (Binder.java:731) |
| 1074 | */ |
| 1075 | } |
| 1076 | } |
| 1077 | } |
| 1078 | |
| 1079 | static String getKey(String email) { |
| 1080 | // Maximum file name length: 255 |
no test coverage detected