diff options
Diffstat (limited to 'services/java/com/android/server/status')
4 files changed, 109 insertions, 44 deletions
diff --git a/services/java/com/android/server/status/DateView.java b/services/java/com/android/server/status/DateView.java index 35a0bae..7c44d67 100644 --- a/services/java/com/android/server/status/DateView.java +++ b/services/java/com/android/server/status/DateView.java @@ -4,7 +4,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.pim.DateFormat; +import android.text.format.DateFormat; import android.util.AttributeSet; import android.util.Log; import android.widget.TextView; diff --git a/services/java/com/android/server/status/StatusBarIcon.java b/services/java/com/android/server/status/StatusBarIcon.java index 6c66f9d..6d09919 100644 --- a/services/java/com/android/server/status/StatusBarIcon.java +++ b/services/java/com/android/server/status/StatusBarIcon.java @@ -152,9 +152,9 @@ class StatusBarIcon { try { return r.getDrawable(data.iconId); } catch (RuntimeException e) { - Log.e(StatusBarService.TAG, "Icon not found in " + Log.w(StatusBarService.TAG, "Icon not found in " + (data.iconPackage != null ? data.iconId : "<system>") - + ": " + Integer.toHexString(data.iconId), e); + + ": " + Integer.toHexString(data.iconId)); } return null; diff --git a/services/java/com/android/server/status/StatusBarPolicy.java b/services/java/com/android/server/status/StatusBarPolicy.java index ad027db..00ff7be 100644 --- a/services/java/com/android/server/status/StatusBarPolicy.java +++ b/services/java/com/android/server/status/StatusBarPolicy.java @@ -22,6 +22,7 @@ import com.android.internal.telephony.SimCard; import com.android.internal.telephony.TelephonyIntents; import android.app.AlertDialog; +import android.bluetooth.BluetoothA2dp; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHeadset; import android.bluetooth.BluetoothIntent; @@ -39,11 +40,11 @@ import android.net.wifi.WifiManager; import android.os.Handler; import android.os.IBinder; import android.os.Message; -import android.pim.DateFormat; import android.provider.Settings; import android.telephony.PhoneStateListener; import android.telephony.ServiceState; import android.telephony.TelephonyManager; +import android.text.format.DateFormat; import android.util.Log; import android.view.View; import android.view.ViewGroup; @@ -154,6 +155,8 @@ public class StatusBarPolicy { // bluetooth device status private IBinder mBluetoothIcon; private IconData mBluetoothData; + private int mBluetoothHeadsetState; + private int mBluetoothA2dpState; // wifi private static final int[] sWifiSignalImages = new int[] { @@ -196,6 +199,9 @@ public class StatusBarPolicy { else if (action.equals(Intent.ACTION_TIME_CHANGED)) { updateClock(); } + else if (action.equals(Intent.ACTION_CONFIGURATION_CHANGED)) { + updateClock(); + } else if (action.equals(Intent.ACTION_TIMEZONE_CHANGED)) { String tz = intent.getStringExtra("time-zone"); mCalendar = Calendar.getInstance(TimeZone.getTimeZone(tz)); @@ -212,7 +218,8 @@ public class StatusBarPolicy { } else if (action.equals(BluetoothIntent.ENABLED_ACTION) || action.equals(BluetoothIntent.DISABLED_ACTION) || - action.equals(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION) ) { + action.equals(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION) || + action.equals(BluetoothA2dp.SINK_STATE_CHANGED_ACTION)) { updateBluetooth(intent); } else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION) || @@ -315,6 +322,7 @@ public class StatusBarPolicy { // Register for Intent broadcasts for... filter.addAction(Intent.ACTION_TIME_TICK); filter.addAction(Intent.ACTION_TIME_CHANGED); + filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); filter.addAction(Intent.ACTION_BATTERY_CHANGED); filter.addAction(Intent.ACTION_TIMEZONE_CHANGED); filter.addAction(Intent.ACTION_ALARM_CHANGED); @@ -324,7 +332,9 @@ public class StatusBarPolicy { filter.addAction(BluetoothIntent.ENABLED_ACTION); filter.addAction(BluetoothIntent.DISABLED_ACTION); filter.addAction(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION); + filter.addAction(BluetoothA2dp.SINK_STATE_CHANGED_ACTION); filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); + filter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION); filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); filter.addAction(WifiManager.RSSI_CHANGED_ACTION); filter.addAction(GpsLocationProvider.GPS_ENABLED_CHANGE_ACTION); @@ -652,7 +662,11 @@ public class StatusBarPolicy { return; } - if (-1 == asu) asu = 0; + // ASU ranges from 0 to 31 - TS 27.007 Sec 8.5 + // asu = 0 (-113dB or less) is very weak + // signal, its better to show 0 bars to the user in such cases. + // asu = 99 is a special case, where the signal strength is unknown. + if (asu <= 0 || asu == 99) asu = 0; else if (asu >= 16) asu = 4; else if (asu >= 8) asu = 3; else if (asu >= 4) asu = 2; @@ -753,10 +767,13 @@ public class StatusBarPolicy { } private final void updateBluetooth(Intent intent) { - boolean visible; + boolean visible = false; if (intent == null) { // Initialize - visible = ((BluetoothDevice) - mContext.getSystemService(Context.BLUETOOTH_SERVICE)).isEnabled(); + BluetoothDevice bluetooth = + (BluetoothDevice) mContext.getSystemService(Context.BLUETOOTH_SERVICE); + if (bluetooth != null) { + visible = bluetooth.isEnabled(); + } mService.setIconVisibility(mBluetoothIcon, visible); return; } @@ -770,14 +787,21 @@ public class StatusBarPolicy { visible = true; } else if (action.equals(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION)) { visible = true; - int state = intent.getIntExtra(BluetoothIntent.HEADSET_STATE, - BluetoothHeadset.STATE_ERROR); - if (state == BluetoothHeadset.STATE_CONNECTED) { - iconId = com.android.internal.R.drawable.stat_sys_data_bluetooth_connected; - } + mBluetoothHeadsetState = intent.getIntExtra(BluetoothIntent.HEADSET_STATE, + BluetoothHeadset.STATE_ERROR); + } else if (action.equals(BluetoothA2dp.SINK_STATE_CHANGED_ACTION)) { + visible = true; + mBluetoothA2dpState = intent.getIntExtra(BluetoothA2dp.SINK_STATE, + BluetoothA2dp.STATE_DISCONNECTED); } else { return; } + + if (mBluetoothHeadsetState == BluetoothHeadset.STATE_CONNECTED || + mBluetoothA2dpState == BluetoothA2dp.STATE_CONNECTED || + mBluetoothA2dpState == BluetoothA2dp.STATE_PLAYING) { + iconId = com.android.internal.R.drawable.stat_sys_data_bluetooth_connected; + } mBluetoothData.iconId = iconId; mService.updateIcon(mBluetoothIcon, mBluetoothData, null); @@ -796,8 +820,14 @@ public class StatusBarPolicy { mService.setIconVisibility(mWifiIcon, false); } + } else if (action.equals(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION)) { + final boolean enabled = intent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, + false); + if (!enabled) { + mService.setIconVisibility(mWifiIcon, false); + } } else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { - + final NetworkInfo networkInfo = (NetworkInfo) intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); diff --git a/services/java/com/android/server/status/StatusBarService.java b/services/java/com/android/server/status/StatusBarService.java index 38b2e77..31f55c8 100644 --- a/services/java/com/android/server/status/StatusBarService.java +++ b/services/java/com/android/server/status/StatusBarService.java @@ -147,10 +147,11 @@ public class StatusBarService extends IStatusBar.Stub final Context mContext; final Display mDisplay; StatusBarView mStatusBarView; + int mPixelFormat; H mHandler = new H(); ArrayList<PendingOp> mQueue = new ArrayList<PendingOp>(); NotificationCallbacks mNotificationCallbacks; - + // All accesses to mIconMap and mNotificationData are syncronized on those objects, // but this is only so dump() can work correctly. Modifying these outside of the UI // thread will not work, there are places in the code that unlock and reaquire between @@ -181,7 +182,7 @@ public class StatusBarService extends IStatusBar.Stub View mNoNotificationsTitle; TextView mSpnLabel; TextView mPlmnLabel; - View mClearButton; + TextView mClearButton; CloseDragHandle mCloseView; int[] mCloseLocation = new int[2]; boolean mExpanded; @@ -252,10 +253,10 @@ public class StatusBarService extends IStatusBar.Stub sb.mService = this; // figure out which pixel-format to use for the status bar. - int pixelFormat = PixelFormat.TRANSLUCENT; + mPixelFormat = PixelFormat.TRANSLUCENT; Drawable bg = sb.getBackground(); if (bg != null) { - pixelFormat = bg.getOpacity(); + mPixelFormat = bg.getOpacity(); } mStatusBarView = sb; @@ -273,7 +274,7 @@ public class StatusBarService extends IStatusBar.Stub mLatestTitle = expanded.findViewById(R.id.latestTitle); mLatestItems = (LinearLayout)expanded.findViewById(R.id.latestItems); mNoNotificationsTitle = expanded.findViewById(R.id.noNotificationsTitle); - mClearButton = expanded.findViewById(R.id.clear_all_button); + mClearButton = (TextView)expanded.findViewById(R.id.clear_all_button); mClearButton.setOnClickListener(mClearButtonListener); mSpnLabel = (TextView)expanded.findViewById(R.id.spnLabel); mPlmnLabel = (TextView)expanded.findViewById(R.id.plmnLabel); @@ -294,18 +295,6 @@ public class StatusBarService extends IStatusBar.Stub mCloseView = (CloseDragHandle)mTrackingView.findViewById(R.id.close); mCloseView.mService = this; - WindowManager.LayoutParams lp = new WindowManager.LayoutParams( - ViewGroup.LayoutParams.FILL_PARENT, - 25, - WindowManager.LayoutParams.TYPE_STATUS_BAR, - WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| - WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING, - pixelFormat); - lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; - lp.setTitle("StatusBar"); - - WindowManagerImpl.getDefault().addView(sb, lp); - // add the more icon for the notifications IconData moreData = IconData.makeIcon(null, context.getPackageName(), R.drawable.stat_notify_more, 0, 42); @@ -326,11 +315,26 @@ public class StatusBarService extends IStatusBar.Stub // receive broadcasts IntentFilter filter = new IntentFilter(); + filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); filter.addAction(Telephony.Intents.SPN_STRINGS_UPDATED_ACTION); context.registerReceiver(mBroadcastReceiver, filter); } + public void systemReady() { + WindowManager.LayoutParams lp = new WindowManager.LayoutParams( + ViewGroup.LayoutParams.FILL_PARENT, + 25, + WindowManager.LayoutParams.TYPE_STATUS_BAR, + WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| + WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING, + mPixelFormat); + lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; + lp.setTitle("StatusBar"); + + WindowManagerImpl.getDefault().addView(mStatusBarView, lp); + } + // ================================================================================ // From IStatusBar // ================================================================================ @@ -665,7 +669,12 @@ public class StatusBarService extends IStatusBar.Stub notification.data = n; updateNotificationView(notification, oldData); } - if (n.tickerText != null + // Show the ticker if one is requested, and the text is different + // than the currently displayed ticker. Also don't do this + // until status bar window is attached to the window manager, + // because... well, what's the point otherwise? And trying to + // run a ticker without being attached will crash! + if (n.tickerText != null && mStatusBarView.getWindowToken() != null && (oldData == null || oldData.tickerText == null || !CharSequences.equals(oldData.tickerText, n.tickerText))) { @@ -788,6 +797,14 @@ public class StatusBarService extends IStatusBar.Stub } } + View.OnFocusChangeListener mFocusChangeListener = new View.OnFocusChangeListener() { + public void onFocusChange(View v, boolean hasFocus) { + // Because 'v' is a ViewGroup, all its children will be (un)selected + // too, which allows marqueeing to work. + v.setSelected(hasFocus); + } + }; + View makeNotificationView(StatusBarNotification notification, ViewGroup parent) { NotificationData n = notification.data; RemoteViews remoteViews = n.contentView; @@ -803,6 +820,7 @@ public class StatusBarService extends IStatusBar.Stub // bind the click event to the content area ViewGroup content = (ViewGroup)row.findViewById(com.android.internal.R.id.content); content.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); + content.setOnFocusChangeListener(mFocusChangeListener); PendingIntent contentIntent = n.contentIntent; if (contentIntent != null) { content.setOnClickListener(new Launcher(contentIntent, n.pkg, n.id)); @@ -862,18 +880,19 @@ public class StatusBarService extends IStatusBar.Stub mNotificationData.update(notification); try { n.contentView.reapply(mContext, notification.contentView); + + // update the contentIntent + ViewGroup content = (ViewGroup)notification.view.findViewById( + com.android.internal.R.id.content); + PendingIntent contentIntent = n.contentIntent; + if (contentIntent != null) { + content.setOnClickListener(new Launcher(contentIntent, n.pkg, n.id)); + } } catch (RuntimeException e) { - Log.e(TAG, "couldn't reapply views for package " - + n.contentView.getPackage(), e); - } - - // update the contentIntent - ViewGroup content = (ViewGroup)notification.view.findViewById( - com.android.internal.R.id.content); - PendingIntent contentIntent = n.contentIntent; - if (contentIntent != null) { - content.setOnClickListener(new Launcher(contentIntent, n.pkg, n.id)); + // It failed to add cleanly. Log, and remove the view from the panel. + Log.w(TAG, "couldn't reapply views for package " + n.contentView.getPackage(), e); + removeNotificationView(notification); } } else { mNotificationData.update(notification); @@ -1426,7 +1445,8 @@ public class StatusBarService extends IStatusBar.Stub ViewGroup.LayoutParams.FILL_PARENT, WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN - | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, + | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS + | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, pixelFormat); // lp.token = mStatusBarView.getWindowToken(); lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; @@ -1629,6 +1649,9 @@ public class StatusBarService extends IStatusBar.Stub intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_PLMN, false), intent.getStringExtra(Telephony.Intents.EXTRA_PLMN)); } + else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) { + updateResources(); + } } }; @@ -1659,6 +1682,18 @@ public class StatusBarService extends IStatusBar.Stub } } + /** + * Reload some of our resources when the configuration changes. + * + * We don't reload everything when the configuration changes -- we probably + * should, but getting that smooth is tough. Someday we'll fix that. In the + * meantime, just update the things that we know change. + */ + void updateResources() { + mClearButton.setText(mContext.getText(R.string.status_bar_clear_all_button)); + Log.d(TAG, "updateResources"); + } + // // tracing // |