@Override public void onCallSucceeded(String payload) { AppCenterLog.info(LOG_TAG, "Measurements reported successfully."); }
public static void removeStoredErrorLogFile(@NonNull UUID id) { File file = getStoredErrorLogFile(id); if (file != null) { AppCenterLog.info(Crashes.LOG_TAG, "Deleting error log file " + file.getName()); FileManager.delete(file); } }
@Override public void run() { if (isInstanceEnabled()) { runnable.run(); } else if (serviceDisabledRunnable != null) { serviceDisabledRunnable.run(); } else { AppCenterLog.info(LOG_TAG, getServiceName() + " service disabled, discarding calls."); } } }, coreDisabledRunnable);
public static void removeStoredThrowableFile(@NonNull UUID id) { File file = getStoredThrowableFile(id); if (file != null) { AppCenterLog.info(Crashes.LOG_TAG, "Deleting throwable file " + file.getName()); FileManager.delete(file); } }
@Override public synchronized void onActivityCreated(Activity activity, Bundle savedInstanceState) { /* Resolve launcher class name only once, use empty string to cache a failed resolution. */ if (mLauncherActivityClassName == null) { mLauncherActivityClassName = ""; PackageManager packageManager = activity.getPackageManager(); Intent intent = packageManager.getLaunchIntentForPackage(activity.getPackageName()); if (intent != null) { mLauncherActivityClassName = intent.resolveActivity(packageManager).getClassName(); } } /* Clear workflow finished state if launch recreated, to achieve check on "startup". */ if (activity.getClass().getName().equals(mLauncherActivityClassName)) { AppCenterLog.info(LOG_TAG, "Launcher activity restarted."); if (mChannel != null && getStoredDownloadState() == DOWNLOAD_STATE_COMPLETED) { mWorkflowCompleted = false; mBrowserOpenedOrAborted = false; } } }
/** * Register application for push without Firebase. */ private synchronized void registerPushTokenWithoutFirebase() { if (mSenderId == null) { int resId = mContext.getResources().getIdentifier("gcm_defaultSenderId", "string", mContext.getPackageName()); try { mSenderId = mContext.getString(resId); } catch (Resources.NotFoundException e) { AppCenterLog.error(LOG_TAG, "Push.setSenderId was not called, aborting registration."); return; } } Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER"); registrationIntent.setPackage("com.google.android.gsf"); registrationIntent.putExtra("sender", mSenderId); registrationIntent.putExtra("app", PendingIntent.getBroadcast(mContext, 0, new Intent(), 0)); try { mContext.startService(registrationIntent); } catch (IllegalStateException e) { AppCenterLog.info(LOG_TAG, "Cannot register in background, will wait to be in foreground"); mTokenNeedsRegistrationInForeground = true; } catch (RuntimeException e) { AppCenterLog.error(LOG_TAG, "Failed to register push token", e); } }
@Override protected synchronized void applyEnabledState(boolean enabled) { initialize(); if (!enabled) { for (File file : ErrorLogHelper.getErrorStorageDirectory().listFiles()) { AppCenterLog.debug(LOG_TAG, "Deleting file " + file); if (!file.delete()) { AppCenterLog.warn(LOG_TAG, "Failed to delete file " + file); } } AppCenterLog.info(LOG_TAG, "Deleted crashes local files"); } }
/** * Check for push message clicked from notification center in activity intent. * * @param intent intent to inspect. */ private synchronized void checkPushInIntent(Activity activity, Intent intent) { if (mInstanceListener != null) { String googleMessageId = PushIntentUtils.getMessageId(intent); if (googleMessageId != null && !googleMessageId.equals(mLastGoogleMessageId) && !googleMessageId.equals(mFirstGoogleMessageId)) { if (mFirstGoogleMessageId == null) { mFirstGoogleMessageId = googleMessageId; } PushNotification notification = new PushNotification(intent); AppCenterLog.info(LOG_TAG, "Clicked push message from background id=" + googleMessageId); mLastGoogleMessageId = googleMessageId; AppCenterLog.debug(LOG_TAG, "Push intent extras=" + intent.getExtras()); mInstanceListener.onPushNotificationReceived(activity, notification); } } }
AppCenterLog.info(LOG_TAG, "App Center SDK configured successfully."); return true;
AppCenterLog.info(LOG_TAG, service.getClass().getSimpleName() + " service configuration updated."); AppCenterLog.info(LOG_TAG, service.getClass().getSimpleName() + " service started from application."); } else { service.onStarted(mApplication, mChannel, null, null, false); AppCenterLog.info(LOG_TAG, service.getClass().getSimpleName() + " service started from library.");
@Test public void registerWithoutFirebaseStartServiceThrowsIllegalState() { when(FirebaseInstanceId.getInstance()).thenThrow(new IllegalStateException()); setSenderId(); doThrow(new IllegalStateException()).when(mContext).startService(any(Intent.class)); start(Push.getInstance(), mock(Channel.class)); assertTrue(Push.isEnabled().get()); verifyStatic(); AppCenterLog.info(anyString(), anyString()); verifyStatic(); AppCenterLog.warn(anyString(), anyString()); Push.getInstance().onActivityResumed(mock(Activity.class)); verify(mContext, times(2)).startService(any(Intent.class)); }
private static void callLogs() { AppCenterLog.logAssert("my-tag", "error with my-tag"); AppCenterLog.logAssert("my-tag", "error with my-tag with exception", new Exception()); AppCenterLog.error("my-tag", "error with my-tag"); AppCenterLog.error("my-tag", "error with my-tag with exception", new Exception()); AppCenterLog.warn("my-tag", "warn with my-tag"); AppCenterLog.warn("my-tag", "warn with my-tag with exception", new Exception()); AppCenterLog.info("my-tag", "info with my-tag"); AppCenterLog.info("my-tag", "info with my-tag with exception", new Exception()); AppCenterLog.debug("my-tag", "debug with my-tag"); AppCenterLog.debug("my-tag", "debug with my-tag with exception", new Exception()); AppCenterLog.verbose("my-tag", "verbose with my-tag"); AppCenterLog.verbose("my-tag", "verbose with my-tag with exception", new Exception()); }
AppCenterLog.info(LOG_TAG, "Postpone enabling in app updates via browser as network is disconnected."); Distribute.getInstance().completeWorkflow(); return;
/** * Gets SQLite database. * * @return SQLite database. * @throws RuntimeException if an error occurs. */ @VisibleForTesting SQLiteDatabase getDatabase() { /* Try opening database. */ try { return mSQLiteOpenHelper.getWritableDatabase(); } catch (RuntimeException e) { AppCenterLog.warn(LOG_TAG, "Failed to open database. Trying to delete database (may be corrupted).", e); /* First error, try to delete database (may be corrupted). */ if (mContext.deleteDatabase(mDatabase)) { AppCenterLog.info(LOG_TAG, "The database was successfully deleted."); } else { AppCenterLog.warn(LOG_TAG, "Failed to delete database."); } /* Retry, let exception thrown if it fails this time. */ return mSQLiteOpenHelper.getWritableDatabase(); } }
/** * Register application for push. */ private synchronized void registerPushToken() { /* Update enable state of the firebase service. */ FirebaseUtils.setFirebaseMessagingServiceEnabled(mContext, FirebaseUtils.isFirebaseAvailable()); try { /* Try to get token through firebase. */ onTokenRefresh(FirebaseUtils.getToken()); AppCenterLog.info(LOG_TAG, "Firebase SDK is available, using Firebase SDK registration."); } catch (FirebaseUtils.FirebaseUnavailableException e) { AppCenterLog.warn(LOG_TAG, "Firebase SDK is not available, using built in registration. " + "For all the Android developers using App Center, there is a change coming where Firebase SDK is required " + "to use Push Notifications. For Android P, its scheduled at the release date for the latest OS version. " + "For all other versions of Android, it will be required after April 2019. " + "Please follow the migration guide at https://aka.ms/acfba.\n" + "Cause: " + e.getMessage()); registerPushTokenWithoutFirebase(); } }
@Override public synchronized void setInstanceEnabled(boolean enabled) { /* Nothing to do if state does not change. */ if (enabled == isInstanceEnabled()) { AppCenterLog.info(getLoggerTag(), String.format("%s service has already been %s.", getServiceName(), enabled ? "enabled" : "disabled")); return; } /* Initialize channel group. */ String groupName = getGroupName(); if (mChannel != null && groupName != null) { /* Register service to channel on enabling. */ if (enabled) { mChannel.addGroup(groupName, getTriggerCount(), getTriggerInterval(), getTriggerMaxParallelRequests(), null, getChannelListener()); } /* Otherwise, clear all persisted logs and remove a group for the service. */ else { mChannel.clear(groupName); mChannel.removeGroup(groupName); } } /* Save new state. */ SharedPreferencesManager.putBoolean(getEnabledPreferenceKey(), enabled); AppCenterLog.info(getLoggerTag(), String.format("%s service has been %s.", getServiceName(), enabled ? "enabled" : "disabled")); /* Don't call it before the service starts. */ if (mChannel != null) { /* Allow sub-class to handle state change. */ applyEnabledState(enabled); } }
AppCenterLog.info(LOG_TAG, "No release available to the current user."); } else { AppCenterLog.error(LOG_TAG, "Failed to check latest release:", e);
AppCenterLog.info(LOG_TAG, "This device is not compatible with the latest release.");