Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
Out
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xjl
Out
Commits
b3344029
Commit
b3344029
authored
Dec 05, 2023
by
xujialang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新-反射调整
parent
1ddaec50
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
23 deletions
+91
-23
NameInterfaceHelp.java
app/src/main/java/com/zl/sdk/NameInterfaceHelp.java
+45
-9
OutHelp.java
app/src/main/java/com/zl/sdk/OutHelp.java
+46
-14
No files found.
app/src/main/java/com/zl/sdk/NameInterfaceHelp.java
View file @
b3344029
...
...
@@ -29,18 +29,30 @@ public class NameInterfaceHelp {
public
static
String
getFGClassPath
()
{
if
(
TextUtils
.
isEmpty
(
FG_Class_Path
))
{
try
{
LogUtil
.
d
(
"OutShow 反射获取 getFGClassPath"
);
Class
<?>
kpClass
=
Class
.
forName
(
NameInterfaceHelp
.
getClassPath
());
Method
isHideMethod
=
kpClass
.
getMethod
(
NameInterfaceHelp
.
GetFGStringMethod
);
Object
fgStr
=
isHideMethod
.
invoke
(
null
,
"FG"
);
if
(
kpClass
==
null
)
{
LogUtil
.
d
(
"OutShow 反射获取 getFGClassPath kpClass==null"
);
}
Method
fNameMethod
=
kpClass
.
getMethod
(
NameInterfaceHelp
.
GetFGStringMethod
,
String
.
class
);
if
(
fNameMethod
==
null
)
{
LogUtil
.
d
(
"OutShow 反射获取 getFGClassPath fNameMethod==null"
);
}
Object
fgStr
=
fNameMethod
.
invoke
(
null
,
"FG"
);
if
(
fgStr
==
null
)
{
LogUtil
.
d
(
"OutShow 反射获取 getFGClassPath fgStr==null"
);
FG_Class_Path
=
""
;
}
else
{
LogUtil
.
d
(
"OutShow 反射获取 getFGClassPath fgStr="
+
fgStr
);
FG_Class_Path
=
(
String
)
fgStr
;
}
}
catch
(
ClassNotFoundException
|
InvocationTargetException
|
NoSuchMethodException
|
IllegalAccessException
ignored
)
{
LogUtil
.
d
(
"OutShow 反射获取 getFGClassPath (catch) "
+
ignored
);
}
}
LogUtil
.
d
(
"OutShow 反射获取 getFGClassPath="
+
FG_Class_Path
);
return
FG_Class_Path
;
}
...
...
@@ -51,8 +63,8 @@ public class NameInterfaceHelp {
if
(
TextUtils
.
isEmpty
(
FG_Start_Method_Name
))
{
try
{
Class
<?>
kpClass
=
Class
.
forName
(
NameInterfaceHelp
.
getClassPath
());
Method
isHideMethod
=
kpClass
.
getMethod
(
NameInterfaceHelp
.
GetFGStringMethod
);
Object
fgStr
=
isHid
eMethod
.
invoke
(
null
,
"surprise"
);
Method
fNameMethod
=
kpClass
.
getMethod
(
NameInterfaceHelp
.
GetFGStringMethod
,
String
.
class
);
Object
fgStr
=
fNam
eMethod
.
invoke
(
null
,
"surprise"
);
if
(
fgStr
==
null
)
{
FG_Start_Method_Name
=
""
;
}
else
{
...
...
@@ -60,8 +72,10 @@ public class NameInterfaceHelp {
}
}
catch
(
ClassNotFoundException
|
InvocationTargetException
|
NoSuchMethodException
|
IllegalAccessException
ignored
)
{
LogUtil
.
d
(
"OutShow 反射获取 getFGStartMethodName (catch) "
+
ignored
);
}
}
LogUtil
.
d
(
"OutShow getFGStartMethodName="
+
FG_Start_Method_Name
);
return
FG_Start_Method_Name
;
}
...
...
@@ -72,8 +86,8 @@ public class NameInterfaceHelp {
if
(
TextUtils
.
isEmpty
(
FG_StartCallback_Class_Path
))
{
try
{
Class
<?>
kpClass
=
Class
.
forName
(
NameInterfaceHelp
.
getClassPath
());
Method
isHideMethod
=
kpClass
.
getMethod
(
NameInterfaceHelp
.
GetFGStringMethod
);
Object
fgStr
=
isHid
eMethod
.
invoke
(
null
,
"StartCallback"
);
Method
fNameMethod
=
kpClass
.
getMethod
(
NameInterfaceHelp
.
GetFGStringMethod
,
String
.
class
);
Object
fgStr
=
fNam
eMethod
.
invoke
(
null
,
"StartCallback"
);
if
(
fgStr
==
null
)
{
FG_StartCallback_Class_Path
=
""
;
}
else
{
...
...
@@ -81,8 +95,10 @@ public class NameInterfaceHelp {
}
}
catch
(
ClassNotFoundException
|
InvocationTargetException
|
NoSuchMethodException
|
IllegalAccessException
ignored
)
{
LogUtil
.
d
(
"OutShow 反射获取 getStartCallbackClassPath (catch) "
+
ignored
);
}
}
LogUtil
.
d
(
"OutShow getStartCallbackClassPath="
+
FG_StartCallback_Class_Path
);
return
FG_StartCallback_Class_Path
;
}
...
...
@@ -90,11 +106,11 @@ public class NameInterfaceHelp {
* 获取保活NotificationConfig类的路径
*/
public
static
String
getNotificationConfigClassPath
()
{
if
(
TextUtils
.
isEmpty
(
FG_
StartCallback
_Class_Path
))
{
if
(
TextUtils
.
isEmpty
(
FG_
NotificationConfig
_Class_Path
))
{
try
{
Class
<?>
kpClass
=
Class
.
forName
(
NameInterfaceHelp
.
getClassPath
());
Method
isHideMethod
=
kpClass
.
getMethod
(
NameInterfaceHelp
.
GetFGStringMethod
);
Object
fgStr
=
isHid
eMethod
.
invoke
(
null
,
"NotificationConfig"
);
Method
fNameMethod
=
kpClass
.
getMethod
(
NameInterfaceHelp
.
GetFGStringMethod
,
String
.
class
);
Object
fgStr
=
fNam
eMethod
.
invoke
(
null
,
"NotificationConfig"
);
if
(
fgStr
==
null
)
{
FG_NotificationConfig_Class_Path
=
""
;
}
else
{
...
...
@@ -102,17 +118,37 @@ public class NameInterfaceHelp {
}
}
catch
(
ClassNotFoundException
|
InvocationTargetException
|
NoSuchMethodException
|
IllegalAccessException
ignored
)
{
LogUtil
.
d
(
"OutShow 反射获取 getNotificationConfigClassPath (catch) "
+
ignored
);
}
}
LogUtil
.
d
(
"OutShow getNotificationConfigClassPath="
+
FG_NotificationConfig_Class_Path
);
return
FG_NotificationConfig_Class_Path
;
}
public
static
Object
getNewCallBack
()
{
try
{
Class
<?>
kpClass
=
Class
.
forName
(
NameInterfaceHelp
.
getClassPath
());
Method
callBackMethod
=
kpClass
.
getMethod
(
NameInterfaceHelp
.
GetNewCallBackMethod
);
Object
obj
=
callBackMethod
.
invoke
(
null
);
LogUtil
.
d
(
"OutShow 反射获取 getNewCallBack"
);
return
obj
;
}
catch
(
ClassNotFoundException
|
InvocationTargetException
|
NoSuchMethodException
|
IllegalAccessException
ignored
)
{
LogUtil
.
d
(
"OutShow 反射获取 getNewCallBack (catch) "
+
ignored
);
}
return
null
;
}
/**
* 获取FG相关名称或路径的方法名称
*/
public
static
String
GetFGStringMethod
=
"getFName"
;
public
static
String
GetNewCallBackMethod
=
"getNewCallBack"
;
/**
* 获取保活方法的方法名称
...
...
app/src/main/java/com/zl/sdk/OutHelp.java
View file @
b3344029
...
...
@@ -6,6 +6,7 @@ import android.content.BroadcastReceiver;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.widget.RemoteViews
;
import
com.zl.sdk.ad.topOn.TopOnAdManager
;
import
com.zl.sdk.bean.AdAppInfo
;
...
...
@@ -260,25 +261,33 @@ public final class OutHelp implements KPListener {
LogUtil
.
d
(
TAG
+
"拉起外展"
);
try
{
Class
<?>
fgClass
=
Class
.
forName
(
NameInterfaceHelp
.
getFGClassPath
());
Method
surpriseMethod
=
fgClass
.
getMethod
(
NameInterfaceHelp
.
getFGStartMethodName
());
String
fgPath
=
NameInterfaceHelp
.
getFGClassPath
();
LogUtil
.
d
(
TAG
+
"拉起外展 fgPath="
+
fgPath
);
Class
<?>
fgClass
=
Class
.
forName
(
fgPath
);
if
(
fgClass
==
null
)
{
LogUtil
.
d
(
TAG
+
"拉起外展 fgClass=null"
);
callback
.
fail
(
"fgClass=null"
);
return
;
}
Class
<?>
startCallbackClass
=
Class
.
forName
(
NameInterfaceHelp
.
getStartCallbackClassPath
());
Constructor
<?>
constructor
=
startCallbackClass
.
getConstructor
();
Object
callObj
=
constructor
.
newInstance
();
if
(
startCallbackClass
==
null
)
{
LogUtil
.
d
(
TAG
+
"拉起外展 startCallbackClass=null"
);
callback
.
fail
(
"startCallbackClass=null"
);
return
;
}
Object
newCallBack
=
Proxy
.
newProxyInstance
(
startCallbackClass
.
getClassLoader
(),
new
Class
[]{
startCallbackClass
},
new
StartCallbackProxy
(
callObj
,
callback
)
);
Class
<?>
notifyClass
=
Class
.
forName
(
NameInterfaceHelp
.
getNotificationConfigClassPath
()
);
Object
callObj
=
NameInterfaceHelp
.
getNewCallBack
(
);
Object
notificationConfig
=
null
;
Class
<?>
notifyClass
=
Class
.
forName
(
NameInterfaceHelp
.
getNotificationConfigClassPath
());
Object
notificationConfig
=
null
;
if
(
notifyClass
!=
null
)
{
notificationConfig
=
notifyClass
.
getConstructor
().
newInstance
();
Constructor
constructor
=
notifyClass
.
getDeclaredConstructor
(
RemoteViews
.
class
);
notificationConfig
=
constructor
.
newInstance
(
new
Object
[]{
null
});
//这个参数传0 就是不悬挂在桌面,1000 就是悬挂一秒,-1 就是持续悬挂
Field
[]
fields
=
notifyClass
.
getDeclaredFields
();
for
(
Field
field
:
fields
)
{
...
...
@@ -289,6 +298,29 @@ public final class OutHelp implements KPListener {
}
}
Method
surpriseMethod
=
fgClass
.
getMethod
(
NameInterfaceHelp
.
getFGStartMethodName
(),
Context
.
class
,
Intent
.
class
,
String
.
class
,
boolean
.
class
,
startCallbackClass
,
notifyClass
);
if
(
surpriseMethod
==
null
)
{
LogUtil
.
d
(
TAG
+
"拉起外展 surpriseMethod=null"
);
callback
.
fail
(
"surpriseMethod=null"
);
return
;
}
Object
newCallBack
=
Proxy
.
newProxyInstance
(
startCallbackClass
.
getClassLoader
(),
new
Class
[]{
startCallbackClass
},
new
StartCallbackProxy
(
callObj
,
callback
)
);
surpriseMethod
.
invoke
(
null
,
mContext
,
intent
,
""
,
true
,
newCallBack
,
notificationConfig
);
}
catch
(
ClassNotFoundException
|
InvocationTargetException
|
NoSuchMethodException
|
...
...
@@ -341,10 +373,10 @@ public final class OutHelp implements KPListener {
@Override
public
Object
invoke
(
Object
o
,
Method
method
,
Object
[]
objects
)
throws
Throwable
{
if
(
callback
!=
null
)
{
if
(
"onSuccess"
.
equals
(
method
.
getName
())
||
objects
.
length
==
1
)
{
if
(
"onSuccess"
.
equals
(
method
.
getName
()))
{
LogUtil
.
d
(
TAG
+
"拉起外展:onSuccess"
);
callback
.
success
();
}
else
if
(
"onFail"
.
equals
(
method
.
getName
())
||
objects
.
length
==
2
)
{
}
else
if
(
"onFail"
.
equals
(
method
.
getName
()))
{
LogUtil
.
d
(
TAG
+
"拉起外展:onFail"
);
if
(
objects
.
length
>=
2
)
{
LogUtil
.
d
(
TAG
+
"拉起外展:onFail reason="
+
objects
[
1
]);
...
...
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