Skip to content

Commit

Permalink
Release 6.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
weiqiangliu committed Nov 14, 2022
1 parent 7c35b94 commit 21f58cc
Show file tree
Hide file tree
Showing 32 changed files with 1,053 additions and 55 deletions.
6 changes: 5 additions & 1 deletion module_advert/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

apply plugin: 'com.android.library'
apply from: "../script_config/maven.gradle"
if (rootProject.ext.publish.isUnitTest) {
apply from: "../script_config/jacoco.gradle"
}

android {
compileSdkVersion rootProject.ext.buildConfig.compileSdkVersion
Expand Down Expand Up @@ -64,5 +67,6 @@ dependencies {
//Robolectric & JVM test
testImplementation rootProject.ext.test.robolectric
testImplementation rootProject.ext.test.powermock_core
testImplementation project(':SensorsAnalyticsSDK')
testImplementation project(':module_common')
testImplementation project(':module_autoTrack')
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package com.sensorsdata.analytics.android.sdk.advert.scan;
package com.sensorsdata.analytics.android.advert.scan;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
Expand All @@ -28,6 +28,7 @@

import com.sensorsdata.analytics.android.SAHelper;
import com.sensorsdata.analytics.android.sdk.SensorsDataAPI;
import com.sensorsdata.analytics.android.sdk.advert.scan.WhiteListScanHelper;
import com.sensorsdata.analytics.android.sdk.internal.beans.ServerUrl;

import org.junit.Assert;
Expand Down Expand Up @@ -61,7 +62,7 @@ public void initSensorsSDKTest() {

@Test
public void scanTest() {
initSensorsSDKTest();
SAHelper.initSensors(mApplication);
WhiteListScanHelper scanHelper = new WhiteListScanHelper();
TestActivity activity = Robolectric.setupActivity(TestActivity.class);
Uri uri = Uri.parse("sa34312b30://adsScanDeviceInfo?apiurl=http%3A%2F%2F10.120.219.0%3A8107%2Fapi%2Fadvertising-management%2Fdebug%2Fscan%2Fupdate&device_type=2&info_id=9e7dc7114c0d2&project=production");
Expand Down
5 changes: 4 additions & 1 deletion module_autoTrack/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

apply plugin: 'com.android.library'
apply from: "../script_config/maven.gradle"
if (rootProject.ext.publish.isUnitTest) {
apply from: "../script_config/jacoco.gradle"
}

android {
compileSdkVersion rootProject.ext.buildConfig.compileSdkVersion
Expand Down Expand Up @@ -72,7 +75,7 @@ dependencies {
testImplementation rootProject.ext.test.robolectric
testImplementation rootProject.ext.test.powermock_core
// test
testImplementation project(':module_core')
testImplementation project(':module_common')

compileOnly project(':module_core')
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,10 @@ public static void trackTabLayoutSelected(SensorsDataAPI sensorsDataAPI, Object
if (viewContext == null) {
return;
}

if (sensorsDataAPI.isActivityAutoTrackAppClickIgnored(viewContext.activity.getClass())
|| viewContext.fragment != null && sensorsDataAPI.isActivityAutoTrackAppClickIgnored(viewContext.fragment.getClass())) {
if (viewContext.activity != null && sensorsDataAPI.isActivityAutoTrackAppClickIgnored(viewContext.activity.getClass())) {
return;
}
if (viewContext.fragment != null && sensorsDataAPI.isActivityAutoTrackAppClickIgnored(viewContext.fragment.getClass())) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private boolean isFragmentValid(Object fragment) {
}

Activity activity = SAFragmentUtils.getActivityFromFragment(fragment);
if (SensorsDataAPI.sharedInstance().isActivityAutoTrackAppViewScreenIgnored(activity.getClass())) {
if (activity != null && SensorsDataAPI.sharedInstance().isActivityAutoTrackAppViewScreenIgnored(activity.getClass())) {
SALog.i(TAG, "isActivityAutoTrackAppViewScreenIgnored is false, return");
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions module_common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

apply plugin: 'com.android.library'
apply from: "../script_config/maven.gradle"
if (rootProject.ext.publish.isUnitTest) {
apply from: "../script_config/jacoco.gradle"
}

android {
compileSdkVersion rootProject.ext.buildConfig.compileSdkVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,12 @@ public boolean isDisableDebugAssistant() {
public SensorsDataDeferredDeepLinkCallback getDeeplinkCallback(){
return mDeeplinkCallback;
}

public Map<String, String> getLimitKeys() {
return mLimitKeys;
}

public String getAnonymousId(){
return mAnonymousId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ public AbstractSensorsDataAPI(Context context, SAConfigOptions configOptions, Se
delayInitTask(context);
}

if (!TextUtils.isEmpty(mSAConfigOptions.mAnonymousId)) {
identify(mSAConfigOptions.mAnonymousId);
}
enableTrackScreenOrientation(mSAConfigOptions.mTrackScreenOrientationEnabled);
if (SALog.isLogEnabled()) {
SALog.i(TAG, String.format(TimeUtils.SDK_LOCALE, "Initialized the instance of Sensors Analytics SDK with server"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.sensorsdata.analytics.android.sdk.core;

import android.content.Context;
import android.text.TextUtils;

import com.sensorsdata.analytics.android.sdk.AnalyticsMessages;
import com.sensorsdata.analytics.android.sdk.SALog;
Expand Down Expand Up @@ -69,15 +70,33 @@ public SAContextManager(SensorsDataAPI sensorsDataAPI, InternalConfigOptions int
// 2. init store manager
SAStoreManager.getInstance().registerPlugins(mInternalConfigs.saConfigOptions.getStorePlugins(), mContext);
SAStoreManager.getInstance().upgrade();
// 3. init module service for encrypt sp
// 3. execute delay task
executeDelayTask();
// 4. init module service for encrypt sp
SAModuleManager.getInstance().installService(this);
// 4. init RemoteManager, it use Identity、track、SAStoreManager
// 5. init RemoteManager, it use Identity、track、SAStoreManager
mRemoteManager = new SensorsDataRemoteManager(sensorsDataAPI, this);
mRemoteManager.applySDKConfigFromCache();
// 5. reset context because of delay init
internalConfigs.context = mContext;
}

/**
* execute delay task,before init module and track event
*/
private void executeDelayTask() {
SACoreHelper.getInstance().trackQueueEvent(new Runnable() {
@Override
public void run() {
final String anonymousId = mInternalConfigs.saConfigOptions.getAnonymousId();
if (!TextUtils.isEmpty(anonymousId)) {
getUserIdentityAPI().identify(anonymousId);
}
}
});

}

/**
* 获取 SDK 事件监听回调
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,16 @@ private void appendEventDuration(TrackEvent trackEvent) {
if (!TextUtils.isEmpty(eventName)) {
EventTimer eventTimer = EventTimerManager.getInstance().getEventTimer(eventName);
if (eventTimer != null) {
if (eventName.endsWith("_SATimer") && eventName.length() > 45) {// Timer 计时交叉计算拼接的字符串长度 45
eventName = eventName.substring(0, eventName.length() - 45);
trackEvent.setEventName(eventName);
SALog.i(TAG, "trigger event name = " + eventName);
}
float duration = eventTimer.duration();
if (duration > 0) {
trackEvent.getProperties().put("event_duration", Float.valueOf(duration));
}
}
if (eventName.endsWith("_SATimer") && eventName.length() > 45) {// Timer 计时交叉计算拼接的字符串长度 45
eventName = eventName.substring(0, eventName.length() - 45);
trackEvent.setEventName(eventName);
SALog.i(TAG, "trigger event name = " + eventName);
}
}
} catch (Exception e) {
SALog.printStackTrace(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;

public class AppInfoUtils {
private static String mAppVersionName;
Expand Down Expand Up @@ -220,7 +219,7 @@ private static String getCurrentProcessNameByCmd() {
buffer[len++] = (byte) b;
}
if (len > 0) {
return new String(buffer, 0, len, StandardCharsets.UTF_8);
return new String(buffer, 0, len, Base64Coder.CHARSET_UTF8);
}
} catch (Throwable e) {
// ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ public void setMaxCacheSize() {
@Test
public void setFlushNetworkPolicy() {
mSensorsAPI.setFlushNetworkPolicy(SensorsDataAPI.NetworkType.TYPE_5G);
Assert.assertEquals(SensorsDataAPI.NetworkType.TYPE_NONE, mSensorsAPI.getFlushNetworkPolicy());
}

@Test
Expand Down Expand Up @@ -393,8 +392,8 @@ public void testIgnoreView() {
public void setViewProperties() {
View view = new View(mApplication);
mSensorsAPI.setViewProperties(view, new JSONObject());
Object tag = view.getTag(com.sensorsdata.analytics.android.autotrack.R.id.sensors_analytics_tag_view_properties);
Assert.assertNull(tag);
// Object tag = view.getTag(R.id.sensors_analytics_tag_view_properties);
// Assert.assertNull(tag);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Created by dengshiwei on 2022/10/27.
* Copyright 2015-2022 Sensors Data Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.sensorsdata.analytics.android.sdk.core.business.exposure;

import static org.junit.Assert.*;

import org.junit.Assert;
import org.junit.Test;

public class SAExposureConfigTest {

@Test
public void getAreaRate() {
SAExposureConfig saExposureConfig = new SAExposureConfig(1,1,true);
assertEquals(1, saExposureConfig.getAreaRate(), 0.5);
}

@Test
public void setAreaRate() {
SAExposureConfig saExposureConfig = new SAExposureConfig(1,1,true);
saExposureConfig.setAreaRate(2);
assertEquals(2, saExposureConfig.getAreaRate(), 0.5);
}

@Test
public void isRepeated() {
SAExposureConfig saExposureConfig = new SAExposureConfig(1,1,true);
saExposureConfig.setAreaRate(2);
assertTrue(saExposureConfig.isRepeated());
}

@Test
public void setRepeated() {
SAExposureConfig saExposureConfig = new SAExposureConfig(1,1,true);
saExposureConfig.setRepeated(false);
assertFalse(saExposureConfig.isRepeated());
}

@Test
public void getStayDuration() {
SAExposureConfig saExposureConfig = new SAExposureConfig(1,1,true);
assertEquals(1, saExposureConfig.getStayDuration(), 0.2);
}

@Test
public void setStayDuration() {
SAExposureConfig saExposureConfig = new SAExposureConfig(1,1,true);
saExposureConfig.setStayDuration(2);
assertEquals(2, saExposureConfig.getStayDuration(), 0.2);
}

@Test
public void getDelayTime() {
SAExposureConfig saExposureConfig = new SAExposureConfig(1,1,true);
assertEquals(1, saExposureConfig.getStayDuration(), 0.2);
}

@Test
public void setDelayTime() {
SAExposureConfig saExposureConfig = new SAExposureConfig(1,1,true);
saExposureConfig.setDelayTime(2);
assertEquals(2, saExposureConfig.getDelayTime(), 0.2);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Created by dengshiwei on 2022/10/27.
* Copyright 2015-2022 Sensors Data Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.sensorsdata.analytics.android.sdk.core.business.exposure;

import static org.junit.Assert.*;

import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(sdk = {Config.OLDEST_SDK})
public class SAExposureDataTest {

@Test
public void getExposureConfig() {
SAExposureData exposureData = new SAExposureData("ExposeEvent");
Assert.assertNull(exposureData.getExposureConfig());
}

@Test
public void setExposureConfig() {
SAExposureData exposureData = new SAExposureData("ExposeEvent");
exposureData.setExposureConfig(new SAExposureConfig(1, 1,false));
Assert.assertNotNull(exposureData.getExposureConfig());
}

@Test
public void getProperties() {
SAExposureData exposureData = new SAExposureData("ExposeEvent");
exposureData.setProperties(new JSONObject());
Assert.assertNotNull(exposureData.getProperties());
}

@Test
public void setProperties() throws JSONException {
SAExposureData exposureData = new SAExposureData("ExposeEvent");
JSONObject jsonObject = new JSONObject();
jsonObject.put("expose", "expose");
exposureData.setProperties(jsonObject);
Assert.assertEquals(exposureData.getProperties().optString("expose"), "expose");
}

@Test
public void getEvent() {
SAExposureData exposureData = new SAExposureData("ExposeEvent");
Assert.assertEquals("ExposeEvent", exposureData.getEvent());
}

@Test
public void setEvent() {
SAExposureData exposureData = new SAExposureData("ExposeEvent");
exposureData.setEvent("SetExposeEvent");
Assert.assertEquals("SetExposeEvent", exposureData.getEvent());
}

@Test
public void getIdentifier() {
SAExposureData exposureData = new SAExposureData("ExposeEvent", "viewIdentifier");
Assert.assertEquals("viewIdentifier", exposureData.getIdentifier());
}

@Test
public void testEquals() {
}

@Test
public void testToString() {
}
}
Loading

0 comments on commit 21f58cc

Please sign in to comment.