fix: 数据上报问题 https://jira.shanqu.cc/browse/GHZS-4698
This commit is contained in:
@ -1,23 +1,17 @@
|
||||
package com.gh.common.util
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Environment
|
||||
import android.preference.PreferenceManager
|
||||
import com.gh.gamecenter.common.exposure.meta.MetaUtil
|
||||
import com.gh.gamecenter.BuildConfig
|
||||
import com.gh.gamecenter.common.constant.Constants
|
||||
import com.gh.gamecenter.entity.TimeEntity
|
||||
import com.gh.gamecenter.common.retrofit.Response
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.lightgame.utils.Utils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import java.io.File
|
||||
|
||||
object DeviceTokenUtils {
|
||||
|
||||
const val DEVICE_ID = "uuid"
|
||||
|
||||
// 同步服务器时间
|
||||
@JvmStatic
|
||||
@Synchronized
|
||||
@ -39,99 +33,29 @@ object DeviceTokenUtils {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getLaunchType(readOnly: Boolean = false): LunchType {
|
||||
fun getLaunchType(): LunchType {
|
||||
var lunchType: LunchType? = null
|
||||
val values = PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().application).all
|
||||
// 版本更新
|
||||
if (values.isNotEmpty()) {
|
||||
for (value in values) {
|
||||
if (value.key.contains("isNewFirstLaunchV")) {
|
||||
if (value.key.contains(Constants.SP_NEW_FIRST_LAUNCH_VERSION)) {
|
||||
lunchType = LunchType.UPDATE
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
// 再次重装
|
||||
if (lunchType == null && !getDeviceId().isNullOrEmpty()) {
|
||||
lunchType = LunchType.AGAIN
|
||||
}
|
||||
// 首次安装
|
||||
if (lunchType == null) {
|
||||
lunchType = LunchType.FIRST
|
||||
}
|
||||
// 保存deviceId
|
||||
var deviceId = MetaUtil.getIMEI()
|
||||
if (deviceId.isNullOrEmpty()) {
|
||||
deviceId = Utils.getTime(HaloApp.getInstance().application).toString()
|
||||
}
|
||||
|
||||
if (!readOnly) {
|
||||
setDeviceId(deviceId)
|
||||
}
|
||||
|
||||
return lunchType
|
||||
}
|
||||
|
||||
private fun getDeviceFileList(): List<File> {
|
||||
val sdCardDir = Environment.getExternalStorageDirectory()
|
||||
val fileList: MutableList<File> = ArrayList()
|
||||
fileList.add(File(sdCardDir.path + "/gh-uuid/$DEVICE_ID"))
|
||||
fileList.add(File(sdCardDir.path + "/system/$DEVICE_ID"))
|
||||
fileList.add(File(sdCardDir.path + "/data/$DEVICE_ID"))
|
||||
return fileList
|
||||
}
|
||||
|
||||
|
||||
@Synchronized
|
||||
private fun setDeviceId(deviceId: String) {
|
||||
//将deviceId存到sp
|
||||
val sp = PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().application)
|
||||
val edit = sp.edit()
|
||||
edit.putString(DEVICE_ID, deviceId)
|
||||
edit.apply()
|
||||
Utils.log("saveDeviceId", "保存成功SP")
|
||||
|
||||
//将deviceId存到SD卡
|
||||
for (file in getDeviceFileList()) {
|
||||
try {
|
||||
val parentFile = file.parentFile
|
||||
if (!parentFile.exists()) parentFile.mkdirs()
|
||||
file.writeText(deviceId)
|
||||
Utils.log("saveDeviceId", "保存成功SDCard目录为:${file.path}")
|
||||
} catch (e: Exception) {
|
||||
Utils.log("保存u${DEVICE_ID}到SDCard异常${file.path} " + e.toString())
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getDeviceId(): String? {
|
||||
val sp = PreferenceManager.getDefaultSharedPreferences(HaloApp.getInstance().application)
|
||||
var deviceId = sp.getString(DEVICE_ID, null)
|
||||
if (deviceId.isNullOrEmpty()) {
|
||||
val fileList = getDeviceFileList()
|
||||
for (file in fileList) {
|
||||
if (file.exists()) {
|
||||
try {
|
||||
deviceId = file.readText()
|
||||
Utils.log("getDeviceId", "获取成功DataFile$DEVICE_ID")
|
||||
return deviceId
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (BuildConfig.DEBUG) {
|
||||
Utils.log("getDeviceId", "获取成功SP$DEVICE_ID")
|
||||
}
|
||||
return deviceId
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enum class LunchType {
|
||||
FIRST,
|
||||
UPDATE,
|
||||
AGAIN
|
||||
UPDATE
|
||||
}
|
||||
|
||||
@ -50,11 +50,9 @@ import com.gh.common.history.HistoryDatabase;
|
||||
import com.gh.common.history.HistoryHelper;
|
||||
import com.gh.common.repository.ReservationRepository;
|
||||
import com.gh.common.simulator.SimulatorGameManager;
|
||||
import com.gh.common.util.ActivationHelper;
|
||||
import com.gh.common.util.AdHelper;
|
||||
import com.gh.common.util.CertificationSwitchHelper;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DeviceTokenUtils;
|
||||
import com.gh.common.util.DirectUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.common.util.ErrorHelper;
|
||||
@ -82,13 +80,11 @@ import com.gh.gamecenter.common.retrofit.Response;
|
||||
import com.gh.gamecenter.common.utils.DialogHelper;
|
||||
import com.gh.gamecenter.common.utils.ExtensionsKt;
|
||||
import com.gh.gamecenter.common.utils.NewFlatLogUtils;
|
||||
import com.gh.gamecenter.common.utils.PermissionHelper;
|
||||
import com.gh.gamecenter.common.utils.SensorsBridge;
|
||||
import com.gh.gamecenter.common.utils.ShareUtils;
|
||||
import com.gh.gamecenter.core.AppExecutor;
|
||||
import com.gh.gamecenter.core.utils.ClassUtils;
|
||||
import com.gh.gamecenter.core.utils.DisplayUtils;
|
||||
import com.gh.gamecenter.core.utils.EmptyCallback;
|
||||
import com.gh.gamecenter.core.utils.GsonUtils;
|
||||
import com.gh.gamecenter.core.utils.MtaHelper;
|
||||
import com.gh.gamecenter.core.utils.SPUtils;
|
||||
@ -171,8 +167,6 @@ public class MainActivity extends BaseActivity {
|
||||
// 黄壮华 按连续按返回键两次才退出应用
|
||||
private final long[] mHits = new long[2];
|
||||
|
||||
public static boolean isNewFirstLaunch;
|
||||
|
||||
private final Handler handler = new Handler();
|
||||
private boolean mShouldShowAd = false; // 是否显示广告
|
||||
|
||||
@ -199,15 +193,10 @@ public class MainActivity extends BaseActivity {
|
||||
replaceFragment(mMainWrapperFragment);
|
||||
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
isNewFirstLaunch = sp.getBoolean("isNewFirstLaunchV" + PackageUtils.getGhVersionName(), true);
|
||||
if (isNewFirstLaunch) {
|
||||
final LunchType lunchType = DeviceTokenUtils.getLaunchType(false);
|
||||
// 延时两秒提交,避免提交时还没获取到 GID/OAID
|
||||
if (HaloApp.getInstance().isNewForThisVersion) {
|
||||
LunchType lunchType = HaloApp.getInstance().getLaunchType();
|
||||
AppExecutor.getUiExecutor().executeWithDelay(() -> {
|
||||
if (!this.isFinishing()) {
|
||||
LogUtils.uploadDevice(lunchType);
|
||||
ActivationHelper.sendActivationInfo();
|
||||
// 第一次打开App删除模拟器游戏记录(不包括更新版本)
|
||||
if (HaloApp.getInstance().isBrandNewInstall) {
|
||||
getTeenagerMode();
|
||||
@ -215,7 +204,7 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
}, 2000L);
|
||||
sp.edit().putBoolean("isNewFirstLaunchV" + PackageUtils.getGhVersionName(), false).apply();
|
||||
sp.edit().putBoolean(Constants.SP_NEW_FIRST_LAUNCH_VERSION + PackageUtils.getGhVersionName(), false).apply();
|
||||
|
||||
// 记录曾安装过的版本 + 渠道
|
||||
SPUtils.setString("installedVersionV" + PackageUtils.getGhVersionName(), HaloApp.getInstance().getChannel());
|
||||
|
||||
@ -50,9 +50,7 @@ class SplashScreenActivity : BaseActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
mViewModel = viewModelProvider()
|
||||
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
mIsNewForThisVersion =
|
||||
mSharedPreferences!!.getBoolean("isNewFirstLaunchV" + PackageUtils.getGhVersionName(), true)
|
||||
HaloApp.getInstance().isNewForThisVersion = mIsNewForThisVersion
|
||||
mIsNewForThisVersion = HaloApp.getInstance().isNewForThisVersion
|
||||
HaloApp.getInstance().isBrandNewInstall = SPUtils.getBoolean(Constants.SP_BRAND_NEW_USER, true)
|
||||
|
||||
// 用户不是新版本,但应用最后更新时间不是上次的时间代表用户重新安装了当前版本
|
||||
|
||||
@ -111,7 +111,7 @@ class SplashScreenViewModel(application: Application) : AndroidViewModel(applica
|
||||
HaloApp.getInstance().setLocalTemporaryDeviceId(localTemporaryDeviceId)
|
||||
SPUtils.setString(Constants.SP_TEMPORARY_DEVICE_ID, localTemporaryDeviceId)
|
||||
}
|
||||
map["launch_type"] = DeviceTokenUtils.getLaunchType(true).name
|
||||
map["launch_type"] = DeviceTokenUtils.getLaunchType().name
|
||||
} else if (HaloApp.getInstance().isReinstallTheSameVersion) {
|
||||
map["launch_type"] = LunchType.UPDATE.toString()
|
||||
}
|
||||
|
||||
@ -13,7 +13,6 @@ import com.gh.common.util.LogUtils
|
||||
import com.gh.common.util.NewFlatLogUtils
|
||||
import com.gh.common.util.NewLogUtils
|
||||
import com.gh.gamecenter.GameDetailActivity
|
||||
import com.gh.gamecenter.MainActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.adapter.viewholder.GameHeadViewHolder
|
||||
import com.gh.gamecenter.adapter.viewholder.GameImageViewHolder
|
||||
@ -55,6 +54,7 @@ import com.gh.gamecenter.home.horizontalslidevideo.HomeHorizontalSlideVideoListV
|
||||
import com.gh.gamecenter.home.video.ScrollCalculatorHelper
|
||||
import com.gh.gamecenter.servers.gametest2.GameServerTestV2Activity
|
||||
import com.gh.gamecenter.subject.SubjectActivity
|
||||
import com.halo.assistant.HaloApp
|
||||
import com.halo.assistant.fragment.game.GamePluginAdapter
|
||||
import com.halo.assistant.fragment.game.GamePluginViewHolder
|
||||
import java.util.*
|
||||
@ -922,7 +922,7 @@ class LegacyHomeFragmentAdapterAssistant(
|
||||
var adapter = holder.binding.recyclerView.adapter
|
||||
|
||||
if (mPluginDisplayStatus == PluginDisplayStatus.DEFAULT) {
|
||||
mPluginDisplayStatus = if (MainActivity.isNewFirstLaunch) {
|
||||
mPluginDisplayStatus = if (HaloApp.getInstance().isNewForThisVersion) {
|
||||
if (pluginList!!.size > 2) {
|
||||
PluginDisplayStatus.OPEN_TWO_AND_BUTTON
|
||||
} else {
|
||||
|
||||
@ -13,7 +13,7 @@ object OAIDHelper {
|
||||
oaidProvider?.doSystemLoad()
|
||||
}
|
||||
|
||||
fun getOAID(context: Context, callback: (String) -> Unit) {
|
||||
fun getOAID(context: Context, callback: (String, Boolean) -> Unit) {
|
||||
val oaidProvider = ARouter.getInstance().build(RouteConsts.provider.oaid).navigation() as? IOAIDProvider
|
||||
|
||||
oaidProvider?.getOAID(context, callback)
|
||||
|
||||
@ -31,16 +31,19 @@ import com.gh.ad.AdDelegateHelper;
|
||||
import com.gh.base.GlobalActivityLifecycleObserver;
|
||||
import com.gh.common.FixedRateJobHelper;
|
||||
import com.gh.common.filter.RegionSettingHelper;
|
||||
import com.gh.common.util.ActivationHelper;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DeviceTokenUtils;
|
||||
import com.gh.common.util.DownloadNotificationHelper;
|
||||
import com.gh.common.util.DownloadObserver;
|
||||
import com.gh.common.util.HomeBottomBarHelper;
|
||||
import com.gh.common.util.LogUtils;
|
||||
import com.gh.common.util.LunchType;
|
||||
import com.gh.common.util.PackageHelper;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.videolog.VideoRecordUtils;
|
||||
import com.gh.download.simple.DownloadMessageHandler;
|
||||
import com.gh.download.simple.SimpleDownloadDatabase;
|
||||
import com.gh.download.simple.SimpleDownloadManager;
|
||||
import com.gh.gamecenter.BuildConfig;
|
||||
import com.gh.gamecenter.Injection;
|
||||
import com.gh.gamecenter.common.constant.Config;
|
||||
@ -115,6 +118,7 @@ public class HaloApp extends MultiDexApplication {
|
||||
private List<String> webViewAbiList;
|
||||
private IFlavorProvider mFlavorProvider = new FlavorProviderImp();
|
||||
private final ServiceLoader<IApplication> mApplicationList = ServiceLoader.load(IApplication.class, this.getClass().getClassLoader());
|
||||
private LunchType mLaunchType = null;
|
||||
|
||||
public static void put(String key, Object object) {
|
||||
sObjectMap.put(key, object);
|
||||
@ -234,6 +238,9 @@ public class HaloApp extends MultiDexApplication {
|
||||
|
||||
initFresco();
|
||||
|
||||
isNewForThisVersion =
|
||||
PreferenceManager.getDefaultSharedPreferences(this).getBoolean(Constants.SP_NEW_FIRST_LAUNCH_VERSION + PackageUtils.getGhVersionName(), true);
|
||||
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
initDataHelper();
|
||||
ExtensionsKt.doOnMainProcessOnly(this, () -> {
|
||||
@ -304,10 +311,21 @@ public class HaloApp extends MultiDexApplication {
|
||||
// https://jira.shanqu.cc/browse/GHZS-3765
|
||||
// 港澳APP去掉oaid的获取
|
||||
if (!EnvHelper.isGATApp()) {
|
||||
OAIDHelper.INSTANCE.getOAID(this, s -> {
|
||||
setOAID(s);
|
||||
MetaUtil.INSTANCE.refreshMeta();
|
||||
SensorsBridge.INSTANCE.setOAID(s);
|
||||
ExtensionsKt.doOnMainProcessOnly(() -> {
|
||||
OAIDHelper.INSTANCE.getOAID(HaloApp.this, (s, isSuccess) -> {
|
||||
setOAID(s);
|
||||
MetaUtil.INSTANCE.refreshMeta();
|
||||
SensorsBridge.INSTANCE.setOAID(s);
|
||||
|
||||
// 上报设备安装事件
|
||||
if (isNewForThisVersion) {
|
||||
final LunchType launchType = getLaunchType();
|
||||
LogUtils.uploadDevice(launchType);
|
||||
|
||||
ActivationHelper.sendActivationInfo();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
return null;
|
||||
});
|
||||
}
|
||||
@ -531,11 +549,18 @@ public class HaloApp extends MultiDexApplication {
|
||||
* 覆盖安装进入过首页的也当作是同意了
|
||||
*/
|
||||
public static boolean isUserAcceptPrivacyPolicy(Context context) {
|
||||
return !PreferenceManager.getDefaultSharedPreferences(context).getBoolean("isNewFirstLaunchV" + PackageUtils.getGhVersionName(), true)
|
||||
return !PreferenceManager.getDefaultSharedPreferences(context).getBoolean(Constants.SP_NEW_FIRST_LAUNCH_VERSION + PackageUtils.getGhVersionName(), true)
|
||||
|| !SPUtils.getBooleanWithContext(context, Constants.SP_BRAND_NEW_USER, true)
|
||||
|| SPUtils.getBooleanWithContext(context, Constants.SP_IS_USER_ACCEPTED_PRIVACY_STATEMENT, false);
|
||||
}
|
||||
|
||||
public LunchType getLaunchType() {
|
||||
if (mLaunchType == null) {
|
||||
mLaunchType = DeviceTokenUtils.getLaunchType();
|
||||
}
|
||||
return mLaunchType;
|
||||
}
|
||||
|
||||
public IFlavorProvider getFlavorProvider() {
|
||||
return mFlavorProvider;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user