Skip to content

Commit 9fdcc65

Browse files
committed
axact update to version 3.2.5
fixes on upload/download dianostic
1 parent 75c5172 commit 9fdcc65

File tree

9 files changed

+202
-62
lines changed

9 files changed

+202
-62
lines changed

app/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ android {
1717
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1818
}
1919
}
20+
packagingOptions{
21+
doNotStrip "*/armeabi-v7a/*.so"
22+
}
2023
}
2124

2225
dependencies {
@@ -26,5 +29,5 @@ dependencies {
2629
})
2730
compile 'com.android.support.constraint:constraint-layout:1.0.2'
2831
testCompile 'junit:junit:4.12'
29-
compile project(':axactandroid-release-armeabi-v7a-v3.2.4-010')
32+
compile project(':axactandroid-release-armeabi-v7a-v3.2.5-011')
3033
}

app/src/main/AndroidManifest.xml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,21 @@
99
android:roundIcon="@mipmap/ic_launcher_round"
1010
android:supportsRtl="true"
1111
android:theme="@style/AppTheme">
12-
<activity android:name=".MainActivity" android:theme="@style/AppTheme">
12+
13+
<activity
14+
android:name=".MainActivity"
15+
android:label="@string/app_name"
16+
android:windowSoftInputMode="adjustResize|stateHidden"/>
17+
18+
<activity
19+
android:name=".BlankActivity"
20+
android:label="@string/app_name"
21+
android:launchMode="singleTop"
22+
android:theme="@android:style/Theme.NoDisplay"
23+
android:windowSoftInputMode="adjustResize|stateHidden"
24+
>
1325
<intent-filter>
1426
<action android:name="android.intent.action.MAIN"/>
15-
1627
<category android:name="android.intent.category.LAUNCHER"/>
1728
</intent-filter>
1829
</activity>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.axiros.axactservice;
2+
3+
import android.app.Activity;
4+
import android.content.ComponentName;
5+
import android.content.Context;
6+
import android.content.Intent;
7+
import android.content.ServiceConnection;
8+
import android.os.Bundle;
9+
import android.os.IBinder;
10+
import android.widget.Toast;
11+
12+
import com.axiros.axact.AxirosService;
13+
14+
/**
15+
* Created by bzero on 8/13/17.
16+
*/
17+
18+
public abstract class BaseActivity extends Activity {
19+
20+
private static BaseActivity curActivity;
21+
22+
@Override
23+
public void onBackPressed() {
24+
if (getFragmentManager().getBackStackEntryCount() > 0) {
25+
super.onBackPressed();
26+
} else {
27+
if (this instanceof MainActivity) {
28+
Intent intent = new Intent(getCurrentActivity(), BlankActivity.class);
29+
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
30+
startActivity(intent);
31+
finish();
32+
}
33+
else {
34+
super.onBackPressed();
35+
}
36+
}
37+
}
38+
39+
40+
@Override
41+
protected void onResume() {
42+
super.onResume();
43+
setCurrentActivity(this);
44+
}
45+
46+
@Override
47+
protected void onPause() {
48+
setCurrentActivity(null);
49+
super.onPause();
50+
}
51+
52+
@Override
53+
protected void onDestroy() {
54+
super.onDestroy();
55+
}
56+
57+
public static BaseActivity getCurrentActivity() {
58+
return curActivity;
59+
}
60+
61+
public static void setCurrentActivity(BaseActivity activity) {
62+
curActivity = activity;
63+
}
64+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.axiros.axactservice;
2+
3+
import android.app.Activity;
4+
import android.content.Intent;
5+
import android.os.Bundle;
6+
7+
/**
8+
* Created by bzero on 8/13/17.
9+
*/
10+
11+
public class BlankActivity extends BaseActivity {
12+
@Override
13+
protected void onCreate(Bundle savedInstanceState) {
14+
super.onCreate(savedInstanceState);
15+
Intent intent = new Intent(BlankActivity.this,
16+
MainActivity.class);
17+
startActivity(intent);
18+
}
19+
20+
@Override
21+
protected void onNewIntent(Intent intent) {
22+
super.onNewIntent(intent);
23+
if ((Intent.FLAG_ACTIVITY_CLEAR_TOP & intent.getFlags()) != 0) {
24+
finish();
25+
}
26+
}
27+
28+
29+
30+
}

app/src/main/java/com/axiros/axactservice/MainActivity.java

Lines changed: 89 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.app.Activity;
44

5+
import android.app.ActivityManager;
56
import android.content.ComponentName;
67
import android.content.Context;
78
import android.content.Intent;
@@ -16,14 +17,15 @@
1617
import android.widget.Button;
1718
import android.widget.ProgressBar;
1819
import android.widget.TextView;
19-
import android.widget.Toast;
2020

2121
import com.axiros.axact.AxirosService;
2222

23-
public class MainActivity extends Activity implements View.OnClickListener, AxirosService.AxirosEventsListener {
24-
Intent mServiceIntent;
25-
AxirosService mService;
26-
boolean mBound = false;
23+
public class MainActivity extends BaseActivity implements View.OnClickListener, AxirosService.AxirosEventsListener {
24+
private static AxirosService mService;
25+
private static AxirosService.LocalBinder mServiceBinder;
26+
private static Intent mServiceIntent;
27+
28+
private static boolean mBound;
2729

2830
MainActivity mActivity;
2931
Button buttonStart, buttonStop;
@@ -113,11 +115,55 @@ private String getNetworkType() {
113115
return networkType;
114116
}
115117

118+
private boolean isServiceRunning() {
119+
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
120+
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)){
121+
if("com.axiros.axact.AxirosService".equals(service.service.getClassName())) {
122+
return true;
123+
}
124+
}
125+
return false;
126+
}
127+
128+
/** Defines callbacks for service binding, passed to bindService() */
129+
private ServiceConnection mConnection = new ServiceConnection() {
130+
131+
@Override
132+
public void onServiceConnected(ComponentName className, IBinder service) {
133+
mServiceBinder = (AxirosService.LocalBinder)service;
134+
mService = mServiceBinder.getServiceInstance();
135+
mService.registerEventsListener(mActivity);
136+
textViewConnection.setText(String.format("Connection type: %s", getNetworkType()));
137+
}
138+
139+
@Override
140+
public void onServiceDisconnected(ComponentName arg0) {
141+
mService.unregisterEventsListener(mActivity);
142+
mService = null;
143+
mServiceBinder = null;
144+
}
145+
};
146+
116147
@Override
117-
protected void onCreate(Bundle savedInstanceState) {
148+
public void onCreate(Bundle savedInstanceState)
149+
{
118150
super.onCreate(savedInstanceState);
119151
setContentView(R.layout.activity_main);
120152

153+
init();
154+
155+
Intent intent = new Intent(this, AxirosService.class);
156+
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
157+
}
158+
159+
@Override
160+
protected void onDestroy() {
161+
unbindService(mConnection);
162+
super.onDestroy();
163+
}
164+
165+
private void init()
166+
{
121167
mActivity = this;
122168

123169
buttonStart = (Button) findViewById(R.id.buttonStart);
@@ -132,8 +178,17 @@ protected void onCreate(Bundle savedInstanceState) {
132178

133179
textViewConnection = (TextView) findViewById(R.id.textViewConnection);
134180

135-
buttonStart.setEnabled(true);
136-
buttonStop.setEnabled(false);
181+
if(isServiceRunning())
182+
{
183+
buttonStart.setEnabled(false);
184+
buttonStop.setEnabled(true);
185+
}
186+
else
187+
{
188+
buttonStart.setEnabled(true);
189+
buttonStop.setEnabled(false);
190+
}
191+
137192

138193
buttonStart.setOnClickListener(this);
139194
buttonStop.setOnClickListener(this);
@@ -143,24 +198,6 @@ protected void onCreate(Bundle savedInstanceState) {
143198

144199
mProgressBarDownload=(ProgressBar)findViewById(R.id.progressBarDownload);
145200
mProgressBarDownload.setProgress(0);
146-
147-
mServiceIntent = new Intent(this, AxirosService.class);
148-
bindService(mServiceIntent, mConnection, 0);
149-
150-
// About this key https://wiki.axiros.com/display/EFI/INTERNAL
151-
mServiceIntent.putExtra("key", "zptkrc8uJaud1spndstrqhCwb/MGaAj72Oiv2WcU43EaawEHu1bGoqrbLdpqF/EQX1ChYOT7dUuKYssVivAHcQ==");
152-
153-
// only integrators with url need to use it
154-
//mServiceIntent.putExtra("cert", "eaq.com.br.crt");
155-
}
156-
157-
@Override
158-
protected void onDestroy() {
159-
Toast.makeText(this, "Stoping AXACT Service.", Toast.LENGTH_LONG).show();
160-
mService.unregisterEventsListener(mActivity);
161-
stopService(mServiceIntent);
162-
unbindService(mConnection);
163-
super.onDestroy();
164201
}
165202

166203
private void clearView() {
@@ -179,21 +216,34 @@ private void clearView() {
179216

180217
@Override
181218
public void onClick(View view) {
219+
220+
221+
if (mServiceIntent == null)
222+
{
223+
mServiceIntent = new Intent(this, AxirosService.class);
224+
// About this key https://wiki.axiros.com/display/EFI/INTERNAL
225+
mServiceIntent.putExtra("key", "zptkrc8uJaud1spndstrqhCwb/MGaAj72Oiv2WcU43EaawEHu1bGoqrbLdpqF/EQX1ChYOT7dUuKYssVivAHcQ==");
226+
227+
// only integrators with url need to use it
228+
mServiceIntent.putExtra("cert", "eaq.com.br.crt");
229+
}
230+
182231
switch (view.getId()) {
232+
183233
case R.id.buttonStart:
184-
if (!mBound) {
185-
startService(mServiceIntent);
186-
}
187234
buttonStart.setEnabled(false);
188235
buttonStop.setEnabled(true);
236+
237+
startService(mServiceIntent);
238+
189239
break;
190240
case R.id.buttonStop:
191-
if (mBound) {
192-
stopService(mServiceIntent);
193-
clearView();
194-
}
195241
buttonStart.setEnabled(true);
196242
buttonStop.setEnabled(false);
243+
244+
stopService(mServiceIntent);
245+
246+
clearView();
197247
break;
198248
}
199249
}
@@ -244,7 +294,7 @@ public void onTick(long millisUntilFinished) {
244294
public void onFinish() {
245295
//Do what you want
246296
countUp++;
247-
mProgressBarUpload.setProgress(100);
297+
mProgressBarUpload.setProgress(0);
248298
}
249299
};
250300
mCountDownTimerUL.start();
@@ -257,6 +307,7 @@ public void udpEchoConfigured() {
257307
runOnUiThread(new Runnable() {
258308
@Override
259309
public void run() {
310+
clearView();;
260311
textViewUDPStatus.setText("Running UDP echo test");
261312
}
262313
});
@@ -269,6 +320,7 @@ public void downloadDiagnosticsResult(long bps) {
269320
@Override
270321
public void run() {
271322
downloadView.setText( String.format("Download Result: %d", result));
323+
mCountDownTimerDL.cancel();
272324
}
273325
});
274326
}
@@ -280,6 +332,9 @@ public void uploadDiagnosticsResult(long bps) {
280332
@Override
281333
public void run() {
282334
uploadView.setText( String.format("Upload Result: %d", result));
335+
if (mCountDownTimerUL != null) {
336+
mCountDownTimerUL.cancel();
337+
}
283338
}
284339
});
285340
}
@@ -295,28 +350,5 @@ public void run() {
295350
});
296351
}
297352

298-
/** Defines callbacks for service binding, passed to bindService() */
299-
private ServiceConnection mConnection = new ServiceConnection() {
300-
301-
@Override
302-
public void onServiceConnected(ComponentName className, IBinder service) {
303-
if (!mBound) {
304-
mBound = true;
305-
AxirosService.LocalBinder binder = (AxirosService.LocalBinder) service;
306-
mService = binder.getServiceInstance();
307-
mService.registerEventsListener(mActivity);
308-
textViewConnection.setText(String.format("Connection type: %s", getNetworkType()));
309-
Toast.makeText(mActivity, "AXACT Service started.", Toast.LENGTH_LONG).show();
310-
}
311-
}
312-
313-
@Override
314-
public void onServiceDisconnected(ComponentName arg0) {
315-
if (mBound) {
316-
mBound = false;
317-
Toast.makeText(mActivity, "AXACT Service stoped.", Toast.LENGTH_LONG).show();
318-
}
319-
}
320-
};
321353

322354
}
-428 KB
Binary file not shown.
302 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configurations.maybeCreate("default")
2-
artifacts.add("default", file('axactandroid-release-armeabi-v7a-v3.2.4-010.aar'))
2+
artifacts.add("default", file('axactandroid-release-armeabi-v7a-v3.2.5-011.aar'))

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include ':app', ':axactandroid-release-armeabi-v7a-v3.2.4-010'
1+
include ':app', ':axactandroid-release-armeabi-v7a-v3.2.5-011'

0 commit comments

Comments
 (0)