TransportControlView.java revision 261381cf9f52776f5f5fad8e6d2d31960c60c945
16b05d58018c2806459c121e507c005639b74aee9Jim Miller/* 26b05d58018c2806459c121e507c005639b74aee9Jim Miller * Copyright (C) 2011 The Android Open Source Project 36b05d58018c2806459c121e507c005639b74aee9Jim Miller * 46b05d58018c2806459c121e507c005639b74aee9Jim Miller * Licensed under the Apache License, Version 2.0 (the "License"); 56b05d58018c2806459c121e507c005639b74aee9Jim Miller * you may not use this file except in compliance with the License. 66b05d58018c2806459c121e507c005639b74aee9Jim Miller * You may obtain a copy of the License at 76b05d58018c2806459c121e507c005639b74aee9Jim Miller * 86b05d58018c2806459c121e507c005639b74aee9Jim Miller * http://www.apache.org/licenses/LICENSE-2.0 96b05d58018c2806459c121e507c005639b74aee9Jim Miller * 106b05d58018c2806459c121e507c005639b74aee9Jim Miller * Unless required by applicable law or agreed to in writing, software 116b05d58018c2806459c121e507c005639b74aee9Jim Miller * distributed under the License is distributed on an "AS IS" BASIS, 126b05d58018c2806459c121e507c005639b74aee9Jim Miller * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 136b05d58018c2806459c121e507c005639b74aee9Jim Miller * See the License for the specific language governing permissions and 146b05d58018c2806459c121e507c005639b74aee9Jim Miller * limitations under the License. 156b05d58018c2806459c121e507c005639b74aee9Jim Miller */ 166b05d58018c2806459c121e507c005639b74aee9Jim Miller 176b05d58018c2806459c121e507c005639b74aee9Jim Millerpackage com.android.internal.widget; 186b05d58018c2806459c121e507c005639b74aee9Jim Miller 191c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport java.lang.ref.WeakReference; 201c18828d20807342d37000746b18a3c1696f3b2eJim Miller 211c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport com.android.internal.widget.LockScreenWidgetCallback; 221c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport com.android.internal.widget.LockScreenWidgetInterface; 236b05d58018c2806459c121e507c005639b74aee9Jim Miller 24f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Triviimport android.app.PendingIntent; 25f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Triviimport android.app.PendingIntent.CanceledException; 261c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport android.content.ComponentName; 276b05d58018c2806459c121e507c005639b74aee9Jim Millerimport android.content.Context; 281c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport android.content.Intent; 291c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport android.graphics.Bitmap; 306b05d58018c2806459c121e507c005639b74aee9Jim Millerimport android.media.AudioManager; 311c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport android.media.MediaMetadataRetriever; 321c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport android.media.RemoteControlClient; 331c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport android.media.IRemoteControlDisplay; 341c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport android.os.Bundle; 356b05d58018c2806459c121e507c005639b74aee9Jim Millerimport android.os.Handler; 366b05d58018c2806459c121e507c005639b74aee9Jim Millerimport android.os.Message; 371c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport android.os.RemoteException; 3868622396b62f9084781add1e12f4d513b633ab54Jean-Michel Triviimport android.os.SystemClock; 391c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport android.text.Spannable; 401c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport android.text.TextUtils; 411c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport android.text.style.ForegroundColorSpan; 426b05d58018c2806459c121e507c005639b74aee9Jim Millerimport android.util.AttributeSet; 431c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport android.util.Log; 441c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport android.view.KeyEvent; 456b05d58018c2806459c121e507c005639b74aee9Jim Millerimport android.view.View; 466b05d58018c2806459c121e507c005639b74aee9Jim Millerimport android.view.View.OnClickListener; 471c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport android.widget.FrameLayout; 481c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport android.widget.ImageView; 491c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport android.widget.TextView; 506b05d58018c2806459c121e507c005639b74aee9Jim Miller 516b05d58018c2806459c121e507c005639b74aee9Jim Miller 521c18828d20807342d37000746b18a3c1696f3b2eJim Millerimport com.android.internal.R; 531c18828d20807342d37000746b18a3c1696f3b2eJim Miller 541c18828d20807342d37000746b18a3c1696f3b2eJim Millerpublic class TransportControlView extends FrameLayout implements OnClickListener, 551c18828d20807342d37000746b18a3c1696f3b2eJim Miller LockScreenWidgetInterface { 561c18828d20807342d37000746b18a3c1696f3b2eJim Miller 571c18828d20807342d37000746b18a3c1696f3b2eJim Miller private static final int MSG_UPDATE_STATE = 100; 581c18828d20807342d37000746b18a3c1696f3b2eJim Miller private static final int MSG_SET_METADATA = 101; 591c18828d20807342d37000746b18a3c1696f3b2eJim Miller private static final int MSG_SET_TRANSPORT_CONTROLS = 102; 601c18828d20807342d37000746b18a3c1696f3b2eJim Miller private static final int MSG_SET_ARTWORK = 103; 611c18828d20807342d37000746b18a3c1696f3b2eJim Miller private static final int MSG_SET_GENERATION_ID = 104; 621c18828d20807342d37000746b18a3c1696f3b2eJim Miller private static final int MAXDIM = 512; 6368622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi private static final int DISPLAY_TIMEOUT_MS = 5000; // 5s 641c18828d20807342d37000746b18a3c1696f3b2eJim Miller protected static final boolean DEBUG = true; 651c18828d20807342d37000746b18a3c1696f3b2eJim Miller protected static final String TAG = "TransportControlView"; 661c18828d20807342d37000746b18a3c1696f3b2eJim Miller 671c18828d20807342d37000746b18a3c1696f3b2eJim Miller private ImageView mAlbumArt; 681c18828d20807342d37000746b18a3c1696f3b2eJim Miller private TextView mTrackTitle; 691c18828d20807342d37000746b18a3c1696f3b2eJim Miller private ImageView mBtnPrev; 701c18828d20807342d37000746b18a3c1696f3b2eJim Miller private ImageView mBtnPlay; 711c18828d20807342d37000746b18a3c1696f3b2eJim Miller private ImageView mBtnNext; 721c18828d20807342d37000746b18a3c1696f3b2eJim Miller private int mClientGeneration; 731c18828d20807342d37000746b18a3c1696f3b2eJim Miller private Metadata mMetadata = new Metadata(); 741c18828d20807342d37000746b18a3c1696f3b2eJim Miller private boolean mAttached; 75f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi private PendingIntent mClientIntent; 761c18828d20807342d37000746b18a3c1696f3b2eJim Miller private int mTransportControlFlags; 771c18828d20807342d37000746b18a3c1696f3b2eJim Miller private int mPlayState; 781c18828d20807342d37000746b18a3c1696f3b2eJim Miller private AudioManager mAudioManager; 791c18828d20807342d37000746b18a3c1696f3b2eJim Miller private LockScreenWidgetCallback mWidgetCallbacks; 801c18828d20807342d37000746b18a3c1696f3b2eJim Miller private IRemoteControlDisplayWeak mIRCD; 811c18828d20807342d37000746b18a3c1696f3b2eJim Miller 821c18828d20807342d37000746b18a3c1696f3b2eJim Miller /** 831c18828d20807342d37000746b18a3c1696f3b2eJim Miller * The metadata which should be populated into the view once we've been attached 841c18828d20807342d37000746b18a3c1696f3b2eJim Miller */ 851c18828d20807342d37000746b18a3c1696f3b2eJim Miller private Bundle mPopulateMetadataWhenAttached = null; 861c18828d20807342d37000746b18a3c1696f3b2eJim Miller 871c18828d20807342d37000746b18a3c1696f3b2eJim Miller // This handler is required to ensure messages from IRCD are handled in sequence and on 881c18828d20807342d37000746b18a3c1696f3b2eJim Miller // the UI thread. 896b05d58018c2806459c121e507c005639b74aee9Jim Miller private Handler mHandler = new Handler() { 901c18828d20807342d37000746b18a3c1696f3b2eJim Miller @Override 916b05d58018c2806459c121e507c005639b74aee9Jim Miller public void handleMessage(Message msg) { 921c18828d20807342d37000746b18a3c1696f3b2eJim Miller switch (msg.what) { 931c18828d20807342d37000746b18a3c1696f3b2eJim Miller case MSG_UPDATE_STATE: 941c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (mClientGeneration == msg.arg1) updatePlayPauseState(msg.arg2); 951c18828d20807342d37000746b18a3c1696f3b2eJim Miller break; 961c18828d20807342d37000746b18a3c1696f3b2eJim Miller 971c18828d20807342d37000746b18a3c1696f3b2eJim Miller case MSG_SET_METADATA: 981c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (mClientGeneration == msg.arg1) updateMetadata((Bundle) msg.obj); 991c18828d20807342d37000746b18a3c1696f3b2eJim Miller break; 1001c18828d20807342d37000746b18a3c1696f3b2eJim Miller 1011c18828d20807342d37000746b18a3c1696f3b2eJim Miller case MSG_SET_TRANSPORT_CONTROLS: 1021c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (mClientGeneration == msg.arg1) updateTransportControls(msg.arg2); 1031c18828d20807342d37000746b18a3c1696f3b2eJim Miller break; 1041c18828d20807342d37000746b18a3c1696f3b2eJim Miller 1051c18828d20807342d37000746b18a3c1696f3b2eJim Miller case MSG_SET_ARTWORK: 1061c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (mClientGeneration == msg.arg1) { 10701d96bd2afdcff866e0e1010eb7c88e101d0f6faJean-Michel Trivi if (mMetadata.bitmap != null) { 10801d96bd2afdcff866e0e1010eb7c88e101d0f6faJean-Michel Trivi mMetadata.bitmap.recycle(); 10901d96bd2afdcff866e0e1010eb7c88e101d0f6faJean-Michel Trivi } 1101c18828d20807342d37000746b18a3c1696f3b2eJim Miller mMetadata.bitmap = (Bitmap) msg.obj; 1111c18828d20807342d37000746b18a3c1696f3b2eJim Miller mAlbumArt.setImageBitmap(mMetadata.bitmap); 1121c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 1131c18828d20807342d37000746b18a3c1696f3b2eJim Miller break; 1141c18828d20807342d37000746b18a3c1696f3b2eJim Miller 1151c18828d20807342d37000746b18a3c1696f3b2eJim Miller case MSG_SET_GENERATION_ID: 1161c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (mWidgetCallbacks != null) { 1171c18828d20807342d37000746b18a3c1696f3b2eJim Miller boolean clearing = msg.arg2 != 0; 1181c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (DEBUG) Log.v(TAG, "New genId = " + msg.arg1 + ", clearing = " + clearing); 1191c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (!clearing) { 1201c18828d20807342d37000746b18a3c1696f3b2eJim Miller mWidgetCallbacks.requestShow(TransportControlView.this); 1211c18828d20807342d37000746b18a3c1696f3b2eJim Miller } else { 1221c18828d20807342d37000746b18a3c1696f3b2eJim Miller mWidgetCallbacks.requestHide(TransportControlView.this); 1231c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 1241c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 1251c18828d20807342d37000746b18a3c1696f3b2eJim Miller mClientGeneration = msg.arg1; 126f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi mClientIntent = (PendingIntent) msg.obj; 1271c18828d20807342d37000746b18a3c1696f3b2eJim Miller break; 1281c18828d20807342d37000746b18a3c1696f3b2eJim Miller 1296b05d58018c2806459c121e507c005639b74aee9Jim Miller } 1306b05d58018c2806459c121e507c005639b74aee9Jim Miller } 1316b05d58018c2806459c121e507c005639b74aee9Jim Miller }; 1326b05d58018c2806459c121e507c005639b74aee9Jim Miller 1331c18828d20807342d37000746b18a3c1696f3b2eJim Miller /** 1341c18828d20807342d37000746b18a3c1696f3b2eJim Miller * This class is required to have weak linkage to the current TransportControlView 1351c18828d20807342d37000746b18a3c1696f3b2eJim Miller * because the remote process can hold a strong reference to this binder object and 1361c18828d20807342d37000746b18a3c1696f3b2eJim Miller * we can't predict when it will be GC'd in the remote process. Without this code, it 1371c18828d20807342d37000746b18a3c1696f3b2eJim Miller * would allow a heavyweight object to be held on this side of the binder when there's 1381c18828d20807342d37000746b18a3c1696f3b2eJim Miller * no requirement to run a GC on the other side. 1391c18828d20807342d37000746b18a3c1696f3b2eJim Miller */ 1401c18828d20807342d37000746b18a3c1696f3b2eJim Miller private static class IRemoteControlDisplayWeak extends IRemoteControlDisplay.Stub { 1411c18828d20807342d37000746b18a3c1696f3b2eJim Miller private WeakReference<Handler> mLocalHandler; 1421c18828d20807342d37000746b18a3c1696f3b2eJim Miller 1431c18828d20807342d37000746b18a3c1696f3b2eJim Miller IRemoteControlDisplayWeak(Handler handler) { 1441c18828d20807342d37000746b18a3c1696f3b2eJim Miller mLocalHandler = new WeakReference<Handler>(handler); 1451c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 1461c18828d20807342d37000746b18a3c1696f3b2eJim Miller 14768622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi public void setPlaybackState(int generationId, int state, long stateChangeTimeMs) { 1481c18828d20807342d37000746b18a3c1696f3b2eJim Miller Handler handler = mLocalHandler.get(); 1491c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (handler != null) { 1501c18828d20807342d37000746b18a3c1696f3b2eJim Miller handler.obtainMessage(MSG_UPDATE_STATE, generationId, state).sendToTarget(); 1516b05d58018c2806459c121e507c005639b74aee9Jim Miller } 1521c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 1536b05d58018c2806459c121e507c005639b74aee9Jim Miller 1541c18828d20807342d37000746b18a3c1696f3b2eJim Miller public void setMetadata(int generationId, Bundle metadata) { 1551c18828d20807342d37000746b18a3c1696f3b2eJim Miller Handler handler = mLocalHandler.get(); 1561c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (handler != null) { 1571c18828d20807342d37000746b18a3c1696f3b2eJim Miller handler.obtainMessage(MSG_SET_METADATA, generationId, 0, metadata).sendToTarget(); 1581c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 1591c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 1601c18828d20807342d37000746b18a3c1696f3b2eJim Miller 1611c18828d20807342d37000746b18a3c1696f3b2eJim Miller public void setTransportControlFlags(int generationId, int flags) { 1621c18828d20807342d37000746b18a3c1696f3b2eJim Miller Handler handler = mLocalHandler.get(); 1631c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (handler != null) { 1641c18828d20807342d37000746b18a3c1696f3b2eJim Miller handler.obtainMessage(MSG_SET_TRANSPORT_CONTROLS, generationId, flags) 1651c18828d20807342d37000746b18a3c1696f3b2eJim Miller .sendToTarget(); 1661c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 1671c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 1681c18828d20807342d37000746b18a3c1696f3b2eJim Miller 1691c18828d20807342d37000746b18a3c1696f3b2eJim Miller public void setArtwork(int generationId, Bitmap bitmap) { 1701c18828d20807342d37000746b18a3c1696f3b2eJim Miller Handler handler = mLocalHandler.get(); 1711c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (handler != null) { 1721c18828d20807342d37000746b18a3c1696f3b2eJim Miller handler.obtainMessage(MSG_SET_ARTWORK, generationId, 0, bitmap).sendToTarget(); 1731c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 1741c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 1751c18828d20807342d37000746b18a3c1696f3b2eJim Miller 1761c18828d20807342d37000746b18a3c1696f3b2eJim Miller public void setAllMetadata(int generationId, Bundle metadata, Bitmap bitmap) { 1771c18828d20807342d37000746b18a3c1696f3b2eJim Miller Handler handler = mLocalHandler.get(); 1781c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (handler != null) { 1791c18828d20807342d37000746b18a3c1696f3b2eJim Miller handler.obtainMessage(MSG_SET_METADATA, generationId, 0, metadata).sendToTarget(); 1801c18828d20807342d37000746b18a3c1696f3b2eJim Miller handler.obtainMessage(MSG_SET_ARTWORK, generationId, 0, bitmap).sendToTarget(); 1811c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 1821c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 1831c18828d20807342d37000746b18a3c1696f3b2eJim Miller 184f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi public void setCurrentClientId(int clientGeneration, PendingIntent mediaIntent, 1851c18828d20807342d37000746b18a3c1696f3b2eJim Miller boolean clearing) throws RemoteException { 1861c18828d20807342d37000746b18a3c1696f3b2eJim Miller Handler handler = mLocalHandler.get(); 1871c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (handler != null) { 1881c18828d20807342d37000746b18a3c1696f3b2eJim Miller handler.obtainMessage(MSG_SET_GENERATION_ID, 189f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi clientGeneration, (clearing ? 1 : 0), mediaIntent).sendToTarget(); 1901c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 1911c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 1921c18828d20807342d37000746b18a3c1696f3b2eJim Miller }; 1936b05d58018c2806459c121e507c005639b74aee9Jim Miller 1946b05d58018c2806459c121e507c005639b74aee9Jim Miller public TransportControlView(Context context, AttributeSet attrs) { 1956b05d58018c2806459c121e507c005639b74aee9Jim Miller super(context, attrs); 1961c18828d20807342d37000746b18a3c1696f3b2eJim Miller Log.v(TAG, "Create TCV " + this); 1971c18828d20807342d37000746b18a3c1696f3b2eJim Miller mAudioManager = new AudioManager(mContext); 1981c18828d20807342d37000746b18a3c1696f3b2eJim Miller mIRCD = new IRemoteControlDisplayWeak(mHandler); 1996b05d58018c2806459c121e507c005639b74aee9Jim Miller } 2006b05d58018c2806459c121e507c005639b74aee9Jim Miller 2011c18828d20807342d37000746b18a3c1696f3b2eJim Miller private void updateTransportControls(int transportControlFlags) { 2021c18828d20807342d37000746b18a3c1696f3b2eJim Miller mTransportControlFlags = transportControlFlags; 2036b05d58018c2806459c121e507c005639b74aee9Jim Miller } 2046b05d58018c2806459c121e507c005639b74aee9Jim Miller 2051c18828d20807342d37000746b18a3c1696f3b2eJim Miller @Override 2061c18828d20807342d37000746b18a3c1696f3b2eJim Miller public void onFinishInflate() { 2071c18828d20807342d37000746b18a3c1696f3b2eJim Miller super.onFinishInflate(); 2081c18828d20807342d37000746b18a3c1696f3b2eJim Miller mTrackTitle = (TextView) findViewById(R.id.title); 2091c18828d20807342d37000746b18a3c1696f3b2eJim Miller mTrackTitle.setSelected(true); // enable marquee 2101c18828d20807342d37000746b18a3c1696f3b2eJim Miller mAlbumArt = (ImageView) findViewById(R.id.albumart); 2111c18828d20807342d37000746b18a3c1696f3b2eJim Miller mBtnPrev = (ImageView) findViewById(R.id.btn_prev); 2121c18828d20807342d37000746b18a3c1696f3b2eJim Miller mBtnPlay = (ImageView) findViewById(R.id.btn_play); 2131c18828d20807342d37000746b18a3c1696f3b2eJim Miller mBtnNext = (ImageView) findViewById(R.id.btn_next); 2141c18828d20807342d37000746b18a3c1696f3b2eJim Miller final View buttons[] = { mBtnPrev, mBtnPlay, mBtnNext }; 2151c18828d20807342d37000746b18a3c1696f3b2eJim Miller for (View view : buttons) { 2161c18828d20807342d37000746b18a3c1696f3b2eJim Miller view.setOnClickListener(this); 2171c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 2186b05d58018c2806459c121e507c005639b74aee9Jim Miller } 2196b05d58018c2806459c121e507c005639b74aee9Jim Miller 2206b05d58018c2806459c121e507c005639b74aee9Jim Miller @Override 2211c18828d20807342d37000746b18a3c1696f3b2eJim Miller public void onAttachedToWindow() { 2221c18828d20807342d37000746b18a3c1696f3b2eJim Miller super.onAttachedToWindow(); 2231c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (mPopulateMetadataWhenAttached != null) { 2241c18828d20807342d37000746b18a3c1696f3b2eJim Miller updateMetadata(mPopulateMetadataWhenAttached); 2251c18828d20807342d37000746b18a3c1696f3b2eJim Miller mPopulateMetadataWhenAttached = null; 2261c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 2271c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (!mAttached) { 2281c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (DEBUG) Log.v(TAG, "Registering TCV " + this); 2291c18828d20807342d37000746b18a3c1696f3b2eJim Miller mAudioManager.registerRemoteControlDisplay(mIRCD); 2301c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 2311c18828d20807342d37000746b18a3c1696f3b2eJim Miller mAttached = true; 2321c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 2331c18828d20807342d37000746b18a3c1696f3b2eJim Miller 2341c18828d20807342d37000746b18a3c1696f3b2eJim Miller @Override 2351c18828d20807342d37000746b18a3c1696f3b2eJim Miller public void onDetachedFromWindow() { 2361c18828d20807342d37000746b18a3c1696f3b2eJim Miller super.onDetachedFromWindow(); 2371c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (mAttached) { 2381c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (DEBUG) Log.v(TAG, "Unregistering TCV " + this); 2391c18828d20807342d37000746b18a3c1696f3b2eJim Miller mAudioManager.unregisterRemoteControlDisplay(mIRCD); 2401c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 2411c18828d20807342d37000746b18a3c1696f3b2eJim Miller mAttached = false; 2421c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 2431c18828d20807342d37000746b18a3c1696f3b2eJim Miller 2441c18828d20807342d37000746b18a3c1696f3b2eJim Miller @Override 2451c18828d20807342d37000746b18a3c1696f3b2eJim Miller protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 2461c18828d20807342d37000746b18a3c1696f3b2eJim Miller super.onMeasure(widthMeasureSpec, heightMeasureSpec); 2471c18828d20807342d37000746b18a3c1696f3b2eJim Miller int dim = Math.min(MAXDIM, Math.max(getWidth(), getHeight())); 2481c18828d20807342d37000746b18a3c1696f3b2eJim Miller// Log.v(TAG, "setting max bitmap size: " + dim + "x" + dim); 2491c18828d20807342d37000746b18a3c1696f3b2eJim Miller// mAudioManager.remoteControlDisplayUsesBitmapSize(mIRCD, dim, dim); 2501c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 2511c18828d20807342d37000746b18a3c1696f3b2eJim Miller 2521c18828d20807342d37000746b18a3c1696f3b2eJim Miller class Metadata { 2531c18828d20807342d37000746b18a3c1696f3b2eJim Miller private String artist; 2541c18828d20807342d37000746b18a3c1696f3b2eJim Miller private String trackTitle; 2551c18828d20807342d37000746b18a3c1696f3b2eJim Miller private String albumTitle; 2561c18828d20807342d37000746b18a3c1696f3b2eJim Miller private Bitmap bitmap; 2571c18828d20807342d37000746b18a3c1696f3b2eJim Miller 2581c18828d20807342d37000746b18a3c1696f3b2eJim Miller public String toString() { 2591c18828d20807342d37000746b18a3c1696f3b2eJim Miller return "Metadata[artist=" + artist + " trackTitle=" + trackTitle + " albumTitle=" + albumTitle + "]"; 2601c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 2611c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 2621c18828d20807342d37000746b18a3c1696f3b2eJim Miller 2631c18828d20807342d37000746b18a3c1696f3b2eJim Miller private String getMdString(Bundle data, int id) { 2641c18828d20807342d37000746b18a3c1696f3b2eJim Miller return data.getString(Integer.toString(id)); 2651c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 2661c18828d20807342d37000746b18a3c1696f3b2eJim Miller 2671c18828d20807342d37000746b18a3c1696f3b2eJim Miller private void updateMetadata(Bundle data) { 2681c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (mAttached) { 2691c18828d20807342d37000746b18a3c1696f3b2eJim Miller mMetadata.artist = getMdString(data, MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST); 2701c18828d20807342d37000746b18a3c1696f3b2eJim Miller mMetadata.trackTitle = getMdString(data, MediaMetadataRetriever.METADATA_KEY_TITLE); 2711c18828d20807342d37000746b18a3c1696f3b2eJim Miller mMetadata.albumTitle = getMdString(data, MediaMetadataRetriever.METADATA_KEY_ALBUM); 2721c18828d20807342d37000746b18a3c1696f3b2eJim Miller populateMetadata(); 2731c18828d20807342d37000746b18a3c1696f3b2eJim Miller } else { 2741c18828d20807342d37000746b18a3c1696f3b2eJim Miller mPopulateMetadataWhenAttached = data; 2751c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 2761c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 2771c18828d20807342d37000746b18a3c1696f3b2eJim Miller 2781c18828d20807342d37000746b18a3c1696f3b2eJim Miller /** 2791c18828d20807342d37000746b18a3c1696f3b2eJim Miller * Populates the given metadata into the view 2801c18828d20807342d37000746b18a3c1696f3b2eJim Miller */ 2811c18828d20807342d37000746b18a3c1696f3b2eJim Miller private void populateMetadata() { 2821c18828d20807342d37000746b18a3c1696f3b2eJim Miller StringBuilder sb = new StringBuilder(); 2831c18828d20807342d37000746b18a3c1696f3b2eJim Miller int trackTitleLength = 0; 2841c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (!TextUtils.isEmpty(mMetadata.trackTitle)) { 2851c18828d20807342d37000746b18a3c1696f3b2eJim Miller sb.append(mMetadata.trackTitle); 2861c18828d20807342d37000746b18a3c1696f3b2eJim Miller trackTitleLength = mMetadata.trackTitle.length(); 2871c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 2881c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (!TextUtils.isEmpty(mMetadata.artist)) { 2891c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (sb.length() != 0) { 2901c18828d20807342d37000746b18a3c1696f3b2eJim Miller sb.append(" - "); 2911c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 2921c18828d20807342d37000746b18a3c1696f3b2eJim Miller sb.append(mMetadata.artist); 2931c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 2941c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (!TextUtils.isEmpty(mMetadata.albumTitle)) { 2951c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (sb.length() != 0) { 2961c18828d20807342d37000746b18a3c1696f3b2eJim Miller sb.append(" - "); 2976b05d58018c2806459c121e507c005639b74aee9Jim Miller } 2981c18828d20807342d37000746b18a3c1696f3b2eJim Miller sb.append(mMetadata.albumTitle); 2991c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 3001c18828d20807342d37000746b18a3c1696f3b2eJim Miller mTrackTitle.setText(sb.toString(), TextView.BufferType.SPANNABLE); 3011c18828d20807342d37000746b18a3c1696f3b2eJim Miller Spannable str = (Spannable) mTrackTitle.getText(); 3021c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (trackTitleLength != 0) { 3031c18828d20807342d37000746b18a3c1696f3b2eJim Miller str.setSpan(new ForegroundColorSpan(0xffffffff), 0, trackTitleLength, 3041c18828d20807342d37000746b18a3c1696f3b2eJim Miller Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); 3051c18828d20807342d37000746b18a3c1696f3b2eJim Miller trackTitleLength++; 3061c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 3071c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (sb.length() > trackTitleLength) { 3081c18828d20807342d37000746b18a3c1696f3b2eJim Miller str.setSpan(new ForegroundColorSpan(0x7fffffff), trackTitleLength, sb.length(), 3091c18828d20807342d37000746b18a3c1696f3b2eJim Miller Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); 3106b05d58018c2806459c121e507c005639b74aee9Jim Miller } 3111c18828d20807342d37000746b18a3c1696f3b2eJim Miller 3121c18828d20807342d37000746b18a3c1696f3b2eJim Miller mAlbumArt.setImageBitmap(mMetadata.bitmap); 3131c18828d20807342d37000746b18a3c1696f3b2eJim Miller final int flags = mTransportControlFlags; 3141c18828d20807342d37000746b18a3c1696f3b2eJim Miller setVisibilityBasedOnFlag(mBtnPrev, flags, RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS); 3151c18828d20807342d37000746b18a3c1696f3b2eJim Miller setVisibilityBasedOnFlag(mBtnNext, flags, RemoteControlClient.FLAG_KEY_MEDIA_NEXT); 3161c18828d20807342d37000746b18a3c1696f3b2eJim Miller setVisibilityBasedOnFlag(mBtnPrev, flags, 3171c18828d20807342d37000746b18a3c1696f3b2eJim Miller RemoteControlClient.FLAG_KEY_MEDIA_PLAY 3181c18828d20807342d37000746b18a3c1696f3b2eJim Miller | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE 3191c18828d20807342d37000746b18a3c1696f3b2eJim Miller | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE 3201c18828d20807342d37000746b18a3c1696f3b2eJim Miller | RemoteControlClient.FLAG_KEY_MEDIA_STOP); 3211c18828d20807342d37000746b18a3c1696f3b2eJim Miller 3221c18828d20807342d37000746b18a3c1696f3b2eJim Miller updatePlayPauseState(mPlayState); 3236b05d58018c2806459c121e507c005639b74aee9Jim Miller } 3246b05d58018c2806459c121e507c005639b74aee9Jim Miller 3251c18828d20807342d37000746b18a3c1696f3b2eJim Miller private static void setVisibilityBasedOnFlag(View view, int flags, int flag) { 3261c18828d20807342d37000746b18a3c1696f3b2eJim Miller if ((flags & flag) != 0) { 3271c18828d20807342d37000746b18a3c1696f3b2eJim Miller view.setVisibility(View.VISIBLE); 3281c18828d20807342d37000746b18a3c1696f3b2eJim Miller } else { 3291c18828d20807342d37000746b18a3c1696f3b2eJim Miller view.setVisibility(View.GONE); 3301c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 3311c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 3321c18828d20807342d37000746b18a3c1696f3b2eJim Miller 3331c18828d20807342d37000746b18a3c1696f3b2eJim Miller private void updatePlayPauseState(int state) { 3341c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (DEBUG) Log.v(TAG, 3351c18828d20807342d37000746b18a3c1696f3b2eJim Miller "updatePlayPauseState(), old=" + mPlayState + ", state=" + state); 3361c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (state == mPlayState) { 3371c18828d20807342d37000746b18a3c1696f3b2eJim Miller return; 3381c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 33967e043db11b29f3c0c84529ae21a0fdd7ae11c6dJim Miller final int imageResId; 34067e043db11b29f3c0c84529ae21a0fdd7ae11c6dJim Miller final int imageDescId; 3411c18828d20807342d37000746b18a3c1696f3b2eJim Miller switch (state) { 342261381cf9f52776f5f5fad8e6d2d31960c60c945Jean-Michel Trivi case RemoteControlClient.PLAYSTATE_ERROR: 343261381cf9f52776f5f5fad8e6d2d31960c60c945Jean-Michel Trivi imageResId = com.android.internal.R.drawable.stat_sys_warning; 344261381cf9f52776f5f5fad8e6d2d31960c60c945Jean-Michel Trivi // TODO use more specific image description string for warning, but here the "play" 345261381cf9f52776f5f5fad8e6d2d31960c60c945Jean-Michel Trivi // message is still valid because this button triggers a play command. 346261381cf9f52776f5f5fad8e6d2d31960c60c945Jean-Michel Trivi imageDescId = com.android.internal.R.string.lockscreen_transport_play_description; 347261381cf9f52776f5f5fad8e6d2d31960c60c945Jean-Michel Trivi break; 348261381cf9f52776f5f5fad8e6d2d31960c60c945Jean-Michel Trivi 3491c18828d20807342d37000746b18a3c1696f3b2eJim Miller case RemoteControlClient.PLAYSTATE_PLAYING: 35067e043db11b29f3c0c84529ae21a0fdd7ae11c6dJim Miller imageResId = com.android.internal.R.drawable.ic_media_pause; 35167e043db11b29f3c0c84529ae21a0fdd7ae11c6dJim Miller imageDescId = com.android.internal.R.string.lockscreen_transport_pause_description; 3526b05d58018c2806459c121e507c005639b74aee9Jim Miller break; 3536b05d58018c2806459c121e507c005639b74aee9Jim Miller 3541c18828d20807342d37000746b18a3c1696f3b2eJim Miller case RemoteControlClient.PLAYSTATE_BUFFERING: 35567e043db11b29f3c0c84529ae21a0fdd7ae11c6dJim Miller imageResId = com.android.internal.R.drawable.ic_media_stop; 35667e043db11b29f3c0c84529ae21a0fdd7ae11c6dJim Miller imageDescId = com.android.internal.R.string.lockscreen_transport_stop_description; 3576b05d58018c2806459c121e507c005639b74aee9Jim Miller break; 3586b05d58018c2806459c121e507c005639b74aee9Jim Miller 3591c18828d20807342d37000746b18a3c1696f3b2eJim Miller case RemoteControlClient.PLAYSTATE_PAUSED: 3601c18828d20807342d37000746b18a3c1696f3b2eJim Miller default: 36167e043db11b29f3c0c84529ae21a0fdd7ae11c6dJim Miller imageResId = com.android.internal.R.drawable.ic_media_play; 36267e043db11b29f3c0c84529ae21a0fdd7ae11c6dJim Miller imageDescId = com.android.internal.R.string.lockscreen_transport_play_description; 3636b05d58018c2806459c121e507c005639b74aee9Jim Miller break; 3646b05d58018c2806459c121e507c005639b74aee9Jim Miller } 36567e043db11b29f3c0c84529ae21a0fdd7ae11c6dJim Miller mBtnPlay.setImageResource(imageResId); 36667e043db11b29f3c0c84529ae21a0fdd7ae11c6dJim Miller mBtnPlay.setContentDescription(getResources().getString(imageDescId)); 3671c18828d20807342d37000746b18a3c1696f3b2eJim Miller mPlayState = state; 3681c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 3691c18828d20807342d37000746b18a3c1696f3b2eJim Miller 3701c18828d20807342d37000746b18a3c1696f3b2eJim Miller public void onClick(View v) { 3711c18828d20807342d37000746b18a3c1696f3b2eJim Miller int keyCode = -1; 3721c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (v == mBtnPrev) { 3731c18828d20807342d37000746b18a3c1696f3b2eJim Miller keyCode = KeyEvent.KEYCODE_MEDIA_PREVIOUS; 3741c18828d20807342d37000746b18a3c1696f3b2eJim Miller } else if (v == mBtnNext) { 3751c18828d20807342d37000746b18a3c1696f3b2eJim Miller keyCode = KeyEvent.KEYCODE_MEDIA_NEXT; 3761c18828d20807342d37000746b18a3c1696f3b2eJim Miller } else if (v == mBtnPlay) { 3771c18828d20807342d37000746b18a3c1696f3b2eJim Miller keyCode = KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE; 3781c18828d20807342d37000746b18a3c1696f3b2eJim Miller 3791c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 3801c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (keyCode != -1) { 3811c18828d20807342d37000746b18a3c1696f3b2eJim Miller sendMediaButtonClick(keyCode); 3821c18828d20807342d37000746b18a3c1696f3b2eJim Miller if (mWidgetCallbacks != null) { 3831c18828d20807342d37000746b18a3c1696f3b2eJim Miller mWidgetCallbacks.userActivity(this); 3841c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 3856b05d58018c2806459c121e507c005639b74aee9Jim Miller } 3866b05d58018c2806459c121e507c005639b74aee9Jim Miller } 3876b05d58018c2806459c121e507c005639b74aee9Jim Miller 3881c18828d20807342d37000746b18a3c1696f3b2eJim Miller private void sendMediaButtonClick(int keyCode) { 389f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi // use the registered PendingIntent that will be processed by the registered 390f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi // media button event receiver, which is the component of mClientIntent 3911c18828d20807342d37000746b18a3c1696f3b2eJim Miller KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode); 3921c18828d20807342d37000746b18a3c1696f3b2eJim Miller Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON); 3931c18828d20807342d37000746b18a3c1696f3b2eJim Miller intent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent); 394f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi try { 395f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi mClientIntent.send(getContext(), 0, intent); 396f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi } catch (CanceledException e) { 397f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi Log.e(TAG, "Error sending intent for media button down: "+e); 398f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi e.printStackTrace(); 399f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi } 4001c18828d20807342d37000746b18a3c1696f3b2eJim Miller 4011c18828d20807342d37000746b18a3c1696f3b2eJim Miller keyEvent = new KeyEvent(KeyEvent.ACTION_UP, keyCode); 4021c18828d20807342d37000746b18a3c1696f3b2eJim Miller intent = new Intent(Intent.ACTION_MEDIA_BUTTON); 4031c18828d20807342d37000746b18a3c1696f3b2eJim Miller intent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent); 404f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi try { 405f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi mClientIntent.send(getContext(), 0, intent); 406f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi } catch (CanceledException e) { 407f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi Log.e(TAG, "Error sending intent for media button up: "+e); 408f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi e.printStackTrace(); 409f0cff0456258478ba768097f73d4367ab67fd7a3Jean-Michel Trivi } 4101c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 4111c18828d20807342d37000746b18a3c1696f3b2eJim Miller 4121c18828d20807342d37000746b18a3c1696f3b2eJim Miller public void setCallback(LockScreenWidgetCallback callback) { 4131c18828d20807342d37000746b18a3c1696f3b2eJim Miller mWidgetCallbacks = callback; 4141c18828d20807342d37000746b18a3c1696f3b2eJim Miller } 4151c18828d20807342d37000746b18a3c1696f3b2eJim Miller 416054340d0a3f242efeaf898cca38625bdcb3b4b5aJeff Sharkey public boolean providesClock() { 417054340d0a3f242efeaf898cca38625bdcb3b4b5aJeff Sharkey return false; 418054340d0a3f242efeaf898cca38625bdcb3b4b5aJeff Sharkey } 419054340d0a3f242efeaf898cca38625bdcb3b4b5aJeff Sharkey 42068622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi private boolean wasPlayingRecently(int state, long stateChangeTimeMs) { 42168622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi switch (state) { 42268622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi case RemoteControlClient.PLAYSTATE_PLAYING: 42368622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi case RemoteControlClient.PLAYSTATE_FAST_FORWARDING: 42468622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi case RemoteControlClient.PLAYSTATE_REWINDING: 42568622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi case RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS: 42668622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi case RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS: 42768622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi case RemoteControlClient.PLAYSTATE_BUFFERING: 42868622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi // actively playing or about to play 42968622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi return true; 43068622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi case RemoteControlClient.PLAYSTATE_NONE: 43168622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi return false; 43268622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi case RemoteControlClient.PLAYSTATE_STOPPED: 43368622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi case RemoteControlClient.PLAYSTATE_PAUSED: 43468622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi case RemoteControlClient.PLAYSTATE_ERROR: 43568622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi // we have stopped playing, check how long ago 43668622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi if (DEBUG) { 43768622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi if ((SystemClock.elapsedRealtime() - stateChangeTimeMs) < DISPLAY_TIMEOUT_MS) { 43868622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi Log.v(TAG, "wasPlayingRecently: time < TIMEOUT was playing recently"); 43968622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi } else { 44068622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi Log.v(TAG, "wasPlayingRecently: time > TIMEOUT"); 44168622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi } 44268622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi } 44368622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi return ((SystemClock.elapsedRealtime() - stateChangeTimeMs) < DISPLAY_TIMEOUT_MS); 44468622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi default: 44568622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi Log.e(TAG, "Unknown playback state " + state + " in wasPlayingRecently()"); 44668622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi return false; 44768622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi } 44868622396b62f9084781add1e12f4d513b633ab54Jean-Michel Trivi } 4496b05d58018c2806459c121e507c005639b74aee9Jim Miller} 450