diff options
| author | Joe Onorato <joeo@google.com> | 2010-10-21 11:09:02 -0400 |
|---|---|---|
| committer | Joe Onorato <joeo@google.com> | 2010-10-21 15:42:34 -0400 |
| commit | f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dc (patch) | |
| tree | 848b4faed343c2fc72a800b0973e6fa1ebbe7d4a | |
| parent | 10e370c68902782c17c42e92c8d5a21978442010 (diff) | |
| download | frameworks_base-f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dc.zip frameworks_base-f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dc.tar.gz frameworks_base-f3c3c4fd14cb4185ec6df5a4355aab8b9f4039dc.tar.bz2 | |
Refactor SystemUI so the status bar isn't a Service of its own.
There is now one SystemUIService, which starts the status bar service.
Pretty soon there will be other things running in here too. This way
we don't need to have each of them started by something individually.
This also moves the choice between tablet and phone status bar into
SystemUI.apk, which seems like a much better place for it.
Change-Id: Ib69ef2f43d648764f8dbb52008f5d036a1ee07d9
14 files changed, 273 insertions, 136 deletions
diff --git a/core/res/res/values-xlarge/config.xml b/core/res/res/values-xlarge/config.xml index 813651e..9504d04 100644 --- a/core/res/res/values-xlarge/config.xml +++ b/core/res/res/values-xlarge/config.xml @@ -20,9 +20,6 @@ <!-- These resources are around just to allow their values to be customized for different hardware and product builds. --> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <!-- Component to be used as the status bar service. Must implement the IStatusBar - interface. This name is in the ComponentName flattened format (package/class) --> - <string name="config_statusBarComponent">com.android.systemui/com.android.systemui.statusbar.tablet.TabletStatusBarService</string> <bool name="config_statusBarCanHide">false</bool> <!-- see comment in values/config.xml --> diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index de2b930..a5c9a40 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -20,9 +20,6 @@ <!-- These resources are around just to allow their values to be customized for different hardware and product builds. --> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> - <!-- Component to be used as the status bar service. Must implement the IStatusBar - interface. This name is in the ComponentName flattened format (package/class) --> - <string name="config_statusBarComponent">com.android.systemui/com.android.systemui.statusbar.PhoneStatusBarService</string> <bool name="config_statusBarCanHide">true</bool> <!-- Do not translate. Defines the slots for the right-hand side icons. That is to say, the diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 5fde3c3..d824f30 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -14,15 +14,13 @@ android:allowClearUserData="false" android:label="@string/app_label" android:icon="@drawable/ic_launcher_settings"> - - <service - android:name=".statusbar.PhoneStatusBarService" - android:exported="false" - /> - <service - android:name=".statusbar.tablet.TabletStatusBarService" - android:exported="false" + <!-- Broadcast receiver that gets the broadcast at boot time and starts + up everything else. + TODO: Should have an android:permission attribute + --> + <service android:name="SystemUIService" + android:exported="true" /> <activity android:name=".usb.UsbStorageActivity" diff --git a/packages/SystemUI/res/layout-xlarge/status_bar.xml b/packages/SystemUI/res/layout-xlarge/status_bar.xml index 28e47b0..8824028 100644 --- a/packages/SystemUI/res/layout-xlarge/status_bar.xml +++ b/packages/SystemUI/res/layout-xlarge/status_bar.xml @@ -34,7 +34,6 @@ android:src="@drawable/ic_sysbar_open" android:background="@drawable/ic_sysbar_icon_bg" android:paddingLeft="6dip" - android:onClick="notificationIconsClicked" /> <LinearLayout @@ -174,7 +173,6 @@ android:background="@drawable/ic_sysbar_icon_bg" android:paddingLeft="4dip" android:paddingRight="4dip" - android:onClick="recentButtonClicked" /> <com.android.systemui.statusbar.KeyButtonView android:id="@+id/home" android:layout_width="wrap_content" diff --git a/packages/SystemUI/res/layout-xlarge/status_bar_center.xml b/packages/SystemUI/res/layout-xlarge/status_bar_center.xml index 2d74672..d4f0e50 100644 --- a/packages/SystemUI/res/layout-xlarge/status_bar_center.xml +++ b/packages/SystemUI/res/layout-xlarge/status_bar_center.xml @@ -22,7 +22,6 @@ android:layout_height="match_parent" android:layout_centerInParent="true" android:clickable="true" - android:onClick="systemInfoClicked" > <com.android.systemui.statusbar.Clock style="@*android:style/TextAppearance.StatusBar.Icon" diff --git a/packages/SystemUI/res/values-xlarge/config.xml b/packages/SystemUI/res/values-xlarge/config.xml index 4cf5d18d11..6df883c 100644 --- a/packages/SystemUI/res/values-xlarge/config.xml +++ b/packages/SystemUI/res/values-xlarge/config.xml @@ -21,5 +21,10 @@ for different hardware and product builds. --> <resources> <integer name="config_status_bar_position">1</integer> + + <!-- Component to be used as the status bar service. Must implement the IStatusBar + interface. This name is in the ComponentName flattened format (package/class) --> + <string name="config_statusBarComponent">com.android.systemui.statusbar.tablet.TabletStatusBarService</string> + </resources> diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index ac00c69..4570d8e 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -31,5 +31,9 @@ --> <integer name="config_status_bar_position">0</integer> + <!-- Component to be used as the status bar service. Must implement the IStatusBar + interface. This name is in the ComponentName flattened format (package/class) --> + <string name="config_statusBarComponent">com.android.systemui.statusbar.PhoneStatusBarService</string> + </resources> diff --git a/packages/SystemUI/src/com/android/systemui/SystemUI.java b/packages/SystemUI/src/com/android/systemui/SystemUI.java new file mode 100644 index 0000000..53fe2ff --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/SystemUI.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui; + +import java.io.FileDescriptor; +import java.io.PrintWriter; + +import android.content.Context; + +public abstract class SystemUI { + public Context mContext; + + public abstract void start(); + + public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { + } +} diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIService.java b/packages/SystemUI/src/com/android/systemui/SystemUIService.java new file mode 100644 index 0000000..dda86d2 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/SystemUIService.java @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui; + +import java.io.FileDescriptor; +import java.io.PrintWriter; + +import android.app.Service; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.os.Binder; +import android.os.IBinder; +import android.util.Slog; + +public class SystemUIService extends Service { + static final String TAG = "SystemUIService"; + + /** + * The class names of the stuff to start. + */ + final Object[] SERVICES = new Object[] { + R.string.config_statusBarComponent, + }; + + /** + * Hold a reference on the stuff we start. + */ + SystemUI[] mServices; + + private Class chooseClass(Object o) { + if (o instanceof Integer) { + final String cl = getString((Integer)o); + try { + return getClassLoader().loadClass(cl); + } catch (ClassNotFoundException ex) { + throw new RuntimeException(ex); + } + } else if (o instanceof Class) { + return (Class)o; + } else { + throw new RuntimeException("Unknown system ui service: " + o); + } + } + + @Override + public void onCreate() { + final int N = SERVICES.length; + mServices = new SystemUI[N]; + for (int i=0; i<N; i++) { + Class cl = chooseClass(SERVICES[i]); + Slog.d(TAG, "loading: " + cl); + try { + mServices[i] = (SystemUI)cl.newInstance(); + } catch (IllegalAccessException ex) { + throw new RuntimeException(ex); + } catch (InstantiationException ex) { + throw new RuntimeException(ex); + } + mServices[i].mContext = this; + Slog.d(TAG, "running: " + mServices[i]); + mServices[i].start(); + } + } + + /** + * Nobody binds to us. + */ + @Override + public IBinder onBind(Intent intent) { + return null; + } + + @Override + protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { + if (checkCallingOrSelfPermission(android.Manifest.permission.DUMP) + != PackageManager.PERMISSION_GRANTED) { + pw.println("Permission Denial: can't dump StatusBar from from pid=" + + Binder.getCallingPid() + + ", uid=" + Binder.getCallingUid()); + return; + } + + for (SystemUI ui: mServices) { + pw.println("dumping service: " + ui.getClass().getName()); + ui.dump(fd, pw, args); + } + } +} + diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java b/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java index fc7b534..bf58b37 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/PhoneStatusBarService.java @@ -27,7 +27,6 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.content.pm.PackageManager; import android.content.res.Resources; import android.graphics.PixelFormat; import android.graphics.Rect; @@ -35,7 +34,6 @@ import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.IBinder; import android.os.RemoteException; -import android.os.Binder; import android.os.Handler; import android.os.Message; import android.os.SystemClock; @@ -195,27 +193,23 @@ public class PhoneStatusBarService extends StatusBarService { } @Override - public void onCreate() { - mDisplay = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); + public void start() { + mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)) + .getDefaultDisplay(); - super.onCreate(); + super.start(); addIntruderView(); // Lastly, call to the icon policy to install/update all the icons. - mIconPolicy = new StatusBarPolicy(this); - } - - @Override - public void onDestroy() { - // we're never destroyed + mIconPolicy = new StatusBarPolicy(mContext); } // ================================================================================ // Constructing the view // ================================================================================ protected View makeStatusBarView() { - final Context context = this; + final Context context = mContext; Resources res = context.getResources(); @@ -293,7 +287,7 @@ public class PhoneStatusBarService extends StatusBarService { } private void addIntruderView() { - final Resources res = getResources(); + final Resources res = mContext.getResources(); final int height= res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); WindowManager.LayoutParams lp = new WindowManager.LayoutParams( @@ -317,7 +311,7 @@ public class PhoneStatusBarService extends StatusBarService { public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon) { if (SPEW) Slog.d(TAG, "addIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex + " icon=" + icon); - StatusBarIconView view = new StatusBarIconView(this, slot); + StatusBarIconView view = new StatusBarIconView(mContext, slot); view.set(icon); mStatusIcons.addView(view, viewIndex, new LinearLayout.LayoutParams(mIconSize, mIconSize)); } @@ -434,7 +428,7 @@ public class PhoneStatusBarService extends StatusBarService { oldEntry.notification = notification; try { // Reapply the RemoteViews - contentView.reapply(this, oldEntry.content); + contentView.reapply(mContext, oldEntry.content); // update the contentIntent final PendingIntent contentIntent = notification.notification.contentIntent; if (contentIntent != null) { @@ -507,7 +501,8 @@ public class PhoneStatusBarService extends StatusBarService { } // create the row view - LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); + LayoutInflater inflater = (LayoutInflater)mContext.getSystemService( + Context.LAYOUT_INFLATER_SERVICE); View row = inflater.inflate(R.layout.status_bar_latest_event, parent, false); // bind the click event to the content area @@ -525,7 +520,7 @@ public class PhoneStatusBarService extends StatusBarService { View expanded = null; Exception exception = null; try { - expanded = remoteViews.apply(this, content); + expanded = remoteViews.apply(mContext, content); } catch (RuntimeException e) { exception = e; @@ -564,7 +559,7 @@ public class PhoneStatusBarService extends StatusBarService { final View content = views[1]; final View expanded = views[2]; // Construct the icon. - final StatusBarIconView iconView = new StatusBarIconView(this, + final StatusBarIconView iconView = new StatusBarIconView(mContext, notification.pkg + "/0x" + Integer.toHexString(notification.id)); final StatusBarIcon ic = new StatusBarIcon(notification.pkg, notification.notification.icon, notification.notification.iconLevel, notification.notification.number); @@ -1050,7 +1045,7 @@ public class PhoneStatusBarService extends StatusBarService { overlay.setSourceBounds( new Rect(pos[0], pos[1], pos[0]+v.getWidth(), pos[1]+v.getHeight())); try { - mIntent.send(PhoneStatusBarService.this, 0, overlay); + mIntent.send(mContext, 0, overlay); } catch (PendingIntent.CanceledException e) { // the stack trace isn't very helpful here. Just log the exception message. Slog.w(TAG, "Sending contentIntent failed: " + e); @@ -1151,7 +1146,7 @@ public class PhoneStatusBarService extends StatusBarService { }; private Animation loadAnim(int id, Animation.AnimationListener listener) { - Animation anim = AnimationUtils.loadAnimation(PhoneStatusBarService.this, id); + Animation anim = AnimationUtils.loadAnimation(mContext, id); if (listener != null) { anim.setAnimationListener(listener); } @@ -1163,15 +1158,7 @@ public class PhoneStatusBarService extends StatusBarService { + " " + v.getWidth() + "x" + v.getHeight() + ")"; } - protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - if (checkCallingOrSelfPermission(android.Manifest.permission.DUMP) - != PackageManager.PERMISSION_GRANTED) { - pw.println("Permission Denial: can't dump StatusBar from from pid=" - + Binder.getCallingPid() - + ", uid=" + Binder.getCallingUid()); - return; - } - + public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { synchronized (mQueueLock) { pw.println("Current Status Bar state:"); pw.println(" mExpanded=" + mExpanded @@ -1519,12 +1506,13 @@ public class PhoneStatusBarService extends StatusBarService { * meantime, just update the things that we know change. */ void updateResources() { - Resources res = getResources(); + final Context context = mContext; + final Resources res = context.getResources(); - mClearButton.setText(getText(R.string.status_bar_clear_all_button)); - mOngoingTitle.setText(getText(R.string.status_bar_ongoing_events_title)); - mLatestTitle.setText(getText(R.string.status_bar_latest_events_title)); - mNoNotificationsTitle.setText(getText(R.string.status_bar_no_notifications_title)); + mClearButton.setText(context.getText(R.string.status_bar_clear_all_button)); + mOngoingTitle.setText(context.getText(R.string.status_bar_ongoing_events_title)); + mLatestTitle.setText(context.getText(R.string.status_bar_latest_events_title)); + mNoNotificationsTitle.setText(context.getText(R.string.status_bar_no_notifications_title)); mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore); @@ -1540,7 +1528,8 @@ public class PhoneStatusBarService extends StatusBarService { } void vibrate() { - android.os.Vibrator vib = (android.os.Vibrator)getSystemService(Context.VIBRATOR_SERVICE); + android.os.Vibrator vib = (android.os.Vibrator)mContext.getSystemService( + Context.VIBRATOR_SERVICE); vib.vibrate(250); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java index a7e5d73..ae1fdbd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java @@ -40,9 +40,10 @@ import com.android.internal.statusbar.StatusBarIcon; import com.android.internal.statusbar.StatusBarIconList; import com.android.internal.statusbar.StatusBarNotification; +import com.android.systemui.SystemUI; import com.android.systemui.R; -public abstract class StatusBarService extends Service implements CommandQueue.Callbacks { +public abstract class StatusBarService extends SystemUI implements CommandQueue.Callbacks { static final String TAG = "StatusBarService"; private static final boolean SPEW = false; @@ -53,16 +54,7 @@ public abstract class StatusBarService extends Service implements CommandQueue.C protected abstract View makeStatusBarView(); protected abstract int getStatusBarGravity(); - /** - * Nobody binds to us. - */ - @Override - public IBinder onBind(Intent intent) { - return null; - } - - @Override - public void onCreate() { + public void start() { // First set up our views and stuff. View sb = makeStatusBarView(); @@ -107,7 +99,7 @@ public abstract class StatusBarService extends Service implements CommandQueue.C } // Put up the view - final Resources res = getResources(); + final Resources res = mContext.getResources(); final int height= res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); final WindowManager.LayoutParams lp = new WindowManager.LayoutParams( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarService.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarService.java index 340e269..6426e7e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarService.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarService.java @@ -16,6 +16,9 @@ package com.android.systemui.statusbar.tablet; +import java.io.FileDescriptor; +import java.io.PrintWriter; + import android.app.ActivityManagerNative; import android.app.PendingIntent; import android.app.Notification; @@ -80,6 +83,7 @@ public class TabletStatusBarService extends StatusBarService { View mSystemInfo; View mNavigationArea; View mMenuButton; + View mRecentButton; NotificationPanel mNotificationPanel; SystemPanel mSystemPanel; @@ -107,11 +111,13 @@ public class TabletStatusBarService extends StatusBarService { boolean mNotificationsOn = true; protected void addPanelWindows() { - final Resources res = getResources(); + final Context context = mContext; + + final Resources res = context.getResources(); final int barHeight= res.getDimensionPixelSize( com.android.internal.R.dimen.status_bar_height); - mNotificationPanel = (NotificationPanel)View.inflate(this, + mNotificationPanel = (NotificationPanel)View.inflate(context, R.layout.sysbar_panel_notifications, null); mNotificationPanel.setVisibility(View.GONE); mNotificationPanel.setOnTouchListener( @@ -132,7 +138,7 @@ public class TabletStatusBarService extends StatusBarService { WindowManagerImpl.getDefault().addView(mNotificationPanel, lp); - mSystemPanel = (SystemPanel) View.inflate(this, R.layout.sysbar_panel_system, null); + mSystemPanel = (SystemPanel) View.inflate(context, R.layout.sysbar_panel_system, null); mSystemPanel.setVisibility(View.GONE); mSystemPanel.setOnTouchListener(new TouchOutsideListener(MSG_CLOSE_SYSTEM_PANEL, mSystemPanel)); @@ -155,17 +161,18 @@ public class TabletStatusBarService extends StatusBarService { } @Override - public void onCreate() { - super.onCreate(); // will add the main bar view + public void start() { + super.start(); // will add the main bar view } protected View makeStatusBarView() { - Resources res = getResources(); + final Context context = mContext; + final Resources res = context.getResources(); mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size); final TabletStatusBarView sb = (TabletStatusBarView)View.inflate( - this, R.layout.status_bar, null); + context, R.layout.status_bar, null); mStatusBarView = sb; sb.setHandler(mHandler); @@ -174,14 +181,19 @@ public class TabletStatusBarService extends StatusBarService { mCurtains = sb.findViewById(R.id.lights_out); mSystemInfo = sb.findViewById(R.id.systemInfo); + mSystemInfo.setOnClickListener(mOnClickListener); mSystemInfo.setOnLongClickListener(new SetLightsOnListener(false)); + mRecentButton = sb.findViewById(R.id.recent); + mRecentButton.setOnClickListener(mOnClickListener); + SetLightsOnListener on = new SetLightsOnListener(true); mCurtains.setOnClickListener(on); mCurtains.setOnLongClickListener(on); // the button to open the notification area mNotificationTrigger = sb.findViewById(R.id.expand); + mNotificationTrigger.setOnClickListener(mOnClickListener); // the more notifications icon mNotificationIconArea = (NotificationIconArea)sb.findViewById(R.id.notificationIcons); @@ -189,15 +201,15 @@ public class TabletStatusBarService extends StatusBarService { // the clear and dnd buttons mNotificationButtons = sb.findViewById(R.id.notificationButtons); mClearButton = (TextView)mNotificationButtons.findViewById(R.id.clear_all_button); - mClearButton.setOnClickListener(mClearButtonListener); + mClearButton.setOnClickListener(mOnClickListener); mDoNotDisturbButton = (TextView)mNotificationButtons.findViewById(R.id.do_not_disturb); - mDoNotDisturbButton.setOnClickListener(mDoNotDisturbButtonListener); + mDoNotDisturbButton.setOnClickListener(mOnClickListener); // where the icons go mIconLayout = (NotificationIconArea.IconLayout) sb.findViewById(R.id.icons); - mTicker = new TabletTicker((Context)this, (FrameLayout)sb.findViewById(R.id.ticker)); + mTicker = new TabletTicker(context, (FrameLayout)sb.findViewById(R.id.ticker)); // System info (center) mBatteryMeter = (ImageView) sb.findViewById(R.id.battery); @@ -366,7 +378,7 @@ public class TabletStatusBarService extends StatusBarService { oldEntry.notification = notification; try { // Reapply the RemoteViews - contentView.reapply(this, oldEntry.content); + contentView.reapply(mContext, oldEntry.content); // update the contentIntent final PendingIntent contentIntent = notification.notification.contentIntent; if (contentIntent != null) { @@ -551,7 +563,49 @@ public class TabletStatusBarService extends StatusBarService { */ } - public void notificationIconsClicked(View v) { + /** + * Cancel this notification and tell the status bar service about the failure. Hold no locks. + */ + void handleNotificationError(IBinder key, StatusBarNotification n, String message) { + removeNotification(key); + try { + mBarService.onNotificationError(n.pkg, n.tag, n.id, n.uid, n.initialPid, message); + } catch (RemoteException ex) { + // The end is nigh. + } + } + + private View.OnClickListener mOnClickListener = new View.OnClickListener() { + public void onClick(View v) { + if (v == mClearButton) { + onClickClearButton(); + } else if (v == mDoNotDisturbButton) { + onClickDoNotDisturb(); + } else if (v == mNotificationTrigger) { + onClickNotificationTrigger(); + } else if (v == mSystemInfo) { + onClickSystemInfo(); + } else if (v == mRecentButton) { + onClickRecentButton(); + } + } + }; + + void onClickClearButton() { + try { + mBarService.onClearAllNotifications(); + } catch (RemoteException ex) { + // system process is dead if we're here. + } + animateCollapse(); + } + + void onClickDoNotDisturb() { + mNotificationsOn = !mNotificationsOn; + animateCollapse(); + } + + public void onClickNotificationTrigger() { if (DEBUG) Slog.d(TAG, "clicked notification icons"); if ((mDisabled & StatusBarManager.DISABLE_EXPAND) == 0) { int msg = (mNotificationPanel.getVisibility() == View.GONE) @@ -562,7 +616,7 @@ public class TabletStatusBarService extends StatusBarService { } } - public void systemInfoClicked(View v) { + public void onClickSystemInfo() { if (DEBUG) Slog.d(TAG, "clicked system info"); if ((mDisabled & StatusBarManager.DISABLE_EXPAND) == 0) { int msg = (mSystemPanel.getVisibility() == View.GONE) @@ -573,45 +627,15 @@ public class TabletStatusBarService extends StatusBarService { } } - public void recentButtonClicked(View v) { + public void onClickRecentButton() { if (DEBUG) Slog.d(TAG, "clicked recent apps"); Intent intent = new Intent(); - intent.setClass(this, RecentApplicationsActivity.class); + intent.setClass(mContext, RecentApplicationsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); - startActivity(intent); - } - - /** - * Cancel this notification and tell the status bar service about the failure. Hold no locks. - */ - void handleNotificationError(IBinder key, StatusBarNotification n, String message) { - removeNotification(key); - try { - mBarService.onNotificationError(n.pkg, n.tag, n.id, n.uid, n.initialPid, message); - } catch (RemoteException ex) { - // The end is nigh. - } + mContext.startActivity(intent); } - private View.OnClickListener mClearButtonListener = new View.OnClickListener() { - public void onClick(View v) { - try { - mBarService.onClearAllNotifications(); - } catch (RemoteException ex) { - // system process is dead if we're here. - } - animateCollapse(); - } - }; - - private View.OnClickListener mDoNotDisturbButtonListener = new View.OnClickListener() { - public void onClick(View v) { - mNotificationsOn = !mNotificationsOn; - animateCollapse(); - } - }; - private class NotificationClicker implements View.OnClickListener { private PendingIntent mIntent; private String mPkg; @@ -642,7 +666,7 @@ public class TabletStatusBarService extends StatusBarService { overlay.setSourceBounds( new Rect(pos[0], pos[1], pos[0]+v.getWidth(), pos[1]+v.getHeight())); try { - mIntent.send(TabletStatusBarService.this, 0, overlay); + mIntent.send(mContext, 0, overlay); } catch (PendingIntent.CanceledException e) { // the stack trace isn't very helpful here. Just log the exception message. Slog.w(TAG, "Sending contentIntent failed: " + e); @@ -685,7 +709,7 @@ public class TabletStatusBarService extends StatusBarService { Slog.d(TAG, "addNotificationViews(key=" + key + ", notification=" + notification); } // Construct the icon. - final StatusBarIconView iconView = new StatusBarIconView(this, + final StatusBarIconView iconView = new StatusBarIconView(mContext, notification.pkg + "/0x" + Integer.toHexString(notification.id)); iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); @@ -743,7 +767,8 @@ public class TabletStatusBarService extends StatusBarService { } // create the row view - LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); + LayoutInflater inflater = (LayoutInflater)mContext.getSystemService( + Context.LAYOUT_INFLATER_SERVICE); View row = inflater.inflate(R.layout.status_bar_latest_event, parent, false); View vetoButton = row.findViewById(R.id.veto); if (entry.notification.isClearable()) { @@ -780,7 +805,7 @@ public class TabletStatusBarService extends StatusBarService { View expanded = null; Exception exception = null; try { - expanded = remoteViews.apply(this, content); + expanded = remoteViews.apply(mContext, content); } catch (RuntimeException e) { exception = e; @@ -853,10 +878,16 @@ public class TabletStatusBarService extends StatusBarService { private void setViewVisibility(View v, int vis, int anim) { if (v.getVisibility() != vis) { //Slog.d(TAG, "setViewVisibility vis=" + (vis == View.VISIBLE) + " v=" + v); - v.setAnimation(AnimationUtils.loadAnimation((Context)this, anim)); + v.setAnimation(AnimationUtils.loadAnimation(mContext, anim)); v.setVisibility(vis); } } + + + public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { + pw.print("mDisabled=0x"); + pw.println(Integer.toHexString(mDisabled)); + } } diff --git a/services/java/com/android/server/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java index 1ffc0ee..400b31f 100644 --- a/services/java/com/android/server/StatusBarManagerService.java +++ b/services/java/com/android/server/StatusBarManagerService.java @@ -111,22 +111,6 @@ public class StatusBarManagerService extends IStatusBarService.Stub } // ================================================================================ - // Constructing the view - // ================================================================================ - - public void systemReady() { - } - - public void systemReady2() { - ComponentName cn = ComponentName.unflattenFromString( - mContext.getString(com.android.internal.R.string.config_statusBarComponent)); - Intent intent = new Intent(); - intent.setComponent(cn); - Slog.i(TAG, "Starting service: " + cn); - mContext.startService(intent); - } - - // ================================================================================ // From IStatusBarService // ================================================================================ public void expand() { diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index ec12e80..46797c5 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -27,9 +27,11 @@ import dalvik.system.Zygote; import android.accounts.AccountManagerService; import android.app.ActivityManagerNative; import android.bluetooth.BluetoothAdapter; +import android.content.ComponentName; import android.content.ContentResolver; import android.content.ContentService; import android.content.Context; +import android.content.Intent; import android.content.pm.IPackageManager; import android.content.res.Configuration; import android.database.ContentObserver; @@ -502,9 +504,6 @@ class ServerThread extends Thread { notification.systemReady(); } - if (statusBar != null) { - statusBar.systemReady(); - } wm.systemReady(); // Update the configuration for this context by hand, because we're going @@ -523,7 +522,7 @@ class ServerThread extends Thread { } // These are needed to propagate to the runnable below. - final StatusBarManagerService statusBarF = statusBar; + final Context contextF = context; final BatteryService batteryF = battery; final ConnectivityService connectivityF = connectivity; final DockObserver dockF = dock; @@ -548,7 +547,7 @@ class ServerThread extends Thread { public void run() { Slog.i(TAG, "Making services ready"); - if (statusBarF != null) statusBarF.systemReady2(); + startSystemUi(contextF); if (batteryF != null) batteryF.systemReady(); if (connectivityF != null) connectivityF.systemReady(); if (dockF != null) dockF.systemReady(); @@ -578,6 +577,14 @@ class ServerThread extends Thread { Looper.loop(); Slog.d(TAG, "System ServerThread is exiting!"); } + + static final void startSystemUi(Context context) { + Intent intent = new Intent(); + intent.setComponent(new ComponentName("com.android.systemui", + "com.android.systemui.SystemUIService")); + Slog.d(TAG, "Starting service: " + intent); + context.startService(intent); + } } public class SystemServer { |
