PropertyConfigurator extends AbstractChannelListener { @Override public void onPreparingLog(@NonNull Log log, @NonNull String groupName) { if (shouldOverridePartAProperties(log)) { AppExtension app = ((CommonSchemaLog) log).getExt().getApp(); UserExtension user = ((CommonSchemaLog) log).getExt().getUser(); DeviceExtension device = ((CommonSchemaLog) log).getExt().getDevice(); if (mAppName != null) { app.setName(mAppName); } else { for (AnalyticsTransmissionTarget target = mTransmissionTarget.mParentTarget; target != null; target = target.mParentTarget) { String parentAppName = target.getPropertyConfigurator().getAppName(); if (parentAppName != null) { app.setName(parentAppName); break; } } } if (mAppVersion != null) { app.setVer(mAppVersion); } else { for (AnalyticsTransmissionTarget target = mTransmissionTarget.mParentTarget; target != null; target = target.mParentTarget) { String parentAppVersion = target.getPropertyConfigurator().getAppVersion(); if (parentAppVersion != null) { app.setVer(parentAppVersion); break; } } } if (mAppLocale != null) { app.setLocale(mAppLocale); } else { for (AnalyticsTransmissionTarget target = mTransmissionTarget.mParentTarget; target != null; target = target.mParentTarget) { String parentAppLocale = target.getPropertyConfigurator().getAppLocale(); if (parentAppLocale != null) { app.setLocale(parentAppLocale); break; } } } if (mUserId != null) { user.setLocalId(mUserId); } else { for (AnalyticsTransmissionTarget target = mTransmissionTarget.mParentTarget; target != null; target = target.mParentTarget) { String parentUserId = target.getPropertyConfigurator().getUserId(); if (parentUserId != null) { user.setLocalId(parentUserId); break; } } } if (mDeviceIdEnabled) { @SuppressLint("HardwareIds") String androidId = Secure.getString(mTransmissionTarget.mContext.getContentResolver(), Secure.ANDROID_ID); device.setLocalId(ANDROID_DEVICE_ID_PREFIX + androidId); } } } PropertyConfigurator(AnalyticsTransmissionTarget transmissionTarget); @Override void onPreparingLog(@NonNull Log log, @NonNull String groupName); void setAppName(final String appName); void setAppVersion(final String appVersion); void setAppLocale(final String appLocale); void setUserId(final String userId); synchronized void setEventProperty(String key, boolean value); synchronized void setEventProperty(String key, Date value); synchronized void setEventProperty(String key, double value); synchronized void setEventProperty(String key, long value); synchronized void setEventProperty(String key, String value); synchronized void removeEventProperty(String key); void collectDeviceId();  }
@Test public void grandparentsHaveNoPropertiesSet() { CommonSchemaLog log = new CommonSchemaEventLog(); log.setExt(new Extensions()); log.getExt().setApp(new AppExtension()); log.getExt().setUser(new UserExtension()); AnalyticsTransmissionTarget grandparent = Analytics.getTransmissionTarget("grandparent"); AnalyticsTransmissionTarget parent = grandparent.getTransmissionTarget("parent"); AnalyticsTransmissionTarget child = parent.getTransmissionTarget("child"); log.addTransmissionTarget("child"); log.setTag(child); grandparent.getPropertyConfigurator().onPreparingLog(log, "groupName"); parent.getPropertyConfigurator().onPreparingLog(log, "groupName"); child.getPropertyConfigurator().onPreparingLog(log, "groupName"); assertNull(log.getExt().getApp().getVer()); assertNull(log.getExt().getApp().getName()); assertNull(log.getExt().getApp().getLocale()); assertNull(log.getExt().getUser().getLocalId()); }