Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit efef1165 authored by Shuo Qian's avatar Shuo Qian Committed by android-build-merger
Browse files

Add a private function to set System Dialer in Telecom service

am: 75890e01

Change-Id: Ie2803d4120170592b380d0a1491078431bb4ed12
parents 42095ffb 75890e01
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -724,6 +724,27 @@ public class TelecomServiceImpl {
            }
        }

        public void setSystemDialerPackage(String packageName) {
            try {
                Log.startSession("TSI.sTDD");
                enforceModifyPermission();
                if (Binder.getCallingUid() != Process.SHELL_UID
                    && Binder.getCallingUid() != Process.ROOT_UID) {
                    throw new SecurityException("Shell-only API.");
                }
                synchronized (mLock) {
                    long token = Binder.clearCallingIdentity();
                    try {
                        TelecomServiceImpl.setSystemDialerPackage(packageName);;
                    } finally {
                        Binder.restoreCallingIdentity(token);
                    }
                }
            } finally {
                Log.endSession();
            }
        }

        /**
         * @see android.telecom.TelecomManager#isInCall
         */
@@ -1709,6 +1730,9 @@ public class TelecomServiceImpl {
    private final SettingsSecureAdapter mSettingsSecureAdapter;
    private final TelecomSystem.SyncRoot mLock;

    // Shell-command configured default System Dialer for testing. Must be null if not configured.
    private static String mDefaultSystemDialerForTest;

    public TelecomServiceImpl(
            Context context,
            CallsManager callsManager,
@@ -1747,9 +1771,16 @@ public class TelecomServiceImpl {
    }

    public static String getSystemDialerPackage(Context context) {
        if (mDefaultSystemDialerForTest != null) {
            return mDefaultSystemDialerForTest;
        }
        return context.getResources().getString(com.android.internal.R.string.config_defaultDialer);
    }

    private static void setSystemDialerPackage(String packageName) {
        mDefaultSystemDialerForTest = packageName;
    }

    public ITelecomService.Stub getBinder() {
        return mBinderImpl;
    }