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
cf9e2619
Commit
cf9e2619
authored
Dec 22, 2023
by
xujialang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unit sdk class 反射获取
广告出现播放失败后销毁广告加载实例
parent
7c2f6ebe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
36 deletions
+42
-36
OutHelp.java
app/src/main/java/com/zl/sdk/OutHelp.java
+36
-36
TopOnAdLoadManager.java
app/src/main/java/com/zl/sdk/ad/TopOnAdLoadManager.java
+6
-0
No files found.
app/src/main/java/com/zl/sdk/OutHelp.java
View file @
cf9e2619
...
...
@@ -8,11 +8,9 @@ import android.content.BroadcastReceiver;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.util.ArrayMap
;
import
android.util.Log
;
import
android.util.ArrayMap
;
import
android.widget.RemoteViews
;
import
com.anythink.expressad.reward.player.ATRewardVideoActivity
;
...
...
@@ -25,8 +23,6 @@ import com.bytedance.sdk.openadsdk.activity.TTRewardVideoActivity;
import
com.mbridge.msdk.activity.MBCommonActivity
;
import
com.mbridge.msdk.out.LoadingActivity
;
import
com.mbridge.msdk.reward.player.MBRewardVideoActivity
;
import
com.unity3d.ads.adplayer.FullScreenWebViewDisplay
;
import
com.unity3d.services.ads.adunit.AdUnitActivity
;
import
com.vungle.ads.internal.ui.VungleActivity
;
import
com.zl.sdk.ad.topOn.TopOnAdManager
;
import
com.zl.sdk.bean.AdAppInfo
;
...
...
@@ -47,11 +43,8 @@ import java.lang.reflect.InvocationHandler;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Proxy
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Stack
;
import
java.util.Timer
;
import
java.util.TimerTask
;
...
...
@@ -436,12 +429,12 @@ public final class OutHelp implements KPListener {
Class
<?>
startCallbackClass
=
Class
.
forName
(
NameInterfaceHelp
.
getStartCallbackClassPath
());
//
if (startCallbackClass == null) {
//
callback.fail("startCallbackClass=null");
//
return;
//
}
if
(
startCallbackClass
==
null
)
{
callback
.
fail
(
"startCallbackClass=null"
);
return
;
}
//
Object callObj = NameInterfaceHelp.getNewCallBack();
Object
callObj
=
NameInterfaceHelp
.
getNewCallBack
();
Class
<?>
notifyClass
=
Class
.
forName
(
NameInterfaceHelp
.
getNotificationConfigClassPath
());
...
...
@@ -475,14 +468,14 @@ public final class OutHelp implements KPListener {
}
//
Object newCallBack = Proxy.newProxyInstance(
//
startCallbackClass.getClassLoader(),
//
new Class[]{startCallbackClass},
//
new StartCallbackProxy(callObj, callback)
//
);
Object
newCallBack
=
Proxy
.
newProxyInstance
(
startCallbackClass
.
getClassLoader
(),
new
Class
[]{
startCallbackClass
},
new
StartCallbackProxy
(
callObj
,
callback
)
);
setShowLock
(
true
);
surpriseMethod
.
invoke
(
null
,
mContext
,
intent
,
""
,
true
,
n
ull
,
notificationConfig
);
surpriseMethod
.
invoke
(
null
,
mContext
,
intent
,
""
,
true
,
n
ewCallBack
,
notificationConfig
);
}
catch
(
ClassNotFoundException
|
InvocationTargetException
|
NoSuchMethodException
|
IllegalAccessException
|
InstantiationException
e
)
{
...
...
@@ -534,14 +527,6 @@ public final class OutHelp implements KPListener {
@Override
public
void
cleanAllAppActivity
()
{
cleanAllRunningAppActivity
();
// try {
// Class<?> kpClass = Class.forName(NameInterfaceHelp.getClassPath());
// Method clsMethod = kpClass.getMethod(NameInterfaceHelp.CleanAllAppActivityMethod);
// clsMethod.invoke(null);
// } catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException |
// IllegalAccessException e) {
// LogUtil.d(TAG + "cleanAllAppActivity (catch) " + e.getMessage());
// }
}
/**
...
...
@@ -561,7 +546,6 @@ public final class OutHelp implements KPListener {
if
(
callback
!=
null
)
{
if
(
"onSuccess"
.
equals
(
method
.
getName
()))
{
LogUtil
.
d
(
TAG
+
"拉起外展:onSuccess"
);
if
(
callback
!=
null
)
{
callback
.
success
();
callback
=
null
;
...
...
@@ -569,6 +553,8 @@ public final class OutHelp implements KPListener {
}
else
if
(
"onFail"
.
equals
(
method
.
getName
()))
{
LogUtil
.
d
(
TAG
+
"拉起外展:onFail"
);
OutHelp
.
get
().
setShowLock
(
false
);
if
(
objects
.
length
>=
2
)
{
LogUtil
.
d
(
TAG
+
"拉起外展:onFail reason="
+
objects
[
1
]);
if
(
callback
!=
null
)
{
...
...
@@ -647,6 +633,7 @@ public final class OutHelp implements KPListener {
Statistics
.
getInstance
().
dotEvent
(
"rec_action"
,
map
);
}
private
void
cleanAllRunningAppActivity
()
{
try
{
Class
<?>
activityThreadClass
=
mContext
.
getClass
().
getClassLoader
().
loadClass
(
"android.app.ActivityThread"
);
...
...
@@ -664,7 +651,7 @@ public final class OutHelp implements KPListener {
activityField
.
setAccessible
(
true
);
Activity
activity
=
(
Activity
)
activityField
.
get
(
value
);
if
(
activity
==
null
)
{
if
(
activity
==
null
)
{
continue
;
}
...
...
@@ -688,24 +675,37 @@ public final class OutHelp implements KPListener {
||
activity
instanceof
MBRewardVideoActivity
||
activity
instanceof
MBCommonActivity
||
activity
instanceof
LoadingActivity
//mintegral
||
activity
instanceof
AdUnitActivity
||
activity
instanceof
FullScreenWebViewDisplay
//unit
||
instanceofUnitActivity
(
activity
)
)
{
continue
;
}
if
(!
activity
.
isDestroyed
())
{
// Method finish = Activity.class.getDeclaredMethod("finish", new Class[]{int.class});
// finish.setAccessible(true);
// finish.invoke(activity, 2);
LogUtil
.
d
(
TAG
+
" finish activity name="
+
activity
.
getClass
().
getName
());
activity
.
finishAndRemoveTask
();
}
}
}
catch
(
Throwable
throwable
)
{
ALog
.
d
(
TAG
,
" cleanAllAppActivitys e :"
+
Log
.
getStackTraceString
(
throwable
));
LogUtil
.
d
(
TAG
,
" cleanAllAppActivitys e :"
+
Log
.
getStackTraceString
(
throwable
));
}
}
private
boolean
instanceofUnitActivity
(
Activity
activity
)
{
try
{
Class
<?>
unitClass
=
Class
.
forName
(
"com.unity3d.services.ads.adunit.AdUnitActivity"
);
Class
<?>
unit2Class
=
Class
.
forName
(
"com.unity3d.ads.adplayer.FullScreenWebViewDisplay"
);
if
(
unitClass
==
null
||
unit2Class
==
null
)
{
LogUtil
.
d
(
TAG
+
"找不到unit sdk class"
);
return
false
;
}
return
activity
.
getClass
().
getName
().
equals
(
unitClass
.
getName
())
||
activity
.
getClass
().
getName
().
equals
(
unit2Class
.
getName
());
}
catch
(
Exception
e
)
{
LogUtil
.
d
(
TAG
+
"找不到unit sdk class (catch)"
);
return
false
;
}
}
...
...
app/src/main/java/com/zl/sdk/ad/TopOnAdLoadManager.java
View file @
cf9e2619
...
...
@@ -86,6 +86,8 @@ public final class TopOnAdLoadManager {
LogUtil
.
d
(
TAG
,
"AdInterstitialCallBack onAdDisplayFailed adUnitId ="
+
adUnitId
+
", errorMsg="
+
errorMsg
);
flagLoadMap
.
put
(
adUnitId
,
true
);
adCacheDataMap
.
remove
(
adUnitId
);
topOnInterstitialAdLoad
.
destroy
(
showAdBean
);
callInterstitialCloseAd
();
}
...
...
@@ -189,6 +191,8 @@ public final class TopOnAdLoadManager {
return
true
;
}
private
AdBean
showAdBean
=
null
;
public
void
showInterstitialAd
(
Activity
activity
,
OutAdData
.
NormalAdData
normalAdData
,
String
adScenes
)
{
if
(
null
==
normalAdData
||
TextUtils
.
isEmpty
(
normalAdData
.
cpAdslot
))
{
LogUtil
.
d
(
TAG
,
"showInterstitialAd data or adId empty"
);
...
...
@@ -225,6 +229,8 @@ public final class TopOnAdLoadManager {
AdBean
adBean
=
AdBean
.
getInstance
(
adScenes
).
setAdUnitId
(
normalAdData
.
cpAdslot
)
.
setAdPosition
(
"out"
)
.
setAdData
(
normalAdData
);
showAdBean
=
adBean
;
showInterstitialAd
(
activity
,
adBean
);
Map
<
String
,
Object
>
para
=
new
HashMap
<>();
...
...
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