Browse Source

[New]更新中台接入

litchi98 2 weeks ago
parent
commit
d0b4348a63

+ 1 - 8
app/build.gradle

@@ -152,26 +152,19 @@ dependencies {
     implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
 
     //Atmob SDK
-    implementation 'extra.common:base:1.0.0-SNAPSHOT'
+    implementation 'extra.common:base:2.0.0-SNAPSHOT'
     implementation "extra.pack:channel:1.1.0-SNAPSHOT"
-    implementation "extra.common:core:2.0.4-SNAPSHOT" //base utils
     implementation "extra.common:network:1.1.0-SNAPSHOT"
     implementation "extra.common:rxjava:1.1.0-SNAPSHOT"
     implementation("plus.pay:pay:1.1.0-SNAPSHOT") {
         exclude group: 'third.pay', module: 'ali'
     }
     api 'com.alipay.sdk:alipaysdk-android:15.8.16@aar'
-
-    //中台sdk
-    implementation "atmob.central:core:1.0.8-SNAPSHOT"
     //字节 融合归因
     implementation 'atmob.sdk:app-convert:2.0.0-SNAPSHOT'
     //引力引擎
     implementation 'atmob.sdk:gravity-engine:4.8.25-SNAPSHOT'
 
-    //oaid
-    implementation "extra.common:oaid:1.2.0-SNAPSHOT"
-
     //AppCompat
     implementation "androidx.appcompat:appcompat:$rootProject.appcompat_version"
 

+ 16 - 25
app/src/main/java/com/datarecovery/master/App.java

@@ -3,11 +3,11 @@ package com.datarecovery.master;
 import android.content.Context;
 
 import com.atmob.app.lib.base.BaseApplication;
-import com.atmob.channelreader.ChannelReader;
-import com.atmob.common.runtime.ProcessUtil;
+import com.atmob.central.AtmobCentralConfig;
+import com.atmob.common.thread.ThreadPoolUtil;
+import com.atmob.compliance.AtmobCompliance;
 import com.atmob.sdk.appconvert.AppConvert;
 import com.atmob.sdk.gravity_engine.GravityEngine;
-import com.atmob.user.AtmobUser;
 import com.datarecovery.master.data.consts.Constants;
 import com.datarecovery.master.sdk.bugly.BuglyHelper;
 import com.datarecovery.master.sdk.central.AtmobCentralHelper;
@@ -25,15 +25,12 @@ import dagger.hilt.android.HiltAndroidApp;
 @HiltAndroidApp
 public class App extends BaseApplication {
 
-
     private static App INSTANCE;
 
-
     public static App getInstance() {
         return INSTANCE;
     }
 
-
     @Override
     protected void attachBaseContext(Context base) {
         super.attachBaseContext(base);
@@ -86,8 +83,17 @@ public class App extends BaseApplication {
     }
 
     @Override
-    protected int complianceStrategy() {
-        return AtmobUser.CHINA;
+    protected AtmobCentralConfig atmobCentralConfig(String channel, int appId, int tgPlatformId) {
+        return new AtmobCentralConfig.Builder()
+                .appKey(BuildConfig.ATMOB_CENTRAL_KEY)
+                .debug(BuildConfig.DEBUG)
+                .centralServer(Constants.Atmob_Server_Base_URL)
+                .channel(channel)
+                .appId(appId)
+                .tgPlatform(tgPlatformId)
+                .complianceStrategy(AtmobCompliance.Strategy.CHINA)
+                .executorService(ThreadPoolUtil.getInstance())
+                .build();
     }
 
     @Override
@@ -95,7 +101,6 @@ public class App extends BaseApplication {
         if (isMainProcess) {
             initBugly();
             initUmeng();
-            initCentral();
             initAppConvert();
             initGravityEngine();
         }
@@ -104,23 +109,13 @@ public class App extends BaseApplication {
     @Override
     public void initAfterGrant(boolean isMainProcess) {
         if (isMainProcess) {
+            UmengHelper.initAfterGrantedAgreement(getApplicationContext());
+            BuglyHelper.initAfterGrantedAgreement();
             QiYuHelper.init(this);
             QuickLoginHelper.init(this);
         }
     }
 
-    private void initCentral() {
-        ChannelReader.default4Test(
-                Constants.App_DefaultChannel,
-                Constants.App_DefaultAppId,
-                Constants.App_DefaultTgPlatformId
-        );
-        String channel = ChannelReader.getChannel(this);
-        int appId = ChannelReader.getAppId(this);
-        int tgPlatformId = ChannelReader.getTgPlatformId(this);
-        AtmobCentralHelper.init(this, channel, appId, tgPlatformId);
-    }
-
     private void initUmeng() {
         UmengHelper.init(this);
     }
@@ -138,11 +133,7 @@ public class App extends BaseApplication {
     }
 
     public void firstPrivacyRelated() {
-        AtmobUser.recordPolicyGrant(true);
         AtmobCentralHelper.onPolicyGranted(true);
-        UmengHelper.initAfterGrantedAgreement(getApplicationContext());
         UmengHelper.submitPolicyGrantResult(getApplicationContext(), true);
-        BuglyHelper.initAfterGrantedAgreement();
-        initAfterGrant(ProcessUtil.isMainProcess(this));
     }
 }

+ 1 - 21
app/src/main/java/com/datarecovery/master/data/api/request/BaseRequest.java

@@ -1,24 +1,8 @@
 package com.datarecovery.master.data.api.request;
 
-import com.atmob.user.param.AtmobParams;
-import com.datarecovery.master.BuildConfig;
-import com.datarecovery.master.data.repositories.AccountRepository;
-import com.google.gson.annotations.SerializedName;
-
-import java.lang.reflect.Field;
-
-public class BaseRequest extends AtmobParams {
-
-    @SerializedName("appPlatform")
-    private final int appPlatform;
-
-    @SerializedName("authToken")
-    private String authToken;
-
+public class BaseRequest extends com.atmob.app.lib.base.BaseRequest {
 
     public BaseRequest() {
-        this.appPlatform = 1;
-        this.authToken = AccountRepository.token;
 //        if (BuildConfig.DEBUG) {
 //            try {
 //                Field androidId = AtmobParams.class.getDeclaredField("androidId");
@@ -31,8 +15,4 @@ public class BaseRequest extends AtmobParams {
 //            }
 //        }
     }
-
-    public int getAppPlatform() {
-        return appPlatform;
-    }
 }

+ 4 - 7
app/src/main/java/com/datarecovery/master/data/consts/ChannelHelper.java

@@ -1,15 +1,14 @@
 package com.datarecovery.master.data.consts;
 
-import com.atmob.user.AtmobUser;
+import com.atmob.central.AtmobCentral;
 
 public class ChannelHelper {
 
-
     public static boolean isTargetSDChannel(String targetChannel) {
-        if (AtmobUser.getAtmobTgPlatformId() != ChannelId.SD) {
+        if (AtmobCentral.getTgPlatform() != ChannelId.SD) {
             return false;
         }
-        String atmobChannel = AtmobUser.getAtmobChannel();
+        String atmobChannel = AtmobCentral.getChannel();
         if (atmobChannel == null || targetChannel == null) {
             return false;
         }
@@ -17,14 +16,12 @@ public class ChannelHelper {
         return index != -1;
     }
 
-
     public static boolean isTargetSuffixChannel(String targetChannel) {
-        String atmobChannel = AtmobUser.getAtmobChannel();
+        String atmobChannel = AtmobCentral.getChannel();
         if (atmobChannel == null || targetChannel == null) {
             return false;
         }
         int index = atmobChannel.indexOf(targetChannel, atmobChannel.length() - targetChannel.length());
         return index != -1;
     }
-
 }

+ 3 - 3
app/src/main/java/com/datarecovery/master/data/repositories/ConfigRepository.java

@@ -6,10 +6,10 @@ import android.text.TextUtils;
 import androidx.lifecycle.LiveData;
 import androidx.lifecycle.MutableLiveData;
 
+import com.atmob.central.AtmobCentral;
 import com.atmob.common.logging.AtmobLog;
 import com.atmob.common.runtime.ContextUtil;
 import com.atmob.sdk.gravity_engine.GravityEngine;
-import com.atmob.user.AtmobUser;
 import com.datarecovery.master.data.api.AtmobApi;
 import com.datarecovery.master.data.api.request.CustomerUrlRequest;
 import com.datarecovery.master.data.api.response.CustomerUrlResponse;
@@ -62,7 +62,7 @@ public class ConfigRepository {
 
     private void getTrialMembershipStatus() {
         //如果是商店包,都开启试用会员
-        if (AtmobUser.getAtmobTgPlatformId() == ChannelId.SD) {
+        if (AtmobCentral.getTgPlatform() == ChannelId.SD) {
             isOpenTrialMembership.setValue(true);
             return;
         }
@@ -73,7 +73,7 @@ public class ConfigRepository {
                 isOpenTrialMembership.setValue(false);
                 return;
             }
-            if (AtmobUser.getAtmobTgPlatformId() != ChannelId.SD || TextUtils.isEmpty(AtmobUser.getAtmobChannel())) {
+            if (AtmobCentral.getTgPlatform() != ChannelId.SD || TextUtils.isEmpty(AtmobCentral.getChannel())) {
                 isOpenTrialMembership.setValue(false);
                 return;
             }

+ 1 - 2
app/src/main/java/com/datarecovery/master/module/about/AboutActivity.java

@@ -11,7 +11,6 @@ import androidx.annotation.NonNull;
 import com.atmob.app.lib.base.BaseActivity;
 import com.atmob.central.AtmobCentral;
 import com.atmob.sdk.gravity_engine.GravityEngine;
-import com.atmob.user.AtmobUser;
 import com.datarecovery.master.data.consts.Constants;
 import com.datarecovery.master.data.consts.EventId;
 import com.datarecovery.master.data.repositories.ConfigRepository;
@@ -107,7 +106,7 @@ public class AboutActivity extends BaseActivity<ActivityAboutBinding> {
         sb.append(ConfigRepository.getInstance().isIsOpenTrialMembership());
 
         sb.append("--");
-        sb.append(AtmobUser.getAtmobChannel());
+        sb.append(AtmobCentral.getChannel());
 
         sb.append("--");
         sb.append(GravityEngine.getAttributionStatus() == GravityEngine.ATTRIBUTED);

+ 2 - 2
app/src/main/java/com/datarecovery/master/module/splash/SplashActivity.java

@@ -9,7 +9,7 @@ import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 
 import com.atmob.app.lib.base.BaseActivity;
-import com.atmob.user.AtmobUser;
+import com.atmob.central.AtmobCentral;
 import com.datarecovery.master.App;
 import com.datarecovery.master.databinding.ActivitySplashBinding;
 import com.datarecovery.master.dialog.AgreementDialog;
@@ -29,7 +29,7 @@ public class SplashActivity extends BaseActivity<ActivitySplashBinding> {
     }
 
     private void checkPolicy() {
-        if (AtmobUser.isPolicyGranted()) {
+        if (AtmobCentral.isPolicyGranted()) {
             nextStep();
         } else {
             showPolicyDialog();

+ 2 - 2
app/src/main/java/com/datarecovery/master/sdk/bugly/BuglyHelper.java

@@ -6,8 +6,8 @@ import android.os.Build;
 
 import androidx.annotation.NonNull;
 
+import com.atmob.central.AtmobCentral;
 import com.atmob.common.runtime.ContextUtil;
-import com.atmob.user.AtmobUser;
 import com.datarecovery.master.BuildConfig;
 import com.tencent.bugly.crashreport.CrashReport;
 
@@ -34,7 +34,7 @@ public class BuglyHelper {
                 getBuglyStrategy(applicationContext)
         );
         CrashReport.setIsDevelopmentDevice(applicationContext, BuildConfig.DEBUG);//设置开发设备
-        if (AtmobUser.isPolicyGranted()) {
+        if (AtmobCentral.isPolicyGranted()) {
             initAfterGrantedAgreement();
         }
     }

+ 0 - 18
app/src/main/java/com/datarecovery/master/sdk/central/AtmobCentralHelper.java

@@ -1,30 +1,12 @@
 package com.datarecovery.master.sdk.central;
 
-import android.content.Context;
-
 import com.atmob.analytics.AtmobAnalytics;
 import com.atmob.central.AtmobCentral;
-import com.atmob.central.AtmobCentralConfig;
-import com.atmob.common.thread.ThreadPoolUtil;
-import com.atmob.compliance.AtmobCompliance;
-import com.datarecovery.master.BuildConfig;
 import com.datarecovery.master.data.consts.Constants;
 
 import java.util.Map;
 
 public class AtmobCentralHelper {
-    public static void init(Context context, String channel, int appId, int tgPlatformId) {
-        AtmobCentral.init(context, new AtmobCentralConfig.Builder()
-                .appKey(BuildConfig.ATMOB_CENTRAL_KEY)
-                .debug(BuildConfig.DEBUG)
-                .centralServer(Constants.Atmob_Server_Base_URL)
-                .channel(channel)
-                .appId(appId)
-                .tgPlatform(tgPlatformId)
-                .complianceStrategy(AtmobCompliance.Strategy.CHINA)
-                .executorService(ThreadPoolUtil.getInstance())
-                .build());
-    }
 
     public static void onPolicyGranted(boolean grand) {
         AtmobCentral.onPolicyGrant(grand);

+ 4 - 4
app/src/main/java/com/datarecovery/master/sdk/umeng/UmengHelper.java

@@ -8,7 +8,7 @@ import androidx.lifecycle.Lifecycle;
 import androidx.lifecycle.LifecycleEventObserver;
 import androidx.lifecycle.ProcessLifecycleOwner;
 
-import com.atmob.user.AtmobUser;
+import com.atmob.central.AtmobCentral;
 import com.datarecovery.master.BuildConfig;
 import com.umeng.analytics.MobclickAgent;
 import com.umeng.commonsdk.UMConfigure;
@@ -27,11 +27,11 @@ public class UmengHelper {
         if (BuildConfig.DEBUG) {
             return;
         }
-        final String channel = AtmobUser.getAtmobChannel();
+        final String channel = AtmobCentral.getChannel();
         UMConfigure.setLogEnabled(false);
         UMConfigure.preInit(application, UMENG_APP_KEY, channel);
         MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO);
-        if (AtmobUser.isPolicyGranted()) {
+        if (AtmobCentral.isPolicyGranted()) {
             initAfterGrantedAgreement(application);
         }
         ProcessLifecycleOwner.get().getLifecycle().addObserver((LifecycleEventObserver) (source, event) -> {
@@ -45,7 +45,7 @@ public class UmengHelper {
         if (BuildConfig.DEBUG) {
             return;
         }
-        final String channel = AtmobUser.getAtmobChannel();
+        final String channel = AtmobCentral.getChannel();
         UMConfigure.init(context, UMENG_APP_KEY, channel, UMConfigure.DEVICE_TYPE_PHONE, null);//last param is PushSecretKey
     }
 

+ 0 - 1
app/src/main/java/com/datarecovery/master/utils/RxHttpHandler.java

@@ -10,7 +10,6 @@ import androidx.annotation.NonNull;
 import com.atmob.app.lib.base.BaseResponse;
 import com.atmob.common.runtime.ContextUtil;
 import com.atmob.common.runtime.ProcessUtil;
-import com.datarecovery.master.data.consts.Constants;
 import com.datarecovery.master.data.consts.ErrorCode;
 import com.datarecovery.master.data.repositories.AccountRepository;
 

+ 3 - 3
app/src/main/res/layout/fragment_mine.xml

@@ -11,9 +11,9 @@
 
         <import type="com.atmob.common.ui.SizeUtil" />
 
-        <import type="com.atmob.user.AtmobUser" />
-
         <import type="com.datarecovery.master.data.consts.ChannelId" />
+
+        <import type="com.atmob.central.AtmobCentral" />
     </data>
 
     <androidx.constraintlayout.widget.ConstraintLayout
@@ -201,7 +201,7 @@
                         android:onClick="@{()->mineViewModel.onCustomerServiceClick()}" />
 
                     <include
-                        isGone="@{!mineViewModel.isLogin || AtmobUser.getAtmobTgPlatformId() == ChannelId.BD}"
+                        isGone="@{!mineViewModel.isLogin || AtmobCentral.getTgPlatform() == ChannelId.BD}"
                         layout="@layout/layout_item_settings"
                         settingsIcon="@{@drawable/icon_small_appeal}"
                         settingsName="@{mineViewModel.mineAppealText}"