mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-12 09:40:50 +01:00
update spice service
add screen records
This commit is contained in:
parent
668e59f4f2
commit
96b2f39c3c
@ -3,9 +3,13 @@ package edu.tsinghua.spice;
|
|||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
|
||||||
|
import edu.tsinghua.spice.Utilies.NetworkStateUtil;
|
||||||
import edu.tsinghua.spice.Utilies.SpiceProfilingUtil;
|
import edu.tsinghua.spice.Utilies.SpiceProfilingUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,6 +34,12 @@ public class SpiceService extends Service {
|
|||||||
SpiceProfilingUtil.log(this, "onCreate");
|
SpiceProfilingUtil.log(this, "onCreate");
|
||||||
mAlarmManager = (AlarmManager) getSystemService(Service.ALARM_SERVICE);
|
mAlarmManager = (AlarmManager) getSystemService(Service.ALARM_SERVICE);
|
||||||
|
|
||||||
|
IntentFilter mScreenOnFilter = new IntentFilter("android.intent.action.SCREEN_ON");
|
||||||
|
SpiceService.this.registerReceiver(mScreenOReceiver, mScreenOnFilter);
|
||||||
|
|
||||||
|
IntentFilter mScreenOffFilter = new IntentFilter("android.intent.action.SCREEN_OFF");
|
||||||
|
SpiceService.this.registerReceiver(mScreenOReceiver, mScreenOffFilter);
|
||||||
|
|
||||||
// Upload Service
|
// Upload Service
|
||||||
final Intent uploadIntent = new Intent(SpiceUploadReceiver.ACTION_UPLOAD_PROFILE);
|
final Intent uploadIntent = new Intent(SpiceUploadReceiver.ACTION_UPLOAD_PROFILE);
|
||||||
mUploadIntent = PendingIntent.getBroadcast(this, 0, uploadIntent, 0);
|
mUploadIntent = PendingIntent.getBroadcast(this, 0, uploadIntent, 0);
|
||||||
@ -42,4 +52,19 @@ public class SpiceService extends Service {
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BroadcastReceiver mScreenOReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
String action = intent.getAction();
|
||||||
|
if (action.equals("android.intent.action.SCREEN_ON")) {
|
||||||
|
SpiceProfilingUtil.profile(context,SpiceProfilingUtil.FILE_NAME_SCREEN, "SCREEN ON" + "," + NetworkStateUtil.getConnectedType(context));
|
||||||
|
SpiceProfilingUtil.log(context, "SCREEN ON" + "," + NetworkStateUtil.getConnectedType(context));
|
||||||
|
} else if (action.equals("android.intent.action.SCREEN_OFF")) {
|
||||||
|
SpiceProfilingUtil.profile(context,SpiceProfilingUtil.FILE_NAME_SCREEN, "SCREEN OFF" + "," + NetworkStateUtil.getConnectedType(context));
|
||||||
|
SpiceProfilingUtil.log(context, "SCREEN OFF" + "," + NetworkStateUtil.getConnectedType(context));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user