OSDN Git Service

Add TelecomManager constructor for passing in TelecomServiceImpl
authorHall Liu <hallliu@google.com>
Fri, 9 Oct 2015 22:58:37 +0000 (15:58 -0700)
committerHall Liu <hallliu@google.com>
Fri, 9 Oct 2015 23:31:10 +0000 (16:31 -0700)
override

Bug: 24618535
Change-Id: I2dafcc9ab496de94eb6a6894916030ed4e7556f8

telecomm/java/android/telecom/TelecomManager.java

index a8f2aca..8b347cc 100644 (file)
@@ -447,6 +447,8 @@ public class TelecomManager {
 
     private final Context mContext;
 
+    private final ITelecomService mTelecomServiceOverride;
+
     /**
      * @hide
      */
@@ -458,12 +460,20 @@ public class TelecomManager {
      * @hide
      */
     public TelecomManager(Context context) {
+        this(context, null);
+    }
+
+    /**
+     * @hide
+     */
+    public TelecomManager(Context context, ITelecomService telecomServiceImpl) {
         Context appContext = context.getApplicationContext();
         if (appContext != null) {
             mContext = appContext;
         } else {
             mContext = context;
         }
+        mTelecomServiceOverride = telecomServiceImpl;
     }
 
     /**
@@ -1340,6 +1350,9 @@ public class TelecomManager {
     }
 
     private ITelecomService getTelecomService() {
+        if (mTelecomServiceOverride != null) {
+            return mTelecomServiceOverride;
+        }
         return ITelecomService.Stub.asInterface(ServiceManager.getService(Context.TELECOM_SERVICE));
     }