summaryrefslogtreecommitdiffstats
path: root/policy/src/com/android/internal
diff options
context:
space:
mode:
authorJim Miller <jaggies@google.com>2011-08-08 22:27:58 -0700
committerJim Miller <jaggies@google.com>2011-08-29 18:29:21 -0700
commit1c18828d20807342d37000746b18a3c1696f3b2e (patch)
tree63dbcf8eba67201333fc0a4fdb025cfe385d8d50 /policy/src/com/android/internal
parentf0eb7655ac897ca06034296f7674b73a65f0e8a9 (diff)
downloadframeworks_base-1c18828d20807342d37000746b18a3c1696f3b2e.zip
frameworks_base-1c18828d20807342d37000746b18a3c1696f3b2e.tar.gz
frameworks_base-1c18828d20807342d37000746b18a3c1696f3b2e.tar.bz2
Fix 5044158: Integrate music transport control into LockScreen
This integrates a new version of TransportControlView into LockScreen and adds plumbing to handle new AudioService events to show/hide the view and updates the required assets for all devices. Updated to use new AudioManager API. Since the current API only supports one RCD, the handler now lives in TransportControlView. Change-Id: I220d4dd760bef35bd84209adc3c5829bf5bc9a2c
Diffstat (limited to 'policy/src/com/android/internal')
-rw-r--r--policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java33
-rw-r--r--policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java25
-rw-r--r--policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java52
-rw-r--r--policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java3
4 files changed, 52 insertions, 61 deletions
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java b/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
index 9629702..40cc7d8 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
@@ -20,6 +20,7 @@ import com.android.internal.R;
import com.android.internal.telephony.IccCard;
import com.android.internal.telephony.IccCard.State;
import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.widget.TransportControlView;
import com.android.internal.policy.impl.KeyguardUpdateMonitor.SimStateCallback;
import java.util.ArrayList;
@@ -52,8 +53,6 @@ class KeyguardStatusViewManager implements OnClickListener {
public static final int BATTERY_LOW_ICON = 0; //R.drawable.ic_lock_idle_low_battery;
private static final long INSTRUCTION_RESET_DELAY = 2000; // time until instruction text resets
- private static final int SHOW_WIDGET = 8;
- private static final int HIDE_WIDGET = 9;
private static final int INSTRUCTION_TEXT = 10;
private static final int CARRIER_TEXT = 11;
private static final int CARRIER_HELP_TEXT = 12;
@@ -71,7 +70,7 @@ class KeyguardStatusViewManager implements OnClickListener {
private TextView mStatus1View;
private TextView mOwnerInfoView;
private TextView mAlarmStatusView;
- private View mTransportView;
+ private TransportControlView mTransportView;
// Top-level container view for above views
private View mContainer;
@@ -162,7 +161,7 @@ class KeyguardStatusViewManager implements OnClickListener {
mStatus1View = (TextView) findViewById(R.id.status1);
mAlarmStatusView = (TextView) findViewById(R.id.alarm_status);
mOwnerInfoView = (TextView) findViewById(R.id.propertyOf);
- mTransportView = findViewById(R.id.transport);
+ mTransportView = (TransportControlView) findViewById(R.id.transport);
mEmergencyCallButton = (Button) findViewById(R.id.emergencyCallButton);
if (mEmergencyCallButton != null) {
mEmergencyCallButton.setText(R.string.lockscreen_emergency_call);
@@ -192,20 +191,6 @@ class KeyguardStatusViewManager implements OnClickListener {
mUpdateMonitor.getTelephonyPlmn(), mUpdateMonitor.getTelephonySpn()));
}
- public void enterWidgetMode() {
- if (mTransportView != null) {
- mTransportView.setVisibility(View.VISIBLE);
- update(SHOW_WIDGET, null);
- }
- }
-
- public void leaveWidgetMode() {
- if (mTransportView != null) {
- mTransportView.setVisibility(View.GONE);
- update(HIDE_WIDGET, null);
- }
- }
-
private boolean inWidgetMode() {
return mTransportView != null && mTransportView.getVisibility() == View.VISIBLE;
}
@@ -248,7 +233,8 @@ class KeyguardStatusViewManager implements OnClickListener {
* @param lockIcon
*/
public void setHelpMessage(int textResId, int lockIcon) {
- mHelpMessageText = getText(textResId).toString();
+ final CharSequence tmp = getText(textResId);
+ mHelpMessageText = tmp == null ? null : tmp.toString();
update(HELP_MESSAGE_TEXT, mHelpMessageText);
}
@@ -603,15 +589,6 @@ class KeyguardStatusViewManager implements OnClickListener {
public void onPhoneStateChanged(String newState) {
updateEmergencyCallButtonState();
}
-
- public void onTransportControlStateChanged(int state) {
- // TODO: define what state means
- if (state == 0) {
- leaveWidgetMode();
- } else {
- enterWidgetMode();
- }
- }
};
private SimStateCallback mSimStateCallback = new SimStateCallback() {
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java b/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
index 77f1932..2955de3 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
@@ -25,6 +25,7 @@ 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.media.IRemoteControlClient;
import android.os.BatteryManager;
import android.os.Handler;
import android.os.Message;
@@ -93,8 +94,6 @@ public class KeyguardUpdateMonitor {
private static final int MSG_SIM_STATE_CHANGE = 304;
private static final int MSG_RINGER_MODE_CHANGED = 305;
private static final int MSG_PHONE_STATE_CHANGED = 306;
- private static final int MSG_TRANSPORT_CONTROL_STATE_CHANGED = 307;
-
/**
* When we receive a
@@ -171,9 +170,6 @@ public class KeyguardUpdateMonitor {
case MSG_PHONE_STATE_CHANGED:
handlePhoneStateChanged((String)msg.obj);
break;
- case MSG_TRANSPORT_CONTROL_STATE_CHANGED:
- handleTransportControlStateChanged(msg.arg1);
- break;
}
}
};
@@ -263,23 +259,10 @@ public class KeyguardUpdateMonitor {
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
mHandler.sendMessage(mHandler.obtainMessage(MSG_PHONE_STATE_CHANGED, state));
}
- // TODO
- else if ("android.media.TRANSPORT_CONTROL_CHANGED".equals(action)) {
- int state = intent.getIntExtra("state", 0);
- mHandler.sendMessage(mHandler.obtainMessage(MSG_TRANSPORT_CONTROL_STATE_CHANGED,
- state));
- }
}
}, filter);
}
- protected void handleTransportControlStateChanged(int state) {
- if (DEBUG) Log.d(TAG, "handleTransportControlStateChanged()");
- for (int i = 0; i < mInfoCallbacks.size(); i++) {
- mInfoCallbacks.get(i).onTransportControlStateChanged(state);
- }
- }
-
protected void handlePhoneStateChanged(String newState) {
if (DEBUG) Log.d(TAG, "handlePhoneStateChanged(" + newState + ")");
for (int i = 0; i < mInfoCallbacks.size(); i++) {
@@ -465,11 +448,6 @@ public class KeyguardUpdateMonitor {
*/
void onPhoneStateChanged(String newState);
- /**
- * Called when AudioService informs us of a change to the transport control client.
- *
- */
- void onTransportControlStateChanged(int state);
}
/**
@@ -567,4 +545,5 @@ public class KeyguardUpdateMonitor {
public void reportFailedAttempt() {
mFailedAttempts++;
}
+
}
diff --git a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
index 5c85903..9c14734 100644
--- a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
+++ b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
@@ -20,6 +20,8 @@ import com.android.internal.R;
import com.android.internal.policy.impl.LockPatternKeyguardView.UnlockMode;
import com.android.internal.telephony.IccCard;
import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.widget.LockScreenWidgetCallback;
+import com.android.internal.widget.TransportControlView;
import android.accounts.Account;
import android.accounts.AccountManager;
@@ -66,6 +68,8 @@ import java.io.IOException;
*/
public class LockPatternKeyguardView extends KeyguardViewBase {
+ private static final int TRANSPORT_USERACTIVITY_TIMEOUT = 10000;
+
static final boolean DEBUG_CONFIGURATION = false;
// time after launching EmergencyDialer before the screen goes blank.
@@ -179,6 +183,22 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
}
};
+ private LockScreenWidgetCallback mWidgetCallback = new LockScreenWidgetCallback() {
+ public void userActivity(View self) {
+ mKeyguardScreenCallback.pokeWakelock(TRANSPORT_USERACTIVITY_TIMEOUT);
+ }
+
+ public void requestShow(View view) {
+ if (DEBUG) Log.v(TAG, "View " + view + " requested show transports");
+ view.setVisibility(View.VISIBLE);
+ }
+
+ public void requestHide(View view) {
+ if (DEBUG) Log.v(TAG, "View " + view + " requested hide transports");
+ view.setVisibility(View.GONE);
+ }
+ };
+
/**
* @return Whether we are stuck on the lock screen because the sim is
* missing.
@@ -490,6 +510,14 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
super.onDetachedFromWindow();
}
+ protected void onConfigurationChanged(Configuration newConfig) {
+ Resources resources = getResources();
+ mShowLockBeforeUnlock = resources.getBoolean(R.bool.config_enableLockBeforeUnlockScreen);
+ mConfiguration = newConfig;
+ if (DEBUG_CONFIGURATION) Log.v(TAG, "**** re-creating lock screen since config changed");
+ updateScreen(mMode, true /* force */);
+ }
+
@Override
protected boolean dispatchHoverEvent(MotionEvent event) {
// Do not let the screen to get locked while the user is disabled and touch
@@ -502,14 +530,6 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
return super.dispatchHoverEvent(event);
}
- protected void onConfigurationChanged(Configuration newConfig) {
- Resources resources = getResources();
- mShowLockBeforeUnlock = resources.getBoolean(R.bool.config_enableLockBeforeUnlockScreen);
- mConfiguration = newConfig;
- if (DEBUG_CONFIGURATION) Log.v(TAG, "**** re-creating lock screen since config changed");
- updateScreen(mMode, true /* force */);
- }
-
@Override
public void wakeWhenReadyTq(int keyCode) {
if (DEBUG) Log.d(TAG, "onWakeKey");
@@ -639,12 +659,14 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
}
View createLockScreen() {
- return new LockScreen(
+ View lockView = new LockScreen(
mContext,
mConfiguration,
mLockPatternUtils,
mUpdateMonitor,
mKeyguardScreenCallback);
+ initializeTransportControlView(lockView);
+ return lockView;
}
View createUnlockScreenFor(UnlockMode unlockMode) {
@@ -710,10 +732,22 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
} else {
throw new IllegalArgumentException("unknown unlock mode " + unlockMode);
}
+ initializeTransportControlView(unlockView);
mUnlockScreenMode = unlockMode;
return unlockView;
}
+ private void initializeTransportControlView(View view) {
+ com.android.internal.widget.TransportControlView tcv =
+ (TransportControlView) view.findViewById(R.id.transport);
+ if (tcv == null) {
+ if (DEBUG) Log.w(TAG, "Couldn't find transport control widget");
+ } else {
+ tcv.setVisibility(View.GONE); // hide tcv until we get the callback below to show it.
+ tcv.setCallback(mWidgetCallback);
+ }
+ }
+
/**
* Given the current state of things, what should be the initial mode of
* the lock screen (lock or unlock).
diff --git a/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java b/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
index ce3bc74..2f2d3b7 100644
--- a/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
@@ -347,7 +347,8 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
// Check if this was the result of hitting the enter key
- if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_DONE) {
+ if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_DONE
+ || actionId == EditorInfo.IME_ACTION_NEXT) {
verifyPasswordAndUnlock();
return true;
}