@@ -360,8 +360,7 @@ public String[] listInterfaces() {
360360 try {
361361 return mConnector .doListCommand ("interface list" , NetdResponseCode .InterfaceListResult );
362362 } catch (NativeDaemonConnectorException e ) {
363- throw new IllegalStateException (
364- "Cannot communicate with native daemon to list interfaces" );
363+ throw e .rethrowAsParcelableException ();
365364 }
366365 }
367366
@@ -372,8 +371,7 @@ public InterfaceConfiguration getInterfaceConfig(String iface) {
372371 try {
373372 rsp = mConnector .doCommand ("interface getcfg " + iface ).get (0 );
374373 } catch (NativeDaemonConnectorException e ) {
375- throw new IllegalStateException (
376- "Cannot communicate with native daemon to get interface config" );
374+ throw e .rethrowAsParcelableException ();
377375 }
378376 Slog .d (TAG , String .format ("rsp <%s>" , rsp ));
379377
@@ -436,8 +434,7 @@ public void setInterfaceConfig(String iface, InterfaceConfiguration cfg) {
436434 try {
437435 mConnector .doCommand (cmd );
438436 } catch (NativeDaemonConnectorException e ) {
439- throw new IllegalStateException (
440- "Unable to communicate with native daemon to interface setcfg - " + e );
437+ throw e .rethrowAsParcelableException ();
441438 }
442439 }
443440
@@ -465,8 +462,7 @@ public void setInterfaceIpv6PrivacyExtensions(String iface, boolean enable) {
465462 try {
466463 mConnector .doCommand (cmd );
467464 } catch (NativeDaemonConnectorException e ) {
468- throw new IllegalStateException (
469- "Unable to communicate with native daemon to set ipv6privacyextensions - " + e );
465+ throw e .rethrowAsParcelableException ();
470466 }
471467 }
472468
@@ -479,8 +475,7 @@ public void clearInterfaceAddresses(String iface) {
479475 try {
480476 mConnector .doCommand (cmd );
481477 } catch (NativeDaemonConnectorException e ) {
482- throw new IllegalStateException (
483- "Unable to communicate with native daemon to interface clearallips - " + e );
478+ throw e .rethrowAsParcelableException ();
484479 }
485480 }
486481
@@ -490,8 +485,7 @@ public void enableIpv6(String iface) {
490485 try {
491486 mConnector .doCommand (String .format ("interface ipv6 %s enable" , iface ));
492487 } catch (NativeDaemonConnectorException e ) {
493- throw new IllegalStateException (
494- "Unable to communicate to native daemon for enabling ipv6" );
488+ throw e .rethrowAsParcelableException ();
495489 }
496490 }
497491
@@ -501,8 +495,7 @@ public void disableIpv6(String iface) {
501495 try {
502496 mConnector .doCommand (String .format ("interface ipv6 %s disable" , iface ));
503497 } catch (NativeDaemonConnectorException e ) {
504- throw new IllegalStateException (
505- "Unable to communicate to native daemon for disabling ipv6" );
498+ throw e .rethrowAsParcelableException ();
506499 }
507500 }
508501
@@ -569,9 +562,7 @@ private void modifyRoute(String interfaceName, int action, RouteInfo route, Stri
569562 try {
570563 rsp = mConnector .doCommand (cmd .toString ());
571564 } catch (NativeDaemonConnectorException e ) {
572- throw new IllegalStateException (
573- "Unable to communicate with native dameon to add routes - "
574- + e );
565+ throw e .rethrowAsParcelableException ();
575566 }
576567
577568 if (DBG ) {
@@ -700,8 +691,7 @@ public boolean getIpForwardingEnabled() throws IllegalStateException{
700691 try {
701692 rsp = mConnector .doCommand ("ipfwd status" );
702693 } catch (NativeDaemonConnectorException e ) {
703- throw new IllegalStateException (
704- "Unable to communicate with native daemon to ipfwd status" );
694+ throw e .rethrowAsParcelableException ();
705695 }
706696
707697 for (String line : rsp ) {
@@ -728,7 +718,7 @@ public void setIpForwardingEnabled(boolean enable) {
728718 try {
729719 mConnector .doCommand (String .format ("ipfwd %sable" , (enable ? "en" : "dis" )));
730720 } catch (NativeDaemonConnectorException e ) {
731- e .rethrowAsParcelableException ();
721+ throw e .rethrowAsParcelableException ();
732722 }
733723 }
734724
@@ -745,7 +735,7 @@ public void startTethering(String[] dhcpRange) {
745735 try {
746736 mConnector .doCommand (cmd );
747737 } catch (NativeDaemonConnectorException e ) {
748- throw new IllegalStateException ( "Unable to communicate to native daemon" );
738+ throw e . rethrowAsParcelableException ( );
749739 }
750740 }
751741
@@ -755,7 +745,7 @@ public void stopTethering() {
755745 try {
756746 mConnector .doCommand ("tether stop" );
757747 } catch (NativeDaemonConnectorException e ) {
758- throw new IllegalStateException ( "Unable to communicate to native daemon to stop tether" );
748+ throw e . rethrowAsParcelableException ( );
759749 }
760750 }
761751
@@ -767,8 +757,7 @@ public boolean isTetheringStarted() {
767757 try {
768758 rsp = mConnector .doCommand ("tether status" );
769759 } catch (NativeDaemonConnectorException e ) {
770- throw new IllegalStateException (
771- "Unable to communicate to native daemon to get tether status" );
760+ throw e .rethrowAsParcelableException ();
772761 }
773762
774763 for (String line : rsp ) {
@@ -793,8 +782,7 @@ public void tetherInterface(String iface) {
793782 try {
794783 mConnector .doCommand ("tether interface add " + iface );
795784 } catch (NativeDaemonConnectorException e ) {
796- throw new IllegalStateException (
797- "Unable to communicate to native daemon for adding tether interface" );
785+ throw e .rethrowAsParcelableException ();
798786 }
799787 }
800788
@@ -804,8 +792,7 @@ public void untetherInterface(String iface) {
804792 try {
805793 mConnector .doCommand ("tether interface remove " + iface );
806794 } catch (NativeDaemonConnectorException e ) {
807- throw new IllegalStateException (
808- "Unable to communicate to native daemon for removing tether interface" );
795+ throw e .rethrowAsParcelableException ();
809796 }
810797 }
811798
@@ -816,8 +803,7 @@ public String[] listTetheredInterfaces() {
816803 return mConnector .doListCommand (
817804 "tether interface list" , NetdResponseCode .TetherInterfaceListResult );
818805 } catch (NativeDaemonConnectorException e ) {
819- throw new IllegalStateException (
820- "Unable to communicate to native daemon for listing tether interfaces" );
806+ throw e .rethrowAsParcelableException ();
821807 }
822808 }
823809
@@ -832,8 +818,7 @@ public void setDnsForwarders(String[] dns) {
832818 try {
833819 mConnector .doCommand (cmd );
834820 } catch (NativeDaemonConnectorException e ) {
835- throw new IllegalStateException (
836- "Unable to communicate to native daemon for setting tether dns" );
821+ throw e .rethrowAsParcelableException ();
837822 }
838823 } catch (IllegalArgumentException e ) {
839824 throw new IllegalStateException ("Error resolving dns name" , e );
@@ -847,8 +832,7 @@ public String[] getDnsForwarders() {
847832 return mConnector .doListCommand (
848833 "tether dns list" , NetdResponseCode .TetherDnsFwdTgtListResult );
849834 } catch (NativeDaemonConnectorException e ) {
850- throw new IllegalStateException (
851- "Unable to communicate to native daemon for listing tether dns" );
835+ throw e .rethrowAsParcelableException ();
852836 }
853837 }
854838
@@ -874,7 +858,7 @@ private void modifyNat(String cmd, String internalInterface, String externalInte
874858 try {
875859 mConnector .doCommand (cmd );
876860 } catch (NativeDaemonConnectorException e ) {
877- e .rethrowAsParcelableException ();
861+ throw e .rethrowAsParcelableException ();
878862 }
879863 }
880864
@@ -910,8 +894,7 @@ public String[] listTtys() {
910894 try {
911895 return mConnector .doListCommand ("list_ttys" , NetdResponseCode .TtyListResult );
912896 } catch (NativeDaemonConnectorException e ) {
913- throw new IllegalStateException (
914- "Unable to communicate to native daemon for listing TTYs" );
897+ throw e .rethrowAsParcelableException ();
915898 }
916899 }
917900
@@ -928,7 +911,7 @@ public void attachPppd(
928911 } catch (IllegalArgumentException e ) {
929912 throw new IllegalStateException ("Error resolving addr" , e );
930913 } catch (NativeDaemonConnectorException e ) {
931- throw new IllegalStateException ( "Error communicating to native daemon to attach pppd" , e );
914+ throw e . rethrowAsParcelableException ( );
932915 }
933916 }
934917
@@ -938,7 +921,7 @@ public void detachPppd(String tty) {
938921 try {
939922 mConnector .doCommand (String .format ("pppd detach %s" , tty ));
940923 } catch (NativeDaemonConnectorException e ) {
941- throw new IllegalStateException ( "Error communicating to native daemon to detach pppd" , e );
924+ throw e . rethrowAsParcelableException ( );
942925 }
943926 }
944927
@@ -972,7 +955,7 @@ public void startAccessPoint(
972955 }
973956 mConnector .doCommand (String .format ("softap startap" ));
974957 } catch (NativeDaemonConnectorException e ) {
975- throw new IllegalStateException ( "Error communicating to native daemon to start softap" , e );
958+ throw e . rethrowAsParcelableException ( );
976959 }
977960 }
978961
@@ -1003,7 +986,7 @@ public void wifiFirmwareReload(String wlanIface, String mode) {
1003986 try {
1004987 mConnector .doCommand (String .format ("softap fwreload " + wlanIface + " " + mode ));
1005988 } catch (NativeDaemonConnectorException e ) {
1006- throw new IllegalStateException ( "Error communicating to native daemon " , e );
989+ throw e . rethrowAsParcelableException ( );
1007990 }
1008991 }
1009992
@@ -1016,8 +999,7 @@ public void stopAccessPoint(String wlanIface) {
1016999 mConnector .doCommand ("softap stop " + wlanIface );
10171000 wifiFirmwareReload (wlanIface , "STA" );
10181001 } catch (NativeDaemonConnectorException e ) {
1019- throw new IllegalStateException ("Error communicating to native daemon to stop soft AP" ,
1020- e );
1002+ throw e .rethrowAsParcelableException ();
10211003 }
10221004 }
10231005
@@ -1036,8 +1018,7 @@ public void setAccessPoint(WifiConfiguration wifiConfig, String wlanIface, Strin
10361018 mConnector .doCommand (str );
10371019 }
10381020 } catch (NativeDaemonConnectorException e ) {
1039- throw new IllegalStateException ("Error communicating to native daemon to set soft AP" ,
1040- e );
1021+ throw e .rethrowAsParcelableException ();
10411022 }
10421023 }
10431024
@@ -1113,7 +1094,7 @@ public void setInterfaceQuota(String iface, long quotaBytes) {
11131094 mConnector .doCommand (command .toString ());
11141095 mActiveQuotaIfaces .add (iface );
11151096 } catch (NativeDaemonConnectorException e ) {
1116- throw new IllegalStateException ( "Error communicating to native daemon" , e );
1097+ throw e . rethrowAsParcelableException ( );
11171098 }
11181099 }
11191100 }
@@ -1142,8 +1123,7 @@ public void removeInterfaceQuota(String iface) {
11421123 // TODO: support quota shared across interfaces
11431124 mConnector .doCommand (command .toString ());
11441125 } catch (NativeDaemonConnectorException e ) {
1145- // TODO: include current iptables state
1146- throw new IllegalStateException ("Error communicating to native daemon" , e );
1126+ throw e .rethrowAsParcelableException ();
11471127 }
11481128 }
11491129 }
@@ -1175,7 +1155,7 @@ public void setInterfaceAlert(String iface, long alertBytes) {
11751155 mConnector .doCommand (command .toString ());
11761156 mActiveAlertIfaces .add (iface );
11771157 } catch (NativeDaemonConnectorException e ) {
1178- throw new IllegalStateException ( "Error communicating to native daemon" , e );
1158+ throw e . rethrowAsParcelableException ( );
11791159 }
11801160 }
11811161 }
@@ -1202,7 +1182,7 @@ public void removeInterfaceAlert(String iface) {
12021182 mConnector .doCommand (command .toString ());
12031183 mActiveAlertIfaces .remove (iface );
12041184 } catch (NativeDaemonConnectorException e ) {
1205- throw new IllegalStateException ( "Error communicating to native daemon" , e );
1185+ throw e . rethrowAsParcelableException ( );
12061186 }
12071187 }
12081188 }
@@ -1221,7 +1201,7 @@ public void setGlobalAlert(long alertBytes) {
12211201 try {
12221202 mConnector .doCommand (command .toString ());
12231203 } catch (NativeDaemonConnectorException e ) {
1224- throw new IllegalStateException ( "Error communicating to native daemon" , e );
1204+ throw e . rethrowAsParcelableException ( );
12251205 }
12261206 }
12271207
@@ -1257,7 +1237,7 @@ public void setUidNetworkRules(int uid, boolean rejectOnQuotaInterfaces) {
12571237 mUidRejectOnQuota .delete (uid );
12581238 }
12591239 } catch (NativeDaemonConnectorException e ) {
1260- throw new IllegalStateException ( "Error communicating to native daemon" , e );
1240+ throw e . rethrowAsParcelableException ( );
12611241 }
12621242 }
12631243 }
@@ -1304,7 +1284,7 @@ private NetworkStats.Entry getNetworkStatsTethering(String ifaceIn, String iface
13041284 try {
13051285 rsp = mConnector .doCommand (command .toString ()).get (0 );
13061286 } catch (NativeDaemonConnectorException e ) {
1307- throw new IllegalStateException ( "Error communicating to native daemon" , e );
1287+ throw e . rethrowAsParcelableException ( );
13081288 }
13091289
13101290 final String [] tok = rsp .split (" " );
@@ -1349,7 +1329,7 @@ public void setInterfaceThrottle(String iface, int rxKbps, int txKbps) {
13491329 mConnector .doCommand (String .format (
13501330 "interface setthrottle %s %d %d" , iface , rxKbps , txKbps ));
13511331 } catch (NativeDaemonConnectorException e ) {
1352- Slog . e ( TAG , "Error communicating with native daemon to set throttle" , e );
1332+ throw e . rethrowAsParcelableException ( );
13531333 }
13541334 }
13551335
@@ -1362,8 +1342,7 @@ private int getInterfaceThrottle(String iface, boolean rx) {
13621342 String .format ("interface getthrottle %s %s" , iface ,
13631343 (rx ? "rx" : "tx" ))).get (0 );
13641344 } catch (NativeDaemonConnectorException e ) {
1365- Slog .e (TAG , "Error communicating with native daemon to getthrottle" , e );
1366- return -1 ;
1345+ throw e .rethrowAsParcelableException ();
13671346 }
13681347
13691348 String [] tok = rsp .split (" " );
@@ -1410,8 +1389,7 @@ public void setDefaultInterfaceForDns(String iface) {
14101389
14111390 mConnector .doCommand (cmd );
14121391 } catch (NativeDaemonConnectorException e ) {
1413- throw new IllegalStateException (
1414- "Error communicating with native daemon to set default interface" , e );
1392+ throw e .rethrowAsParcelableException ();
14151393 }
14161394 }
14171395
@@ -1430,8 +1408,7 @@ public void setDnsServersForInterface(String iface, String[] servers) {
14301408 } catch (IllegalArgumentException e ) {
14311409 throw new IllegalStateException ("Error setting dnsn for interface" , e );
14321410 } catch (NativeDaemonConnectorException e ) {
1433- throw new IllegalStateException (
1434- "Error communicating with native daemon to set dns for interface" , e );
1411+ throw e .rethrowAsParcelableException ();
14351412 }
14361413 }
14371414
@@ -1443,8 +1420,7 @@ public void flushDefaultDnsCache() {
14431420
14441421 mConnector .doCommand (cmd );
14451422 } catch (NativeDaemonConnectorException e ) {
1446- throw new IllegalStateException (
1447- "Error communicating with native deamon to flush default interface" , e );
1423+ throw e .rethrowAsParcelableException ();
14481424 }
14491425 }
14501426
@@ -1456,8 +1432,7 @@ public void flushInterfaceDnsCache(String iface) {
14561432
14571433 mConnector .doCommand (cmd );
14581434 } catch (NativeDaemonConnectorException e ) {
1459- throw new IllegalStateException (
1460- "Error communicating with native daemon to flush interface " + iface , e );
1435+ throw e .rethrowAsParcelableException ();
14611436 }
14621437 }
14631438
0 commit comments