Commit c66c9801 authored by xujialang's avatar xujialang

更新-2

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