Added logging

pull/213/head
M66B 1 year ago
parent c4b5ee7349
commit fd340632dc

@ -1268,8 +1268,8 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
} }
private void handleImportGraphContacts(Bundle args) { private void handleImportGraphContacts(Bundle args) {
final Context context = getContext();
try { try {
final Context context = getContext();
long account = args.getLong("account"); long account = args.getLong("account");
String user = args.getString("user"); String user = args.getString("user");
EmailProvider provider = EmailProvider.getProvider(context, "outlookgraph"); EmailProvider provider = EmailProvider.getProvider(context, "outlookgraph");
@ -1296,16 +1296,18 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
authRequestBuilder.setPrompt(provider.graph.prompt); authRequestBuilder.setPrompt(provider.graph.prompt);
Intent authIntent = authService.getAuthorizationRequestIntent(authRequestBuilder.build()); Intent authIntent = authService.getAuthorizationRequestIntent(authRequestBuilder.build());
Log.i("Graph/contacts intent=" + authIntent); EntityLog.log(context, "Graph/contacts intent=" + authIntent);
startActivityForResult(authIntent, ActivitySetup.REQUEST_GRAPH_CONTACTS_OAUTH); startActivityForResult(authIntent, ActivitySetup.REQUEST_GRAPH_CONTACTS_OAUTH);
} catch (Throwable ex) { } catch (Throwable ex) {
EntityLog.log(context, "Graph/contacts ex=" + Log.formatThrowable(ex, false));
Log.unexpectedError(getParentFragmentManager(), ex); Log.unexpectedError(getParentFragmentManager(), ex);
} }
} }
private void onHandleGraphContactsOAuth(@NonNull Intent data) { private void onHandleGraphContactsOAuth(@NonNull Intent data) {
final Context context = getContext();
try { try {
Log.i("Graph/contacts authorized"); EntityLog.log(context, "Graph/contacts authorized");
AuthorizationResponse auth = AuthorizationResponse.fromIntent(data); AuthorizationResponse auth = AuthorizationResponse.fromIntent(data);
if (auth == null) { if (auth == null) {
@ -1316,7 +1318,6 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
throw ex; throw ex;
} }
final Context context = getContext();
final EmailProvider provider = EmailProvider.getProvider(context, "outlookgraph"); final EmailProvider provider = EmailProvider.getProvider(context, "outlookgraph");
AuthorizationService authService = new AuthorizationService(context); AuthorizationService authService = new AuthorizationService(context);
@ -1352,7 +1353,7 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
if (access == null || access.accessToken == null) if (access == null || access.accessToken == null)
throw new IllegalStateException("No access token"); throw new IllegalStateException("No access token");
Log.i("Graph/contacts got token"); EntityLog.log(context, "Graph/contacts got token");
int semi = auth.request.state.lastIndexOf(':'); int semi = auth.request.state.lastIndexOf(':');
long account = Long.parseLong(auth.request.state.substring(semi + 1)); long account = Long.parseLong(auth.request.state.substring(semi + 1));
@ -1372,6 +1373,7 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
@Override @Override
protected void onExecuted(Bundle args, @NonNull Integer count) { protected void onExecuted(Bundle args, @NonNull Integer count) {
EntityLog.log(context, "Graph/contacts count=" + count);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().putBoolean("suggest_sent", true).apply(); prefs.edit().putBoolean("suggest_sent", true).apply();
@ -1391,6 +1393,7 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
@Override @Override
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {
EntityLog.log(context, "Graph/contacts ex=" + Log.formatThrowable(ex, false));
Log.unexpectedError(getParentFragmentManager(), ex); Log.unexpectedError(getParentFragmentManager(), ex);
} }
}.execute(FragmentSetup.this, args, "graph:contacts"); }.execute(FragmentSetup.this, args, "graph:contacts");
@ -1400,6 +1403,7 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
} }
}); });
} catch (Throwable ex) { } catch (Throwable ex) {
EntityLog.log(context, "Graph/contacts ex=" + Log.formatThrowable(ex, false));
Log.unexpectedError(getParentFragmentManager(), ex); Log.unexpectedError(getParentFragmentManager(), ex);
} }
} }

@ -136,7 +136,6 @@ public class MicrosoftGraph {
connection.setConnectTimeout(GRAPH_TIMEOUT * 1000); connection.setConnectTimeout(GRAPH_TIMEOUT * 1000);
ConnectionHelper.setUserAgent(context, connection); ConnectionHelper.setUserAgent(context, connection);
connection.setRequestProperty("Authorization", "Bearer " + accessToken); connection.setRequestProperty("Authorization", "Bearer " + accessToken);
connection.setRequestProperty("Content-Type", "text/plain");
connection.connect(); connection.connect();
try { try {
@ -157,7 +156,7 @@ public class MicrosoftGraph {
String email = jemail.optString("address"); String email = jemail.optString("address");
if (!TextUtils.isEmpty(email)) { if (!TextUtils.isEmpty(email)) {
EntityContact contact = db.contact().getContact(account, EntityContact.TYPE_TO, email); EntityContact contact = db.contact().getContact(account, EntityContact.TYPE_TO, email);
EntityLog.log(context, displayName + " <" + email + ">" + EntityLog.log(context, "Graph/contacts " + displayName + " <" + email + ">" +
" account=" + account + " exists=" + (contact != null)); " account=" + account + " exists=" + (contact != null));
if (contact == null) { if (contact == null) {
contact = new EntityContact(); contact = new EntityContact();

Loading…
Cancel
Save