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

Commit 84766903 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change I9987ba41 into eclair

* changes:
  Fix 2270597: Add callback to watch ringer state and update lock screen UI when it changes.
parents f275f0c0 47088bbb
Loading
Loading
Loading
Loading
+38 −15
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.database.ContentObserver;
import static android.os.BatteryManager.BATTERY_STATUS_CHARGING;
import static android.os.BatteryManager.BATTERY_STATUS_FULL;
import static android.os.BatteryManager.BATTERY_STATUS_UNKNOWN;
import android.media.AudioManager;
import android.os.Handler;
import android.os.Message;
import android.provider.Settings;
@@ -94,6 +95,7 @@ public class KeyguardUpdateMonitor {
    private static final int MSG_BATTERY_UPDATE = 302;
    private static final int MSG_CARRIER_INFO_UPDATE = 303;
    private static final int MSG_SIM_STATE_CHANGE = 304;
    private static final int MSG_RINGER_MODE_CHANGED = 305;


    /**
@@ -160,6 +162,9 @@ public class KeyguardUpdateMonitor {
                    case MSG_SIM_STATE_CHANGE:
                        handleSimStateChange((SimArgs) msg.obj);
                        break;
                    case MSG_RINGER_MODE_CHANGED:
                        handleRingerModeChange(msg.arg1);
                        break;
                }
            }
        };
@@ -217,6 +222,7 @@ public class KeyguardUpdateMonitor {
        filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
        filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
        filter.addAction(SPN_STRINGS_UPDATED_ACTION);
        filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
        context.registerReceiver(new BroadcastReceiver() {

            public void onReceive(Context context, Intent intent) {
@@ -246,11 +252,21 @@ public class KeyguardUpdateMonitor {
                    mHandler.sendMessage(mHandler.obtainMessage(
                            MSG_SIM_STATE_CHANGE,
                            new SimArgs(intent)));
                } else if (AudioManager.RINGER_MODE_CHANGED_ACTION.equals(action)) {
                    mHandler.sendMessage(mHandler.obtainMessage(MSG_RINGER_MODE_CHANGED,
                            intent.getIntExtra(AudioManager.EXTRA_RINGER_MODE, -1), 0));
                }
            }
        }, filter);
    }

    protected void handleRingerModeChange(int mode) {
        if (DEBUG) Log.d(TAG, "handleRingerModeChange(" + mode + ")");
        for (int i = 0; i < mInfoCallbacks.size(); i++) {
            mInfoCallbacks.get(i).onRingerModeChanged(mode);
        }
    }

    /**
     * Handle {@link #MSG_CONFIGURATION_CHANGED}
     */
@@ -443,7 +459,7 @@ public class KeyguardUpdateMonitor {
    }

    /**
     * Callback for general information releveant to lock screen.
     * Callback for general information relevant to lock screen.
     */
    interface InfoCallback {
        void onRefreshBatteryInfo(boolean showBatteryInfo, boolean pluggedIn, int batteryLevel);
@@ -455,6 +471,13 @@ public class KeyguardUpdateMonitor {
         * @param spn The service provider name.  May be null if it shouldn't be displayed.
         */
        void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn);

        /**
         * Called when the ringer mode changes.
         * @param state the current ringer state, as defined in
         * {@link AudioManager#RINGER_MODE_CHANGED_ACTION}
         */
        void onRingerModeChanged(int state);
    }

    /**
+10 −2
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import android.os.SystemProperties;

import java.util.Date;
import java.io.File;
import java.text.SimpleDateFormat;

/**
 * The screen within {@link LockPatternKeyguardView} that shows general
@@ -577,4 +576,13 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
    public void cleanUp() {
        mUpdateMonitor.removeCallback(this);
    }

    /** {@inheritDoc} */
    public void onRingerModeChanged(int state) {
        boolean silent = AudioManager.RINGER_MODE_SILENT == state;
        if (silent != mSilentMode) {
            mSilentMode = silent;
            updateRightTabResources();
        }
    }
}
+12 −7
Original line number Diff line number Diff line
@@ -368,6 +368,11 @@ class UnlockScreen extends LinearLayoutWithDefaultTouchRecepient
        mCarrier.setText(LockScreen.getCarrierString(plmn, spn));
    }

    /** {@inheritDoc} */
    public void onRingerModeChanged(int state) {
        // not currently used
    }

    // ---------- SimStateCallback

    /** {@inheritDoc} */