OSDN Git Service

Simplify equals() method of ServiceState
authorNathan Harold <nharold@google.com>
Thu, 28 Jun 2018 00:21:17 +0000 (17:21 -0700)
committerNathan Harold <nharold@google.com>
Thu, 28 Jun 2018 01:55:49 +0000 (18:55 -0700)
For whatever reason, ServiceState used a
somewhat-convoluted check for null and
class type. Updating to use a canonical
and brief approach.

Bug: 8675309
Test: compilation
Change-Id: I0d635067a06093affff478e13c28bbbe2bfda7df

telephony/java/android/telephony/ServiceState.java

index e86b482..ccb4ef8 100644 (file)
@@ -756,17 +756,8 @@ public class ServiceState implements Parcelable {
 
     @Override
     public boolean equals (Object o) {
-        ServiceState s;
-
-        try {
-            s = (ServiceState) o;
-        } catch (ClassCastException ex) {
-            return false;
-        }
-
-        if (o == null) {
-            return false;
-        }
+        if (!(o instanceof ServiceState)) return false;
+        ServiceState s = (ServiceState) o;
 
         return (mVoiceRegState == s.mVoiceRegState
                 && mDataRegState == s.mDataRegState