Skip to content

Commit d0b8b7e

Browse files
committed
refactor android classes to use DebugTool
1 parent 53b98f2 commit d0b8b7e

13 files changed

Lines changed: 136 additions & 144 deletions

File tree

android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import android.app.Service;
3636
import android.content.Context;
3737
import android.support.annotation.RestrictTo;
38-
import android.util.Log;
3938

4039
import com.smartdevicelink.SdlConnection.SdlSession;
4140
import com.smartdevicelink.SdlConnection.SdlSession2;
@@ -160,7 +159,7 @@ void onTransportDisconnected(String info, boolean availablePrimary, BaseTranspor
160159
super.onTransportDisconnected(info, availablePrimary, transportConfig);
161160
if (availablePrimary) {
162161
_transportConfig = transportConfig;
163-
Log.d(TAG, "notifying RPC session ended, but potential primary transport available");
162+
DebugTool.logInfo(TAG, "notifying RPC session ended, but potential primary transport available");
164163
cycleProxy(SdlDisconnectedReason.PRIMARY_TRANSPORT_CYCLE_REQUEST);
165164
} else {
166165
onClose(info, null, null);

android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenManager.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import android.content.IntentFilter;
3939
import android.graphics.Bitmap;
4040
import android.os.Build;
41-
import android.util.Log;
4241

4342
import com.smartdevicelink.managers.BaseSubManager;
4443
import com.smartdevicelink.managers.CompletionListener;
@@ -192,7 +191,7 @@ public void onNotified(RPCNotification notification) {
192191
if (notification != null) {
193192
OnDriverDistraction ddState = (OnDriverDistraction) notification;
194193
Boolean isDismissible = ddState.getLockscreenDismissibility();
195-
Log.i(TAG, "Lock screen dismissible: "+ isDismissible);
194+
DebugTool.logInfo(TAG, "Lock screen dismissible: "+ isDismissible);
196195
if (isDismissible != null) {
197196
// both of these conditions must be met to be able to dismiss lockscreen
198197
if (isDismissible && enableDismissGesture){

android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTransport.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838
import android.os.Build;
3939
import android.os.Looper;
4040
import android.os.Parcelable;
41-
import android.util.Log;
4241

4342
import com.smartdevicelink.SdlConnection.SdlConnection;
4443
import com.smartdevicelink.exception.SdlException;
4544
import com.smartdevicelink.protocol.SdlPacket;
4645
import com.smartdevicelink.transport.enums.TransportType;
4746
import com.smartdevicelink.transport.utl.TransportRecord;
47+
import com.smartdevicelink.util.DebugTool;
4848

4949
import java.util.List;
5050

@@ -122,7 +122,7 @@ protected boolean sendBytesOverTransport(SdlPacket packet) {
122122

123123
@Override
124124
public void openConnection() throws SdlException {
125-
Log.d(TAG, "Open connection");
125+
DebugTool.logInfo(TAG, "Open connection");
126126
if(brokerThread!=null){
127127
brokerThread.startConnection();
128128
}//else should log out
@@ -134,7 +134,7 @@ public void disconnect() {
134134
if(isDisconnecting){
135135
return;
136136
}
137-
Log.d(TAG, "Close connection");
137+
DebugTool.logInfo(TAG, "Close connection");
138138
this.isDisconnecting= true;
139139
if(brokerThread!= null){
140140
brokerThread.cancel();
@@ -275,7 +275,7 @@ public void initTransportBroker(){
275275
@Override
276276
public boolean onHardwareConnected(TransportType type) {
277277
if(super.onHardwareConnected(type)){
278-
Log.d(TAG, "On transport connected...");
278+
DebugTool.logInfo(TAG, "On transport connected...");
279279
if(!connected){
280280
connected = true;
281281
handleTransportConnected();
@@ -299,17 +299,17 @@ public void onHardwareDisconnected(TransportRecord transportRecord, List<Transpo
299299
public void onHardwareDisconnected(TransportType type) {
300300
super.onHardwareDisconnected(type);
301301
if(connected){
302-
Log.d(TAG, "Handling disconnect");
302+
DebugTool.logInfo(TAG, "Handling disconnect");
303303
connected = false;
304304
SdlConnection.enableLegacyMode(isLegacyModeEnabled(), TransportType.BLUETOOTH);
305305
if(isLegacyModeEnabled()){
306-
Log.d(TAG, "Handle transport disconnect, legacy mode enabled");
306+
DebugTool.logInfo(TAG, "Handle transport disconnect, legacy mode enabled");
307307
this.stop();
308308
isDisconnecting = true;
309309
//handleTransportDisconnected("");
310310
handleTransportError("",null); //This seems wrong, but it works
311311
}else{
312-
Log.d(TAG, "Handle transport Error");
312+
DebugTool.logInfo(TAG, "Handle transport Error");
313313
isDisconnecting = true;
314314
handleTransportError("",null); //This seems wrong, but it works
315315
}
@@ -321,7 +321,7 @@ public void onLegacyModeEnabled() {
321321
super.onLegacyModeEnabled();
322322
SdlConnection.enableLegacyMode(isLegacyModeEnabled(), TransportType.BLUETOOTH);
323323
if(isLegacyModeEnabled()){
324-
Log.d(TAG, "Handle on legacy mode enabled");
324+
DebugTool.logInfo(TAG, "Handle on legacy mode enabled");
325325
this.stop();
326326
isDisconnecting = true;
327327
//handleTransportDisconnected("");

android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexUsbTransport.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
import android.os.Handler;
3737
import android.os.Message;
3838
import android.os.ParcelFileDescriptor;
39-
import android.util.Log;
4039

4140
import com.smartdevicelink.protocol.SdlPacket;
4241
import com.smartdevicelink.transport.enums.TransportType;
42+
import com.smartdevicelink.util.DebugTool;
4343

4444
import java.io.FileDescriptor;
4545
import java.io.FileInputStream;
@@ -68,7 +68,7 @@ public class MultiplexUsbTransport extends MultiplexBaseTransport{
6868
MultiplexUsbTransport(ParcelFileDescriptor parcelFileDescriptor, Handler handler, Bundle bundle){
6969
super(handler, TransportType.USB);
7070
if(parcelFileDescriptor == null){
71-
Log.e(TAG, "Error with object");
71+
DebugTool.logError(TAG, "Error with object");
7272
this.parcelFileDescriptor = null;
7373
throw new ExceptionInInitializerError("ParcelFileDescriptor can't be null");
7474
}else{
@@ -101,7 +101,7 @@ public synchronized void start(){
101101
setState(STATE_CONNECTING);
102102
FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
103103
if(fileDescriptor == null || !fileDescriptor.valid()){
104-
Log.e(TAG, "USB FD was null or not valid,");
104+
DebugTool.logError(TAG, "USB FD was null or not valid,");
105105
setState(STATE_NONE);
106106
return;
107107
}
@@ -228,15 +228,15 @@ public void run() { //FIXME probably check to see what the BT does
228228
bytesRead = inputStream.read(buffer);
229229
if (bytesRead == -1) {
230230
if (isInterrupted()) {
231-
Log.e(TAG,"EOF reached, and thread is interrupted");
231+
DebugTool.logError(TAG,"EOF reached, and thread is interrupted");
232232
} else {
233-
Log.i(TAG,"EOF reached, disconnecting!");
233+
DebugTool.logInfo(TAG,"EOF reached, disconnecting!");
234234
connectionLost();
235235
}
236236
return;
237237
}
238238
if (isInterrupted()) {
239-
Log.w(TAG,"Read some data, but thread is interrupted");
239+
DebugTool.logWarning(TAG,"Read some data, but thread is interrupted");
240240
return;
241241
}
242242
if(connectionSuccessful != null && connectionSuccessful == false){
@@ -268,9 +268,9 @@ public void run() { //FIXME probably check to see what the BT does
268268
}
269269
} catch (IOException e) {
270270
if (isInterrupted()) {
271-
Log.w(TAG,"Can't read data, and thread is interrupted");
271+
DebugTool.logWarning(TAG,"Can't read data, and thread is interrupted");
272272
} else {
273-
Log.w(TAG,"Can't read data, disconnecting!");
273+
DebugTool.logWarning(TAG,"Can't read data, disconnecting!");
274274
connectionLost();
275275
}
276276
return;
@@ -319,7 +319,7 @@ public WriterThread(FileDescriptor fileDescriptor) {
319319
public void write(byte[] buffer, int offset, int count) {
320320
try {
321321
if(buffer==null){
322-
Log.w(TAG, "Can't write to device, nothing to send");
322+
DebugTool.logWarning(TAG, "Can't write to device, nothing to send");
323323
return;
324324
}
325325
//This would be a good spot to log out all bytes received
@@ -331,7 +331,7 @@ public void write(byte[] buffer, int offset, int count) {
331331
} catch (IOException|NullPointerException e) { // STRICTLY to catch mmOutStream NPE
332332
// Exception during write
333333
//OMG! WE MUST NOT BE CONNECTED ANYMORE! LET THE USER KNOW
334-
Log.e(TAG, "Error sending bytes to connected device!");
334+
DebugTool.logError(TAG, "Error sending bytes to connected device!");
335335
connectionLost();
336336
}
337337
}
@@ -345,7 +345,7 @@ public synchronized void cancel() {
345345
}
346346
} catch (IOException e) {
347347
// close() of connect socket failed
348-
Log.d(TAG, "Write Thread: " + e.getMessage());
348+
DebugTool.logInfo(TAG, "Write Thread: " + e.getMessage());
349349
}
350350
}
351351
}

android/sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import android.os.Handler;
4949
import android.os.Looper;
5050
import android.support.annotation.NonNull;
51-
import android.util.Log;
5251

5352
import com.smartdevicelink.util.AndroidTools;
5453
import com.smartdevicelink.util.DebugTool;
@@ -172,11 +171,11 @@ public boolean validate(){
172171
String packageName = null;
173172

174173
if(this.service != null){
175-
Log.d(TAG, "Supplied service name of " + this.service.getClassName());
174+
DebugTool.logInfo(TAG, "Supplied service name of " + this.service.getClassName());
176175
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.O && !isServiceRunning(context,this.service)){
177176
//This means our service isn't actually running, so set to null. Hopefully we can find a real router service after this.
178177
service = null;
179-
Log.w(TAG, "Supplied service is not actually running.");
178+
DebugTool.logWarning(TAG, "Supplied service is not actually running.");
180179
} else {
181180
// If the running router service is created by this app, the validation is good by default
182181
if (this.service.getPackageName().equals(context.getPackageName())) {
@@ -622,7 +621,7 @@ public int compare(ResolveInfo lhs, ResolveInfo rhs) {
622621

623622
return apps;
624623
}else{
625-
Log.i(TAG, "No SDL apps, list was null");
624+
DebugTool.logInfo(TAG, "No SDL apps, list was null");
626625
return null;
627626
}
628627
}
@@ -635,7 +634,7 @@ public int compare(ResolveInfo lhs, ResolveInfo rhs) {
635634
public static boolean createTrustedListRequest(final Context context, boolean forceRefresh){
636635
return createTrustedListRequest(context,forceRefresh,null,null);
637636
}
638-
public static boolean createTrustedListRequest(final Context context, boolean forceRefresh, TrustedListCallback listCallback){Log.d(TAG,"Checking to make sure we have a list");
637+
public static boolean createTrustedListRequest(final Context context, boolean forceRefresh, TrustedListCallback listCallback){DebugTool.logInfo(TAG,"Checking to make sure we have a list");
639638
return createTrustedListRequest(context,forceRefresh,null,listCallback);
640639
}
641640

@@ -691,7 +690,7 @@ else if(getSecurityLevel(context) == MultiplexTransportConfig.FLAG_MULTI_SECURIT
691690
}
692691
return false;
693692
}else{
694-
Log.d(TAG, "Sdl apps have changed. Need to request new trusted router service list.");
693+
DebugTool.logInfo(TAG, "Sdl apps have changed. Need to request new trusted router service list.");
695694
}
696695
}
697696

@@ -710,7 +709,7 @@ public void httpCallComplete(String response) {
710709

711710
@Override
712711
public void httpFailure(int statusCode) {
713-
Log.e(TAG, "Error while requesting trusted app list: "
712+
DebugTool.logError(TAG, "Error while requesting trusted app list: "
714713
+ statusCode);
715714
pendingListRefresh = false;
716715
if(listCallback!=null){listCallback.onListObtained(false);}

0 commit comments

Comments
 (0)