Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cash_plugin_toolbox
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
cash_plugin_toolbox
Commits
70824f10
Commit
70824f10
authored
Aug 22, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update isReviewMachine logic
parent
c2a562e8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
6 deletions
+111
-6
src/main/java/com/common/toolbox/PluginConfig.java
+18
-0
src/main/java/com/common/toolbox/app_utils/DeviceInfo.java
+93
-6
No files found.
src/main/java/com/common/toolbox/PluginConfig.java
View file @
70824f10
package
com
.
common
.
toolbox
;
import
android.app.Application
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
com.common.toolbox.app_utils.DeviceInfo
;
/**
* Created by SiKang on 2019-07-28.
*/
public
class
PluginConfig
{
//是否是渠道包
private
static
Context
context
;
public
static
boolean
IS_WEBSITE
=
false
;
public
static
boolean
IS_SAFE_DEVICE
=
false
;
public
static
void
init
(
Application
application
)
{
context
=
application
;
SharedPreferences
sp
=
context
.
getSharedPreferences
(
DeviceInfo
.
SP_NAME
,
Context
.
MODE_PRIVATE
);
IS_SAFE_DEVICE
=
sp
.
getBoolean
(
DeviceInfo
.
IS_SAFE_DEVICE
,
false
);
}
public
static
Context
getContext
()
{
return
context
;
}
}
src/main/java/com/common/toolbox/app_utils/DeviceInfo.java
View file @
70824f10
package
com
.
common
.
toolbox
.
app_utils
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.content.pm.ApplicationInfo
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.os.Build
;
import
android.os.Environment
;
import
android.text.TextUtils
;
...
...
@@ -7,6 +12,10 @@ import android.text.TextUtils;
import
com.common.toolbox.PluginConfig
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.UUID
;
...
...
@@ -20,6 +29,8 @@ public class DeviceInfo {
private
static
String
DEVICE_SIGN
=
""
;
private
static
String
SD_SIGN
=
""
;
private
static
Locale
defaultLocale
;
public
static
String
SP_NAME
=
"cash_plugin_sp"
;
public
static
String
IS_SAFE_DEVICE
=
"safe_device"
;
/**
* 读取SD卡中的设备指纹
...
...
@@ -147,16 +158,41 @@ public class DeviceInfo {
*/
public
static
boolean
isReviewMachine
()
{
//如果是渠道包,忽略
if
(
PluginConfig
.
IS_WEBSITE
)
{
if
(
PluginConfig
.
IS_WEBSITE
||
PluginConfig
.
IS_SAFE_DEVICE
)
{
return
false
;
}
if
(
defaultLocale
!=
null
)
{
boolean
isIndo
=
defaultLocale
.
getCountry
().
equals
(
"ID"
)
&&
defaultLocale
.
getLanguage
().
equals
(
"in"
);
boolean
isChinese
=
defaultLocale
.
getCountry
().
equals
(
"CN"
)
&&
defaultLocale
.
getLanguage
().
equals
(
"zh"
);
return
!(
isIndo
||
isChinese
);
String
packages
=
getPkgsFromeAppList
(
getAppList
(
PluginConfig
.
getContext
(),
30
));
if
(
packages
.
contains
(
"androidx.test.tools.crawler"
)
||
packages
.
contains
(
"androidx.test.services"
)
||
packages
.
contains
(
"android.support.test.services"
)
||
packages
.
contains
(
"com.google.android.gmscore.testing.testsupport"
)
||
packages
.
contains
(
"com.google.android.gms.policy_test_support"
)
||
packages
.
contains
(
"com.google.android.apps.mtaas.testloop"
)
||
packages
.
contains
(
"com.google.android.apps.mtaas.loginutil"
)
||
packages
.
contains
(
"com.google.android.apps.mtaas.deviceadmin"
)
||
packages
.
contains
(
"com.google.android.apps.mtaas.updateutil"
))
{
return
true
;
}
return
false
;
return
true
;
// if (defaultLocale != null) {
// boolean isIndo = defaultLocale.getCountry().equals("ID") && defaultLocale.getLanguage().equals("in");
// boolean isChinese = defaultLocale.getCountry().equals("CN") && defaultLocale.getLanguage().equals("zh");
// return !(isIndo || isChinese);
// }
// return false;
}
/**
* 登录后将设备加入白名单,不再显示假界面
*/
public
static
void
addDevicetoWhiteList
()
{
SharedPreferences
sp
=
PluginConfig
.
getContext
().
getSharedPreferences
(
SP_NAME
,
Context
.
MODE_PRIVATE
);
SharedPreferences
.
Editor
edit
=
sp
.
edit
();
edit
.
putBoolean
(
IS_SAFE_DEVICE
,
true
);
edit
.
commit
();
}
public
static
boolean
isRoot
()
{
...
...
@@ -167,4 +203,55 @@ public class DeviceInfo {
}
}
public
static
String
getPkgsFromeAppList
(
List
<
PackageInfo
>
appList
)
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
"&"
);
for
(
PackageInfo
info
:
appList
)
{
builder
.
append
(
info
.
packageName
);
builder
.
append
(
"&"
);
}
builder
.
deleteCharAt
(
0
);
return
builder
.
toString
();
}
/**
* 获取设备上的应用列表
*
* @param count 指定数量
*/
public
static
List
<
PackageInfo
>
getAppList
(
Context
context
,
int
count
)
{
List
<
PackageInfo
>
appList
=
new
ArrayList
<>();
try
{
PackageManager
manager
=
context
.
getPackageManager
();
List
<
PackageInfo
>
packages
=
manager
.
getInstalledPackages
(
0
);
for
(
int
i
=
0
;
i
<
packages
.
size
();
i
++)
{
PackageInfo
packageInfo
=
packages
.
get
(
i
);
//Only display the non-system app info
if
((
packageInfo
.
applicationInfo
.
flags
&
ApplicationInfo
.
FLAG_SYSTEM
)
==
0
)
{
appList
.
add
(
packageInfo
);
//如果非系统应用,则添加至appList
}
}
Collections
.
sort
(
appList
,
new
Comparator
<
PackageInfo
>()
{
@Override
public
int
compare
(
PackageInfo
lhs
,
PackageInfo
rhs
)
{
if
(
lhs
==
null
||
rhs
==
null
)
{
return
0
;
}
if
(
lhs
.
lastUpdateTime
<
rhs
.
lastUpdateTime
)
{
return
1
;
}
else
if
(
lhs
.
lastUpdateTime
>
rhs
.
lastUpdateTime
)
{
return
-
1
;
}
else
{
return
0
;
}
}
});
return
appList
.
subList
(
0
,
count
);
}
catch
(
Exception
e
)
{
return
appList
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment