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

Commit f3e83e45 authored by Santos Cordon's avatar Santos Cordon
Browse files

Dynamically obtain telecomm service from PhoneManager.java

Bug: 16206418
Change-Id: Ie8845f4baf8956d03fcaf26cb899f5fb056df6cc
parent 0769e550
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -565,9 +565,7 @@ class ContextImpl extends Context {

        registerService(PHONE_SERVICE, new ServiceFetcher() {
                public Object createService(ContextImpl ctx) {
                    IBinder b = ServiceManager.getService(TELECOMM_SERVICE);
                    return new PhoneManager(ctx.getOuterContext(),
                            ITelecommService.Stub.asInterface(b));
                    return new PhoneManager(ctx.getOuterContext());
                }});

        registerService(UI_MODE_SERVICE, new ServiceFetcher() {
+34 −20
Original line number Diff line number Diff line
@@ -30,20 +30,17 @@ public final class PhoneManager {
    private static final String TAG = PhoneManager.class.getSimpleName();

    private final Context mContext;
    private final ITelecommService mService;

    /**
     * @hide
     */
    public PhoneManager(Context context, ITelecommService service) {
    public PhoneManager(Context context) {
        Context appContext = context.getApplicationContext();
        if (appContext != null) {
            mContext = appContext;
        } else {
            mContext = context;
        }

        mService = service;
    }

    /**
@@ -56,10 +53,13 @@ public final class PhoneManager {
     * @return True if the digits were processed as an MMI code, false otherwise.
     */
    public boolean handlePinMmi(String dialString) {
        ITelecommService service = getTelecommService();
        if (service != null) {
            try {
            return mService.handlePinMmi(dialString);
                return service.handlePinMmi(dialString);
            } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelecommService#handlePinMmi", e);
                Log.e(TAG, "Error calling ITelecommService()#handlePinMmi", e);
            }
        }
        return false;
    }
@@ -71,10 +71,13 @@ public final class PhoneManager {
     * </p>
     */
    public void cancelMissedCallsNotification() {
        ITelecommService service = getTelecommService();
        if (service != null) {
            try {
            mService.cancelMissedCallsNotification();
                service.cancelMissedCallsNotification();
            } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelecommService#cancelMissedCallNotification", e);
                Log.e(TAG, "Error calling ITelecommService()#cancelMissedCallNotification", e);
            }
        }
    }

@@ -89,10 +92,13 @@ public final class PhoneManager {
     * @param showDialpad Brings up the in-call dialpad as part of showing the in-call screen.
     */
    public void showCallScreen(boolean showDialpad) {
        ITelecommService service = getTelecommService();
        if (service != null) {
            try {
            mService.showCallScreen(showDialpad);
                service.showCallScreen(showDialpad);
            } catch (RemoteException e) {
            Log.e(TAG, "Error calling ITelecommService#showCallScreen", e);
                Log.e(TAG, "Error calling ITelecommService()#showCallScreen", e);
            }
        }
    }

@@ -103,11 +109,19 @@ public final class PhoneManager {
     * </p>
     */
    public boolean isInAPhoneCall() {
        ITelecommService service = getTelecommService();
        if (service != null) {
            try {
            return mService.isInAPhoneCall();
                return service.isInAPhoneCall();
            } catch (RemoteException e) {
            Log.e(TAG, "Error caling ITelecommService#isInAPhoneCall", e);
                Log.e(TAG, "Error caling ITelecommService()#isInAPhoneCall", e);
            }
        }
        return false;
    }

    private ITelecommService getTelecommService() {
        return ITelecommService.Stub.asInterface(
                ServiceManager.getService(Context.TELECOMM_SERVICE));
    }
}