diff options
45 files changed, 261 insertions, 175 deletions
diff --git a/core/java/android/widget/AdapterViewFlipper.java b/core/java/android/widget/AdapterViewFlipper.java index 3b026bd..285dee8 100644 --- a/core/java/android/widget/AdapterViewFlipper.java +++ b/core/java/android/widget/AdapterViewFlipper.java @@ -105,7 +105,17 @@ public class AdapterViewFlipper extends AdapterViewAnimator { final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_USER_PRESENT); - getContext().registerReceiver(mReceiver, filter); + + // OK, this is gross but needed. This class is supported by the + // remote views machanism and as a part of that the remote views + // can be inflated by a context for another user without the app + // having interact users permission - just for loading resources. + // For exmaple, when adding widgets from a user profile to the + // home screen. Therefore, we register the receiver as the current + // user not the one the context is for. + getContext().registerReceiverAsUser(mReceiver, android.os.Process.myUserHandle(), + filter, null, mHandler); + if (mAutoStart) { // Automatically start when requested diff --git a/packages/CaptivePortalLogin/AndroidManifest.xml b/packages/CaptivePortalLogin/AndroidManifest.xml index 5f78afe..c5fb167 100644 --- a/packages/CaptivePortalLogin/AndroidManifest.xml +++ b/packages/CaptivePortalLogin/AndroidManifest.xml @@ -25,7 +25,7 @@ <activity android:name="com.android.captiveportallogin.CaptivePortalLoginActivity" android:label="@string/action_bar_label" - android:theme="@android:style/Theme.Holo" > + android:theme="@style/AppTheme" > <intent-filter> <action android:name="android.intent.action.ACTION_SEND"/> <category android:name="android.intent.category.DEFAULT"/> diff --git a/packages/CaptivePortalLogin/res/layout/activity_captive_portal_login.xml b/packages/CaptivePortalLogin/res/layout/activity_captive_portal_login.xml index d8f2928..a11bed0 100644 --- a/packages/CaptivePortalLogin/res/layout/activity_captive_portal_login.xml +++ b/packages/CaptivePortalLogin/res/layout/activity_captive_portal_login.xml @@ -5,9 +5,16 @@ android:layout_height="match_parent" tools:context="com.android.captiveportallogin.CaptivePortalLoginActivity" tools:ignore="MergeRootFrame"> - <RelativeLayout + <LinearLayout android:layout_width="match_parent" - android:layout_height="match_parent" > + android:layout_height="match_parent" + android:orientation="vertical" > + + <ProgressBar + android:id="@+id/progress_bar" + android:layout_width="match_parent" + android:layout_height="wrap_content" + style="?android:attr/progressBarStyleHorizontal" /> <WebView android:id="@+id/webview" @@ -16,5 +23,5 @@ android:layout_alignParentBottom="false" android:layout_alignParentRight="false" /> -</RelativeLayout> +</LinearLayout> </FrameLayout> diff --git a/packages/CaptivePortalLogin/res/values/styles.xml b/packages/CaptivePortalLogin/res/values/styles.xml index 6ce89c7..7ccd3d3 100644 --- a/packages/CaptivePortalLogin/res/values/styles.xml +++ b/packages/CaptivePortalLogin/res/values/styles.xml @@ -4,7 +4,7 @@ Base application theme, dependent on API level. This theme is replaced by AppBaseTheme from res/values-vXX/styles.xml on newer devices. --> - <style name="AppBaseTheme" parent="android:Theme.Light"> + <style name="AppBaseTheme" parent="@android:style/Theme.Material.Settings"> <!-- Theme customizations available in newer API levels can go in res/values-vXX/styles.xml, while customizations related to @@ -15,6 +15,8 @@ <!-- Application theme. --> <style name="AppTheme" parent="AppBaseTheme"> <!-- All customizations that are NOT specific to a particular API-level can go here. --> + <!-- Setting's theme's accent color makes ProgressBar useless, reset back. --> + <item name="android:colorAccent">@*android:color/material_light_blue_A200</item> </style> </resources> diff --git a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java index 09525b2..ae52a1e 100644 --- a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java +++ b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java @@ -26,11 +26,13 @@ import android.provider.Settings; import android.provider.Settings.Global; import android.view.Menu; import android.view.MenuItem; +import android.view.View; import android.view.Window; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; +import android.widget.ProgressBar; import java.io.IOException; import java.net.HttpURLConnection; @@ -66,7 +68,6 @@ public class CaptivePortalLoginActivity extends Activity { done(true); } - requestWindowFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.activity_captive_portal_login); getActionBar().setDisplayShowHomeEnabled(false); @@ -164,7 +165,9 @@ public class CaptivePortalLoginActivity extends Activity { private class MyWebChromeClient extends WebChromeClient { @Override public void onProgressChanged(WebView view, int newProgress) { - setProgress(newProgress*100); + ProgressBar myProgressBar = (ProgressBar) findViewById(R.id.progress_bar); + myProgressBar.setProgress(newProgress); + myProgressBar.setVisibility(newProgress == 100 ? View.GONE : View.VISIBLE); } } } diff --git a/packages/SystemUI/res/layout/heads_up.xml b/packages/SystemUI/res/layout/heads_up.xml index 0e2b6d6..650ee5d 100644 --- a/packages/SystemUI/res/layout/heads_up.xml +++ b/packages/SystemUI/res/layout/heads_up.xml @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. --> +<!-- extends FrameLayout --> <com.android.systemui.statusbar.policy.HeadsUpNotificationView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent" @@ -21,11 +22,12 @@ android:background="@drawable/heads_up_scrim"> <FrameLayout + android:layout_width="@dimen/notification_panel_width" android:layout_height="wrap_content" + android:layout_gravity="@integer/notification_panel_layout_gravity" android:paddingStart="@dimen/notification_side_padding" android:paddingEnd="@dimen/notification_side_padding" android:elevation="8dp" - android:id="@+id/content_holder" - style="@style/NotificationsQuickSettings" /> + android:id="@+id/content_holder" /> </com.android.systemui.statusbar.policy.HeadsUpNotificationView>
\ No newline at end of file diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml index fa1077b..fc2dc02 100644 --- a/packages/SystemUI/res/layout/status_bar_expanded.xml +++ b/packages/SystemUI/res/layout/status_bar_expanded.xml @@ -55,7 +55,9 @@ android:visibility="invisible" /> <com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer - style="@style/NotificationsQuickSettings" + android:layout_width="@dimen/notification_panel_width" + android:layout_height="match_parent" + android:layout_gravity="@integer/notification_panel_layout_gravity" android:id="@+id/notification_container_parent" android:clipToPadding="false" android:clipChildren="false"> diff --git a/packages/SystemUI/res/layout/status_bar_expanded_header.xml b/packages/SystemUI/res/layout/status_bar_expanded_header.xml index 1afde69..688a88c 100644 --- a/packages/SystemUI/res/layout/status_bar_expanded_header.xml +++ b/packages/SystemUI/res/layout/status_bar_expanded_header.xml @@ -20,8 +20,9 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui" android:id="@+id/header" - style="@style/StatusBarHeader" + android:layout_width="@dimen/notification_panel_width" android:layout_height="@dimen/status_bar_header_height" + android:layout_gravity="@integer/notification_panel_layout_gravity" android:paddingStart="@dimen/notification_side_padding" android:paddingEnd="@dimen/notification_side_padding" android:baselineAligned="false" diff --git a/packages/SystemUI/res/layout/volume_dialog.xml b/packages/SystemUI/res/layout/volume_dialog.xml index 112f3a9..3765fe8 100644 --- a/packages/SystemUI/res/layout/volume_dialog.xml +++ b/packages/SystemUI/res/layout/volume_dialog.xml @@ -15,8 +15,10 @@ limitations under the License. --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="@dimen/volume_panel_width" + android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginLeft="@dimen/notification_side_padding" + android:layout_marginRight="@dimen/notification_side_padding" android:background="@drawable/qs_background_primary" android:translationZ="@dimen/volume_panel_z" android:layout_marginBottom="@dimen/volume_panel_z"> diff --git a/packages/SystemUI/res/values-land/config.xml b/packages/SystemUI/res/values-land/config.xml index 5755029..2b1a4dc 100644 --- a/packages/SystemUI/res/values-land/config.xml +++ b/packages/SystemUI/res/values-land/config.xml @@ -24,9 +24,6 @@ value at runtime for some things) --> <integer name="status_bar_recents_bg_gradient_degrees">90</integer> - <!-- The number of columns in the QuickSettings --> - <integer name="quick_settings_num_columns">4</integer> - <!-- The maximum number of rows in the QuickSettings --> <integer name="quick_settings_max_rows">2</integer> diff --git a/packages/SystemUI/res/values-land/dimens.xml b/packages/SystemUI/res/values-land/dimens.xml index 42c4392..9b772bd 100644 --- a/packages/SystemUI/res/values-land/dimens.xml +++ b/packages/SystemUI/res/values-land/dimens.xml @@ -41,6 +41,7 @@ <!-- The side padding for the task stack as a percentage of the width. --> <item name="recents_stack_width_padding_percentage" format="float" type="dimen">0.2229</item> - <!-- Width of the zen mode interstitial dialog. --> - <dimen name="zen_mode_dialog_width">384dp</dimen> + <!-- Standard notification width + gravity --> + <dimen name="notification_panel_width">@dimen/standard_notification_panel_width</dimen> + <integer name="notification_panel_layout_gravity">@integer/standard_notification_panel_layout_gravity</integer> </resources> diff --git a/packages/SystemUI/res/values-sw600dp/config.xml b/packages/SystemUI/res/values-sw600dp/config.xml index 9f4c364..4f6d209 100644 --- a/packages/SystemUI/res/values-sw600dp/config.xml +++ b/packages/SystemUI/res/values-sw600dp/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> - <!-- The number of columns in the QuickSettings --> - <integer name="quick_settings_num_columns">4</integer> - <!-- The maximum number of rows in the QuickSettings --> <integer name="quick_settings_max_rows">4</integer> diff --git a/packages/SystemUI/res/values-sw600dp/dimens.xml b/packages/SystemUI/res/values-sw600dp/dimens.xml index 6beccc5..2d82d6e 100644 --- a/packages/SystemUI/res/values-sw600dp/dimens.xml +++ b/packages/SystemUI/res/values-sw600dp/dimens.xml @@ -16,12 +16,9 @@ */ --> <resources> - <!-- The width of the notification panel window: 400 + 16 + 16 (padding in the bg drawable) --> - <dimen name="notification_panel_width">432dp</dimen> - - <!-- Gravity for the notification panel --> - <!-- 0x31 = top|center_horizontal --> - <integer name="notification_panel_layout_gravity">0x31</integer> + <!-- Standard notification width + gravity --> + <dimen name="notification_panel_width">@dimen/standard_notification_panel_width</dimen> + <integer name="notification_panel_layout_gravity">@integer/standard_notification_panel_layout_gravity</integer> <!-- Diameter of outer shape drawable shown in navbar search--> <dimen name="navbar_search_outerring_diameter">430dip</dimen> @@ -49,9 +46,6 @@ <!-- The side padding for the task stack as a percentage of the width. --> <item name="recents_stack_width_padding_percentage" format="float" type="dimen">0.075</item> - <!-- Width of the zen mode interstitial dialog. --> - <dimen name="zen_mode_dialog_width">384dp</dimen> - <!-- The fraction of the screen height where the clock on the Keyguard has its center. The max value is used when no notifications are displaying, and the min value is when the highest possible number of notifications are showing. --> diff --git a/packages/SystemUI/res/values-sw600dp/styles.xml b/packages/SystemUI/res/values-sw600dp/styles.xml index 88372bc..5daf08e 100644 --- a/packages/SystemUI/res/values-sw600dp/styles.xml +++ b/packages/SystemUI/res/values-sw600dp/styles.xml @@ -19,17 +19,6 @@ <item name="android:layout_width">480dp</item> </style> - <style name="NotificationsQuickSettings"> - <item name="android:layout_width">@dimen/notification_panel_width</item> - <item name="android:layout_height">match_parent</item> - <item name="android:layout_gravity">top|center_horizontal</item> - </style> - - <style name="StatusBarHeader"> - <item name="android:layout_width">@dimen/notification_panel_width</item> - <item name="android:layout_gravity">center_horizontal</item> - </style> - <style name="SearchPanelCard"> <item name="android:layout_width">550dp</item> <item name="android:layout_height">@dimen/search_panel_card_height</item> diff --git a/packages/SystemUI/res/values-sw720dp/dimens.xml b/packages/SystemUI/res/values-sw720dp/dimens.xml index 7695b12..3cd5f67 100644 --- a/packages/SystemUI/res/values-sw720dp/dimens.xml +++ b/packages/SystemUI/res/values-sw720dp/dimens.xml @@ -22,12 +22,8 @@ be situations where they don't sync up perfectly with PhoneStatusBar. --> <!-- ======================================== --> - <!-- The width of the ticker, including the icon --> - <dimen name="notification_ticker_width">360dp</dimen> <!-- gap on either side of status bar notification icons --> <dimen name="status_bar_icon_padding">1dp</dimen> - <!-- The width of the notification panel window --> - <dimen name="notification_panel_width">512dp</dimen> <!-- The minimum height of the notification panel window --> <dimen name="notification_panel_min_height">770dp</dimen> <!-- Bottom margin (from display edge) for status bar panels --> diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index efddc62..11a8063 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -136,9 +136,14 @@ <!-- Height of the status bar header bar when on Keyguard --> <dimen name="status_bar_header_height_keyguard">40dp</dimen> + <!-- Width for the notification panel and related windows --> + <dimen name="match_parent">-1px</dimen> + <dimen name="standard_notification_panel_width">416dp</dimen><!-- includes notification_side_padding on each side --> + <dimen name="notification_panel_width">@dimen/match_parent</dimen> + <!-- Gravity for the notification panel --> - <!-- 0x37 = fill_horizontal|top --> - <integer name="notification_panel_layout_gravity">0x37</integer> + <integer name="standard_notification_panel_layout_gravity">0x31</integer><!-- top|center_horizontal --> + <integer name="notification_panel_layout_gravity">0x37</integer><!-- fill_horizontal|top --> <!-- Height of the carrier/wifi name label --> <dimen name="carrier_label_height">24dp</dimen> @@ -269,9 +274,6 @@ <!-- The height of the speed bump view. --> <dimen name="speed_bump_height">16dp</dimen> - <!-- Width of the zen mode interstitial dialog. --> - <dimen name="zen_mode_dialog_width">320dp</dimen> - <!-- Lockscreen affordance drag distance for camera and phone. --> <dimen name="affordance_drag_distance">100dp</dimen> diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index 197c0f1..fc66730 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -254,16 +254,7 @@ <item name="android:colorControlActivated">@color/system_accent_color</item> </style> - <style name="NotificationsQuickSettings"> - <item name="android:layout_width">match_parent</item> - <item name="android:layout_height">match_parent</item> - </style> - - <style name="StatusBarHeader"> - <item name="android:layout_width">match_parent</item> - </style> - - <style name="QSBorderlessButton"> + <style name="QSBorderlessButton"> <item name="android:padding">12dp</item> <item name="android:background">@drawable/btn_borderless_rect</item> <item name="android:gravity">center</item> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 7ec0cc5..16e51c9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -98,7 +98,7 @@ public abstract class BaseStatusBar extends SystemUI implements RecentsComponent.Callbacks, ExpandableNotificationRow.ExpansionLogger, NotificationData.Environment { public static final String TAG = "StatusBar"; - public static final boolean DEBUG = false; + public static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); public static final boolean MULTIUSER_DEBUG = false; protected static final int MSG_SHOW_RECENT_APPS = 1019; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index a3b7c92..6af2cf8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -32,6 +32,7 @@ import android.view.ViewTreeObserver; import android.view.accessibility.AccessibilityEvent; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; +import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.TextView; @@ -70,7 +71,7 @@ public class NotificationPanelView extends PanelView implements private View mReserveNotificationSpace; private MirrorView mSystemIconsCopy; private View mQsNavbarScrim; - + private View mNotificationContainerParent; private NotificationStackScrollLayout mNotificationStackScroller; private int mNotificationTopPadding; private boolean mAnimateNextTopPaddingChange; @@ -125,7 +126,6 @@ public class NotificationPanelView extends PanelView implements private Interpolator mFastOutSlowInInterpolator; private Interpolator mFastOutLinearInterpolator; - private Interpolator mLinearOutSlowInInterpolator; private ObjectAnimator mClockAnimator; private int mClockAnimationTarget = -1; private int mTopPaddingAdjustment; @@ -180,6 +180,7 @@ public class NotificationPanelView extends PanelView implements mScrollView = (ObservableScrollView) findViewById(R.id.scroll_view); mScrollView.setListener(this); mReserveNotificationSpace = findViewById(R.id.reserve_notification_space); + mNotificationContainerParent = findViewById(R.id.notification_container_parent); mNotificationStackScroller = (NotificationStackScrollLayout) findViewById(R.id.notification_stack_scroller); mNotificationStackScroller.setOnHeightChangedListener(this); @@ -189,8 +190,6 @@ public class NotificationPanelView extends PanelView implements android.R.interpolator.fast_out_slow_in); mFastOutLinearInterpolator = AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.fast_out_linear_in); - mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(getContext(), - android.R.interpolator.linear_out_slow_in); mKeyguardBottomArea = (KeyguardBottomAreaView) findViewById(R.id.keyguard_bottom_area); mQsNavbarScrim = findViewById(R.id.qs_navbar_scrim); mAfforanceHelper = new KeyguardAffordanceHelper(this, getContext()); @@ -215,6 +214,25 @@ public class NotificationPanelView extends PanelView implements getResources().getDimensionPixelSize(R.dimen.notification_scrim_wait_distance); } + public void updateResources() { + int panelWidth = getResources().getDimensionPixelSize(R.dimen.notification_panel_width); + int panelGravity = getResources().getInteger(R.integer.notification_panel_layout_gravity); + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mHeader.getLayoutParams(); + if (lp.width != panelWidth) { + lp.width = panelWidth; + lp.gravity = panelGravity; + mHeader.setLayoutParams(lp); + mHeader.post(mUpdateHeader); + } + + lp = (FrameLayout.LayoutParams) mNotificationContainerParent.getLayoutParams(); + if (lp.width != panelWidth) { + lp.width = panelWidth; + lp.gravity = panelGravity; + mNotificationContainerParent.setLayoutParams(lp); + } + } + @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); @@ -1685,4 +1703,11 @@ public class NotificationPanelView extends PanelView implements updateQsState(); } } + + private final Runnable mUpdateHeader = new Runnable() { + @Override + public void run() { + mHeader.updateEverything(); + } + }; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 750fb39..015a21d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -3030,11 +3030,20 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, */ void updateResources() { // Update the quick setting tiles - if (mQSPanel != null) mQSPanel.updateResources(); + if (mQSPanel != null) { + mQSPanel.updateResources(); + } loadDimens(); mLinearOutSlowIn = AnimationUtils.loadInterpolator( mContext, android.R.interpolator.linear_out_slow_in); + + if (mNotificationPanel != null) { + mNotificationPanel.updateResources(); + } + if (mHeadsUpNotificationView != null) { + mHeadsUpNotificationView.updateResources(); + } } protected void loadDimens() { @@ -3076,7 +3085,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mKeyguardMaxNotificationCount = res.getInteger(R.integer.keyguard_max_notification_count); - if (false) Log.v(TAG, "updateResources"); + if (DEBUG) Log.v(TAG, "updateResources"); } // Visibility reporting diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java index b3051b4..0c62fd3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java @@ -243,21 +243,25 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL boolean changed = expanded != mExpanded; mExpanded = expanded; if (changed) { - updateHeights(); - updateVisibilities(); - updateSystemIconsLayoutParams(); - updateClickTargets(); - updateMultiUserSwitch(); - if (mQSPanel != null) { - mQSPanel.setExpanded(expanded); - } - updateClockScale(); - updateAvatarScale(); - updateClockLp(); - requestCaptureValues(); + updateEverything(); } } + public void updateEverything() { + updateHeights(); + updateVisibilities(); + updateSystemIconsLayoutParams(); + updateClickTargets(); + updateMultiUserSwitch(); + if (mQSPanel != null) { + mQSPanel.setExpanded(mExpanded); + } + updateClockScale(); + updateAvatarScale(); + updateClockLp(); + requestCaptureValues(); + } + private void updateHeights() { int height = mExpanded ? mExpandedHeight : mCollapsedHeight; ViewGroup.LayoutParams lp = getLayoutParams(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java index 2aceb95..6ae076f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java @@ -70,6 +70,15 @@ public class HeadsUpNotificationView extends FrameLayout implements SwipeHelper. if (DEBUG) Log.v(TAG, "create() " + mTouchSensitivityDelay); } + public void updateResources() { + if (mContentHolder != null) { + final LayoutParams lp = (LayoutParams) mContentHolder.getLayoutParams(); + lp.width = getResources().getDimensionPixelSize(R.dimen.notification_panel_width); + lp.gravity = getResources().getInteger(R.integer.notification_panel_layout_gravity); + mContentHolder.setLayoutParams(lp); + } + } + public void setBar(PhoneStatusBar bar) { mBar = bar; } diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java b/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java index d202036..3a63a79 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumePanel.java @@ -24,6 +24,7 @@ import android.content.DialogInterface; import android.content.DialogInterface.OnDismissListener; import android.content.Intent; import android.content.IntentFilter; +import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.PixelFormat; @@ -44,7 +45,6 @@ import android.os.Vibrator; import android.provider.Settings.Global; import android.util.Log; import android.util.SparseArray; -import android.view.Gravity; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -355,23 +355,8 @@ public class VolumePanel extends Handler { } }; - // Change some window properties final Window window = mDialog.getWindow(); - final LayoutParams lp = window.getAttributes(); - lp.token = null; - // Offset from the top - lp.y = res.getDimensionPixelOffset(com.android.systemui.R.dimen.volume_panel_top); - lp.type = LayoutParams.TYPE_STATUS_BAR_PANEL; - lp.format = PixelFormat.TRANSLUCENT; - lp.windowAnimations = com.android.systemui.R.style.VolumePanelAnimation; - lp.gravity = Gravity.TOP; - window.setAttributes(lp); - window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); window.requestFeature(Window.FEATURE_NO_TITLE); - window.addFlags(LayoutParams.FLAG_NOT_FOCUSABLE - | LayoutParams.FLAG_NOT_TOUCH_MODAL - | LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH - | LayoutParams.FLAG_HARDWARE_ACCELERATED); mDialog.setCanceledOnTouchOutside(true); mDialog.setContentView(com.android.systemui.R.layout.volume_dialog); mDialog.setOnDismissListener(new OnDismissListener() { @@ -384,9 +369,24 @@ public class VolumePanel extends Handler { }); mDialog.create(); - // temporary workaround, until we support window-level shadows - mDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0x00000000)); + final LayoutParams lp = window.getAttributes(); + lp.token = null; + lp.y = res.getDimensionPixelOffset(com.android.systemui.R.dimen.volume_panel_top); + lp.type = LayoutParams.TYPE_STATUS_BAR_PANEL; + lp.format = PixelFormat.TRANSLUCENT; + lp.windowAnimations = com.android.systemui.R.style.VolumePanelAnimation; + lp.setTitle(TAG); + window.setAttributes(lp); + + updateWidth(); + + window.setBackgroundDrawable(new ColorDrawable(0x00000000)); + window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); + window.addFlags(LayoutParams.FLAG_NOT_FOCUSABLE + | LayoutParams.FLAG_NOT_TOUCH_MODAL + | LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH + | LayoutParams.FLAG_HARDWARE_ACCELERATED); mView = window.findViewById(R.id.content); mView.setOnTouchListener(new View.OnTouchListener() { @Override @@ -416,6 +416,19 @@ public class VolumePanel extends Handler { registerReceiver(); } + public void onConfigurationChanged(Configuration newConfig) { + updateWidth(); + } + + private void updateWidth() { + final Resources res = mContext.getResources(); + final LayoutParams lp = mDialog.getWindow().getAttributes(); + lp.width = res.getDimensionPixelSize(com.android.systemui.R.dimen.notification_panel_width); + lp.gravity = + res.getInteger(com.android.systemui.R.integer.notification_panel_layout_gravity); + mDialog.getWindow().setAttributes(lp); + } + public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("VolumePanel state:"); pw.print(" mTag="); pw.println(mTag); @@ -1016,7 +1029,6 @@ public class VolumePanel extends Handler { int stream = (streamType == AudioService.STREAM_REMOTE_MUSIC) ? -1 : streamType; // when the stream is for remote playback, use -1 to reset the stream type evaluation mAudioManager.forceVolumeControlStream(stream); - mDialog.show(); if (mCallback != null) { mCallback.onVisible(true); diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java index cc351f9..04a3b88 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java @@ -3,6 +3,7 @@ package com.android.systemui.volume; import android.app.ActivityManagerNative; import android.content.Context; import android.content.Intent; +import android.content.res.Configuration; import android.database.ContentObserver; import android.media.AudioManager; import android.media.IRemoteVolumeController; @@ -73,6 +74,14 @@ public class VolumeUI extends SystemUI { } @Override + protected void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + if (mPanel != null) { + mPanel.onConfigurationChanged(newConfig); + } + } + + @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (mPanel != null) { mPanel.dump(fd, pw, args); diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java index e9d0c46..4315e0d 100644 --- a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java +++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java @@ -3125,9 +3125,13 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku // Apps hosting the AppWidget get to bind to a remote view service in the provider. return true; } - if (mContext.checkCallingPermission(android.Manifest.permission.BIND_APPWIDGET) + final int userId = UserHandle.getUserId(uid); + if ((widget.host.getUserId() == userId || (widget.provider != null + && widget.provider.getUserId() == userId)) + && mContext.checkCallingPermission(android.Manifest.permission.BIND_APPWIDGET) == PackageManager.PERMISSION_GRANTED) { - // Apps that can bind have access to all appWidgetIds. + // Apps that run in the same user as either the host or the provider and + // have the bind widget permission have access to the widget. return true; } return false; @@ -3187,14 +3191,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku } public boolean isHostInPackageForUid(Host host, int uid, String packageName) { - if (UserHandle.getAppId(uid) == Process.myUid()) { - // For a host that's in the system process, ignore the user id. - return UserHandle.isSameApp(host.id.uid, uid) - && host.id.packageName.equals(packageName); - } else { - return host.id.uid == uid - && host.id.packageName.equals(packageName); - } + return host.id.uid == uid && host.id.packageName.equals(packageName); } public boolean isProviderInPackageForUid(Provider provider, int uid, diff --git a/services/core/java/com/android/server/hdmi/DeviceDiscoveryAction.java b/services/core/java/com/android/server/hdmi/DeviceDiscoveryAction.java index 924d7aa..d67b8f1 100644 --- a/services/core/java/com/android/server/hdmi/DeviceDiscoveryAction.java +++ b/services/core/java/com/android/server/hdmi/DeviceDiscoveryAction.java @@ -39,7 +39,7 @@ import java.util.List; * <li>Gather "Vendor id" of all acknowledge devices * </ol> */ -final class DeviceDiscoveryAction extends FeatureAction { +final class DeviceDiscoveryAction extends HdmiCecFeatureAction { private static final String TAG = "DeviceDiscoveryAction"; // State in which the action is waiting for device polling. diff --git a/services/core/java/com/android/server/hdmi/DevicePowerStatusAction.java b/services/core/java/com/android/server/hdmi/DevicePowerStatusAction.java index c3c3fe1..d965caa 100644 --- a/services/core/java/com/android/server/hdmi/DevicePowerStatusAction.java +++ b/services/core/java/com/android/server/hdmi/DevicePowerStatusAction.java @@ -30,7 +30,7 @@ import android.util.Slog; * <p> * Package-private, accessed by {@link HdmiControlService} only. */ -final class DevicePowerStatusAction extends FeatureAction { +final class DevicePowerStatusAction extends HdmiCecFeatureAction { private static final String TAG = "DevicePowerStatusAction"; // State in which the action is waiting for <Report Power Status>. diff --git a/services/core/java/com/android/server/hdmi/DeviceSelectAction.java b/services/core/java/com/android/server/hdmi/DeviceSelectAction.java index e006e1c..ed37ead 100644 --- a/services/core/java/com/android/server/hdmi/DeviceSelectAction.java +++ b/services/core/java/com/android/server/hdmi/DeviceSelectAction.java @@ -33,7 +33,7 @@ import com.android.server.hdmi.HdmiControlService.SendMessageCallback; * for a new active source. It does its best to wake up the target in standby mode * before issuing the command >Set Stream path<. */ -final class DeviceSelectAction extends FeatureAction { +final class DeviceSelectAction extends HdmiCecFeatureAction { private static final String TAG = "DeviceSelect"; // Time in milliseconds we wait for the device power status to switch to 'Standby' diff --git a/services/core/java/com/android/server/hdmi/FeatureAction.java b/services/core/java/com/android/server/hdmi/HdmiCecFeatureAction.java index b7b2f90..f32e660 100644 --- a/services/core/java/com/android/server/hdmi/FeatureAction.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecFeatureAction.java @@ -29,21 +29,19 @@ import java.util.List; /** * Encapsulates a sequence of CEC/MHL command exchange for a certain feature. - * - * <p>Many CEC/MHL features are accomplished by CEC devices on the bus exchanging - * more than one command. {@link FeatureAction} represents the life cycle of the communication, - * manages the state as the process progresses, and if necessary, returns the result - * to the caller which initiates the action, through the callback given at the creation - * of the object. All the actual action classes inherit FeatureAction. - * - * <p>More than one FeatureAction objects can be up and running simultaneously, - * maintained by {@link HdmiCecLocalDevice}. Each action is passed a new command - * arriving from the bus, and either consumes it if the command is what the action expects, - * or yields it to other action. - * - * Declared as package private, accessed by {@link HdmiControlService} only. + * <p> + * Many CEC/MHL features are accomplished by CEC devices on the bus exchanging more than one + * command. {@link HdmiCecFeatureAction} represents the life cycle of the communication, manages the + * state as the process progresses, and if necessary, returns the result to the caller which + * initiates the action, through the callback given at the creation of the object. All the actual + * action classes inherit FeatureAction. + * <p> + * More than one FeatureAction objects can be up and running simultaneously, maintained by + * {@link HdmiCecLocalDevice}. Each action is passed a new command arriving from the bus, and either + * consumes it if the command is what the action expects, or yields it to other action. Declared as + * package private, accessed by {@link HdmiControlService} only. */ -abstract class FeatureAction { +abstract class HdmiCecFeatureAction { private static final String TAG = "FeatureAction"; // Timer handler message used for timeout event @@ -61,9 +59,9 @@ abstract class FeatureAction { // Timer that manages timeout events. protected ActionTimer mActionTimer; - private ArrayList<Pair<FeatureAction, Runnable>> mOnFinishedCallbacks; + private ArrayList<Pair<HdmiCecFeatureAction, Runnable>> mOnFinishedCallbacks; - FeatureAction(HdmiCecLocalDevice source) { + HdmiCecFeatureAction(HdmiCecLocalDevice source) { mSource = source; mService = mSource.getService(); mActionTimer = createActionTimer(mService.getServiceLooper()); @@ -173,11 +171,11 @@ abstract class FeatureAction { mService.sendCecCommand(cmd, callback); } - protected final void addAndStartAction(FeatureAction action) { + protected final void addAndStartAction(HdmiCecFeatureAction action) { mSource.addAndStartAction(action); } - protected final <T extends FeatureAction> List<T> getActions(final Class<T> clazz) { + protected final <T extends HdmiCecFeatureAction> List<T> getActions(final Class<T> clazz) { return mSource.getActions(clazz); } @@ -191,16 +189,16 @@ abstract class FeatureAction { * * @param action */ - protected final void removeAction(FeatureAction action) { + protected final void removeAction(HdmiCecFeatureAction action) { mSource.removeAction(action); } - protected final <T extends FeatureAction> void removeAction(final Class<T> clazz) { + protected final <T extends HdmiCecFeatureAction> void removeAction(final Class<T> clazz) { mSource.removeActionExcept(clazz, null); } - protected final <T extends FeatureAction> void removeActionExcept(final Class<T> clazz, - final FeatureAction exception) { + protected final <T extends HdmiCecFeatureAction> void removeActionExcept(final Class<T> clazz, + final HdmiCecFeatureAction exception) { mSource.removeActionExcept(clazz, exception); } @@ -233,7 +231,7 @@ abstract class FeatureAction { removeAction(this); } if (mOnFinishedCallbacks != null) { - for (Pair<FeatureAction, Runnable> actionCallbackPair: mOnFinishedCallbacks) { + for (Pair<HdmiCecFeatureAction, Runnable> actionCallbackPair: mOnFinishedCallbacks) { if (actionCallbackPair.first.mState != STATE_NONE) { actionCallbackPair.second.run(); } @@ -269,7 +267,7 @@ abstract class FeatureAction { getSourceAddress(), targetAddress)); } - protected final void addOnFinishedCallback(FeatureAction action, Runnable runnable) { + protected final void addOnFinishedCallback(HdmiCecFeatureAction action, Runnable runnable) { if (mOnFinishedCallbacks == null) { mOnFinishedCallbacks = new ArrayList<>(); } diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java index 18bfe32..be4c834 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java @@ -102,7 +102,7 @@ abstract class HdmiCecLocalDevice { // A collection of FeatureAction. // Note that access to this collection should happen in service thread. - private final LinkedList<FeatureAction> mActions = new LinkedList<>(); + private final LinkedList<HdmiCecFeatureAction> mActions = new LinkedList<>(); private final Handler mHandler = new Handler () { @Override @@ -250,7 +250,7 @@ abstract class HdmiCecLocalDevice { @ServiceThreadOnly private boolean dispatchMessageToAction(HdmiCecMessage message) { assertRunOnServiceThread(); - for (FeatureAction action : mActions) { + for (HdmiCecFeatureAction action : mActions) { if (action.processCommand(message)) { return true; } @@ -486,7 +486,7 @@ abstract class HdmiCecLocalDevice { } @ServiceThreadOnly - void addAndStartAction(final FeatureAction action) { + void addAndStartAction(final HdmiCecFeatureAction action) { assertRunOnServiceThread(); if (mService.isPowerStandbyOrTransient()) { Slog.w(TAG, "Skip the action during Standby: " + action); @@ -498,9 +498,9 @@ abstract class HdmiCecLocalDevice { // See if we have an action of a given type in progress. @ServiceThreadOnly - <T extends FeatureAction> boolean hasAction(final Class<T> clazz) { + <T extends HdmiCecFeatureAction> boolean hasAction(final Class<T> clazz) { assertRunOnServiceThread(); - for (FeatureAction action : mActions) { + for (HdmiCecFeatureAction action : mActions) { if (action.getClass().equals(clazz)) { return true; } @@ -510,10 +510,10 @@ abstract class HdmiCecLocalDevice { // Returns all actions matched with given class type. @ServiceThreadOnly - <T extends FeatureAction> List<T> getActions(final Class<T> clazz) { + <T extends HdmiCecFeatureAction> List<T> getActions(final Class<T> clazz) { assertRunOnServiceThread(); List<T> actions = Collections.<T>emptyList(); - for (FeatureAction action : mActions) { + for (HdmiCecFeatureAction action : mActions) { if (action.getClass().equals(clazz)) { if (actions.isEmpty()) { actions = new ArrayList<T>(); @@ -525,12 +525,12 @@ abstract class HdmiCecLocalDevice { } /** - * Remove the given {@link FeatureAction} object from the action queue. + * Remove the given {@link HdmiCecFeatureAction} object from the action queue. * - * @param action {@link FeatureAction} to remove + * @param action {@link HdmiCecFeatureAction} to remove */ @ServiceThreadOnly - void removeAction(final FeatureAction action) { + void removeAction(final HdmiCecFeatureAction action) { assertRunOnServiceThread(); action.finish(false); mActions.remove(action); @@ -539,19 +539,19 @@ abstract class HdmiCecLocalDevice { // Remove all actions matched with the given Class type. @ServiceThreadOnly - <T extends FeatureAction> void removeAction(final Class<T> clazz) { + <T extends HdmiCecFeatureAction> void removeAction(final Class<T> clazz) { assertRunOnServiceThread(); removeActionExcept(clazz, null); } // Remove all actions matched with the given Class type besides |exception|. @ServiceThreadOnly - <T extends FeatureAction> void removeActionExcept(final Class<T> clazz, - final FeatureAction exception) { + <T extends HdmiCecFeatureAction> void removeActionExcept(final Class<T> clazz, + final HdmiCecFeatureAction exception) { assertRunOnServiceThread(); - Iterator<FeatureAction> iter = mActions.iterator(); + Iterator<HdmiCecFeatureAction> iter = mActions.iterator(); while (iter.hasNext()) { - FeatureAction action = iter.next(); + HdmiCecFeatureAction action = iter.next(); if (action != exception && action.getClass().equals(clazz)) { action.finish(false); iter.remove(); @@ -698,9 +698,9 @@ abstract class HdmiCecLocalDevice { // If all actions are not cleared in DEVICE_CLEANUP_TIMEOUT, enforce to finish them. // onCleard will be called at the last action's finish method. - Iterator<FeatureAction> iter = mActions.iterator(); + Iterator<HdmiCecFeatureAction> iter = mActions.iterator(); while (iter.hasNext()) { - FeatureAction action = iter.next(); + HdmiCecFeatureAction action = iter.next(); action.finish(false); iter.remove(); } diff --git a/services/core/java/com/android/server/hdmi/HotplugDetectionAction.java b/services/core/java/com/android/server/hdmi/HotplugDetectionAction.java index 8fc0bbc..51e68b6 100644 --- a/services/core/java/com/android/server/hdmi/HotplugDetectionAction.java +++ b/services/core/java/com/android/server/hdmi/HotplugDetectionAction.java @@ -33,7 +33,7 @@ import java.util.List; * For other devices, keep 15 secs period. */ // Seq #3 -final class HotplugDetectionAction extends FeatureAction { +final class HotplugDetectionAction extends HdmiCecFeatureAction { private static final String TAG = "HotPlugDetectionAction"; private static final int POLLING_INTERVAL_MS = 5000; diff --git a/services/core/java/com/android/server/hdmi/NewDeviceAction.java b/services/core/java/com/android/server/hdmi/NewDeviceAction.java index 8154204..a5fdbea 100644 --- a/services/core/java/com/android/server/hdmi/NewDeviceAction.java +++ b/services/core/java/com/android/server/hdmi/NewDeviceAction.java @@ -33,7 +33,7 @@ import java.io.UnsupportedEncodingException; * * <p>Package-private, accessed by {@link HdmiControlService} only. */ -final class NewDeviceAction extends FeatureAction { +final class NewDeviceAction extends HdmiCecFeatureAction { private static final String TAG = "NewDeviceAction"; diff --git a/services/core/java/com/android/server/hdmi/OneTouchPlayAction.java b/services/core/java/com/android/server/hdmi/OneTouchPlayAction.java index 752cc37..7db991a 100644 --- a/services/core/java/com/android/server/hdmi/OneTouchPlayAction.java +++ b/services/core/java/com/android/server/hdmi/OneTouchPlayAction.java @@ -28,7 +28,7 @@ import android.util.Slog; * <p> * Package-private, accessed by {@link HdmiControlService} only. */ -final class OneTouchPlayAction extends FeatureAction { +final class OneTouchPlayAction extends HdmiCecFeatureAction { private static final String TAG = "OneTouchPlayAction"; // State in which the action is waiting for <Report Power Status>. In normal situation diff --git a/services/core/java/com/android/server/hdmi/OneTouchRecordAction.java b/services/core/java/com/android/server/hdmi/OneTouchRecordAction.java index befc640..39c0d7f 100644 --- a/services/core/java/com/android/server/hdmi/OneTouchRecordAction.java +++ b/services/core/java/com/android/server/hdmi/OneTouchRecordAction.java @@ -29,7 +29,7 @@ import com.android.server.hdmi.HdmiControlService.SendMessageCallback; /** * Feature action that performs one touch record. */ -public class OneTouchRecordAction extends FeatureAction { +public class OneTouchRecordAction extends HdmiCecFeatureAction { private static final String TAG = "OneTouchRecordAction"; // Timer out for waiting <Record Status> 120s diff --git a/services/core/java/com/android/server/hdmi/RequestArcAction.java b/services/core/java/com/android/server/hdmi/RequestArcAction.java index 3b1ad53..9c530a3 100644 --- a/services/core/java/com/android/server/hdmi/RequestArcAction.java +++ b/services/core/java/com/android/server/hdmi/RequestArcAction.java @@ -23,7 +23,7 @@ import android.util.Slog; /** * Base feature action class for <Request ARC Initiation>/<Request ARC Termination>. */ -abstract class RequestArcAction extends FeatureAction { +abstract class RequestArcAction extends HdmiCecFeatureAction { private static final String TAG = "RequestArcAction"; // State in which waits for ARC response. diff --git a/services/core/java/com/android/server/hdmi/RoutingControlAction.java b/services/core/java/com/android/server/hdmi/RoutingControlAction.java index dbf1961..435ab7f 100644 --- a/services/core/java/com/android/server/hdmi/RoutingControlAction.java +++ b/services/core/java/com/android/server/hdmi/RoutingControlAction.java @@ -38,7 +38,7 @@ import com.android.server.hdmi.HdmiControlService.SendMessageCallback; * <li> Routing at CEC enable time * </ul> */ -final class RoutingControlAction extends FeatureAction { +final class RoutingControlAction extends HdmiCecFeatureAction { private static final String TAG = "RoutingControlAction"; // State in which we wait for <Routing Information> to arrive. If timed out, we use the diff --git a/services/core/java/com/android/server/hdmi/SendKeyAction.java b/services/core/java/com/android/server/hdmi/SendKeyAction.java index ca2826e..9f09eb4 100644 --- a/services/core/java/com/android/server/hdmi/SendKeyAction.java +++ b/services/core/java/com/android/server/hdmi/SendKeyAction.java @@ -32,7 +32,7 @@ import android.view.KeyEvent; * * <p>Package-private, accessed by {@link HdmiControlService} only. */ -final class SendKeyAction extends FeatureAction { +final class SendKeyAction extends HdmiCecFeatureAction { private static final String TAG = "SendKeyAction"; // State in which the action is at work. The state is set in {@link #start()} and diff --git a/services/core/java/com/android/server/hdmi/SetArcTransmissionStateAction.java b/services/core/java/com/android/server/hdmi/SetArcTransmissionStateAction.java index 6104eb2..9f7f98a 100644 --- a/services/core/java/com/android/server/hdmi/SetArcTransmissionStateAction.java +++ b/services/core/java/com/android/server/hdmi/SetArcTransmissionStateAction.java @@ -24,7 +24,7 @@ import android.util.Slog; * Once TV gets <Initiate ARC>, TV sends <Report ARC Initiated> to AV Receiver. * If it fails or it gets <Terminate ARC>, TV just disables ARC. */ -final class SetArcTransmissionStateAction extends FeatureAction { +final class SetArcTransmissionStateAction extends HdmiCecFeatureAction { private static final String TAG = "SetArcTransmissionStateAction"; // State in which the action sent <Rerpot Arc Initiated> and diff --git a/services/core/java/com/android/server/hdmi/SystemAudioAction.java b/services/core/java/com/android/server/hdmi/SystemAudioAction.java index 057f9ba..7e45a99 100644 --- a/services/core/java/com/android/server/hdmi/SystemAudioAction.java +++ b/services/core/java/com/android/server/hdmi/SystemAudioAction.java @@ -28,7 +28,7 @@ import java.util.List; /** * Base feature action class for SystemAudioActionFromTv and SystemAudioActionFromAvr. */ -abstract class SystemAudioAction extends FeatureAction { +abstract class SystemAudioAction extends HdmiCecFeatureAction { private static final String TAG = "SystemAudioAction"; // Transient state to differentiate with STATE_NONE where the on-finished callback diff --git a/services/core/java/com/android/server/hdmi/SystemAudioAutoInitiationAction.java b/services/core/java/com/android/server/hdmi/SystemAudioAutoInitiationAction.java index 137cada..3653aac 100644 --- a/services/core/java/com/android/server/hdmi/SystemAudioAutoInitiationAction.java +++ b/services/core/java/com/android/server/hdmi/SystemAudioAutoInitiationAction.java @@ -22,7 +22,7 @@ import com.android.server.hdmi.HdmiControlService.SendMessageCallback; * Action to initiate system audio once AVR is detected on Device discovery action. */ // Seq #27 -final class SystemAudioAutoInitiationAction extends FeatureAction { +final class SystemAudioAutoInitiationAction extends HdmiCecFeatureAction { private final int mAvrAddress; // State that waits for <System Audio Mode Status> once send diff --git a/services/core/java/com/android/server/hdmi/SystemAudioStatusAction.java b/services/core/java/com/android/server/hdmi/SystemAudioStatusAction.java index 1066204..bfcda50 100644 --- a/services/core/java/com/android/server/hdmi/SystemAudioStatusAction.java +++ b/services/core/java/com/android/server/hdmi/SystemAudioStatusAction.java @@ -27,7 +27,7 @@ import com.android.server.hdmi.HdmiControlService.SendMessageCallback; /** * Action to update audio status (volume or mute) of audio amplifier */ -final class SystemAudioStatusAction extends FeatureAction { +final class SystemAudioStatusAction extends HdmiCecFeatureAction { private static final String TAG = "SystemAudioStatusAction"; // State that waits for <ReportAudioStatus>. diff --git a/services/core/java/com/android/server/hdmi/TimerRecordingAction.java b/services/core/java/com/android/server/hdmi/TimerRecordingAction.java index 1a179e6..8fc0182 100644 --- a/services/core/java/com/android/server/hdmi/TimerRecordingAction.java +++ b/services/core/java/com/android/server/hdmi/TimerRecordingAction.java @@ -31,7 +31,7 @@ import java.util.Arrays; /** * Feature action that performs timer recording. */ -public class TimerRecordingAction extends FeatureAction { +public class TimerRecordingAction extends HdmiCecFeatureAction { private static final String TAG = "TimerRecordingAction"; // Timer out for waiting <Timer Status> 120s. diff --git a/services/core/java/com/android/server/hdmi/VolumeControlAction.java b/services/core/java/com/android/server/hdmi/VolumeControlAction.java index e32b792..01c6f3e 100644 --- a/services/core/java/com/android/server/hdmi/VolumeControlAction.java +++ b/services/core/java/com/android/server/hdmi/VolumeControlAction.java @@ -28,7 +28,7 @@ import com.android.internal.util.Preconditions; * from Audio Receiver(AVR). If TV receives no <Report Audio Status> from AVR, this action * will be finished in {@link #IRT_MS} * {@link #VOLUME_CHANGE_TIMEOUT_MAX_COUNT} (ms). */ -final class VolumeControlAction extends FeatureAction { +final class VolumeControlAction extends HdmiCecFeatureAction { private static final String TAG = "VolumeControlAction"; private static final int VOLUME_MUTE = 101; diff --git a/services/core/java/com/android/server/job/JobSchedulerService.java b/services/core/java/com/android/server/job/JobSchedulerService.java index 9ac90dc..14457ec 100644 --- a/services/core/java/com/android/server/job/JobSchedulerService.java +++ b/services/core/java/com/android/server/job/JobSchedulerService.java @@ -74,7 +74,7 @@ public class JobSchedulerService extends com.android.server.SystemService static final boolean DEBUG = true; /** The number of concurrent jobs we run at one time. */ private static final int MAX_JOB_CONTEXTS_COUNT = 3; - static final String TAG = "JobManagerService"; + static final String TAG = "JobSchedulerService"; /** Master list of jobs. */ final JobStore mJobs; @@ -88,6 +88,11 @@ public class JobSchedulerService extends com.android.server.SystemService */ static final int MIN_IDLE_COUNT = 1; /** + * Minimum # of charging jobs that must be ready in order to force the JMS to schedule things + * early. + */ + static final int MIN_CHARGING_COUNT = 1; + /** * Minimum # of connectivity jobs that must be ready in order to force the JMS to schedule * things early. */ @@ -95,8 +100,9 @@ public class JobSchedulerService extends com.android.server.SystemService /** * Minimum # of jobs (with no particular constraints) for which the JMS will be happy running * some work early. + * This is correlated with the amount of batching we'll be able to do. */ - static final int MIN_READY_JOBS_COUNT = 4; + static final int MIN_READY_JOBS_COUNT = 2; /** * Track Services that have currently active or pending jobs. The index is provided by @@ -546,7 +552,8 @@ public class JobSchedulerService extends com.android.server.SystemService */ private void maybeQueueReadyJobsForExecutionH() { synchronized (mJobs) { - int idleCount = 0; + int chargingCount = 0; + int idleCount = 0; int backoffCount = 0; int connectivityCount = 0; List<JobStatus> runnableJobs = new ArrayList<JobStatus>(); @@ -563,17 +570,34 @@ public class JobSchedulerService extends com.android.server.SystemService if (job.hasConnectivityConstraint() || job.hasUnmeteredConstraint()) { connectivityCount++; } + if (job.hasChargingConstraint()) { + chargingCount++; + } runnableJobs.add(job); } else if (isReadyToBeCancelledLocked(job)) { stopJobOnServiceContextLocked(job); } } - if (backoffCount > 0 || idleCount >= MIN_IDLE_COUNT || + if (backoffCount > 0 || + idleCount >= MIN_IDLE_COUNT || connectivityCount >= MIN_CONNECTIVITY_COUNT || + chargingCount >= MIN_CHARGING_COUNT || runnableJobs.size() >= MIN_READY_JOBS_COUNT) { + if (DEBUG) { + Slog.d(TAG, "maybeQueueReadyJobsForExecutionH: Running jobs."); + } for (int i=0; i<runnableJobs.size(); i++) { mPendingJobs.add(runnableJobs.get(i)); } + } else { + if (DEBUG) { + Slog.d(TAG, "maybeQueueReadyJobsForExecutionH: Not running anything."); + } + } + if (DEBUG) { + Slog.d(TAG, "idle=" + idleCount + " connectivity=" + + connectivityCount + " charging=" + chargingCount + " tot=" + + runnableJobs.size()); } } } diff --git a/services/core/java/com/android/server/job/controllers/IdleController.java b/services/core/java/com/android/server/job/controllers/IdleController.java index 2213934..7b71027 100644 --- a/services/core/java/com/android/server/job/controllers/IdleController.java +++ b/services/core/java/com/android/server/job/controllers/IdleController.java @@ -113,12 +113,13 @@ public class IdleController extends StateController { public IdlenessTracker() { mAlarm = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); - Intent intent = new Intent(ACTION_TRIGGER_IDLE); - intent.setComponent(new ComponentName(mContext, this.getClass())); + Intent intent = new Intent(ACTION_TRIGGER_IDLE) + .setPackage("android") + .setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); mIdleTriggerIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0); - // at boot we presume that the user has just "interacted" with the - // device in some meaningful way + // At boot we presume that the user has just "interacted" with the + // device in some meaningful way. mIdle = false; } @@ -163,9 +164,11 @@ public class IdleController extends StateController { // when the screen goes off or dreaming starts, we schedule the // alarm that will tell us when we have decided the device is // truly idle. - long when = SystemClock.elapsedRealtime() + INACTIVITY_IDLE_THRESHOLD; + final long nowElapsed = SystemClock.elapsedRealtime(); + final long when = nowElapsed + INACTIVITY_IDLE_THRESHOLD; if (DEBUG) { - Slog.v(TAG, "Scheduling idle : " + action + " when=" + when); + Slog.v(TAG, "Scheduling idle : " + action + " now:" + nowElapsed + " when=" + + when); } mAlarm.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP, when, IDLE_WINDOW_SLOP, mIdleTriggerIntent); |