|
|
@@ -11,6 +11,7 @@ import com.sheep.gamegroup.model.entity.AppRecord;
|
|
|
import com.sheep.gamegroup.util.Jump2View;
|
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
|
import com.sheep.gamegroup.util.MyDbManager;
|
|
|
+import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -19,8 +20,6 @@ import java.util.List;
|
|
|
* realicing@sina.com
|
|
|
*/
|
|
|
public class MonitorAppService extends AccessibilityService {
|
|
|
- private AppRecord lastAppRecord;
|
|
|
- private long lastTime;
|
|
|
@Override
|
|
|
public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
|
|
|
// 此方法是在主线程中回调过来的,所以消息是阻塞执行的
|
|
|
@@ -40,13 +39,16 @@ public class MonitorAppService extends AccessibilityService {
|
|
|
appRecord.setPackageName(packageName.toString());
|
|
|
if(!textList.isEmpty())
|
|
|
appRecord.setTag(textList.get(0).toString());
|
|
|
+
|
|
|
+ AppRecord lastAppRecord = SheepApp.getInstance().getLastAppRecord();
|
|
|
+ long lastTime = SheepApp.getInstance().getLastTime();
|
|
|
if(lastAppRecord != null && lastTime != 0)
|
|
|
lastAppRecord.setTime(lastAppRecord.getTime() + curTime - lastTime);
|
|
|
if(lastAppRecord != null)
|
|
|
MyDbManager.getInstance().saveOrUpdate(lastAppRecord);
|
|
|
|
|
|
- lastTime = curTime;
|
|
|
- lastAppRecord = appRecord;
|
|
|
+ SheepApp.getInstance().setLastTime(curTime);
|
|
|
+ SheepApp.getInstance().setLastAppRecord(appRecord);
|
|
|
break;
|
|
|
// case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
|
|
|
// System.out.println("MonitorAppService TYPE_WINDOW_CONTENT_CHANGED: " + " packageName: " + packageName + " source: " + ListUtil.getIndex(textList, 0));
|