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

Commit fb92b65b authored by Roman Birg's avatar Roman Birg
Browse files

Telecom: refresh missed call notification on locale change



Ticket: OPO-610

Change-Id: If31bd443671de373ebb80a11bd583be0e590b48a
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent c427d599
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -243,6 +243,16 @@ public class CallsManager extends Call.ListenerBase implements VideoProviderProx
                mLock, this, mContactsAsyncHelper, mCallerInfoAsyncQueryFactory);
    }

    /**
     * Refreshes the missed calls notification(s).
     * @hide
     */
    public void refreshMissedCalls() {
        mMissedCallNotifier.clearMissedCallNotifications();
        mMissedCallNotifier.updateOnStartup(
                mLock, this, mContactsAsyncHelper, mCallerInfoAsyncQueryFactory);
    }

    public void setRespondViaSmsManager(RespondViaSmsManager respondViaSmsManager) {
        if (mRespondViaSmsManager != null) {
            mListeners.remove(mRespondViaSmsManager);
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ public interface MissedCallNotifier extends CallsManager.CallsManagerListener {

    void clearMissedCalls();

    void clearMissedCallNotifications();

    void showMissedCallNotification(Call call);

    void updateOnStartup(
+18 −0
Original line number Diff line number Diff line
@@ -1248,4 +1248,22 @@ public class TelecomServiceImpl {
    private TelephonyManager getTelephonyManager() {
        return (TelephonyManager)mContext.getSystemService(Context.TELEPHONY_SERVICE);
    }

    /**
     * Reposting is useful when the device configuration changes and we need to reload
     * based on resources.
     *
     * @hide
     */
    public void repostMissedCallNotification(String callingPackage) {
        synchronized (mLock) {
            enforcePermissionOrPrivilegedDialer(MODIFY_PHONE_STATE, callingPackage);
            long token = Binder.clearCallingIdentity();
            try {
                mCallsManager.refreshMissedCalls();
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }
    }
}
+30 −0
Original line number Diff line number Diff line
@@ -16,11 +16,15 @@

package com.android.server.telecom.components;

import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.Service;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.IBinder;
import android.os.RemoteException;

import com.android.internal.telephony.CallerInfoAsyncQuery;
import com.android.server.telecom.CallerInfoAsyncQueryFactory;
@@ -36,11 +40,27 @@ import com.android.server.telecom.ProximitySensorManager;
import com.android.server.telecom.TelecomSystem;
import com.android.server.telecom.ui.MissedCallNotifierImpl;

import java.util.Locale;

import libcore.util.Objects;

/**
 * Implementation of the ITelecom interface.
 */
public class TelecomService extends Service implements TelecomSystem.Component {

    private Locale mLastLocale;

    @Override
    public void onCreate() {
        super.onCreate();
        try {
            mLastLocale = ActivityManagerNative.getDefault().getConfiguration().locale;
        } catch (RemoteException e) {
            mLastLocale = null;
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.d(this, "onBind");
@@ -116,4 +136,14 @@ public class TelecomService extends Service implements TelecomSystem.Component {
    public TelecomSystem getTelecomSystem() {
        return TelecomSystem.getInstance();
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        if (!Objects.equal(mLastLocale, newConfig.locale)) {
            getTelecomSystem().getTelecomServiceImpl()
                    .repostMissedCallNotification(getPackageName());
            mLastLocale = newConfig.locale;
        }
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -257,6 +257,11 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements
        cancelMissedCallNotification();
    }

    @Override
    public void clearMissedCallNotifications() {
        cancelMissedCallNotification();
    }

    /**
     * Broadcasts missed call notification to custom component if set.
     * @param number The phone number associated with the notification. null if