Commit 69346e65 by 宁斌

1、項目結構整理,2、添加獲取deviceId方案

parent 5d2696f1
...@@ -13,12 +13,12 @@ dependencies { ...@@ -13,12 +13,12 @@ dependencies {
if (project.name != 'library-base' && project.name != 'library-database' && project.name != 'library-fragmentation_core' && project.name != 'library-qm-qmui' && project.name != 'library-qm-arch' && project.name != 'library-qm-skin-maker' && project.name != 'library-ui') { if (project.name != 'library-base' && project.name != 'library-database' && project.name != 'library-fragmentation_core' && project.name != 'library-qm-qmui' && project.name != 'library-qm-arch' && project.name != 'library-qm-skin-maker' && project.name != 'library-ui') {
api project(':library-base') api project(':library-base')
} }
if (project.name != 'library-common' && project.name != 'library-base' && project.name != 'library-database' && project.name != 'library-fragmentation_core' && project.name != 'library-qm-qmui' && project.name != 'library-qm-arch' && project.name != 'library-qm-skin-maker') { if (project.name != 'library-common' && project.name != 'library-base' && project.name != 'library-oaid' && project.name != 'library-database' && project.name != 'library-fragmentation_core' && project.name != 'library-qm-qmui' && project.name != 'library-qm-arch' && project.name != 'library-qm-skin-maker') {
api project(':library-common') api project(':library-common')
} }
if (project.name == 'table-module') { // if (!project.name.contains('library')) {
api project(':library-pay') // api project(':library-order')
} // }
if (project.name != 'library-database' && project.name != 'library-base' && project.name != 'library-fragmentation_core' && project.name != 'library-qm-qmui' && project.name != 'library-qm-arch' && project.name != 'library-qm-skin-maker') { if (project.name != 'library-database' && project.name != 'library-base' && project.name != 'library-fragmentation_core' && project.name != 'library-qm-qmui' && project.name != 'library-qm-arch' && project.name != 'library-qm-skin-maker') {
api project(':library-database') api project(':library-database')
} }
...@@ -31,9 +31,10 @@ dependencies { ...@@ -31,9 +31,10 @@ dependencies {
if (project.name != 'library-qm-skin-maker' && project.name != 'library-qm-arch' && project.name != 'library-qm-qmui') { if (project.name != 'library-qm-skin-maker' && project.name != 'library-qm-arch' && project.name != 'library-qm-qmui') {
api project(':library-qm-skin-maker') api project(':library-qm-skin-maker')
} }
if (project.name != 'library-ui' && project.name != 'library-base' && project.name != 'library-common' && project.name != 'library-database' && project.name != 'library-fragmentation_core' && project.name != 'library-qm-skin-maker' && project.name != 'library-qm-arch' && project.name != 'library-qm-qmui') { if (project.name != 'library-ui' && project.name != 'library-base' && project.name != 'library-common' && project.name != 'library-oaid' && project.name != 'library-database' && project.name != 'library-fragmentation_core' && project.name != 'library-qm-skin-maker' && project.name != 'library-qm-arch' && project.name != 'library-qm-qmui') {
api project(':library-ui') api project(':library-ui')
} }
implementation rootProject.ext.dependencies["retrofit-url-manager"] implementation rootProject.ext.dependencies["retrofit-url-manager"]
api rootProject.ext.dependencies["butterknife"] api rootProject.ext.dependencies["butterknife"]
annotationProcessor rootProject.ext.dependencies["butterknife-compiler"] annotationProcessor rootProject.ext.dependencies["butterknife-compiler"]
......
...@@ -125,6 +125,7 @@ dependencies { ...@@ -125,6 +125,7 @@ dependencies {
addComponent 'component-coldchain' addComponent 'component-coldchain'
addComponent 'component-supply-chain' addComponent 'component-supply-chain'
addComponent 'component-webview' addComponent 'component-webview'
addComponent 'component-scan'
implementation 'androidx.viewpager2:viewpager2:1.0.0-alpha03' implementation 'androidx.viewpager2:viewpager2:1.0.0-alpha03'
annotationProcessor rootProject.ext.dependencies["dagger2-compiler"] annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
......
...@@ -318,7 +318,7 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements ...@@ -318,7 +318,7 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
SPUtils.put(UserConstans.AUTO_LOGIN, mRbAutoLogin.isChecked()); SPUtils.put(UserConstans.AUTO_LOGIN, mRbAutoLogin.isChecked());
} }
@OnClick({R2.id.btn_gsa_user_login, R2.id.iv_clear_pwd, R2.id.iv_clear_account, R2.id.tv_remember_pwd_text, R2.id.ic_look_pwd, R2.id.tv_auto_login_text, R2.id.tv_forget_pwd}) @OnClick({R2.id.btn_gsa_user_login, R2.id.iv_clear_pwd, R2.id.iv_clear_account, R2.id.ic_look_pwd, R2.id.tv_forget_pwd})
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
case R.id.ic_look_pwd: case R.id.ic_look_pwd:
...@@ -334,17 +334,6 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements ...@@ -334,17 +334,6 @@ public class LoginActivity extends LoginInterfaceImpl<LoginPresenter> implements
} }
edPwd.setSelection(edPwd.getText() == null ? 0 : edPwd.getText().toString().length()); edPwd.setSelection(edPwd.getText() == null ? 0 : edPwd.getText().toString().length());
break; break;
case R.id.tv_remember_pwd_text:
//記住密碼
mRbRememberPwd.toggle();
break;
case R.id.tv_auto_login_text:
//自動登陸
mRbAutoLogin.toggle();
if (mRbAutoLogin.isChecked()) {
mRbRememberPwd.setChecked(true);
}
break;
case R.id.btn_gsa_user_login: case R.id.btn_gsa_user_login:
//登陸 //登陸
if (edPwd.getText() == null || edPwd.getText().length() < 6) { if (edPwd.getText() == null || edPwd.getText().length() < 6) {
......
...@@ -13,13 +13,7 @@ ...@@ -13,13 +13,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application android:networkSecurityConfig="@xml/network_android"> <application android:networkSecurityConfig="@xml/network_android">
<activity android:name=".mvp.ui.activity.MipcaCaptureActivity"> <activity android:name=".mvp.ui.activity.MipcaCaptureActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> </activity>
</application> </application>
......
...@@ -14,13 +14,7 @@ ...@@ -14,13 +14,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application android:networkSecurityConfig="@xml/network_android"> <application android:networkSecurityConfig="@xml/network_android">
<activity android:name=".mvp.ui.activity.WebActivity"> <activity android:name=".mvp.ui.activity.WebActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> </activity>
</application> </application>
......
...@@ -179,6 +179,7 @@ dependencies { ...@@ -179,6 +179,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
api 'com.github.huangyanbin:SmartTable:2.2.0' api 'com.github.huangyanbin:SmartTable:2.2.0'
implementation "androidx.documentfile:documentfile:1.0.1"
} }
repositories { repositories {
mavenCentral() mavenCentral()
......
...@@ -25,3 +25,19 @@ ...@@ -25,3 +25,19 @@
-keep public class com.google.android.material.bottomnavigation.BottomNavigationMenuView { *; } -keep public class com.google.android.material.bottomnavigation.BottomNavigationMenuView { *; }
-keep public class com.google.android.material.bottomnavigation.BottomNavigationPresenter { *; } -keep public class com.google.android.material.bottomnavigation.BottomNavigationPresenter { *; }
-keep public class com.google.android.material.bottomnavigation.BottomNavigationItemView { *; } -keep public class com.google.android.material.bottomnavigation.BottomNavigationItemView { *; }
# 本库模块专用的混淆规则
-keep class com.asus.msa.SupplementaryDID.** { *; }
-keep interface com.asus.msa.SupplementaryDID.** { *; }
-keep class com.bun.lib.** { *; }
-keep interface com.bun.lib.** { *; }
-keep class com.heytap.openid.** { *; }
-keep interface com.heytap.openid.** { *; }
-keep class com.samsung.android.deviceidservice.** { *; }
-keep interface com.samsung.android.deviceidservice.** { *; }
-keep class com.uodis.opendevice.aidl.** { *; }
-keep interface com.uodis.opendevice.aidl.** { *; }
-keep class com.zui.deviceidservice.** { *; }
-keep interface com.zui.deviceidservice.** { *; }
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="com.asus.msa.SupplementaryDID.ACCESS" />
<application <application
android:name="com.gingersoft.gsa.cloud.app.GsaCloudApplication" android:name="com.gingersoft.gsa.cloud.app.GsaCloudApplication"
android:allowBackup="true" android:allowBackup="true"
......
// IDidAidlInterface.aidl
package com.asus.msa.SupplementaryDID;
// Declare any non-default types here with import statements
interface IDidAidlInterface {
String getID();
}
// MsaIdInterface.aidl
package com.bun.lib;
// Declare any non-default types here with import statements
interface MsaIdInterface {
boolean c();
String getOAID();
boolean isSupported();
void shutDown();
}
// IOpenID.aidl
package com.heytap.openid;
// Declare any non-default types here with import statements
interface IOpenID {
String getSerID(String pkgName, String sign, String type);
}
// IDeviceIdService.aidl
package com.samsung.android.deviceidservice;
// Declare any non-default types here with import statements
interface IDeviceIdService {
String getID();
}
// OpenDeviceIdentifierService.aidl
package com.uodis.opendevice.aidl;
// Declare any non-default types here with import statements
interface OpenDeviceIdentifierService {
String getIDs();
boolean getBoos();
}
// IDeviceidInterface.aidl
package com.zui.deviceidservice;
// Declare any non-default types here with import statements
interface IDeviceidInterface {
String a();
String b();
boolean c();
}
...@@ -7,7 +7,9 @@ import android.content.pm.PackageManager; ...@@ -7,7 +7,9 @@ import android.content.pm.PackageManager;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Build; import android.os.Build;
import android.os.RemoteException; import android.os.RemoteException;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.billy.cc.core.component.CC; import com.billy.cc.core.component.CC;
import com.dianping.logan.Logan; import com.dianping.logan.Logan;
import com.dianping.logan.OnLoganProtocolStatus; import com.dianping.logan.OnLoganProtocolStatus;
...@@ -24,26 +26,27 @@ import com.elvishew.xlog.printer.file.clean.FileLastModifiedCleanStrategy; ...@@ -24,26 +26,27 @@ import com.elvishew.xlog.printer.file.clean.FileLastModifiedCleanStrategy;
import com.elvishew.xlog.printer.file.naming.DateFileNameGenerator; import com.elvishew.xlog.printer.file.naming.DateFileNameGenerator;
import com.gingersoft.gsa.cloud.common.BuildConfig; import com.gingersoft.gsa.cloud.common.BuildConfig;
import com.gingersoft.gsa.cloud.common.R; import com.gingersoft.gsa.cloud.common.R;
import com.gingersoft.gsa.cloud.common.config.DoraemonKitConfig;
import com.gingersoft.gsa.cloud.common.config.LoganConfig;
import com.gingersoft.gsa.cloud.common.config.expandconfig.ExpandInfoSetting;
import com.gingersoft.gsa.cloud.common.config.expandconfig.FunctionExtendedConfiguration;
import com.gingersoft.gsa.cloud.common.config.expandconfig.UIStyleExtendedConfiguration;
import com.gingersoft.gsa.cloud.common.constans.HttpsConstans;
import com.gingersoft.gsa.cloud.common.constans.PrintConstans;
import com.gingersoft.gsa.cloud.common.loadsir.CustomCallback; import com.gingersoft.gsa.cloud.common.loadsir.CustomCallback;
import com.gingersoft.gsa.cloud.common.loadsir.EmptyCallback; import com.gingersoft.gsa.cloud.common.loadsir.EmptyCallback;
import com.gingersoft.gsa.cloud.common.loadsir.ErrorCallback; import com.gingersoft.gsa.cloud.common.loadsir.ErrorCallback;
import com.gingersoft.gsa.cloud.common.loadsir.LoadingCallback; import com.gingersoft.gsa.cloud.common.loadsir.LoadingCallback;
import com.gingersoft.gsa.cloud.common.loadsir.TimeoutCallback; import com.gingersoft.gsa.cloud.common.loadsir.TimeoutCallback;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.oaId.DeviceID;
import com.gingersoft.gsa.cloud.common.utils.AidlUtil; import com.gingersoft.gsa.cloud.common.utils.AidlUtil;
import com.gingersoft.gsa.cloud.common.utils.FileUtils; import com.gingersoft.gsa.cloud.common.utils.FileUtils;
import com.gingersoft.gsa.cloud.common.utils.crash.AppCrashHandler; import com.gingersoft.gsa.cloud.common.utils.crash.AppCrashHandler;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil; import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.common.utils.other.SPUtils; import com.gingersoft.gsa.cloud.common.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.common.utils.xlog.MyBackupStrategy; import com.gingersoft.gsa.cloud.common.utils.xlog.MyBackupStrategy;
import com.gingersoft.gsa.cloud.common.config.DoraemonKitConfig;
import com.gingersoft.gsa.cloud.common.config.LoganConfig;
import com.gingersoft.gsa.cloud.common.config.expandconfig.ExpandInfoSetting;
import com.gingersoft.gsa.cloud.common.config.expandconfig.FunctionExtendedConfiguration;
import com.gingersoft.gsa.cloud.common.config.expandconfig.UIStyleExtendedConfiguration;
import com.gingersoft.gsa.cloud.common.constans.HttpsConstans;
import com.gingersoft.gsa.cloud.common.constans.PrintConstans;
import com.gingersoft.gsa.cloud.database.DaoManager; import com.gingersoft.gsa.cloud.database.DaoManager;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.hyweb.n5.lib.exception.NoInitPrinterException; import com.hyweb.n5.lib.exception.NoInitPrinterException;
import com.hyweb.n5.lib.util.PrinterUtil; import com.hyweb.n5.lib.util.PrinterUtil;
import com.jess.arms.base.BaseApplication; import com.jess.arms.base.BaseApplication;
...@@ -51,8 +54,10 @@ import com.kingja.loadsir.core.LoadSir; ...@@ -51,8 +54,10 @@ import com.kingja.loadsir.core.LoadSir;
import com.scwang.smartrefresh.layout.SmartRefreshLayout; import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter; import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader; import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import java.io.File; import java.io.File;
import java.util.Locale; import java.util.Locale;
import me.jessyan.autosize.AutoSize; import me.jessyan.autosize.AutoSize;
import me.jessyan.autosize.AutoSizeConfig; import me.jessyan.autosize.AutoSizeConfig;
import me.jessyan.autosize.onAdaptListener; import me.jessyan.autosize.onAdaptListener;
...@@ -106,6 +111,8 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -106,6 +111,8 @@ public class GsaCloudApplication extends BaseApplication {
//初始化美團日誌框架 //初始化美團日誌框架
initLogan(); initLogan();
LoganManager.w_action(TAG, TAG + ": onCreate start....."); LoganManager.w_action(TAG, TAG + ": onCreate start.....");
//初始化設備唯一ID
initDeviceId();
//初始化服務器地址 //初始化服務器地址
initDomainUrl(); initDomainUrl();
//初始化側滑回退 //初始化側滑回退
...@@ -164,6 +171,14 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -164,6 +171,14 @@ public class GsaCloudApplication extends BaseApplication {
DoraemonKit.install(getAppContext(), DoraemonKitConfig.PRODUCE_ID); DoraemonKit.install(getAppContext(), DoraemonKitConfig.PRODUCE_ID);
} }
/**
* 獲取設備唯一ID
*
* @return
*/
public final static void initDeviceId() {
DeviceID.initDeviceId();
}
public Activity getCurrentActivity() { public Activity getCurrentActivity() {
return mCurrentActivity; return mCurrentActivity;
......
...@@ -113,10 +113,6 @@ public class FunctionExtendedConfiguration { ...@@ -113,10 +113,6 @@ public class FunctionExtendedConfiguration {
.remark("餐檯模式開檯自動彈出輸入人數彈窗") .remark("餐檯模式開檯自動彈出輸入人數彈窗")
.build(); .build();
private ExpandInfoSetting DelayedPrinting = ExpandInfoSetting.builder()
.valueInt(3)
.remark("延遲打印間隔")
.build();
/** /**
* skyorder相關 * skyorder相關
*/ */
...@@ -143,11 +139,11 @@ public class FunctionExtendedConfiguration { ...@@ -143,11 +139,11 @@ public class FunctionExtendedConfiguration {
public <T> T getRoundingValue() { public <T> T getRoundingVaule() {
return Rounding.getValue(); return Rounding.getValue();
} }
public <T> T getRoundingDecimalValue() { public <T> T getRoundingDecimalVaule() {
return RoundingDecimal.getValue(); return RoundingDecimal.getValue();
} }
...@@ -155,79 +151,79 @@ public class FunctionExtendedConfiguration { ...@@ -155,79 +151,79 @@ public class FunctionExtendedConfiguration {
return ItemDecimals.getValue(); return ItemDecimals.getValue();
} }
public <T> T getDeliveryPrintCountValue() { public <T> T getDeliveryPrintCountVaule() {
return DeliveryPrintCount.getValue(); return DeliveryPrintCount.getValue();
} }
public <T> T getDeliveryClosingPCValue() { public <T> T getDeliveryClosingPCVaule() {
return DeliveryClosingPC.getValue(); return DeliveryClosingPC.getValue();
} }
public <T> T getTableModePrintCountValue() { public <T> T getTableModePrintCountVaule() {
return TableModePrintCount.getValue(); return TableModePrintCount.getValue();
} }
public <T> T getTableModeClosingPCValue() { public <T> T getTableModeClosingPCVaule() {
return TableModeClosingPC.getValue(); return TableModeClosingPC.getValue();
} }
public <T> T getOrderReceivingTimeoutValue() { public <T> T getOrderReceivingTimeoutVaule() {
return OrderReceivingTimeout.getValue(); return OrderReceivingTimeout.getValue();
} }
public <T> T getPrintMemberInfoValue() { public <T> T getPrintMemberInfoVaule() {
return PrintMemberInfo.getValue(); return PrintMemberInfo.getValue();
} }
public <T> T getPrintPageValue() { public <T> T getPrintPageVaule() {
return PrintPage.getValue(); return PrintPage.getValue();
} }
public <T> T getPrintMergerFoodValue() { public <T> T getPrintMergerFoodVaule() {
return PrintMergerFood.getValue(); return PrintMergerFood.getValue();
} }
public <T> T getPrintStatisticsAmountValue() { public <T> T getPrintStatisticsAmountVaule() {
return PrintStatisticsAmount.getValue(); return PrintStatisticsAmount.getValue();
} }
public <T> T getPrintFirstOrderValue() { public <T> T getPrintFirstOrderVaule() {
return PrintFirstOrder.getValue(); return PrintFirstOrder.getValue();
} }
public <T> T getFrozenChainAutoOrderValue() { public <T> T getFrozenChainAutoOrderVaule() {
return FrozenChainAutoOrder.getValue(); return FrozenChainAutoOrder.getValue();
} }
public <T> T getMergeSendFoodValue() { public <T> T getMergeSendFoodVaule() {
return MergeSendFood.getValue(); return MergeSendFood.getValue();
} }
public <T> T getAutoPrinterPaperValue() { public <T> T getAutoPrinterPaperVaule() {
return AutoPrinterPaper.getValue(); return AutoPrinterPaper.getValue();
} }
public <T> T getToPrintQRCodeValue() { public <T> T getToPrintQRCodeVaule() {
return ToPrintQRCode.getValue(); return ToPrintQRCode.getValue();
} }
public <T> T getAutoQuitTimeValue() { public <T> T getAutoQuitTimeVaule() {
return AutoQuitTime.getValue(); return AutoQuitTime.getValue();
} }
public <T> T getQRCodeTimeSliceValue() { public <T> T getQRCodeTimeSliceVaule() {
return QRCodeTimeSlice.getValue(); return QRCodeTimeSlice.getValue();
} }
public <T> T getSkyQRCodeTableFlagTextValue() { public <T> T getSkyQRCodeTableFlagTextVaule() {
return SkyQRCodeTableFlagText.getValue(); return SkyQRCodeTableFlagText.getValue();
} }
public <T> T getSkyQRCodePrintTopInfoValue() { public <T> T getSkyQRCodePrintTopInfoVaule() {
return SkyQRCodePrintTopInfo.getValue(); return SkyQRCodePrintTopInfo.getValue();
} }
public <T> T getSkyQRCodePrintBottomInfoValue() { public <T> T getSkyQRCodePrintBottomInfoVaule() {
return SkyQRCodePrintBottomInfo.getValue(); return SkyQRCodePrintBottomInfo.getValue();
} }
...@@ -239,9 +235,4 @@ public class FunctionExtendedConfiguration { ...@@ -239,9 +235,4 @@ public class FunctionExtendedConfiguration {
return OpenTableAutoShowKeyboard.getValue(); return OpenTableAutoShowKeyboard.getValue();
} }
public <T> T geDelayedPrintingValue() {
return DelayedPrinting.getValue();
}
} }
package com.gingersoft.gsa.cloud.common.config.globalconfig.applyOptions.intercept; package com.gingersoft.gsa.cloud.common.config.globalconfig.applyOptions.intercept;
import com.gingersoft.gsa.cloud.common.core.user.UserContext;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication; import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.BuildConfig; import com.gingersoft.gsa.cloud.common.BuildConfig;
import com.gingersoft.gsa.cloud.common.utils.encryption.Aes;
import com.gingersoft.gsa.cloud.common.constans.AppConstans; import com.gingersoft.gsa.cloud.common.constans.AppConstans;
import com.gingersoft.gsa.cloud.common.core.user.UserContext;
import com.gingersoft.gsa.cloud.common.oaId.DeviceID;
import com.gingersoft.gsa.cloud.common.utils.encryption.Aes;
import com.jess.arms.utils.DeviceUtils; import com.jess.arms.utils.DeviceUtils;
import java.io.IOException; import java.io.IOException;
import okhttp3.Headers; import okhttp3.Headers;
import okhttp3.Interceptor; import okhttp3.Interceptor;
import okhttp3.Request; import okhttp3.Request;
...@@ -30,6 +29,8 @@ public class HeadersInterceptor implements Interceptor { ...@@ -30,6 +29,8 @@ public class HeadersInterceptor implements Interceptor {
builder.set("appinfo", DeviceUtils.getVersionName(GsaCloudApplication.getAppContext())); builder.set("appinfo", DeviceUtils.getVersionName(GsaCloudApplication.getAppContext()));
builder.set("mobileId", "1"); builder.set("mobileId", "1");
builder.set("uid", UserContext.newInstance().getMemberId() + ""); builder.set("uid", UserContext.newInstance().getMemberId() + "");
builder.set("deviceId", DeviceID.getDeviceId());
Headers headers = originalRequest.headers(); Headers headers = originalRequest.headers();
for (int i = 0; i < headers.size(); i++) { for (int i = 0; i < headers.size(); i++) {
builder.set(headers.name(i), headers.value(i)); builder.set(headers.name(i), headers.value(i));
......
package com.gingersoft.gsa.cloud.common.core.order.order; package com.gingersoft.gsa.cloud.common.core.order.order;
import com.gingersoft.gsa.cloud.common.core.member.MemberInfo; import com.gingersoft.gsa.cloud.common.core.member.MemberInfo;
import com.gingersoft.gsa.cloud.common.core.pay.bean.PayMethod;
import com.gingersoft.gsa.cloud.common.core.order.bean.request.DeleteOrderRequest; import com.gingersoft.gsa.cloud.common.core.order.bean.request.DeleteOrderRequest;
import com.gingersoft.gsa.cloud.common.core.order.bean.response.OrderResponse; import com.gingersoft.gsa.cloud.common.core.order.bean.response.OrderResponse;
import com.gingersoft.gsa.cloud.common.core.order.commodity.OrderDetail; import com.gingersoft.gsa.cloud.common.core.order.commodity.OrderDetail;
import com.gingersoft.gsa.cloud.common.core.pay.bean.PayMethod;
import com.gingersoft.gsa.cloud.common.core.pay.pos.hywebpos.request.pos.SaleRequest;
import com.gingersoft.gsa.cloud.common.core.table.TableBean; import com.gingersoft.gsa.cloud.common.core.table.TableBean;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -136,6 +138,11 @@ public class DoshokuOrder extends BaseOrder { ...@@ -136,6 +138,11 @@ public class DoshokuOrder extends BaseOrder {
} }
} }
public void pay(SaleRequest request){
}
@Override @Override
public void initialization() { public void initialization() {
if (deleteMealOrders != null) { if (deleteMealOrders != null) {
......
package com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.request;
import lombok.Data;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019/7/16
* 修订历史:2019/7/16
* 描述:補小费请求数据
*/
@Data
public class AdjustTipRequest {
private String EVENT_NAME;
private String PAYMENT_APP_ID;
private String TXN_ID;
private double TOTAL_TXN_AMT;
private double TOTAL_FOREIGN_AMT;
}
package com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.request;
import lombok.Data;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019/6/13
* 修订历史:2019/6/13
* 描述:支付请求数据
*/
@Data
public class PayRequest {
private String EVENT_NAME;
private String PAYMENT_APP_ID;
private String TXN_ID;
private double TIPS;
private double TXN_AMT;
}
package com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.request;
import lombok.Data;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019/6/13
* 修订历史:2019/6/13
* 描述:退款请求数据
*/
@Data
public class RefundRequest {
private String EVENT_NAME;
private String PAYMENT_APP_ID;
private String TXN_ID;
private double TXN_AMT;
private String QRC_VALUE;
private boolean PRINT_SS;
}
package com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.request;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019-11-07
* 修订历史:2019-11-07
* 描述:
*/
public class RetrievalRequest {
private String EVENT_NAME;
private String TXN_ID;
}
package com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.request;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019/7/16
* 修订历史:2019/7/16
* 描述:清机请求数据
*/
public class SettlementRequest {
private String EVENT_NAME;
private boolean PRINT_SS;
}
package com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.request;
import lombok.Data;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019-10-31
* 修订历史:2019-10-31
* 描述:取消支付请求数据
*/
@Data
public class VoidRequest {
private String EVENT_NAME;
private String TXN_ID;
private String PAYMENT_APP_ID;
private String QRC_VALUE;
private boolean PRINT_SS;
private String MERCHANT_REF;
}
package com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.response;
import lombok.Data;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019/7/16
* 修订历史:2019/7/16
* 描述:補小费响应数据
*/
@Data
public class AdjustTipResponse {
/**
* EVENT_NAME : ADJUST_RESP
* STATUS : 00
* PAYMENT_TYPE : VC
* RESP_CODE : C1000
* TIPS : -56
* HOST_REF : 729706000007
* TXN_TIME : 171053
* TXN_DATE : 20190725
* TXN_ID : PAY201907251706431518
* TXN_AMT : 58
*/
private String EVENT_NAME;
private String STATUS;
private String PAYMENT_TYPE;
private String RESP_CODE;
private double TIPS;
private String HOST_REF;
private String TXN_TIME;
private String TXN_DATE;
private String TXN_ID;
private double TXN_AMT;
}
package com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.response;
import lombok.Data;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019/6/6
* 修订历史:2019/6/6
* 描述:退款响应数据
*/
@Data
public class RefundResponse {
private String EVENT_NAME;
private String TXN_ID;
private double TXN_AMT;
private String RESP_CODE;
private String TRACE_NO;
private String TXN_TIME;
private String TXN_DATE;
private String HOST_REF;
private String STATUS;
}
package com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.response;
import lombok.Data;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019-11-07
* 修订历史:2019-11-07
* 描述:
*/
@Data
public class RetrievalResponse {
private String EVENT_NAME;
private String TXN_TYPE;
private String TXN_ID;
private String STATUS ;
//仅当STATUS = 00时才返回以下字段
private String TXN_STATUS ;
private String TXN_AMT ;
private double TIPS ;
private String PAYMENT_TYPE ;
private String RESP_CODE;
private String LOYALTY_TYPE;
private String CAMPAIGN_ID;
private String TRACE_NO;
private String TXN_DATE;
private String TXN_TIME;
private String HOST_REF;
private String COUPON_ID;
private String AUTH_CODE;
private int TENDER ;
private double AUTH_AMT;
private double DISCOUNT ;
private String LOCAL_CUR;
private String FOREIGN_CUR;
private double FXRATE ;
private double FOREIGN_AMT;
private String MID ;
private String TID ;
private String PAN ;
private String EXPIRY_DATE ;
}
package com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.response;
import lombok.Data;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019/6/6
* 修订历史:2019/6/6
* 描述:支付响应数据
*/
@Data
public class SaleResponse {
private int id;
private String amount;
private String tipsprice;
private int paytype;
private double paysales;
private String name;
//N5支付回调数据
/**
* EVENT_NAME : SALE_RESP
* MID : 011603999000001
* PAYMENT_TYPE : UP
* PAN : 621483******1227
* TRACE_NO : 000008
* TIPS : 0
* RESP_CODE : C1000
* HOST_REF : 729706000007
* TXN_TIME : 111905
* TXN_ID : 18522
* TXN_DATE : 20190613
* STATUS : 00
* EXPIRY_DATE : ****
* AUTH_CODE : 080657
* TID : 21700503
* TXN_AMT : 0.5
*/
private String EVENT_NAME;
private String MID;
private String PAYMENT_TYPE;
private String PAN;
private String TRACE_NO;
private double TIPS;
private String RESP_CODE;
private String HOST_REF;
private String TXN_TIME;
private String TXN_ID;
private String TXN_DATE;
private String STATUS;
private String EXPIRY_DATE;
private String AUTH_CODE;
private String TID;
private double TXN_AMT;
}
package com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.response;
import lombok.Data;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019/7/19
* 修订历史:2019/7/19
* 描述:清机响应数据
*/
@Data
public class SettlementResponse {
/**
* EVENT_NAME : SETTLE_RESP
* STATUS : 09
*/
private String EVENT_NAME;
private String STATUS;
}
package com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.response;
import lombok.Data;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019/6/6
* 修订历史:2019/6/6
* 描述:取消支付响应数据
*/
@Data
public class VoidResponse {
private String EVENT_NAME;
private String TXN_ID;
private double TXN_AMT;
private String RESP_CODE;
private String TRACE_NO;
private String TXN_TIME;
private String TXN_DATE;
private String HOST_REF;
private String STATUS;
}
package com.gingersoft.gsa.cloud.common.core.pay.n5pos.callback;
/**
* @作者: bin
* @創建時間: 2020-12-16 15:55
* @更新時間: 2020-12-16 15:55
* @描述: N5Pos支付回調
*/
//public class CommandImpl implements ICommand {
public class CommandImpl {
private static final String TAG = CommandImpl.class.getSimpleName();
}
package com.gingersoft.gsa.cloud.common.core.pay.n5pos.callback;
import android.content.Context;
import com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.request.AdjustTipRequest;
import com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.request.PayRequest;
import com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.request.RefundRequest;
import com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.request.RetrievalRequest;
import com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.request.SettlementRequest;
import com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.request.VoidRequest;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019/6/13
* 修订历史:2019/6/13
* 描述:
*/
public interface IN5PosAction {
void sendSaleRequest(Context context, PayRequest request);
void sendVoidRequest(Context context, VoidRequest request);
void sendRefundRequest(Context context, RefundRequest request);
void sendAdjustTipResuest(Context context, AdjustTipRequest request);
void sendRetrievalRequest(Context context, RetrievalRequest request);
void sendSettlementRequest(Context context, SettlementRequest request);
}
package com.gingersoft.gsa.cloud.common.core.pay.n5pos.callback;
import com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.response.AdjustTipResponse;
import com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.response.RefundResponse;
import com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.response.RetrievalResponse;
import com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.response.SaleResponse;
import com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.response.SettlementResponse;
import com.gingersoft.gsa.cloud.common.core.pay.n5pos.bean.response.VoidResponse;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019-11-01
* 修订历史:2019-11-01
* 描述:
*/
public interface IN5PosCallback {
void onSaleCall(SaleResponse response);
void onVoidCall(VoidResponse response);
void onRefundCall(RefundResponse response);
void onRetrievalCall(RetrievalResponse response);
void onAdjustCall(AdjustTipResponse response);
void onSettleCall(SettlementResponse response);
void onPrinterCall(String response);
}
package com.gingersoft.gsa.cloud.common.core.pay.n5pos.constant;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2019/6/12
* 修订历史:2019/6/12
* 描述:
*/
public interface PayConstant {
/**
* N5異常问题 :
*
* 1、N5 POS 機操作超時:當操作超時時,N5 POS 機將返回主畫面,並向 ECR 發送 Status Code“98”的響應消息。ECR 應將此筆交易視為失敗。
* 2、N5 POS 機忙碌:當 ECR 向處於忙碌狀態的 N5 POS 機發送請求時,ECR 將收到 Status Code “97”的響應。在發送另一個請求之前,ECR 應該提示消息要求用戶完成 N5 POS 機中的當前 交易。
* 3、N5 POS機應用程序崩潰處理:當ECR發現N5 POS機的某些響應遺失時(這可能是由於應用程 序崩潰)。ECR應該向N5 POS機發送交易查詢請求命令,以獲取交易結果。
*/
/**
* 支付状态
*/
String PAY_STATUS_00 = "00"; //成功 √
String PAY_STATUS_02 = "02"; //微信、支付宝正在处理这笔退款请求(可认为已成功) √
String PAY_STATUS_03 = "03"; //确认/处理 (支付、清機 同步接口防止N5機器關機未收到結果) √
String PAY_STATUS_09 = "09"; //用户取消 √
String PAY_STATUS_10 = "10"; //主持人拒绝 √
String PAY_STATUS_11 = "11"; //用户撤销(应用于仅限微信/支付宝) √
String PAY_STATUS_12 = "12"; //交易有已经作废/已完成
String PAY_STATUS_13 = "13"; //找不到交易
String PAY_STATUS_90 = "90"; //通讯/格式 错误 √
String PAY_STATUS_91 = "91"; //功能或 付款方式没有 支持的 √
String PAY_STATUS_97 = "97"; //N5 POS忙碌 √
String PAY_STATUS_98 = "98"; //超时 √
String PAY_STATUS_99 = "99"; //未知错误 √
String PAY_STATUS_200 = "200"; //自定義錯誤提示 √
/**
* 支付申请清单
*/
String PAY_TYPE_CC = "CC";
String PAY_TYPE_QRC = "QRC";
String PAY_TYPE_AE = "AE";
String PAY_TYPE_INTEGRAL = "INTEGRAL";
//扫码支付
String PAY_TYPE_QR = "QR";
String PAY_TYPE_ALP = "ALP";
String PAY_TYPE_WCP = "WCP";
/**
* 付款方式清单
* <p>
* VC Visa卡
* VC-QR Visa卡QR
* <p>
* MC 万事达卡
* MC-QR 万事达卡QR
* <p>
* JCB JCB
* JCB-QR JCB QR
* <p>
* UP 银联
* UP-QR 银联QR
* <p>
* AE AMEX
* <p>
* ALP 支付宝
* WCP 微信支付
*/
String PAY_WAY_CASH = "CASH"; //现金
String PAY_WAY_CARD = "CC"; //信用卡
String PAY_WAY_AE = "AE"; //AMEX
String PAY_WAY_QR = "QR"; //QR /条码付款(例如VMJ QR,UP QR)
String PAY_WAY_ALI_WCP = "ALP,WCP"; //微信,支付宝
}
package com.gingersoft.gsa.cloud.common.core.restaurant.utils; package com.gingersoft.gsa.cloud.common.core.restaurant.utils;
import android.text.TextUtils; import android.text.TextUtils;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication; import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.common.config.expandconfig.ExpandInfoSetting; import com.gingersoft.gsa.cloud.common.config.expandconfig.ExpandInfoSetting;
import com.gingersoft.gsa.cloud.common.config.expandconfig.FunctionExtendedConfiguration; import com.gingersoft.gsa.cloud.common.config.expandconfig.FunctionExtendedConfiguration;
import com.gingersoft.gsa.cloud.common.config.expandconfig.UIStyleExtendedConfiguration; import com.gingersoft.gsa.cloud.common.config.expandconfig.UIStyleExtendedConfiguration;
import com.gingersoft.gsa.cloud.common.constans.ExpandConstant; import com.gingersoft.gsa.cloud.common.constans.ExpandConstant;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.database.bean.ExpandInfo; import com.gingersoft.gsa.cloud.database.bean.ExpandInfo;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
......
/*
* Copyright (c) 2019-2020 gzu-liyujiang <1032694760@qq.com>
*
* The software is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*/
package com.gingersoft.gsa.cloud.common.oaId;
import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.oaId.impl.DefaultDeviceIdImpl;
/**
* Created by liyujiang on 2020/5/30
*
* @author 大定府羡民
*/
public final class DeviceID {
private static String mDeviceId;
private DeviceID() {
super();
}
private static IDeviceId with(Context context) {
IDeviceId deviceId;
// if (SystemUtils.isLenovo() || SystemUtils.isMotolora()) {
// deviceId = new LenovoDeviceIdImpl(context);
// } else if (SystemUtils.isMeizu()) {
// deviceId = new MeizuDeviceIdImpl(context);
// } else if (SystemUtils.isNubia()) {
// deviceId = new NubiaDeviceIdImpl(context);
// } else if (SystemUtils.isXiaomi() || SystemUtils.isBlackShark()) {
// deviceId = new XiaomiDeviceIdImpl(context);
// } else if (SystemUtils.isSamsung()) {
// deviceId = new SamsungDeviceIdImpl(context);
// } else if (SystemUtils.isVivo()) {
// deviceId = new VivoDeviceIdImpl(context);
// } else if (SystemUtils.isASUS()) {
// deviceId = new AsusDeviceIdImpl(context);
// } else if (SystemUtils.isHuawei()) {
// deviceId = new HuaweiDeviceIdImpl(context);
// } else if (SystemUtils.isOppo() || SystemUtils.isOnePlus()) {
// deviceId = new OppoDeviceIdImpl(context);
// } else if (SystemUtils.isZTE() || SystemUtils.isFreeme() || SystemUtils.isSSUI()) {
// deviceId = new MsaDeviceIdImpl(context);
// } else {
deviceId = new DefaultDeviceIdImpl();
// }
// Logger.print(deviceInfo() + "\nsupportOAID: " + deviceId.supportOAID());
LoganManager.w_code("DeviceID",deviceInfo() + "\nsupportOAID: " + deviceId.supportOAID());
return deviceId;
}
public static String deviceInfo() {
//noinspection StringBufferReplaceableByString
StringBuilder sb = new StringBuilder();
sb.append("BrandModel:");
sb.append(Build.BRAND);
sb.append(" ");
sb.append(Build.MODEL);
sb.append("\n");
sb.append("Manufacturer:");
sb.append(Build.MANUFACTURER);
sb.append("\n");
sb.append("SystemVersion:");
sb.append(Build.VERSION.RELEASE);
sb.append(" (API ");
sb.append(Build.VERSION.SDK_INT);
sb.append(")");
return sb.toString();
}
public static void initDeviceId() {
DeviceID.with(GsaCloudApplication.getAppContext())
.doGet(new IOAIDGetter() {
@Override
public void onOAIDGetComplete(@NonNull String oaid) {
mDeviceId = oaid;
}
@Override
public void onOAIDGetError(@NonNull Exception exception) {
int i =2;
}
});
}
public static String getDeviceId() {
if (TextUtils.isEmpty(mDeviceId)) {
throw new RuntimeException("Please initialize the device id first!");
}
return mDeviceId;
}
}
/*
* Copyright (c) 2019-2020 gzu-liyujiang <1032694760@qq.com>
*
* The software is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*/
package com.gingersoft.gsa.cloud.common.oaId;
import androidx.annotation.NonNull;
/**
* Created by liyujiang on 2020/5/30
*
* @author 大定府羡民
*/
public interface IDeviceId {
boolean supportOAID();
void doGet(@NonNull final IOAIDGetter getter);
/**
* @deprecated Use {@link #doGet(IOAIDGetter)} instead
*/
@Deprecated
void doGet(@NonNull final IGetter getter);
}
/*
* Copyright (c) 2019-2020 gzu-liyujiang <1032694760@qq.com>
*
* The software is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*/
package com.gingersoft.gsa.cloud.common.oaId;
import androidx.annotation.NonNull;
/**
* Created by liyujiang on 2020/5/30
*
* @author 大定府羡民
* @deprecated Use {@link IOAIDGetter} instead
*/
@Deprecated
public interface IGetter {
void onDeviceIdGetComplete(@NonNull String oaid);
void onDeviceIdGetError(@NonNull Exception exception);
}
/*
* Copyright (c) 2019-2020 gzu-liyujiang <1032694760@qq.com>
*
* The software is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*/
package com.gingersoft.gsa.cloud.common.oaId;
import androidx.annotation.NonNull;
/**
* Created by liyujiang on 2020/8/20
*
* @author 大定府羡民
*/
public interface IOAIDGetter {
void onOAIDGetComplete(@NonNull String deviceId);
void onOAIDGetError(@NonNull Exception exception);
}
/*
* Copyright (c) 2019-2020 gzu-liyujiang <1032694760@qq.com>
*
* The software is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*/
package com.gingersoft.gsa.cloud.common.oaId;
import android.annotation.SuppressLint;
import android.os.Build;
import android.text.TextUtils;
import androidx.annotation.RestrictTo;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import java.lang.reflect.Method;
/**
* Created by liyujiang on 2020/5/29
*
* @author 大定府羡民
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public final class SystemUtils {
public static String sysProperty(String key, String defValue) {
String res = null;
try {
@SuppressLint("PrivateApi") Class<?> clazz = Class.forName("android.os.SystemProperties");
Method method = clazz.getMethod("get", String.class, String.class);
res = (String) method.invoke(clazz, new Object[]{key, defValue});
} catch (Exception e) {
LoganManager.w_code("SystemUtils",e.getMessage());
}
if (res == null) {
res = "";
}
return res;
}
public static boolean isASUS() {
// 华硕手机
return Build.MANUFACTURER.toUpperCase().equals("ASUS");
}
public static boolean isHuawei() {
// 华为手机
return Build.MANUFACTURER.toUpperCase().equals("HUAWEI");
}
public static boolean isZTE() {
// 中兴手机
return Build.MANUFACTURER.toUpperCase().equals("ZTE");
}
public static boolean isXiaomi() {
// 小米手机
return Build.MANUFACTURER.toUpperCase().equals("XIAOMI");
}
public static boolean isOppo() {
// 欧珀手机
return Build.MANUFACTURER.toUpperCase().equals("OPPO");
}
public static boolean isVivo() {
// 维沃手机
return Build.MANUFACTURER.toUpperCase().equals("VIVO");
}
public static boolean isOnePlus() {
// 一加手机
return Build.MANUFACTURER.toUpperCase().equals("ONEPLUS");
}
public static boolean isBlackShark() {
// 黑鲨手机
return Build.MANUFACTURER.toUpperCase().equals("BLACKSHARK");
}
public static boolean isSamsung() {
// 三星手机
return Build.MANUFACTURER.toUpperCase().equals("SAMSUNG");
}
public static boolean isMotolora() {
// 摩托罗拉手机
return Build.MANUFACTURER.toUpperCase().equals("MOTOLORA");
}
public static boolean isNubia() {
// 努比亚手机
return Build.MANUFACTURER.toUpperCase().equals("NUBIA");
}
public static boolean isMeizu() {
// 魅族手机
return Build.MANUFACTURER.toUpperCase().equals("MEIZU");
}
public static boolean isLenovo() {
// 联想手机
return Build.MANUFACTURER.toUpperCase().equals("LENOVO");
}
public static boolean isFreeme() {
// 卓易手机
if (Build.MANUFACTURER.toUpperCase().equals("FREEMEOS")) {
return true;
}
String pro = sysProperty("ro.build.freeme.label", "");
return !TextUtils.isEmpty(pro) && pro.toUpperCase().equals("FREEMEOS");
}
public static boolean isSSUI() {
// 这是啥玩意的手机?
if (Build.MANUFACTURER.toUpperCase().equals("SSUI")) {
return true;
}
String pro = sysProperty("ro.ssui.product", "unknown");
return !TextUtils.isEmpty(pro) && !pro.toUpperCase().equals("UNKNOWN");
}
}
/*
* Copyright (c) 2019-2020 gzu-liyujiang <1032694760@qq.com>
*
* The software is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*/
package com.gingersoft.gsa.cloud.common.oaId.defaultImp;
import android.content.Context;
import android.os.Build;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import java.security.MessageDigest;
import java.util.Locale;
import java.util.UUID;
/**
* @作者: bin
* @創建時間: 2020-12-25 14:31
* @更新時間: 2020-12-25 14:31
* @描述: OAID 獲取不到後的其他備選方案
* <p>
* 方案1:相较于前两种方案,限制性较小,只要硬件信息不变结果就不变。而且该方案可自行定制组合。 TODO 硬件标识对Android 10来说都不可取了
* 方案2:是很多软件采用的方案,因很少有人删除SD卡文件;但需要注意权限;
* 方案3:局限性较大,不建议使用;
*/
public class DefaultDeviceIdUtils {
private final String TAG = getClass().getSimpleName();
/**
* 方案1:imei + android_id + serial + 硬件uuid(自生成)
* 如果,又想唯一,又不想因用户的删除而重新生成UUID,该怎么做呢?
* <p>
* 不依赖随机的UUID,咱们根据硬件标识来创建唯一的数据;
* <p>
* 我们可以将多个可获得的硬件标识拼接起来(尽可能不依赖权限),最大程度上降低重复性。
* 以imei、android_id、serial为例,如果能取到值,每个数据几乎可以代表唯一。
* 如果这些数据都能获取到,拼起来的数据重复性降到极低(UUID也存在重复性,重复性极低而已)
* <p>
* AndroidId : 如:df176fbb152ddce,无需权限,极个别设备获取不到数据或得到错误数据;
* serial:如:LKX7N18328000931,无需权限,极个别设备获取不到数据;
* IMEI : 如:23b12e30ec8a2f17,需要权限;
* Mac: 如:6e:a5:....需要权限,高版本手机获得数据均为 02:00.....(不可使用)
* Build.BOARD 如:BLA 主板名称,无需权限,同型号设备相同
* Build.BRAND 如:HUAWEI 厂商名称,无需权限,同型号设备相同
* Build.HARDWARE 如:kirin970 硬件名称,无需权限,同型号设备相同
* Build......更多硬件信息,略
* <p>
* 分析了这么多硬件标识,我们就使用imei + android_id + serial + 硬件UUID(使用Build属性生成,如果硬件信息不变,则UUID值不变)。这是我们项目的实际方案,大家也可根据自己的需要自由组合硬件标识。
* 那么,问题又来了,不同设备的硬件标识长度不同,拼接处理的DeviceId字符串长度不同,怎么才能统一长度呢?
* 也很简单,我们先拼接好DeviceId数据,取其SHA1值,再转16进制即可(统一40位长度)
*/
private static final String scheme_1 = "iasu";
/**
* 獲取設備ID
*
* @param context
* @return
*/
public static final String getDefaultDeviceIds(Context context) {
//第一方案獲取ID失敗
String deviceId = getDeviceId(context);
if (deviceId == null) {
String defaultDeviceId = UUID.randomUUID().toString().replace("-", "");
//使用第二方案獲取(用戶未給與SD卡權限)
deviceId = SDDeviceId.getSDDeviceId(defaultDeviceId);
if (TextUtils.isEmpty(deviceId)) {
//使用第三方案獲取
deviceId = SPDeviceId.getSPDeviceId(defaultDeviceId);
}
}
LoganManager.w_code("getDefaultDeviceIds","getDefaultDeviceIds = "+deviceId);
return deviceId;
}
/**
* 获得设备硬件标识
*
* @param context 上下文
* @return 设备硬件标识
*/
public static String getDeviceId(Context context) {
StringBuilder sbDeviceId = new StringBuilder();
//获得设备默认IMEI(>=6.0 需要ReadPhoneState权限)
String imei = getIMEI(context);
//获得AndroidId(无需权限)
String androidid = getAndroidId(context);
//获得设备序列号(无需权限)
String serial = getSERIAL();
//获得硬件uuid(根据硬件相关属性,生成uuid)(无需权限)
String uuid = getDeviceUUID().replace("-", "");
//追加imei
if (imei != null && imei.length() > 0) {
sbDeviceId.append(imei);
sbDeviceId.append("|");
}
//追加androidid
if (androidid != null && androidid.length() > 0) {
sbDeviceId.append(androidid);
sbDeviceId.append("|");
}
//追加serial
if (serial != null && serial.length() > 0) {
sbDeviceId.append(serial);
sbDeviceId.append("|");
}
//追加硬件uuid
if (uuid != null && uuid.length() > 0) {
sbDeviceId.append(uuid);
}
//生成SHA1,统一DeviceId长度
if (sbDeviceId.length() > 0) {
try {
byte[] hash = getHashByString(sbDeviceId.toString());
String sha1 = bytesToHex(hash);
if (sha1 != null && sha1.length() > 0) {
//返回最终的DeviceId
return scheme_1 + "_" + sha1;
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
//如果以上硬件标识数据均无法获得,
//则DeviceId默认使用系统随机数,这样保证DeviceId不为空
// return UUID.randomUUID().toString().replace("-", "");
return null;
}
//需要获得READ_PHONE_STATE权限,>=6.0,默认返回null
private static String getIMEI(Context context) {
try {
TelephonyManager tm = (TelephonyManager)
context.getSystemService(Context.TELEPHONY_SERVICE);
return tm.getDeviceId();
} catch (Exception ex) {
ex.printStackTrace();
}
return "";
}
/**
* 获得设备的AndroidId
*
* @param context 上下文
* @return 设备的AndroidId
*/
private static String getAndroidId(Context context) {
try {
return Settings.Secure.getString(context.getContentResolver(),
Settings.Secure.ANDROID_ID);
} catch (Exception ex) {
ex.printStackTrace();
}
return "";
}
/**
* 获得设备序列号(如:WTK7N16923005607), 个别设备无法获取
*
* @return 设备序列号
*/
private static String getSERIAL() {
try {
return Build.SERIAL;
} catch (Exception ex) {
ex.printStackTrace();
}
return "";
}
/**
* 获得设备硬件uuid
* 使用硬件信息,计算出一个随机数
*
* @return 设备硬件uuid
*/
private static String getDeviceUUID() {
try {
String dev = "3883756" +
Build.BOARD.length() % 10 +
Build.BRAND.length() % 10 +
Build.DEVICE.length() % 10 +
Build.HARDWARE.length() % 10 +
Build.ID.length() % 10 +
Build.MODEL.length() % 10 +
Build.PRODUCT.length() % 10 +
Build.SERIAL.length() % 10;
return new UUID(dev.hashCode(),
Build.SERIAL.hashCode()).toString();
} catch (Exception ex) {
ex.printStackTrace();
return "";
}
}
/**
* 取SHA1
*
* @param data 数据
* @return 对应的hash值
*/
private static byte[] getHashByString(String data) {
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA1");
messageDigest.reset();
messageDigest.update(data.getBytes("UTF-8"));
return messageDigest.digest();
} catch (Exception e) {
return "".getBytes();
}
}
/**
* 转16进制字符串
*
* @param data 数据
* @return 16进制字符串
*/
private static String bytesToHex(byte[] data) {
StringBuilder sb = new StringBuilder();
String stmp;
for (int n = 0; n < data.length; n++) {
stmp = (Integer.toHexString(data[n] & 0xFF));
if (stmp.length() == 1)
sb.append("0");
sb.append(stmp);
}
return sb.toString().toUpperCase(Locale.CHINA);
}
}
package com.gingersoft.gsa.cloud.common.oaId.defaultImp;
import android.text.TextUtils;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.utils.FileUtils;
/**
* @作者: bin
* @創建時間: 2020-12-25 15:01
* @更新時間: 2020-12-25 15:01
* @描述: 方案2:usd + "_" + UUID + SD卡(存取)
*/
public class SDDeviceId {
/**
* 方案2:UUID + SD卡(存取)
* APP首次使用时,创建UUID,并保存到SD卡中。
* 以后再次使用时,直接从SD卡取出来即可;
* 很多APP就是这么做的;
* <p>
* 优点:数据唯一、不随APP一起删除;
* 缺点:需要SD卡读写权限;防不住用户手动删除SD卡的文件;
*/
private static final String scheme_2 = "usd";
/**
* 存放deviceId的文件
*/
private static String DEVICE_ID_FILE_NAME = "systemDeviceId.txt";
public static String getSDDeviceId(String defaultDeviceId) {
//讀取設備ID
String deviceId = FileUtils.read(GsaCloudApplication.getAppContext(), "systemDeviceId.txt");
if (TextUtils.isEmpty(deviceId)) {
defaultDeviceId = scheme_2 + "_" + defaultDeviceId;
//寫入設備ID
FileUtils.write(GsaCloudApplication.getAppContext(), "systemDeviceId.txt", defaultDeviceId);
deviceId = defaultDeviceId;
}
return deviceId;
}
}
package com.gingersoft.gsa.cloud.common.oaId.defaultImp;
import android.text.TextUtils;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.jess.arms.utils.DataHelper;
/**
* @作者: bin
* @創建時間: 2020-12-25 15:01
* @更新時間: 2020-12-25 15:01
* @描述: 方案3:ush + "_" + UUID + SharePreference(存取)
*/
public class SPDeviceId {
/**
* 方案3:UUID + SharePreference(存取)
* APP首次使用时,创建UUID,并保存到SharePreference中。
* 以后再次使用时,直接从SharePreference取出来即可;
* <p>
* 优点:数据唯一、不需要权限;
* 缺点:会随APP一起删除,即:重新安装APP,DeviceId值会改变(新UUID);
*/
private static final String scheme_3 = "ush";
public static String getSPDeviceId(String defaultDeviceId) {
String deviceId = DataHelper.getStringSF(GsaCloudApplication.getAppContext(), scheme_3);
if (TextUtils.isEmpty(deviceId)) {
defaultDeviceId = scheme_3 + "_" + defaultDeviceId;
//SP數據丟失 重新使用最新的UUID作為deviceId
putSPDeviceId(defaultDeviceId);
deviceId = defaultDeviceId;
}
return deviceId;
}
public static void putSPDeviceId(String defaultDeviceId) {
DataHelper.setStringSF(GsaCloudApplication.getAppContext(), scheme_3, defaultDeviceId);
}
}
/*
* Copyright (c) 2019-2020 gzu-liyujiang <1032694760@qq.com>
*
* The software is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*/
package com.gingersoft.gsa.cloud.common.oaId.impl;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageInfo;
import android.os.IBinder;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import com.asus.msa.SupplementaryDID.IDidAidlInterface;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.oaId.IDeviceId;
import com.gingersoft.gsa.cloud.common.oaId.IGetter;
import com.gingersoft.gsa.cloud.common.oaId.IOAIDGetter;
import java.lang.reflect.Method;
/**
* Created by liyujiang on 2020/5/30
*
* @author 大定府羡民
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public class AsusDeviceIdImpl implements IDeviceId {
private final String TAG = getClass().getSimpleName();
private Context context;
public AsusDeviceIdImpl(Context context) {
this.context = context;
}
@Override
public boolean supportOAID() {
try {
PackageInfo pi = context.getPackageManager().getPackageInfo("com.asus.msa.SupplementaryDID", 0);
return pi != null;
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
return false;
}
}
@Override
public void doGet(@NonNull final IOAIDGetter getter) {
Intent intent = new Intent("com.asus.msa.action.ACCESS_DID");
ComponentName componentName = new ComponentName("com.asus.msa.SupplementaryDID", "com.asus.msa.SupplementaryDID.SupplementaryDIDService");
intent.setComponent(componentName);
try {
boolean isBinded = context.bindService(intent, new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
LoganManager.w_code(TAG,"ASUS SupplementaryDIDService connected");
try {
//IDidAidlInterface anInterface = new IDidAidlInterface.Stub.asInterface(service);
Method asInterface = IDidAidlInterface.Stub.class.getDeclaredMethod("asInterface", IBinder.class);
IDidAidlInterface anInterface = (IDidAidlInterface) asInterface.invoke(null, service);
if (anInterface == null) {
throw new RuntimeException("IDidAidlInterface is null");
}
String ID = anInterface.getID();
if (ID == null || ID.length() == 0) {
throw new RuntimeException("ASUS ID get failed");
}
getter.onOAIDGetComplete(ID);
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
getter.onOAIDGetError(e);
} finally {
context.unbindService(this);
}
}
@Override
public void onServiceDisconnected(ComponentName name) {
LoganManager.w_code(TAG,"ASUS SupplementaryDIDService disconnected");
}
}, Context.BIND_AUTO_CREATE);
if (!isBinded) {
throw new RuntimeException("ASUS SupplementaryDIDService bind failed");
}
} catch (Exception e) {
// SecurityException: Not allowed to bind to service Intent
getter.onOAIDGetError(e);
}
}
@SuppressWarnings("deprecation")
@Override
public void doGet(@NonNull final IGetter getter) {
doGet(new IOAIDGetter() {
@Override
public void onOAIDGetComplete(@NonNull String oaid) {
getter.onDeviceIdGetComplete(oaid);
}
@Override
public void onOAIDGetError(@NonNull Exception exception) {
getter.onDeviceIdGetError(exception);
}
});
}
}
/*
* Copyright (c) 2019-2020 gzu-liyujiang <1032694760@qq.com>
*
* The software is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*/
package com.gingersoft.gsa.cloud.common.oaId.impl;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.oaId.IDeviceId;
import com.gingersoft.gsa.cloud.common.oaId.IGetter;
import com.gingersoft.gsa.cloud.common.oaId.IOAIDGetter;
import com.gingersoft.gsa.cloud.common.oaId.defaultImp.DefaultDeviceIdUtils;
/**
* 随机生成一个全局唯一标识,通过`SharedPreferences`及`ExternalStorage`进行永久化存储。
* 注:非系统及预装APP无法获得`WRITE_SETTINGS`权限,故放弃使用`Settings`进行永久化存储。
* Created by liyujiang on 2020/5/30
*
* @author 大定府羡民
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public class DefaultDeviceIdImpl implements IDeviceId {
@Override
public boolean supportOAID() {
return false;
}
@Override
public void doGet(@NonNull final IOAIDGetter getter) {
String deviceId = DefaultDeviceIdUtils.getDefaultDeviceIds(GsaCloudApplication.getAppContext());
if (!TextUtils.isEmpty(deviceId)) {
getter.onOAIDGetComplete(deviceId);
} else {
getter.onOAIDGetError(new RuntimeException("OAID unsupported"));
}
}
@SuppressWarnings("deprecation")
@Override
public void doGet(@NonNull final IGetter getter) {
doGet(new IOAIDGetter() {
@Override
public void onOAIDGetComplete(@NonNull String oaid) {
getter.onDeviceIdGetComplete(oaid);
}
@Override
public void onOAIDGetError(@NonNull Exception exception) {
getter.onDeviceIdGetError(exception);
}
});
}
}
/*
* Copyright (c) 2019-2020 gzu-liyujiang <1032694760@qq.com>
*
* The software is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*/
package com.gingersoft.gsa.cloud.common.oaId.impl;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageInfo;
import android.os.IBinder;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.oaId.IDeviceId;
import com.gingersoft.gsa.cloud.common.oaId.IGetter;
import com.gingersoft.gsa.cloud.common.oaId.IOAIDGetter;
import com.uodis.opendevice.aidl.OpenDeviceIdentifierService;
/**
* Created by liyujiang on 2020/5/30
*
* @author 大定府羡民
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public class HuaweiDeviceIdImpl implements IDeviceId {
private final String TAG = getClass().getSimpleName();
private Context context;
public HuaweiDeviceIdImpl(Context context) {
this.context = context;
}
@Override
public boolean supportOAID() {
try {
PackageInfo pi = context.getPackageManager().getPackageInfo("com.huawei.hwid", 0);
return pi != null;
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
return false;
}
}
@Override
public void doGet(@NonNull final IOAIDGetter getter) {
Intent intent = new Intent("com.uodis.opendevice.OPENIDS_SERVICE");
intent.setPackage("com.huawei.hwid");
try {
boolean isBinded = context.bindService(intent, new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
LoganManager.w_code(TAG,"Huawei OPENIDS_SERVICE connected");
try {
OpenDeviceIdentifierService anInterface = OpenDeviceIdentifierService.Stub.asInterface(service);
String IDs = anInterface.getIDs();
if (IDs == null || IDs.length() == 0) {
throw new RuntimeException("Huawei IDs get failed");
}
getter.onOAIDGetComplete(IDs);
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
getter.onOAIDGetError(e);
} finally {
context.unbindService(this);
}
}
@Override
public void onServiceDisconnected(ComponentName name) {
LoganManager.w_code(TAG,"Huawei OPENIDS_SERVICE disconnected");
}
}, Context.BIND_AUTO_CREATE);
if (!isBinded) {
throw new RuntimeException("Huawei OPENIDS_SERVICE bind failed");
}
} catch (Exception e) {
getter.onOAIDGetError(e);
}
}
@SuppressWarnings("deprecation")
@Override
public void doGet(@NonNull final IGetter getter) {
doGet(new IOAIDGetter() {
@Override
public void onOAIDGetComplete(@NonNull String oaid) {
getter.onDeviceIdGetComplete(oaid);
}
@Override
public void onOAIDGetError(@NonNull Exception exception) {
getter.onDeviceIdGetError(exception);
}
});
}
}
/*
* Copyright (c) 2019-2020 gzu-liyujiang <1032694760@qq.com>
*
* The software is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*/
package com.gingersoft.gsa.cloud.common.oaId.impl;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageInfo;
import android.os.IBinder;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.oaId.IDeviceId;
import com.gingersoft.gsa.cloud.common.oaId.IGetter;
import com.gingersoft.gsa.cloud.common.oaId.IOAIDGetter;
import com.zui.deviceidservice.IDeviceidInterface;
import java.lang.reflect.Method;
/**
* Created by liyujiang on 2020/5/30
*
* @author 大定府羡民
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public class LenovoDeviceIdImpl implements IDeviceId {
private final String TAG = getClass().getSimpleName();
private Context context;
public LenovoDeviceIdImpl(Context context) {
this.context = context;
}
@Override
public boolean supportOAID() {
try {
PackageInfo pi = context.getPackageManager().getPackageInfo("com.zui.deviceidservice", 0);
return pi != null;
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
return false;
}
}
@Override
public void doGet(@NonNull final IOAIDGetter getter) {
Intent intent = new Intent();
intent.setClassName("com.zui.deviceidservice", "com.zui.deviceidservice.DeviceidService");
try {
boolean isBinded = context.bindService(intent, new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
LoganManager.w_code(TAG,"Lenovo DeviceidService connected");
try {
//IDeviceidInterface anInterface = new IDeviceidInterface.Stub.asInterface(service);
Method asInterface = IDeviceidInterface.Stub.class.getDeclaredMethod("asInterface", IBinder.class);
IDeviceidInterface anInterface = (IDeviceidInterface) asInterface.invoke(null, service);
if (anInterface == null) {
throw new RuntimeException("IDeviceidInterface is null");
}
String deviceId = anInterface.a();
if (deviceId == null || deviceId.length() == 0) {
throw new RuntimeException("Lenovo deviceId get failed");
}
getter.onOAIDGetComplete(deviceId);
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
getter.onOAIDGetError(e);
} finally {
context.unbindService(this);
}
}
@Override
public void onServiceDisconnected(ComponentName name) {
LoganManager.w_code(TAG,"Lenovo DeviceidService disconnected");
}
}, Context.BIND_AUTO_CREATE);
if (!isBinded) {
getter.onOAIDGetError(new RuntimeException("Lenovo DeviceidService bind failed"));
}
} catch (Exception e) {
getter.onOAIDGetError(e);
}
}
@SuppressWarnings("deprecation")
@Override
public void doGet(@NonNull final IGetter getter) {
doGet(new IOAIDGetter() {
@Override
public void onOAIDGetComplete(@NonNull String oaid) {
getter.onDeviceIdGetComplete(oaid);
}
@Override
public void onOAIDGetError(@NonNull Exception exception) {
getter.onDeviceIdGetError(exception);
}
});
}
}
/*
* Copyright (c) 2019-2020 gzu-liyujiang <1032694760@qq.com>
*
* The software is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*/
package com.gingersoft.gsa.cloud.common.oaId.impl;
import android.content.Context;
import android.content.pm.ProviderInfo;
import android.database.Cursor;
import android.net.Uri;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.oaId.IDeviceId;
import com.gingersoft.gsa.cloud.common.oaId.IGetter;
import com.gingersoft.gsa.cloud.common.oaId.IOAIDGetter;
import java.util.Objects;
/**
* Created by liyujiang on 2020/5/30
*
* @author 大定府羡民
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public class MeizuDeviceIdImpl implements IDeviceId {
private final String TAG = getClass().getSimpleName();
private Context context;
public MeizuDeviceIdImpl(Context context) {
this.context = context;
}
@Override
public boolean supportOAID() {
try {
ProviderInfo pi = context.getPackageManager().resolveContentProvider("com.meizu.flyme.openidsdk", 0);
if (pi != null) {
return true;
}
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
}
return false;
}
@Override
public void doGet(@NonNull final IOAIDGetter getter) {
Uri uri = Uri.parse("content://com.meizu.flyme.openidsdk/");
try (Cursor cursor = context.getContentResolver().query(uri, null, null, new String[]{"oaid"}, null)) {
Objects.requireNonNull(cursor).moveToFirst();
String ret = null;
int valueIdx = cursor.getColumnIndex("value");
if (valueIdx > 0) {
ret = cursor.getString(valueIdx);
}
if (ret == null || ret.length() == 0) {
throw new RuntimeException("OAID query failed");
}
getter.onOAIDGetComplete(ret);
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
getter.onOAIDGetError(e);
}
}
@SuppressWarnings("deprecation")
@Override
public void doGet(@NonNull final IGetter getter) {
doGet(new IOAIDGetter() {
@Override
public void onOAIDGetComplete(@NonNull String oaid) {
getter.onDeviceIdGetComplete(oaid);
}
@Override
public void onOAIDGetError(@NonNull Exception exception) {
getter.onDeviceIdGetError(exception);
}
});
}
}
/*
* Copyright (c) 2019-2020 gzu-liyujiang <1032694760@qq.com>
*
* The software is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*/
package com.gingersoft.gsa.cloud.common.oaId.impl;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageInfo;
import android.os.IBinder;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import com.bun.lib.MsaIdInterface;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.oaId.IDeviceId;
import com.gingersoft.gsa.cloud.common.oaId.IGetter;
import com.gingersoft.gsa.cloud.common.oaId.IOAIDGetter;
import java.lang.reflect.Method;
/**
* Created by liyujiang on 2020/5/30
*
* @author 大定府羡民
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public class MsaDeviceIdImpl implements IDeviceId {
private final String TAG = getClass().getSimpleName();
private Context context;
public MsaDeviceIdImpl(Context context) {
this.context = context;
}
@Override
public boolean supportOAID() {
try {
PackageInfo pi = context.getPackageManager().getPackageInfo("com.mdid.msa", 0);
return pi != null;
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
return false;
}
}
@Override
public void doGet(@NonNull final IOAIDGetter getter) {
try {
Intent intent = new Intent("com.bun.msa.action.start.service");
intent.setClassName("com.mdid.msa", "com.mdid.msa.service.MsaKlService");
intent.putExtra("com.bun.msa.param.pkgname", context.getPackageName());
intent.putExtra("com.bun.msa.param.runinset", true);
context.startService(intent);
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
}
Intent intent = new Intent("com.bun.msa.action.bindto.service");
intent.setClassName("com.mdid.msa", "com.mdid.msa.service.MsaIdService");
intent.putExtra("com.bun.msa.param.pkgname", context.getPackageName());
try {
boolean isBinded = context.bindService(intent, new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
LoganManager.w_code(TAG,"MsaIdService connected");
try {
//MsaIdInterface anInterface = new MsaIdInterface.Stub.asInterface(service);
Method asInterface = MsaIdInterface.Stub.class.getDeclaredMethod("asInterface", IBinder.class);
MsaIdInterface anInterface = (MsaIdInterface) asInterface.invoke(null, service);
if (anInterface == null) {
throw new RuntimeException("MsaIdInterface is null");
}
String oaid = anInterface.getOAID();
if (oaid == null || oaid.length() == 0) {
throw new RuntimeException("Msa oaid get failed");
}
getter.onOAIDGetComplete(oaid);
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
getter.onOAIDGetError(e);
} finally {
context.unbindService(this);
}
}
@Override
public void onServiceDisconnected(ComponentName name) {
LoganManager.w_code(TAG,"MsaIdService disconnected");
}
}, Context.BIND_AUTO_CREATE);
if (!isBinded) {
throw new RuntimeException("MsaIdService bind failed");
}
} catch (Exception e) {
getter.onOAIDGetError(e);
}
}
@SuppressWarnings("deprecation")
@Override
public void doGet(@NonNull final IGetter getter) {
doGet(new IOAIDGetter() {
@Override
public void onOAIDGetComplete(@NonNull String oaid) {
getter.onDeviceIdGetComplete(oaid);
}
@Override
public void onOAIDGetError(@NonNull Exception exception) {
getter.onDeviceIdGetError(exception);
}
});
}
}
/*
* Copyright (c) 2019-2020 gzu-liyujiang <1032694760@qq.com>
*
* The software is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*/
package com.gingersoft.gsa.cloud.common.oaId.impl;
import android.content.ContentProviderClient;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.oaId.IDeviceId;
import com.gingersoft.gsa.cloud.common.oaId.IGetter;
import com.gingersoft.gsa.cloud.common.oaId.IOAIDGetter;
/**
* Created by liyujiang on 2020/5/30
*
* @author 大定府羡民
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public class NubiaDeviceIdImpl implements IDeviceId {
private final String TAG = getClass().getSimpleName();
private Context context;
public NubiaDeviceIdImpl(Context context) {
this.context = context;
}
@Override
public boolean supportOAID() {
return false;
}
@Override
public void doGet(@NonNull final IOAIDGetter getter) {
String oaid = null;
Bundle bundle = null;
try {
Uri uri = Uri.parse("content://cn.nubia.identity/identity");
if (Build.VERSION.SDK_INT > 17) {
ContentProviderClient client = context.getContentResolver().acquireContentProviderClient(uri);
if (client != null) {
bundle = client.call("getOAID", null, null);
if (Build.VERSION.SDK_INT >= 24) {
client.close();
} else {
client.release();
}
}
} else {
bundle = context.getContentResolver().call(uri, "getOAID", null, null);
}
if (bundle == null) {
throw new RuntimeException("getOAID call failed");
}
if (bundle.getInt("code", -1) == 0) {
oaid = bundle.getString("id");
}
String failedMsg = bundle.getString("message");
if (oaid != null && oaid.length() > 0) {
getter.onOAIDGetComplete(oaid);
} else {
throw new RuntimeException(failedMsg);
}
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
getter.onOAIDGetError(e);
}
}
@SuppressWarnings("deprecation")
@Override
public void doGet(@NonNull final IGetter getter) {
doGet(new IOAIDGetter() {
@Override
public void onOAIDGetComplete(@NonNull String oaid) {
getter.onDeviceIdGetComplete(oaid);
}
@Override
public void onOAIDGetError(@NonNull Exception exception) {
getter.onDeviceIdGetError(exception);
}
});
}
}
/*
* Copyright (c) 2019-2020 gzu-liyujiang <1032694760@qq.com>
*
* The software is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*/
package com.gingersoft.gsa.cloud.common.oaId.impl;
import android.annotation.SuppressLint;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.os.IBinder;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.oaId.IDeviceId;
import com.gingersoft.gsa.cloud.common.oaId.IGetter;
import com.gingersoft.gsa.cloud.common.oaId.IOAIDGetter;
import com.heytap.openid.IOpenID;
import java.lang.reflect.Method;
import java.security.MessageDigest;
/**
* Created by liyujiang on 2020/5/30
*
* @author 大定府羡民
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public class OppoDeviceIdImpl implements IDeviceId {
private final String TAG = getClass().getSimpleName();
private Context context;
private String sign;
public OppoDeviceIdImpl(Context context) {
this.context = context;
}
@Override
public boolean supportOAID() {
try {
PackageInfo pi = context.getPackageManager().getPackageInfo("com.heytap.openid", 0);
return pi != null;
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
return false;
}
}
@Override
public void doGet(@NonNull final IOAIDGetter getter) {
Intent intent = new Intent("action.com.heytap.openid.OPEN_ID_SERVICE");
intent.setComponent(new ComponentName("com.heytap.openid", "com.heytap.openid.IdentifyService"));
try {
boolean isBinded = context.bindService(intent, new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
LoganManager.w_code(TAG,"HeyTap IdentifyService connected");
try {
String ouid = realGetOUID(service);
if (ouid == null || ouid.length() == 0) {
throw new RuntimeException("HeyTap OUID get failed");
} else {
getter.onOAIDGetComplete(ouid);
}
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
getter.onOAIDGetError(e);
} finally {
context.unbindService(this);
}
}
@Override
public void onServiceDisconnected(ComponentName name) {
LoganManager.w_code(TAG,"HeyTap IdentifyService disconnected");
}
}, Context.BIND_AUTO_CREATE);
if (!isBinded) {
throw new RuntimeException("HeyTap IdentifyService bind failed");
}
} catch (Exception e) {
getter.onOAIDGetError(e);
}
}
@SuppressLint("PackageManagerGetSignatures")
private String realGetOUID(IBinder service) throws Exception {
String pkgName = context.getPackageName();
if (sign == null) {
Signature[] signatures = context.getPackageManager().getPackageInfo(pkgName, PackageManager.GET_SIGNATURES).signatures;
byte[] byteArray = signatures[0].toByteArray();
MessageDigest messageDigest = MessageDigest.getInstance("SHA1");
byte[] digest = messageDigest.digest(byteArray);
StringBuilder sb = new StringBuilder();
for (byte b : digest) {
sb.append(Integer.toHexString((b & 255) | 256).substring(1, 3));
}
sign = sb.toString();
//IOpenID anInterface = new IOpenID.Stub.asInterface(service);
Method asInterface = IOpenID.Stub.class.getDeclaredMethod("asInterface", IBinder.class);
IOpenID anInterface = (IOpenID) asInterface.invoke(null, service);
if (anInterface == null) {
throw new RuntimeException("IOpenID is null");
}
return anInterface.getSerID(pkgName, sign, "OUID");
}
return null;
}
@SuppressWarnings("deprecation")
@Override
public void doGet(@NonNull final IGetter getter) {
doGet(new IOAIDGetter() {
@Override
public void onOAIDGetComplete(@NonNull String oaid) {
getter.onDeviceIdGetComplete(oaid);
}
@Override
public void onOAIDGetError(@NonNull Exception exception) {
getter.onDeviceIdGetError(exception);
}
});
}
}
/*
* Copyright (c) 2019-2020 gzu-liyujiang <1032694760@qq.com>
*
* The software is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*/
package com.gingersoft.gsa.cloud.common.oaId.impl;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageInfo;
import android.os.IBinder;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.oaId.IDeviceId;
import com.gingersoft.gsa.cloud.common.oaId.IGetter;
import com.gingersoft.gsa.cloud.common.oaId.IOAIDGetter;
import com.samsung.android.deviceidservice.IDeviceIdService;
import java.lang.reflect.Method;
/**
* Created by liyujiang on 2020/5/30
*
* @author 大定府羡民
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public class SamsungDeviceIdImpl implements IDeviceId {
private final String TAG = getClass().getSimpleName();
private Context context;
public SamsungDeviceIdImpl(Context context) {
this.context = context;
}
@Override
public boolean supportOAID() {
try {
PackageInfo pi = context.getPackageManager().getPackageInfo("com.samsung.android.deviceidservice", 0);
return pi != null;
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
return false;
}
}
@Override
public void doGet(@NonNull final IOAIDGetter getter) {
Intent intent = new Intent();
intent.setClassName("com.samsung.android.deviceidservice", "com.samsung.android.deviceidservice.DeviceIdService");
try {
boolean isBinded = context.bindService(intent, new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
LoganManager.w_code(TAG,"Samsung DeviceIdService connected");
try {
//IDeviceIdService anInterface = new IDeviceIdService.Stub.asInterface(service);
Method asInterface = IDeviceIdService.Stub.class.getDeclaredMethod("asInterface", IBinder.class);
IDeviceIdService anInterface = (IDeviceIdService) asInterface.invoke(null, service);
if (anInterface == null) {
throw new RuntimeException("IDeviceIdService is null");
}
String deviceId = anInterface.getID();
if (deviceId == null || deviceId.length() == 0) {
throw new RuntimeException("Samsung DeviceId get failed");
}
getter.onOAIDGetComplete(deviceId);
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
getter.onOAIDGetError(e);
} finally {
context.unbindService(this);
}
}
@Override
public void onServiceDisconnected(ComponentName name) {
LoganManager.w_code(TAG,"Samsung DeviceIdService disconnected");
}
}, Context.BIND_AUTO_CREATE);
if (!isBinded) {
throw new RuntimeException("Samsung DeviceIdService bind failed");
}
} catch (Exception e) {
getter.onOAIDGetError(e);
}
}
@SuppressWarnings("deprecation")
@Override
public void doGet(@NonNull final IGetter getter) {
doGet(new IOAIDGetter() {
@Override
public void onOAIDGetComplete(@NonNull String oaid) {
getter.onDeviceIdGetComplete(oaid);
}
@Override
public void onOAIDGetError(@NonNull Exception exception) {
getter.onDeviceIdGetError(exception);
}
});
}
}
/*
* Copyright (c) 2019-2020 gzu-liyujiang <1032694760@qq.com>
*
* The software is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*/
package com.gingersoft.gsa.cloud.common.oaId.impl;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.oaId.IDeviceId;
import com.gingersoft.gsa.cloud.common.oaId.IGetter;
import com.gingersoft.gsa.cloud.common.oaId.IOAIDGetter;
import com.gingersoft.gsa.cloud.common.oaId.SystemUtils;
import java.util.Objects;
/**
* Created by liyujiang on 2020/5/30
*
* @author 大定府羡民
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public class VivoDeviceIdImpl implements IDeviceId {
private final String TAG = getClass().getSimpleName();
private Context context;
public VivoDeviceIdImpl(Context context) {
this.context = context;
}
@Override
public boolean supportOAID() {
return SystemUtils.sysProperty("persist.sys.identifierid.supported", "0").equals("1");
}
@Override
public void doGet(@NonNull final IOAIDGetter getter) {
Uri uri = Uri.parse("content://com.vivo.vms.IdProvider/IdentifierId/OAID");
try (Cursor cursor = context.getContentResolver().query(uri, null, null, null, null)) {
Objects.requireNonNull(cursor).moveToFirst();
String ret = cursor.getString(cursor.getColumnIndex("value"));
if (ret != null && ret.length() > 0) {
LoganManager.w_code(TAG,"oaid from provider: " + uri);
getter.onOAIDGetComplete(ret);
} else {
throw new RuntimeException("OAID query failed");
}
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
getter.onOAIDGetError(e);
}
}
@SuppressWarnings("deprecation")
@Override
public void doGet(@NonNull final IGetter getter) {
doGet(new IOAIDGetter() {
@Override
public void onOAIDGetComplete(@NonNull String oaid) {
getter.onDeviceIdGetComplete(oaid);
}
@Override
public void onOAIDGetError(@NonNull Exception exception) {
getter.onDeviceIdGetError(exception);
}
});
}
}
/*
* Copyright (c) 2019-2020 gzu-liyujiang <1032694760@qq.com>
*
* The software is licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*/
package com.gingersoft.gsa.cloud.common.oaId.impl;
import android.annotation.SuppressLint;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import com.gingersoft.gsa.cloud.common.logan.LoganManager;
import com.gingersoft.gsa.cloud.common.oaId.IDeviceId;
import com.gingersoft.gsa.cloud.common.oaId.IGetter;
import com.gingersoft.gsa.cloud.common.oaId.IOAIDGetter;
import java.lang.reflect.Method;
/**
* Created by liyujiang on 2020/5/30
*
* @author 大定府羡民
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public class XiaomiDeviceIdImpl implements IDeviceId {
private final String TAG = getClass().getSimpleName();
private Context context;
private Class<?> idProvider;
public XiaomiDeviceIdImpl(Context context) {
this.context = context;
}
@SuppressLint("PrivateApi")
@Override
public boolean supportOAID() {
try {
idProvider = Class.forName("com.android.id.impl.IdProviderImpl");
return true;
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
return false;
}
}
@SuppressLint("PrivateApi")
@Override
public void doGet(@NonNull final IOAIDGetter getter) {
if (idProvider == null) {
try {
idProvider = Class.forName("com.android.id.impl.IdProviderImpl");
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
}
}
String did = null;
try {
Method udidMethod = idProvider.getMethod("getDefaultUDID", Context.class);
did = invokeMethod(udidMethod);
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
}
if (did != null && did.length() > 0) {
getter.onOAIDGetComplete(did);
return;
}
try {
Method oaidMethod = idProvider.getMethod("getOAID", Context.class);
did = invokeMethod(oaidMethod);
if (did != null && did.length() > 0) {
getter.onOAIDGetComplete(did);
} else {
throw new RuntimeException("Xiaomi OAID get failed");
}
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
getter.onOAIDGetError(e);
}
}
private String invokeMethod(Method method) {
String result = null;
if (method != null) {
try {
result = (String) method.invoke(idProvider.newInstance(), context);
} catch (Exception e) {
LoganManager.w_code(TAG,e.getMessage());
}
}
return result;
}
@SuppressWarnings("deprecation")
@Override
public void doGet(@NonNull final IGetter getter) {
doGet(new IOAIDGetter() {
@Override
public void onOAIDGetComplete(@NonNull String oaid) {
getter.onDeviceIdGetComplete(oaid);
}
@Override
public void onOAIDGetError(@NonNull Exception exception) {
getter.onDeviceIdGetError(exception);
}
});
}
}
...@@ -16,6 +16,7 @@ import com.gingersoft.gsa.cloud.common.utils.encryption.BASE64Encoder; ...@@ -16,6 +16,7 @@ import com.gingersoft.gsa.cloud.common.utils.encryption.BASE64Encoder;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
...@@ -168,17 +169,19 @@ public class FileUtils { ...@@ -168,17 +169,19 @@ public class FileUtils {
* @param context * @param context
*/ */
public static void write(Context context, String fileName, String content) { public static void write(Context context, String fileName, String content) {
if (content == null) if (content == null) {
content = ""; content = "";
}
FileOutputStream fos = null;
try { try {
FileOutputStream fos = context.openFileOutput(fileName, fos = context.openFileOutput(fileName, Context.MODE_PRIVATE);
Context.MODE_PRIVATE);
fos.write(content.getBytes()); fos.write(content.getBytes());
} catch (IOException e) {
fos.close();
} catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if (fos != null) {
closeQuietly(fos);
}
} }
} }
...@@ -207,7 +210,6 @@ public class FileUtils { ...@@ -207,7 +210,6 @@ public class FileUtils {
while ((length = inStream.read(buffer)) != -1) { while ((length = inStream.read(buffer)) != -1) {
outStream.write(buffer, 0, length); outStream.write(buffer, 0, length);
} }
outStream.close(); outStream.close();
inStream.close(); inStream.close();
return outStream.toString(); return outStream.toString();
...@@ -285,6 +287,18 @@ public class FileUtils { ...@@ -285,6 +287,18 @@ public class FileUtils {
return filename; return filename;
} }
public static void closeQuietly(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (RuntimeException rethrown) {
throw rethrown;
} catch (Exception ignored) {
}
}
}
/** /**
* 根据URI获取文件真实路径(兼容多张机型) * 根据URI获取文件真实路径(兼容多张机型)
* *
......
...@@ -171,29 +171,6 @@ public class AppCrashHandler implements UncaughtExceptionHandler { ...@@ -171,29 +171,6 @@ public class AppCrashHandler implements UncaughtExceptionHandler {
Looper.loop(); Looper.loop();
} }
}); });
//使用Toast来显示异常信息
// new Thread() {
// @Override
// public void run() {
// Looper.prepare();
// String showText = ErrorStr;
// Throwable cause = ex.getCause();
// if (cause != null && BuildConfig.DEBUG) {
// StackTraceElement[] stackTrace = cause.getStackTrace();
// if (stackTrace != null && stackTrace.length > 0) {
// String causeName = cause.getClass().getSimpleName();
//
// String fileName = stackTrace[0].getFileName();
// fileName = fileName.substring(0, fileName.length() - 4);
// int lineNumber = stackTrace[0].getLineNumber();
// showText += "-" + fileName + "-" + lineNumber + "-" + causeName;
// OkHttp3Utils.noticePersonnel(RP_ERROR, showText);
// }
// }
// Toast.makeText(mContext, showText, Toast.LENGTH_LONG).show();
// Looper.loop();
// }
// }.start();
final Writer result = new StringWriter(); final Writer result = new StringWriter();
final PrintWriter printWriter = new PrintWriter(result); final PrintWriter printWriter = new PrintWriter(result);
...@@ -300,8 +277,9 @@ public class AppCrashHandler implements UncaughtExceptionHandler { ...@@ -300,8 +277,9 @@ public class AppCrashHandler implements UncaughtExceptionHandler {
try { try {
File dir = new File(FileUtils.ERRORLOG_PATH); File dir = new File(FileUtils.ERRORLOG_PATH);
//不存在就創建目錄 //不存在就創建目錄
if (!dir.exists()) if (!dir.exists()) {
dir.mkdirs(); dir.mkdirs();
}
FileOutputStream fos = new FileOutputStream(new File(FileUtils.ERRORLOG_PATH, fileName)); FileOutputStream fos = new FileOutputStream(new File(FileUtils.ERRORLOG_PATH, fileName));
fos.write(sb.toString().getBytes()); fos.write(sb.toString().getBytes());
fos.close(); fos.close();
......
...@@ -23,14 +23,14 @@ android { ...@@ -23,14 +23,14 @@ android {
// minifyEnabled false // minifyEnabled false
// shrinkResources false // shrinkResources false
// zipAlignEnabled false // zipAlignEnabled false
// proguardFiles 'proguard-rules.pro' // proguardFiles 'proguard.cfg'
// } // }
debug { debug {
buildConfigField "boolean", "LOG_DEBUG", "true" buildConfigField "boolean", "LOG_DEBUG", "true"
buildConfigField "boolean", "USE_CANARY", "true" buildConfigField "boolean", "USE_CANARY", "true"
minifyEnabled false minifyEnabled false
proguardFiles 'proguard-rules.pro' proguardFiles 'proguard.cfg'
} }
release { release {
buildConfigField "boolean", "LOG_DEBUG", "false" buildConfigField "boolean", "LOG_DEBUG", "false"
...@@ -38,7 +38,7 @@ android { ...@@ -38,7 +38,7 @@ android {
minifyEnabled true minifyEnabled true
// shrinkResources true // shrinkResources true
zipAlignEnabled true zipAlignEnabled true
proguardFiles 'proguard-rules.pro' proguardFiles 'proguard.cfg'
} }
} }
} }
......
...@@ -37,14 +37,14 @@ android { ...@@ -37,14 +37,14 @@ android {
// minifyEnabled false // minifyEnabled false
// shrinkResources false // shrinkResources false
// zipAlignEnabled false // zipAlignEnabled false
// proguardFiles 'proguard-rules.pro' // proguardFiles 'proguard.cfg'
// } // }
debug { debug {
buildConfigField "boolean", "LOG_DEBUG", "true" buildConfigField "boolean", "LOG_DEBUG", "true"
buildConfigField "boolean", "USE_CANARY", "true" buildConfigField "boolean", "USE_CANARY", "true"
minifyEnabled false minifyEnabled false
proguardFiles 'proguard-rules.pro' proguardFiles 'proguard.cfg'
} }
release { release {
buildConfigField "boolean", "LOG_DEBUG", "false" buildConfigField "boolean", "LOG_DEBUG", "false"
...@@ -52,7 +52,7 @@ android { ...@@ -52,7 +52,7 @@ android {
minifyEnabled true minifyEnabled true
// shrinkResources true // shrinkResources true
zipAlignEnabled true zipAlignEnabled true
proguardFiles 'proguard-rules.pro' proguardFiles 'proguard.cfg'
} }
} }
} }
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
android:name="android.support.FILE_PROVIDER_PATHS" android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/update_file_paths"/> android:resource="@xml/update_file_paths"/>
</provider> </provider>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
include ':library'
include ':component-scan' include ':component-scan'
include 'cc-register', include 'cc-register',
'cc', 'cc',
...@@ -13,7 +14,7 @@ include 'cc-register', ...@@ -13,7 +14,7 @@ include 'cc-register',
'library-qm-skin-maker', 'library-qm-skin-maker',
'library-fragmentation_core', 'library-fragmentation_core',
'library-updateApk', 'library-updateApk',
'library-pay', // 'library-order',
'component-login', 'component-login',
'component-main', 'component-main',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment