diff options
author | Robert Quattlebaum <rquattle@google.com> | 2017-07-12 17:11:15 -0700 |
---|---|---|
committer | Robert Quattlebaum <rquattle@google.com> | 2017-07-17 19:39:55 -0700 |
commit | 9fc6ffb261beafe4becb5972f2c38437e5c211dd (patch) | |
tree | 87e0f094e745270ad672f9240ecba8a4589414fa | |
parent | 41641f3e0d7ebccbb18ef1e03898688b50ae3e30 (diff) | |
download | lowpan-9fc6ffb261beafe4becb5972f2c38437e5c211dd.tar.gz |
LowpanService: Stop using properties.
This commit updates the LoWPAN Service to no longer use properties for
fetching information about the interface, since this is no longer
possible.
Bug: b/63708348
Test: Compiled and tested manually by forming and scanning
Change-Id: I4ee70b8b2a2e8f43239e36ae5f0626a51818e3ab
-rw-r--r-- | service/java/com/android/server/lowpan/LowpanInterfaceTracker.java | 19 | ||||
-rw-r--r-- | service/java/com/android/server/lowpan/LowpanServiceImpl.java | 22 |
2 files changed, 26 insertions, 15 deletions
diff --git a/service/java/com/android/server/lowpan/LowpanInterfaceTracker.java b/service/java/com/android/server/lowpan/LowpanInterfaceTracker.java index afa3f80..cdfab75 100644 --- a/service/java/com/android/server/lowpan/LowpanInterfaceTracker.java +++ b/service/java/com/android/server/lowpan/LowpanInterfaceTracker.java @@ -32,9 +32,11 @@ import android.net.ip.IpManager.ProvisioningConfiguration; import android.net.lowpan.ILowpanInterface; import android.net.lowpan.LowpanException; import android.net.lowpan.LowpanInterface; -import android.net.lowpan.LowpanProperties; +import android.net.lowpan.LowpanRuntimeException; import android.os.Looper; import android.os.Message; +import android.os.RemoteException; +import android.os.ServiceSpecificException; import android.util.Log; import com.android.internal.util.HexDump; import com.android.internal.util.Protocol; @@ -112,7 +114,6 @@ class LowpanInterfaceTracker extends StateMachine { final FaultState mFaultState = new FaultState(); final ConnectedState mConnectedState = new ConnectedState(); - private LocalLowpanCallback mLocalLowpanCallback = new LocalLowpanCallback(); // Misc Private Classes @@ -268,9 +269,13 @@ class LowpanInterfaceTracker extends StateMachine { if (mHwAddr == null) { byte[] hwAddr = null; try { - hwAddr = mLowpanInterface.getProperty(LowpanProperties.KEY_MAC_ADDRESS); - } catch (LowpanException x) { + hwAddr = mLowpanInterface.getService().getMacAddress(); + + } catch (RemoteException | ServiceSpecificException x) { + // Don't let misbehavior of an interface service + // crash the system service. Log.e(TAG, x.toString()); + transitionTo(mFaultState); } if (hwAddr != null) { @@ -296,7 +301,6 @@ class LowpanInterfaceTracker extends StateMachine { } break; - case CMD_PROVISIONING_SUCCESS: case CMD_LINK_PROPERTIES_CHANGE: mLinkProperties = (LinkProperties) message.obj; if (DBG) { @@ -424,7 +428,7 @@ class LowpanInterfaceTracker extends StateMachine { case CMD_PROVISIONING_SUCCESS: Log.i(TAG, "Provisioning Success: " + message.obj.toString()); transitionTo(mConnectedState); - break; + return HANDLED; } return NOT_HANDLED; } @@ -493,9 +497,6 @@ class LowpanInterfaceTracker extends StateMachine { mNetworkCapabilities.setLinkUpstreamBandwidthKbps(100); mNetworkCapabilities.setLinkDownstreamBandwidthKbps(100); - // Things don't seem to work properly without this. TODO: Investigate. - //mNetworkCapabilities.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); - // CHECKSTYLE:OFF IndentationCheck addState(mInitState); addState(mDefaultState); diff --git a/service/java/com/android/server/lowpan/LowpanServiceImpl.java b/service/java/com/android/server/lowpan/LowpanServiceImpl.java index 08c4306..07677e3 100644 --- a/service/java/com/android/server/lowpan/LowpanServiceImpl.java +++ b/service/java/com/android/server/lowpan/LowpanServiceImpl.java @@ -25,6 +25,7 @@ import android.os.HandlerThread; import android.os.IBinder; import android.os.Looper; import android.os.RemoteException; +import android.os.ServiceSpecificException; import android.util.Log; import java.util.HashMap; import java.util.HashSet; @@ -111,9 +112,12 @@ public class LowpanServiceImpl extends ILowpanManager.Stub { for (ILowpanManagerListener listener : mListenerSet) { try { listener.onInterfaceRemoved(lowpanInterface); - } catch (RemoteException x) { - // Just skip. + } catch (RemoteException | ServiceSpecificException x) { + // Don't let misbehavior of a listener + // crash the system service. Log.e(TAG, "Exception caught: " + x); + + // TODO: Consider removing the listener...? } } } @@ -125,9 +129,12 @@ public class LowpanServiceImpl extends ILowpanManager.Stub { for (ILowpanManagerListener listener : mListenerSet) { try { listener.onInterfaceAdded(lowpanInterface); - } catch (RemoteException x) { - // Just skip. + } catch (RemoteException | ServiceSpecificException x) { + // Don't let misbehavior of a listener + // crash the system service. Log.e(TAG, "Exception caught: " + x); + + // TODO: Consider removing the listener...? } } } @@ -161,7 +168,9 @@ public class LowpanServiceImpl extends ILowpanManager.Stub { }, 0); - } catch (RemoteException x) { + } catch (RemoteException | ServiceSpecificException x) { + // Don't let misbehavior of an interface + // crash the system service. Log.e(TAG, "Exception caught: " + x); return; } @@ -224,7 +233,7 @@ public class LowpanServiceImpl extends ILowpanManager.Stub { try { name = lowpanInterface.getName(); - } catch (RemoteException x) { + } catch (RemoteException | ServiceSpecificException x) { // Directly fetching the name failed, so fall back to // a reverse lookup. synchronized (mInterfaceMap) { @@ -258,6 +267,7 @@ public class LowpanServiceImpl extends ILowpanManager.Stub { 0); mListenerSet.add(listener); } catch (RemoteException x) { + // We only get this exception if listener has already died. Log.e(TAG, "Exception caught: " + x); } } |