Commit c66c9801 authored by xujialang's avatar xujialang

更新-2

parent 3191b0d5
...@@ -4,6 +4,7 @@ import android.annotation.SuppressLint; ...@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import androidx.annotation.Keep; import androidx.annotation.Keep;
...@@ -38,7 +39,6 @@ public final class OutHelp implements KPListener { ...@@ -38,7 +39,6 @@ public final class OutHelp implements KPListener {
private boolean isDebug = false; private boolean isDebug = false;
private Intent intent = null; private Intent intent = null;
private KPListener kpListener = null;
//是否第一次轮询 //是否第一次轮询
private boolean firstLx = true; private boolean firstLx = true;
...@@ -51,8 +51,10 @@ public final class OutHelp implements KPListener { ...@@ -51,8 +51,10 @@ public final class OutHelp implements KPListener {
* *
* @param context 上下文 * @param context 上下文
* @param isDebug 开启调试 * @param isDebug 开启调试
* @param isDebug appId
* @param isDebug appKey
*/ */
public void init(Context context, boolean isDebug) { public void init(Context context, boolean isDebug,String appId,String appKey) {
this.mContext = context; this.mContext = context;
this.isDebug = isDebug; this.isDebug = isDebug;
...@@ -64,60 +66,34 @@ public final class OutHelp implements KPListener { ...@@ -64,60 +66,34 @@ public final class OutHelp implements KPListener {
// IcOptManager.getInstance().init(context); // IcOptManager.getInstance().init(context);
IconHelp.get().init(context); IconHelp.get().init(context);
//初始化触发条件
initTriggerConditions(); initTriggerConditions();
} }
private void initTriggerConditions() { private void initTriggerConditions() {
initTimer(); initTimer();
initReciver(); initReceiver();
} }
private void initReciver() {
}
private void initTimer() { private void initTimer() {
Timer timer = new Timer(); Timer timer = new Timer();
timer.schedule(new TimerTask() { timer.schedule(new TimerTask() {
@Override @Override
public void run() { public void run() {
showOutAd(firstLx); showOutAd(firstLx, null);
} }
}, 60 * 1000); }, 60 * 1000);
} }
private void initReceiver() {
@Override TriggerReceiver triggerReceiver = new TriggerReceiver();
public boolean isInit() { IntentFilter intentfilter = new IntentFilter();
if (kpListener != null) { intentfilter.addAction(Intent.ACTION_USER_PRESENT);
return kpListener.isInit(); intentfilter.addAction(Intent.ACTION_SCREEN_ON);
} intentfilter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
return false; mContext.registerReceiver(triggerReceiver, intentfilter);
}
@Override
public boolean iconShow() {
if (kpListener != null) {
return kpListener.iconShow();
}
return true;
}
@Override
public boolean isAppForeground() {
if (kpListener != null) {
return kpListener.isAppForeground();
}
return AppUtils.isAppForeground();
} }
@Override
public void startOutDialog(Intent intent, DialogShowStatusCallback callback) {
if (kpListener != null) {
kpListener.startOutDialog(intent, callback);
}
}
/** /**
* 进入外展广告播放逻辑(解锁) * 进入外展广告播放逻辑(解锁)
...@@ -126,13 +102,9 @@ public final class OutHelp implements KPListener { ...@@ -126,13 +102,9 @@ public final class OutHelp implements KPListener {
* @param callback 结果回调 * @param callback 结果回调
*/ */
public void showOutAd(ActionFrom actionFrom, DialogShowStatusCallback callback) { public void showOutAd(ActionFrom actionFrom, DialogShowStatusCallback callback) {
try { intent = new Intent(mContext, );
intent = new Intent(mContext, Class.forName(targetClass)); dialogShowStatusCallback = callback;
dialogShowStatusCallback = callback; OutAdManager.get().startShowOutAd(actionFrom);
OutAdManager.get().startShowOutAd(actionFrom);
} catch (ClassNotFoundException e) {
LogUtil.e("showOutAd", "目标页面未找到");
}
} }
...@@ -143,13 +115,9 @@ public final class OutHelp implements KPListener { ...@@ -143,13 +115,9 @@ public final class OutHelp implements KPListener {
* @param callback 结果回调 * @param callback 结果回调
*/ */
private void showOutAd(boolean isFirst, DialogShowStatusCallback callback) { private void showOutAd(boolean isFirst, DialogShowStatusCallback callback) {
try { intent = new Intent(mContext, );
intent = new Intent(mContext, Class.forName(targetClass)); dialogShowStatusCallback = callback;
dialogShowStatusCallback = callback; OutAdManager.get().checkShowOutAd(isFirst);
OutAdManager.get().checkShowOutAd(isFirst);
} catch (ClassNotFoundException e) {
LogUtil.e("showOutAd", "目标页面未找到");
}
} }
...@@ -186,6 +154,38 @@ public final class OutHelp implements KPListener { ...@@ -186,6 +154,38 @@ public final class OutHelp implements KPListener {
} }
/**
* 反射获取保活是否初始化
*/
@Override
public boolean isInit() {
return false;
}
/**
* 反射获取icon状态
*/
@Override
public boolean iconShow() {
return false;
}
@Override
public boolean isAppForeground() {
return AppUtils.isAppForeground(mContext.getPackageName());
}
/**
* 反射调用保活拉起弹窗
* @param intent
* @param callback
*/
@Override
public void startOutDialog(Intent intent, DialogShowStatusCallback callback) {
}
public static class TriggerReceiver extends BroadcastReceiver { public static class TriggerReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
...@@ -193,21 +193,17 @@ public final class OutHelp implements KPListener { ...@@ -193,21 +193,17 @@ public final class OutHelp implements KPListener {
return; return;
} }
String action = intent.getAction(); String action = intent.getAction();
LogUtil.d(TAG, "onReceive action =" + action);
switch (action) { switch (action) {
case Intent.ACTION_USER_PRESENT: { case Intent.ACTION_USER_PRESENT: {
LogUtil.d(TAG, "onReceive ACTION_USER_PRESENT");
LogUtil.d("OutShow ===>>> 解锁"); LogUtil.d("OutShow ===>>> 解锁");
OutAdManager.get().showOutAd("", ActionFrom.ACTION_USER_PRESENT, null); OutHelp.get().showOutAd(ActionFrom.ACTION_USER_PRESENT, null);
break; break;
} }
case Intent.ACTION_SCREEN_ON: { case Intent.ACTION_SCREEN_ON: {
LogUtil.d(TAG, "onReceive ACTION_SCREEN_ON");
LogUtil.d("OutShow ===>>> 亮屏"); LogUtil.d("OutShow ===>>> 亮屏");
break; break;
} }
case Intent.ACTION_CLOSE_SYSTEM_DIALOGS: { case Intent.ACTION_CLOSE_SYSTEM_DIALOGS: {
LogUtil.d(TAG, "onReceive ACTION_CLOSE_SYSTEM_DIALOGS =" + intent.getStringExtra("reason"));
LogUtil.d("OutShow ===>>> 桌面"); LogUtil.d("OutShow ===>>> 桌面");
break; break;
} }
......
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