|
|
|
@ -270,14 +270,29 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
public void onCreate() {
|
|
|
|
|
super.onCreate();
|
|
|
|
|
|
|
|
|
|
Context context = getApplicationContext();
|
|
|
|
|
try {
|
|
|
|
|
if (usingEthernet()) {
|
|
|
|
|
try {
|
|
|
|
|
File filesDir = context.getFilesDir();
|
|
|
|
|
File ethShellFile = new File(filesDir, "eth.sh");
|
|
|
|
|
if (ethShellFile.exists()) {
|
|
|
|
|
ethShellFile.delete();
|
|
|
|
|
}
|
|
|
|
|
FilesUtils.copyAssetsFile(context, "eth.sh", ethShellFile.getAbsolutePath());
|
|
|
|
|
|
|
|
|
|
File ethShellFile = new File(getFilesDir(), "eth.sh");
|
|
|
|
|
|
|
|
|
|
FilesUtils.copyAssetsFile(getApplicationContext(), "eth.sh", ethShellFile.getAbsolutePath());
|
|
|
|
|
File ethToolFile = new File(filesDir, "ethtool");
|
|
|
|
|
if (ethToolFile.exists()) {
|
|
|
|
|
ethToolFile.delete();
|
|
|
|
|
}
|
|
|
|
|
String srcFileName = android.os.Process.is64Bit() ? "ethtool" : "ethtool-v7a";
|
|
|
|
|
FilesUtils.copyAssetsFile(context, srcFileName, ethToolFile.getAbsolutePath());
|
|
|
|
|
ethToolFile.setExecutable(true);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mConnectivityManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
|
|
mConnectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
|
|
|
|
|
|
|
Network[] nws = mConnectivityManager.getAllNetworks();
|
|
|
|
|
for (Network nw : nws) {
|
|
|
|
@ -294,10 +309,14 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
|
|
|
|
|
mHander = new ServiceHandler();
|
|
|
|
|
|
|
|
|
|
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
|
|
|
|
mNotificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
|
|
|
|
|
mStateService = STATE_SERVICE.NOT_CONNECTED;
|
|
|
|
|
|
|
|
|
|
DeviceUtil.getPhoneState(this.getApplicationContext());
|
|
|
|
|
try {
|
|
|
|
|
DeviceUtil.getPhoneState(context);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mScreenaAtionReceiver = new ScreenActionReceiver();
|
|
|
|
|
|
|
|
|
@ -335,7 +354,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
intentFilter.addAction(ACTION_STOP);
|
|
|
|
|
intentFilter.addAction(ACTION_UPDATE_CONFIGS);
|
|
|
|
|
|
|
|
|
|
LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver (mLocalMsgReceiver, intentFilter);
|
|
|
|
|
LocalBroadcastManager.getInstance(context).registerReceiver (mLocalMsgReceiver, intentFilter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
@ -354,21 +373,12 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
getApplicationContext().registerReceiver(mHeartBeatReceiver, filter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
AlarmManager alarmManager = (AlarmManager) getApplicationContext().getSystemService(ALARM_SERVICE);
|
|
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
|
AlarmManager.AlarmClockInfo aci = alarmManager.getNextAlarmClock();
|
|
|
|
|
if (aci == null) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
enableGps(true);
|
|
|
|
|
requestPosition();
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void onDestroy() {
|
|
|
|
|