Merge "Recompute focus stack if cleared while starting an activity."
diff --git a/api/current.txt b/api/current.txt
index 7e74c61..4e51621 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -15145,7 +15145,7 @@
method public void setPropertyString(java.lang.String, java.lang.String);
field public static final int EVENT_KEY_EXPIRED = 3; // 0x3
field public static final int EVENT_KEY_REQUIRED = 2; // 0x2
- field public static final int EVENT_PROVISION_REQUIRED = 1; // 0x1
+ field public static final deprecated int EVENT_PROVISION_REQUIRED = 1; // 0x1
field public static final int EVENT_SESSION_RECLAIMED = 5; // 0x5
field public static final int EVENT_VENDOR_DEFINED = 4; // 0x4
field public static final int KEY_TYPE_OFFLINE = 2; // 0x2
@@ -37450,6 +37450,7 @@
method public void goBack();
method public void goBackOrForward(int);
method public void goForward();
+ method public void insertVisualStateCallback(long, android.webkit.WebView.VisualStateCallback);
method public void invokeZoomPicker();
method public boolean isPrivateBrowsingEnabled();
method public void loadData(java.lang.String, java.lang.String, java.lang.String);
@@ -37524,6 +37525,11 @@
method public abstract deprecated void onNewPicture(android.webkit.WebView, android.graphics.Picture);
}
+ public static abstract class WebView.VisualStateCallback {
+ ctor public WebView.VisualStateCallback();
+ method public abstract void onComplete(long);
+ }
+
public class WebView.WebViewTransport {
ctor public WebView.WebViewTransport();
method public synchronized android.webkit.WebView getWebView();
@@ -37535,6 +37541,7 @@
method public void doUpdateVisitedHistory(android.webkit.WebView, java.lang.String, boolean);
method public void onFormResubmission(android.webkit.WebView, android.os.Message, android.os.Message);
method public void onLoadResource(android.webkit.WebView, java.lang.String);
+ method public void onPageCommitVisible(android.webkit.WebView, java.lang.String);
method public void onPageFinished(android.webkit.WebView, java.lang.String);
method public void onPageStarted(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
method public void onReceivedClientCertRequest(android.webkit.WebView, android.webkit.ClientCertRequest);
diff --git a/api/system-current.txt b/api/system-current.txt
index 30da80c..d0dd852 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -16334,7 +16334,7 @@
method public void unprovisionDevice();
field public static final int EVENT_KEY_EXPIRED = 3; // 0x3
field public static final int EVENT_KEY_REQUIRED = 2; // 0x2
- field public static final int EVENT_PROVISION_REQUIRED = 1; // 0x1
+ field public static final deprecated int EVENT_PROVISION_REQUIRED = 1; // 0x1
field public static final int EVENT_SESSION_RECLAIMED = 5; // 0x5
field public static final int EVENT_VENDOR_DEFINED = 4; // 0x4
field public static final int KEY_TYPE_OFFLINE = 2; // 0x2
@@ -39882,6 +39882,7 @@
method public void goBack();
method public void goBackOrForward(int);
method public void goForward();
+ method public void insertVisualStateCallback(long, android.webkit.WebView.VisualStateCallback);
method public void invokeZoomPicker();
method public boolean isPrivateBrowsingEnabled();
method public void loadData(java.lang.String, java.lang.String, java.lang.String);
@@ -39986,6 +39987,11 @@
method public void super_setLayoutParams(android.view.ViewGroup.LayoutParams);
}
+ public static abstract class WebView.VisualStateCallback {
+ ctor public WebView.VisualStateCallback();
+ method public abstract void onComplete(long);
+ }
+
public class WebView.WebViewTransport {
ctor public WebView.WebViewTransport();
method public synchronized android.webkit.WebView getWebView();
@@ -39997,6 +40003,7 @@
method public void doUpdateVisitedHistory(android.webkit.WebView, java.lang.String, boolean);
method public void onFormResubmission(android.webkit.WebView, android.os.Message, android.os.Message);
method public void onLoadResource(android.webkit.WebView, java.lang.String);
+ method public void onPageCommitVisible(android.webkit.WebView, java.lang.String);
method public void onPageFinished(android.webkit.WebView, java.lang.String);
method public void onPageStarted(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
method public void onReceivedClientCertRequest(android.webkit.WebView, android.webkit.ClientCertRequest);
@@ -40143,6 +40150,7 @@
method public abstract void goBackOrForward(int);
method public abstract void goForward();
method public abstract void init(java.util.Map<java.lang.String, java.lang.Object>, boolean);
+ method public abstract void insertVisualStateCallback(long, android.webkit.WebView.VisualStateCallback);
method public abstract void invokeZoomPicker();
method public abstract boolean isPaused();
method public abstract boolean isPrivateBrowsingEnabled();
diff --git a/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java b/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java
index 367a078..b5a019d 100644
--- a/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java
+++ b/core/java/android/hardware/camera2/legacy/LegacyCameraDevice.java
@@ -292,6 +292,10 @@
Log.e(TAG, "configureOutputs - null outputs are not allowed");
return BAD_VALUE;
}
+ if (!output.isValid()) {
+ Log.e(TAG, "configureOutputs - invalid output surfaces are not allowed");
+ return BAD_VALUE;
+ }
StreamConfigurationMap streamConfigurations = mStaticCharacteristics.
get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
@@ -522,7 +526,7 @@
* @return the width and height of the surface
*
* @throws NullPointerException if the {@code surface} was {@code null}
- * @throws IllegalStateException if the {@code surface} was invalid
+ * @throws BufferQueueAbandonedException if the {@code surface} was invalid
*/
public static Size getSurfaceSize(Surface surface) throws BufferQueueAbandonedException {
checkNotNull(surface);
diff --git a/core/java/android/hardware/camera2/legacy/LegacyExceptionUtils.java b/core/java/android/hardware/camera2/legacy/LegacyExceptionUtils.java
index 7e0c01b..4b7cfbf 100644
--- a/core/java/android/hardware/camera2/legacy/LegacyExceptionUtils.java
+++ b/core/java/android/hardware/camera2/legacy/LegacyExceptionUtils.java
@@ -60,7 +60,7 @@
case CameraBinderDecorator.NO_ERROR: {
return CameraBinderDecorator.NO_ERROR;
}
- case CameraBinderDecorator.ENODEV: {
+ case CameraBinderDecorator.BAD_VALUE: {
throw new BufferQueueAbandonedException();
}
}
diff --git a/core/java/android/hardware/camera2/legacy/RequestThreadManager.java b/core/java/android/hardware/camera2/legacy/RequestThreadManager.java
index ff74c59..691798f 100644
--- a/core/java/android/hardware/camera2/legacy/RequestThreadManager.java
+++ b/core/java/android/hardware/camera2/legacy/RequestThreadManager.java
@@ -498,6 +498,10 @@
return;
}
for(Surface s : surfaces) {
+ if (s == null || !s.isValid()) {
+ Log.w(TAG, "Jpeg surface is invalid, skipping...");
+ continue;
+ }
try {
LegacyCameraDevice.setSurfaceFormat(s, LegacyMetadataMapper.HAL_PIXEL_FORMAT_BLOB);
} catch (LegacyExceptionUtils.BufferQueueAbandonedException e) {
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index e303f61..de970cb 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -364,6 +364,12 @@
public static final int GO_TO_SLEEP_REASON_HDMI = 5;
/**
+ * Go to sleep reason code: Going to sleep due to the sleep button being pressed.
+ * @hide
+ */
+ public static final int GO_TO_SLEEP_REASON_SLEEP_BUTTON = 6;
+
+ /**
* Go to sleep flag: Skip dozing state and directly go to full sleep.
* @hide
*/
diff --git a/core/java/android/view/PhoneWindow.java b/core/java/android/view/PhoneWindow.java
index 37859b8..543021e 100644
--- a/core/java/android/view/PhoneWindow.java
+++ b/core/java/android/view/PhoneWindow.java
@@ -1759,7 +1759,8 @@
} else {
MediaSessionLegacyHelper.getHelper(getContext()).sendAdjustVolumeBy(
mVolumeControlStreamType, direction,
- AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_VIBRATE);
+ AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_VIBRATE
+ | AudioManager.FLAG_FROM_KEY);
}
return true;
}
@@ -1837,15 +1838,15 @@
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
case KeyEvent.KEYCODE_VOLUME_DOWN: {
+ final int flags = AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_VIBRATE
+ | AudioManager.FLAG_FROM_KEY;
// If we have a session send it the volume command, otherwise
// use the suggested stream.
if (mMediaController != null) {
- mMediaController.adjustVolume(0, AudioManager.FLAG_PLAY_SOUND
- | AudioManager.FLAG_VIBRATE);
+ mMediaController.adjustVolume(0, flags);
} else {
MediaSessionLegacyHelper.getHelper(getContext()).sendAdjustVolumeBy(
- mVolumeControlStreamType, 0,
- AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_VIBRATE);
+ mVolumeControlStreamType, 0, flags);
}
return true;
}
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 67ad642..6711a6b 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -364,6 +364,20 @@
}
/**
+ * Callback interface supplied to {@link #insertVisualStateCallback} for receiving
+ * notifications about the visual state.
+ */
+ public static abstract class VisualStateCallback {
+ /**
+ * Invoked when the visual state is ready to be drawn in the next {@link #onDraw}.
+ *
+ * @param requestId the id supplied to the corresponding {@link #insertVisualStateCallback}
+ * request
+ */
+ public abstract void onComplete(long requestId);
+ }
+
+ /**
* Interface to listen for new pictures as they change.
*
* @deprecated This interface is now obsolete.
@@ -1144,6 +1158,60 @@
}
/**
+ * Inserts a {@link VisualStateCallback}.
+ *
+ * <p>Updates to the the DOM are reflected asynchronously such that when the DOM is updated the
+ * subsequent {@link WebView#onDraw} invocation might not reflect those updates. The
+ * {@link VisualStateCallback} provides a mechanism to notify the caller when the contents of
+ * the DOM at the current time are ready to be drawn the next time the {@link WebView} draws.
+ * By current time we mean the time at which this API was called. The next draw after the
+ * callback completes is guaranteed to reflect all the updates to the DOM applied before the
+ * current time, but it may also contain updates applied after the current time.</p>
+ *
+ * <p>The state of the DOM covered by this API includes the following:
+ * <ul>
+ * <li>primitive HTML elements (div, img, span, etc..)</li>
+ * <li>images</li>
+ * <li>CSS animations</li>
+ * <li>WebGL</li>
+ * <li>canvas</li>
+ * </ul>
+ * It does not include the state of:
+ * <ul>
+ * <li>the video tag</li>
+ * </ul></p>
+ *
+ * <p>To guarantee that the {@link WebView} will successfully render the first frame
+ * after the {@link VisualStateCallback#onComplete} method has been called a set of conditions
+ * must be met:
+ * <ul>
+ * <li>If the {@link WebView}'s visibility is set to {@link View#VISIBLE VISIBLE} then
+ * the {@link WebView} must be attached to the view hierarchy.</li>
+ * <li>If the {@link WebView}'s visibility is set to {@link View#INVISIBLE INVISIBLE}
+ * then the {@link WebView} must be attached to the view hierarchy and must be made
+ * {@link View#VISIBLE VISIBLE} from the {@link VisualStateCallback#onComplete} method.</li>
+ * <li>If the {@link WebView}'s visibility is set to {@link View#GONE GONE} then the
+ * {@link WebView} must be attached to the view hierarchy and its
+ * {@link AbsoluteLayout.LayoutParams LayoutParams}'s width and height need to be set to fixed
+ * values and must be made {@link View#VISIBLE VISIBLE} from the
+ * {@link VisualStateCallback#onComplete} method.</li>
+ * </ul></p>
+ *
+ * <p>When using this API it is also recommended to enable pre-rasterization if the
+ * {@link WebView} is offscreen to avoid flickering. See WebSettings#setOffscreenPreRaster for
+ * more details and do consider its caveats.</p>
+ *
+ * @param requestId an id that will be returned in the callback to allow callers to match
+ * requests with callbacks.
+ * @param callback the callback to be invoked.
+ */
+ public void insertVisualStateCallback(long requestId, VisualStateCallback callback) {
+ checkThread();
+ if (TRACE) Log.d(LOGTAG, "insertVisualStateCallback");
+ mProvider.insertVisualStateCallback(requestId, callback);
+ }
+
+ /**
* Clears this WebView so that onDraw() will draw nothing but white background,
* and onMeasure() will return 0 if MeasureSpec is not MeasureSpec.EXACTLY.
* @deprecated Use WebView.loadUrl("about:blank") to reliably reset the view state
diff --git a/core/java/android/webkit/WebViewClient.java b/core/java/android/webkit/WebViewClient.java
index 34b8cf6..53c7e04 100644
--- a/core/java/android/webkit/WebViewClient.java
+++ b/core/java/android/webkit/WebViewClient.java
@@ -83,6 +83,32 @@
}
/**
+ * Notify the host application that the page commit is visible.
+ *
+ * <p>This is the earliest point at which we can guarantee that the contents of the previously
+ * loaded page will not longer be drawn in the next {@link WebView#onDraw}. The next draw will
+ * render the {@link WebView#setBackgroundColor background color} of the WebView or some of the
+ * contents from the committed page already. This callback may be useful when reusing
+ * {@link WebView}s to ensure that no stale content is shown. This method is only called for
+ * the main frame.</p>
+ *
+ * <p>This method is called when the state of the DOM at the point at which the
+ * body of the HTTP response (commonly the string of html) had started loading will be visible.
+ * If you set a background color for the page in the HTTP response body this will most likely
+ * be visible and perhaps some other elements. At that point no other resources had usually
+ * been loaded, so you can expect images for example to not be visible. If you want
+ * a finer level of granularity consider calling {@link WebView#insertVisualStateCallback}
+ * directly.</p>
+ *
+ * <p>Please note that all the conditions and recommendations presented in
+ * {@link WebView#insertVisualStateCallback} also apply to this API.<p>
+ *
+ * @param url the url of the committed page
+ */
+ public void onPageCommitVisible(WebView view, String url) {
+ }
+
+ /**
* Notify the host application of a resource request and allow the
* application to return the data. If the return value is null, the WebView
* will continue to load the resource as usual. Otherwise, the return
diff --git a/core/java/android/webkit/WebViewProvider.java b/core/java/android/webkit/WebViewProvider.java
index 0cdb875..fa2ce1b 100644
--- a/core/java/android/webkit/WebViewProvider.java
+++ b/core/java/android/webkit/WebViewProvider.java
@@ -40,6 +40,8 @@
import android.view.inputmethod.InputConnection;
import android.webkit.WebView.HitTestResult;
import android.webkit.WebView.PictureListener;
+import android.webkit.WebView.VisualStateCallback;
+
import java.io.BufferedWriter;
import java.io.File;
@@ -146,6 +148,8 @@
public boolean pageDown(boolean bottom);
+ public void insertVisualStateCallback(long requestId, VisualStateCallback callback);
+
public void clearView();
public Picture capturePicture();
diff --git a/core/java/com/android/internal/app/WindowDecorActionBar.java b/core/java/com/android/internal/app/WindowDecorActionBar.java
index 2bf02f1..7ae7d0f 100644
--- a/core/java/com/android/internal/app/WindowDecorActionBar.java
+++ b/core/java/com/android/internal/app/WindowDecorActionBar.java
@@ -23,7 +23,6 @@
import com.android.internal.R;
import com.android.internal.view.ActionBarPolicy;
-import com.android.internal.view.ActionModeWrapper;
import com.android.internal.view.menu.MenuBuilder;
import com.android.internal.view.menu.MenuPopupHelper;
import com.android.internal.view.menu.SubMenuBuilder;
diff --git a/core/java/com/android/internal/view/ActionModeWrapper.java b/core/java/com/android/internal/view/ActionModeWrapper.java
deleted file mode 100644
index d98617d..0000000
--- a/core/java/com/android/internal/view/ActionModeWrapper.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright (C) 2015 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.internal.view;
-
-import android.content.Context;
-import android.view.ActionMode;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-
-import com.android.internal.view.menu.MenuBuilder;
-
-/**
- * ActionMode implementation that wraps several actions modes and creates them on the fly depending
- * on the ActionMode type chosen by the client.
- */
-public class ActionModeWrapper extends ActionMode {
-
- /**
- * Interface to defer the ActionMode creation until the type is chosen.
- */
- public interface ActionModeProvider {
- /**
- * Create the desired ActionMode, that will immediately be used as the current active mode
- * in the decorator.
- *
- * @param callback The {@link ActionMode.Callback} to be used.
- * @param menuBuilder The {@link MenuBuilder} that should be used by the created
- * {@link ActionMode}. This will already have been populated.
- * @return A new {@link ActionMode} ready to be used that uses menuBuilder as its menu.
- */
- ActionMode createActionMode(ActionMode.Callback callback, MenuBuilder menuBuilder);
- }
-
- private ActionMode mActionMode;
- private final Context mContext;
- private MenuBuilder mMenu;
- private final ActionMode.Callback mCallback;
- private boolean mTypeLocked = false;
-
- private CharSequence mTitle;
- private CharSequence mSubtitle;
- private View mCustomView;
-
- private final ActionModeProvider mActionModeProvider;
-
- public ActionModeWrapper(
- Context context, ActionMode.Callback callback, ActionModeProvider actionModeProvider) {
- mContext = context;
- mMenu = new MenuBuilder(context).setDefaultShowAsAction(
- MenuItem.SHOW_AS_ACTION_IF_ROOM);
- mCallback = callback;
- mActionModeProvider = actionModeProvider;
- }
-
- @Override
- public void setTitle(CharSequence title) {
- if (mActionMode != null) {
- mActionMode.setTitle(title);
- } else {
- mTitle = title;
- }
- }
-
- @Override
- public void setTitle(int resId) {
- if (mActionMode != null) {
- mActionMode.setTitle(resId);
- } else {
- mTitle = resId != 0 ? mContext.getString(resId) : null;
- }
- }
-
- @Override
- public void setSubtitle(CharSequence subtitle) {
- if (mActionMode != null) {
- mActionMode.setSubtitle(subtitle);
- } else {
- mSubtitle = subtitle;
- }
- }
-
- @Override
- public void setSubtitle(int resId) {
- if (mActionMode != null) {
- mActionMode.setSubtitle(resId);
- } else {
- mSubtitle = resId != 0 ? mContext.getString(resId) : null;
- }
- }
-
- @Override
- public void setCustomView(View view) {
- if (mActionMode != null) {
- mActionMode.setCustomView(view);
- } else {
- mCustomView = view;
- }
- }
-
- public ActionMode getWrappedActionMode() {
- return mActionMode;
- }
-
- /**
- * Set the current type as final and create the necessary ActionMode. After this call, any
- * changes to the ActionMode type will be ignored.
- */
- public void lockType() {
- mTypeLocked = true;
- switch (getType()) {
- case ActionMode.TYPE_PRIMARY:
- default:
- mActionMode = mActionModeProvider.createActionMode(mCallback, mMenu);
- break;
- case ActionMode.TYPE_FLOATING:
- // Not implemented yet.
- break;
- }
-
- if (mActionMode == null) {
- return;
- }
-
- mActionMode.setTitle(mTitle);
- mActionMode.setSubtitle(mSubtitle);
- if (mCustomView != null) {
- mActionMode.setCustomView(mCustomView);
- }
-
- mTitle = null;
- mSubtitle = null;
- mCustomView = null;
- }
-
- @Override
- public void setType(int type) {
- if (!mTypeLocked) {
- super.setType(type);
- } else {
- throw new IllegalStateException(
- "You can't change the ActionMode's type after onCreateActionMode.");
- }
- }
-
- @Override
- public void invalidate() {
- if (mActionMode != null) {
- mActionMode.invalidate();
- }
- }
-
- @Override
- public void finish() {
- if (mActionMode != null) {
- mActionMode.finish();
- } else {
- mCallback.onDestroyActionMode(this);
- }
- }
-
- @Override
- public Menu getMenu() {
- return mMenu;
- }
-
- @Override
- public CharSequence getTitle() {
- if (mActionMode != null) {
- return mActionMode.getTitle();
- }
- return mTitle;
- }
-
- @Override
- public CharSequence getSubtitle() {
- if (mActionMode != null) {
- return mActionMode.getSubtitle();
- }
- return mSubtitle;
- }
-
- @Override
- public View getCustomView() {
- if (mActionMode != null) {
- return mActionMode.getCustomView();
- }
- return mCustomView;
- }
-
- @Override
- public MenuInflater getMenuInflater() {
- return new MenuInflater(mContext);
- }
-
-}
diff --git a/core/jni/android_hardware_camera2_legacy_LegacyCameraDevice.cpp b/core/jni/android_hardware_camera2_legacy_LegacyCameraDevice.cpp
index 87896df..afdfd8f 100644
--- a/core/jni/android_hardware_camera2_legacy_LegacyCameraDevice.cpp
+++ b/core/jni/android_hardware_camera2_legacy_LegacyCameraDevice.cpp
@@ -373,8 +373,7 @@
return NULL;
}
if (anw == NULL) {
- jniThrowExceptionFmt(env, "java/lang/IllegalArgumentException",
- "Surface had no valid native window.");
+ ALOGE("%s: Surface had no valid native window.", __FUNCTION__);
return NULL;
}
return anw;
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index a781786..37c9598 100755
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -664,6 +664,12 @@
-->
<integer name="config_triplePressOnPowerBehavior">0</integer>
+ <!-- Control the behavior when the user presses the sleep button.
+ 0 - Go to sleep (doze)
+ 1 - Go to sleep (doze) and go home
+ -->
+ <integer name="config_shortPressOnSleepBehavior">0</integer>
+
<!-- Package name for default keyguard appwidget [DO NOT TRANSLATE] -->
<string name="widget_default_package_name" translatable="false"></string>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 20ec563..0617503 100755
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -367,6 +367,7 @@
<java-symbol type="integer" name="config_shortPressOnPowerBehavior" />
<java-symbol type="integer" name="config_toastDefaultGravity" />
<java-symbol type="integer" name="config_triplePressOnPowerBehavior" />
+ <java-symbol type="integer" name="config_shortPressOnSleepBehavior" />
<java-symbol type="integer" name="config_wifi_framework_scan_interval" />
<java-symbol type="integer" name="config_wifi_supplicant_scan_interval" />
<java-symbol type="integer" name="config_wifi_scan_interval_p2p_connected" />
diff --git a/docs/html/guide/topics/manifest/application-element.jd b/docs/html/guide/topics/manifest/application-element.jd
index 8a0e837..b5af9c3 100644
--- a/docs/html/guide/topics/manifest/application-element.jd
+++ b/docs/html/guide/topics/manifest/application-element.jd
@@ -449,11 +449,15 @@
<dt><a name="vmSafeMode"></a>{@code android:vmSafeMode}</dt>
<dd>Indicates whether the app would like the virtual machine (VM) to operate
in safe mode. The default value is {@code "false"}.
+
+<p> This attribute was added in API level 8 where a value of "true"
+disabled the Dalvik just-in-time (JIT) compiler. </p>
+
+<p> This attribute was adapted in API level 22 where a value of "true"
+disabled the ART ahead-of-time (AOT) compiler. </p>
</dd>
-
-
</dl></dd>
<!-- ##api level indication## -->
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index 8c1ba05..365b935 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -438,6 +438,12 @@
*/
public static final int FLAG_SHOW_VIBRATE_HINT = 1 << 11;
+ /**
+ * Adjusting the volume due to a hardware key press.
+ * @hide
+ */
+ public static final int FLAG_FROM_KEY = 1 << 12;
+
private static final String[] FLAG_NAMES = {
"FLAG_SHOW_UI",
"FLAG_ALLOW_RINGER_MODES",
@@ -451,6 +457,7 @@
"FLAG_ACTIVE_MEDIA_ONLY",
"FLAG_SHOW_UI_WARNINGS",
"FLAG_SHOW_VIBRATE_HINT",
+ "FLAG_FROM_KEY",
};
/** @hide */
diff --git a/media/java/android/media/ImageReader.java b/media/java/android/media/ImageReader.java
index 824a7ad..18ffe12 100644
--- a/media/java/android/media/ImageReader.java
+++ b/media/java/android/media/ImageReader.java
@@ -443,6 +443,7 @@
@Override
public void close() {
setOnImageAvailableListener(null, null);
+ if (mSurface != null) mSurface.release();
nativeClose();
}
diff --git a/media/java/android/media/MediaDrm.java b/media/java/android/media/MediaDrm.java
index d7752b9..6b37a34 100644
--- a/media/java/android/media/MediaDrm.java
+++ b/media/java/android/media/MediaDrm.java
@@ -254,6 +254,9 @@
* This event type indicates that the app needs to request a certificate from
* the provisioning server. The request message data is obtained using
* {@link #getProvisionRequest}
+ *
+ * @deprecated Handle provisioning via {@link android.media.NotProvisionedException}
+ * instead.
*/
public static final int EVENT_PROVISION_REQUIRED = 1;
diff --git a/media/java/android/media/session/MediaSessionLegacyHelper.java b/media/java/android/media/session/MediaSessionLegacyHelper.java
index 3276f0c..c61d7ad 100644
--- a/media/java/android/media/session/MediaSessionLegacyHelper.java
+++ b/media/java/android/media/session/MediaSessionLegacyHelper.java
@@ -197,17 +197,17 @@
break;
}
if (down || up) {
- int flags;
+ int flags = AudioManager.FLAG_FROM_KEY;
if (musicOnly) {
// This flag is used when the screen is off to only affect
// active media
- flags = AudioManager.FLAG_ACTIVE_MEDIA_ONLY;
+ flags |= AudioManager.FLAG_ACTIVE_MEDIA_ONLY;
} else {
// These flags are consistent with the home screen
if (up) {
- flags = AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_VIBRATE;
+ flags |= AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_VIBRATE;
} else {
- flags = AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_VIBRATE;
+ flags |= AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_VIBRATE;
}
}
if (direction != 0) {
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index d9aff44..2d87e8f 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -621,7 +621,7 @@
<!-- QuickSettings: Wifi detail panel, text when there are no items [CHAR LIMIT=NONE] -->
<string name="quick_settings_wifi_detail_empty_text">No saved networks available</string>
<!-- QuickSettings: Cast title [CHAR LIMIT=NONE] -->
- <string name="quick_settings_cast_title">Cast screen</string>
+ <string name="quick_settings_cast_title">Cast</string>
<!-- QuickSettings: Cast detail panel, status text when casting [CHAR LIMIT=NONE] -->
<string name="quick_settings_casting">Casting</string>
<!-- QuickSettings: Cast detail panel, default device name [CHAR LIMIT=NONE] -->
diff --git a/services/core/java/com/android/server/am/ActivityManagerDebugConfig.java b/services/core/java/com/android/server/am/ActivityManagerDebugConfig.java
index ae4006d..fd4974e 100644
--- a/services/core/java/com/android/server/am/ActivityManagerDebugConfig.java
+++ b/services/core/java/com/android/server/am/ActivityManagerDebugConfig.java
@@ -30,10 +30,10 @@
// will be tagged with their class names instead fot the generic tag.
static final boolean TAG_WITH_CLASS_NAME = false;
- // While debugging it is sometimes useful to have the category name of the log prepended to the
+ // While debugging it is sometimes useful to have the category name of the log appended to the
// base log tag to make sifting through logs with the same base tag easier. By setting this
- // constant to true, the category name of the log point will be prepended to the log tag.
- static final boolean PREPEND_CATEGORY_NAME = false;
+ // constant to true, the category name of the log point will be appended to the log tag.
+ static final boolean APPEND_CATEGORY_NAME = false;
// Default log tag for the activity manager package.
static final String TAG_AM = "ActivityManager";
@@ -74,12 +74,17 @@
static final boolean DEBUG_USER_LEAVING = DEBUG_ALL || false;
static final boolean DEBUG_VISBILITY = DEBUG_ALL || false;
- static final String POSTFIX_BACKUP = (PREPEND_CATEGORY_NAME) ? "_Backup" : "";
- static final String POSTFIX_BROADCAST = (PREPEND_CATEGORY_NAME) ? "_Broadcast" : "";
- static final String POSTFIX_CLEANUP = (PREPEND_CATEGORY_NAME) ? "_Cleanup" : "";
+ static final String POSTFIX_BACKUP = (APPEND_CATEGORY_NAME) ? "_Backup" : "";
+ static final String POSTFIX_BROADCAST = (APPEND_CATEGORY_NAME) ? "_Broadcast" : "";
+ static final String POSTFIX_CLEANUP = (APPEND_CATEGORY_NAME) ? "_Cleanup" : "";
+ static final String POSTFIX_CONFIGURATION = (APPEND_CATEGORY_NAME) ? "_Configuration" : "";
+ static final String POSTFIX_FOCUS = (APPEND_CATEGORY_NAME) ? "_Focus" : "";
+ static final String POSTFIX_IMMERSIVE = (APPEND_CATEGORY_NAME) ? "_Immersive" : "";
+ static final String POSTFIX_LRU = (APPEND_CATEGORY_NAME) ? "_LRU" : "";
static final String POSTFIX_MU = "_MU";
- static final String POSTFIX_SERVICE = (PREPEND_CATEGORY_NAME) ? "_Service" : "";
+ static final String POSTFIX_OOM_ADJ = (APPEND_CATEGORY_NAME) ? "_OomAdj" : "";
+ static final String POSTFIX_SERVICE = (APPEND_CATEGORY_NAME) ? "_Service" : "";
static final String POSTFIX_SERVICE_EXECUTING =
- (PREPEND_CATEGORY_NAME) ? "_ServiceExecuting" : "";
+ (APPEND_CATEGORY_NAME) ? "_ServiceExecuting" : "";
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 8f9ce51..dcee96a 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -254,15 +254,14 @@
private static final String TAG_BACKUP = TAG + POSTFIX_BACKUP;
private static final String TAG_BROADCAST = TAG + POSTFIX_BROADCAST;
private static final String TAG_CLEANUP = TAG + POSTFIX_CLEANUP;
+ private static final String TAG_CONFIGURATION = TAG + POSTFIX_CONFIGURATION;
+ private static final String TAG_FOCUS = TAG + POSTFIX_FOCUS;
+ private static final String TAG_IMMERSIVE = TAG + POSTFIX_IMMERSIVE;
+ private static final String TAG_LRU = TAG + POSTFIX_LRU;
private static final String TAG_MU = TAG + POSTFIX_MU;
+ private static final String TAG_OOM_ADJ = TAG + POSTFIX_OOM_ADJ;
// TODO(ogunwale): Migrate all the constants below to use ActivityManagerDebugConfig class.
- static final boolean DEBUG_CONFIGURATION = DEBUG_ALL || false;
- static final boolean DEBUG_FOCUS = false;
- static final boolean DEBUG_IMMERSIVE = DEBUG_ALL || false;
- static final boolean DEBUG_MU = DEBUG_ALL || false;
- static final boolean DEBUG_OOM_ADJ = DEBUG_ALL || false;
- static final boolean DEBUG_LRU = DEBUG_ALL || false;
static final boolean DEBUG_PAUSE = DEBUG_ALL || false;
static final boolean DEBUG_POWER = DEBUG_ALL || false;
static final boolean DEBUG_POWER_QUICK = DEBUG_POWER || false;
@@ -283,8 +282,6 @@
static final boolean DEBUG_PSS = DEBUG_ALL || false;
static final boolean DEBUG_LOCKSCREEN = DEBUG_ALL || false;
static final boolean DEBUG_RECENTS = DEBUG_ALL || false;
- static final boolean VALIDATE_TOKENS = false;
- static final boolean SHOW_ACTIVITY_START_TIME = true;
// Control over CPU and battery monitoring.
static final long BATTERY_STATS_TIME = 30*60*1000; // write battery stats every 30 minutes.
@@ -1705,10 +1702,9 @@
case IMMERSIVE_MODE_LOCK_MSG: {
final boolean nextState = (msg.arg1 != 0);
if (mUpdateLock.isHeld() != nextState) {
- if (DEBUG_IMMERSIVE) {
- final ActivityRecord r = (ActivityRecord) msg.obj;
- Slog.d(TAG, "Applying new update lock state '" + nextState + "' for " + r);
- }
+ if (DEBUG_IMMERSIVE) Slog.d(TAG_IMMERSIVE,
+ "Applying new update lock state '" + nextState
+ + "' for " + (ActivityRecord)msg.obj);
if (nextState) {
mUpdateLock.acquire();
} else {
@@ -2481,7 +2477,7 @@
final void setFocusedActivityLocked(ActivityRecord r, String reason) {
if (r != null && mFocusedActivity != r) {
- if (DEBUG_FOCUS) Slog.d(TAG, "setFocusedActivityLocked: r=" + r);
+ if (DEBUG_FOCUS) Slog.d(TAG_FOCUS, "setFocusedActivityLocked: r=" + r);
mFocusedActivity = r;
if (r.task != null && r.task.voiceInteractor != null) {
startRunningVoiceLocked(r.task.voiceSession, r.info.applicationInfo.uid);
@@ -2505,7 +2501,7 @@
@Override
public void setFocusedStack(int stackId) {
- if (DEBUG_FOCUS) Slog.d(TAG, "setFocusedStack: stackId=" + stackId);
+ if (DEBUG_FOCUS) Slog.d(TAG_FOCUS, "setFocusedStack: stackId=" + stackId);
synchronized (ActivityManagerService.this) {
ActivityStack stack = mStackSupervisor.getStack(stackId);
if (stack != null) {
@@ -2587,7 +2583,7 @@
if (index > 0) {
index--;
}
- if (DEBUG_LRU) Slog.d(TAG, "Moving dep from " + lrui + " to " + index
+ if (DEBUG_LRU) Slog.d(TAG_LRU, "Moving dep from " + lrui + " to " + index
+ " in LRU list: " + app);
mLruProcesses.add(index, app);
return index;
@@ -2633,13 +2629,13 @@
if (hasActivity) {
final int N = mLruProcesses.size();
if (N > 0 && mLruProcesses.get(N-1) == app) {
- if (DEBUG_LRU) Slog.d(TAG, "Not moving, already top activity: " + app);
+ if (DEBUG_LRU) Slog.d(TAG_LRU, "Not moving, already top activity: " + app);
return;
}
} else {
if (mLruProcessServiceStart > 0
&& mLruProcesses.get(mLruProcessServiceStart-1) == app) {
- if (DEBUG_LRU) Slog.d(TAG, "Not moving, already top other: " + app);
+ if (DEBUG_LRU) Slog.d(TAG_LRU, "Not moving, already top other: " + app);
return;
}
}
@@ -2649,7 +2645,7 @@
if (app.persistent && lrui >= 0) {
// We don't care about the position of persistent processes, as long as
// they are in the list.
- if (DEBUG_LRU) Slog.d(TAG, "Not moving, persistent: " + app);
+ if (DEBUG_LRU) Slog.d(TAG_LRU, "Not moving, persistent: " + app);
return;
}
@@ -2718,27 +2714,29 @@
int nextIndex;
if (hasActivity) {
final int N = mLruProcesses.size();
- if (app.activities.size() == 0 && mLruProcessActivityStart < (N-1)) {
+ if (app.activities.size() == 0 && mLruProcessActivityStart < (N - 1)) {
// Process doesn't have activities, but has clients with
// activities... move it up, but one below the top (the top
// should always have a real activity).
- if (DEBUG_LRU) Slog.d(TAG, "Adding to second-top of LRU activity list: " + app);
- mLruProcesses.add(N-1, app);
+ if (DEBUG_LRU) Slog.d(TAG_LRU,
+ "Adding to second-top of LRU activity list: " + app);
+ mLruProcesses.add(N - 1, app);
// To keep it from spamming the LRU list (by making a bunch of clients),
// we will push down any other entries owned by the app.
final int uid = app.info.uid;
- for (int i=N-2; i>mLruProcessActivityStart; i--) {
+ for (int i = N - 2; i > mLruProcessActivityStart; i--) {
ProcessRecord subProc = mLruProcesses.get(i);
if (subProc.info.uid == uid) {
// We want to push this one down the list. If the process after
// it is for the same uid, however, don't do so, because we don't
// want them internally to be re-ordered.
- if (mLruProcesses.get(i-1).info.uid != uid) {
- if (DEBUG_LRU) Slog.d(TAG, "Pushing uid " + uid + " swapping at " + i
- + ": " + mLruProcesses.get(i) + " : " + mLruProcesses.get(i-1));
+ if (mLruProcesses.get(i - 1).info.uid != uid) {
+ if (DEBUG_LRU) Slog.d(TAG_LRU,
+ "Pushing uid " + uid + " swapping at " + i + ": "
+ + mLruProcesses.get(i) + " : " + mLruProcesses.get(i - 1));
ProcessRecord tmp = mLruProcesses.get(i);
- mLruProcesses.set(i, mLruProcesses.get(i-1));
- mLruProcesses.set(i-1, tmp);
+ mLruProcesses.set(i, mLruProcesses.get(i - 1));
+ mLruProcesses.set(i - 1, tmp);
i--;
}
} else {
@@ -2748,13 +2746,13 @@
}
} else {
// Process has activities, put it at the very tipsy-top.
- if (DEBUG_LRU) Slog.d(TAG, "Adding to top of LRU activity list: " + app);
+ if (DEBUG_LRU) Slog.d(TAG_LRU, "Adding to top of LRU activity list: " + app);
mLruProcesses.add(app);
}
nextIndex = mLruProcessServiceStart;
} else if (hasService) {
// Process has services, put it at the top of the service list.
- if (DEBUG_LRU) Slog.d(TAG, "Adding to top of LRU service list: " + app);
+ if (DEBUG_LRU) Slog.d(TAG_LRU, "Adding to top of LRU service list: " + app);
mLruProcesses.add(mLruProcessActivityStart, app);
nextIndex = mLruProcessServiceStart;
mLruProcessActivityStart++;
@@ -2765,7 +2763,7 @@
// If there is a client, don't allow the process to be moved up higher
// in the list than that client.
int clientIndex = mLruProcesses.lastIndexOf(client);
- if (DEBUG_LRU && clientIndex < 0) Slog.d(TAG, "Unknown client " + client
+ if (DEBUG_LRU && clientIndex < 0) Slog.d(TAG_LRU, "Unknown client " + client
+ " when updating " + app);
if (clientIndex <= lrui) {
// Don't allow the client index restriction to push it down farther in the
@@ -2776,7 +2774,7 @@
index = clientIndex;
}
}
- if (DEBUG_LRU) Slog.d(TAG, "Adding at " + index + " of LRU list: " + app);
+ if (DEBUG_LRU) Slog.d(TAG_LRU, "Adding at " + index + " of LRU list: " + app);
mLruProcesses.add(index, app);
nextIndex = index-1;
mLruProcessActivityStart++;
@@ -5599,7 +5597,7 @@
if (app.instrumentationClass != null) {
ensurePackageDexOpt(app.instrumentationClass.getPackageName());
}
- if (DEBUG_CONFIGURATION) Slog.v(TAG, "Binding proc "
+ if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Binding proc "
+ processName + " with config " + mConfiguration);
ApplicationInfo appInfo = app.instrumentationInfo != null
? app.instrumentationInfo : app.info;
@@ -6137,8 +6135,7 @@
int callingUid, int userId, IBinder token, String resultWho,
int requestCode, Intent[] intents, String[] resolvedTypes, int flags,
Bundle options) {
- if (DEBUG_MU)
- Slog.v(TAG_MU, "getIntentSenderLocked(): uid=" + callingUid);
+ if (DEBUG_MU) Slog.v(TAG_MU, "getIntentSenderLocked(): uid=" + callingUid);
ActivityRecord activity = null;
if (type == ActivityManager.INTENT_SENDER_ACTIVITY_RESULT) {
activity = ActivityRecord.isInStackLocked(token);
@@ -8616,8 +8613,8 @@
STOCK_PM_FLAGS | PackageManager.GET_URI_PERMISSION_PATTERNS);
} catch (RemoteException ex) {
}
- if (DEBUG_MU)
- Slog.v(TAG_MU, "generateApplicationProvidersLocked, app.info.uid = " + app.uid);
+ if (DEBUG_MU) Slog.v(TAG_MU,
+ "generateApplicationProvidersLocked, app.info.uid = " + app.uid);
int userId = app.userId;
if (providers != null) {
int N = providers.size();
@@ -8644,8 +8641,8 @@
cpr = new ContentProviderRecord(this, cpi, app.info, comp, singleton);
mProviderMap.putProviderByClass(comp, cpr);
}
- if (DEBUG_MU)
- Slog.v(TAG_MU, "generateApplicationProvidersLocked, cpi.uid = " + cpr.uid);
+ if (DEBUG_MU) Slog.v(TAG_MU,
+ "generateApplicationProvidersLocked, cpi.uid = " + cpr.uid);
app.pubProviders.put(cpi.name, cpr);
if (!cpi.multiprocess || !"android".equals(cpi.packageName)) {
// Don't add this if it is a platform component that is marked
@@ -9174,10 +9171,9 @@
return null;
}
try {
- if (DEBUG_MU) {
- Slog.v(TAG_MU, "Waiting to start provider " + cpr + " launchingApp="
- + cpr.launchingApp);
- }
+ if (DEBUG_MU) Slog.v(TAG_MU,
+ "Waiting to start provider " + cpr
+ + " launchingApp=" + cpr.launchingApp);
if (conn != null) {
conn.waiting = true;
}
@@ -9299,8 +9295,7 @@
enforceNotIsolatedCaller("publishContentProviders");
synchronized (this) {
final ProcessRecord r = getRecordForAppLocked(caller);
- if (DEBUG_MU)
- Slog.v(TAG_MU, "ProcessRecord uid = " + r.uid);
+ if (DEBUG_MU) Slog.v(TAG_MU, "ProcessRecord uid = " + r.uid);
if (r == null) {
throw new SecurityException(
"Unable to find app for caller " + caller
@@ -9317,8 +9312,7 @@
continue;
}
ContentProviderRecord dst = r.pubProviders.get(src.info.name);
- if (DEBUG_MU)
- Slog.v(TAG_MU, "ContentProviderRecord uid = " + dst.uid);
+ if (DEBUG_MU) Slog.v(TAG_MU, "ContentProviderRecord uid = " + dst.uid);
if (dst != null) {
ComponentName comp = new ComponentName(dst.info.packageName, dst.info.name);
mProviderMap.putProviderByClass(comp, dst);
@@ -10400,9 +10394,7 @@
// update associated state if we're frontmost
if (r == mFocusedActivity) {
- if (DEBUG_IMMERSIVE) {
- Slog.d(TAG, "Frontmost changed immersion: "+ r);
- }
+ if (DEBUG_IMMERSIVE) Slog.d(TAG_IMMERSIVE, "Frontmost changed immersion: "+ r);
applyUpdateLockStateLocked(r);
}
}
@@ -10751,7 +10743,8 @@
// This happens before any activities are started, so we can
// change mConfiguration in-place.
updateConfigurationLocked(configuration, null, false, true);
- if (DEBUG_CONFIGURATION) Slog.v(TAG, "Initial config: " + mConfiguration);
+ if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
+ "Initial config: " + mConfiguration);
}
}
@@ -15094,10 +15087,9 @@
result = UserHandle.isSameApp(aInfo.uid, Process.PHONE_UID)
|| (aInfo.flags & ApplicationInfo.FLAG_PERSISTENT) != 0;
}
- if (DEBUG_MU) {
- Slog.v(TAG, "isSingleton(" + componentProcessName + ", " + aInfo
- + ", " + className + ", 0x" + Integer.toHexString(flags) + ") = " + result);
- }
+ if (DEBUG_MU) Slog.v(TAG_MU,
+ "isSingleton(" + componentProcessName + ", " + aInfo + ", " + className + ", 0x"
+ + Integer.toHexString(flags) + ") = " + result);
return result;
}
@@ -16484,9 +16476,8 @@
Configuration newConfig = new Configuration(mConfiguration);
changes = newConfig.updateFrom(values);
if (changes != 0) {
- if (DEBUG_SWITCH || DEBUG_CONFIGURATION) {
- Slog.i(TAG, "Updating configuration to: " + values);
- }
+ if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.i(TAG_CONFIGURATION,
+ "Updating configuration to: " + values);
EventLog.writeEvent(EventLogTags.CONFIGURATION_CHANGED, changes);
@@ -16537,7 +16528,7 @@
ProcessRecord app = mLruProcesses.get(i);
try {
if (app.thread != null) {
- if (DEBUG_CONFIGURATION) Slog.v(TAG, "Sending to proc "
+ if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Sending to proc "
+ app.processName + " new config " + mConfiguration);
app.thread.scheduleConfigurationChanged(configCopy);
}
@@ -17740,15 +17731,15 @@
if (app.curAdj != app.setAdj) {
ProcessList.setOomAdj(app.pid, app.info.uid, app.curAdj);
- if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(
- TAG, "Set " + app.pid + " " + app.processName +
- " adj " + app.curAdj + ": " + app.adjType);
+ if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG_OOM_ADJ,
+ "Set " + app.pid + " " + app.processName + " adj " + app.curAdj + ": "
+ + app.adjType);
app.setAdj = app.curAdj;
}
if (app.setSchedGroup != app.curSchedGroup) {
app.setSchedGroup = app.curSchedGroup;
- if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG,
+ if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG_OOM_ADJ,
"Setting process group of " + app.processName
+ " to " + app.curSchedGroup);
if (app.waitingToKill != null &&
@@ -17832,7 +17823,7 @@
}
}
if (app.setProcState != app.curProcState) {
- if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG,
+ if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG_OOM_ADJ,
"Proc state change of " + app.processName
+ " to " + app.curProcState);
boolean setImportant = app.setProcState < ActivityManager.PROCESS_STATE_SERVICE;
@@ -18097,7 +18088,7 @@
// step that cached level.
app.curRawAdj = curCachedAdj;
app.curAdj = app.modifyRawOomAdj(curCachedAdj);
- if (DEBUG_LRU && false) Slog.d(TAG, "Assigning activity LRU #" + i
+ if (DEBUG_LRU && false) Slog.d(TAG_LRU, "Assigning activity LRU #" + i
+ " adj: " + app.curAdj + " (curCachedAdj=" + curCachedAdj
+ ")");
if (curCachedAdj != nextCachedAdj) {
@@ -18120,7 +18111,7 @@
// state is still as a service), which is what we want.
app.curRawAdj = curEmptyAdj;
app.curAdj = app.modifyRawOomAdj(curEmptyAdj);
- if (DEBUG_LRU && false) Slog.d(TAG, "Assigning empty LRU #" + i
+ if (DEBUG_LRU && false) Slog.d(TAG_LRU, "Assigning empty LRU #" + i
+ " adj: " + app.curAdj + " (curEmptyAdj=" + curEmptyAdj
+ ")");
if (curEmptyAdj != nextEmptyAdj) {
@@ -18210,13 +18201,13 @@
// We always allow the memory level to go up (better). We only allow it to go
// down if we are in a state where that is allowed, *and* the total number of processes
// has gone down since last time.
- if (DEBUG_OOM_ADJ) Slog.d(TAG, "oom: memFactor=" + memFactor + " last=" + mLastMemoryLevel
- + " allowLow=" + mAllowLowerMemLevel + " numProcs=" + mLruProcesses.size()
- + " last=" + mLastNumProcesses);
+ if (DEBUG_OOM_ADJ) Slog.d(TAG_OOM_ADJ, "oom: memFactor=" + memFactor
+ + " last=" + mLastMemoryLevel + " allowLow=" + mAllowLowerMemLevel
+ + " numProcs=" + mLruProcesses.size() + " last=" + mLastNumProcesses);
if (memFactor > mLastMemoryLevel) {
if (!mAllowLowerMemLevel || mLruProcesses.size() >= mLastNumProcesses) {
memFactor = mLastMemoryLevel;
- if (DEBUG_OOM_ADJ) Slog.d(TAG, "Keeping last mem factor!");
+ if (DEBUG_OOM_ADJ) Slog.d(TAG_OOM_ADJ, "Keeping last mem factor!");
}
}
mLastMemoryLevel = memFactor;
@@ -18256,9 +18247,8 @@
&& !app.killedByAm) {
if (app.trimMemoryLevel < curLevel && app.thread != null) {
try {
- if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG,
- "Trimming memory of " + app.processName
- + " to " + curLevel);
+ if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG_OOM_ADJ,
+ "Trimming memory of " + app.processName + " to " + curLevel);
app.thread.scheduleTrimMemory(curLevel);
} catch (RemoteException e) {
}
@@ -18293,7 +18283,7 @@
if (app.trimMemoryLevel < ComponentCallbacks2.TRIM_MEMORY_BACKGROUND
&& app.thread != null) {
try {
- if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG,
+ if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG_OOM_ADJ,
"Trimming memory of heavy-weight " + app.processName
+ " to " + ComponentCallbacks2.TRIM_MEMORY_BACKGROUND);
app.thread.scheduleTrimMemory(
@@ -18311,7 +18301,7 @@
final int level = ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN;
if (app.trimMemoryLevel < level && app.thread != null) {
try {
- if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG,
+ if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG_OOM_ADJ,
"Trimming memory of bg-ui " + app.processName
+ " to " + level);
app.thread.scheduleTrimMemory(level);
@@ -18322,7 +18312,7 @@
}
if (app.trimMemoryLevel < fgTrimLevel && app.thread != null) {
try {
- if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG,
+ if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG_OOM_ADJ,
"Trimming memory of fg " + app.processName
+ " to " + fgTrimLevel);
app.thread.scheduleTrimMemory(fgTrimLevel);
@@ -18348,7 +18338,7 @@
if (app.trimMemoryLevel < ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN
&& app.thread != null) {
try {
- if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG,
+ if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG_OOM_ADJ,
"Trimming memory of ui hidden " + app.processName
+ " to " + ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN);
app.thread.scheduleTrimMemory(
@@ -18383,12 +18373,12 @@
}
if (DEBUG_OOM_ADJ) {
+ final long duration = SystemClock.uptimeMillis() - now;
if (false) {
- RuntimeException here = new RuntimeException("here");
- here.fillInStackTrace();
- Slog.d(TAG, "Did OOM ADJ in " + (SystemClock.uptimeMillis()-now) + "ms", here);
+ Slog.d(TAG_OOM_ADJ, "Did OOM ADJ in " + duration + "ms",
+ new RuntimeException("here").fillInStackTrace());
} else {
- Slog.d(TAG, "Did OOM ADJ in " + (SystemClock.uptimeMillis()-now) + "ms");
+ Slog.d(TAG_OOM_ADJ, "Did OOM ADJ in " + duration + "ms");
}
}
}
diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java
index ca2721c..d34b33b 100755
--- a/services/core/java/com/android/server/am/ActivityRecord.java
+++ b/services/core/java/com/android/server/am/ActivityRecord.java
@@ -76,6 +76,7 @@
final class ActivityRecord {
private static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityRecord" : TAG_AM;
+ private static final boolean SHOW_ACTIVITY_START_TIME = true;
static final boolean DEBUG_SAVED_STATE = ActivityStackSupervisor.DEBUG_SAVED_STATE;
final public static String RECENTS_PACKAGE_NAME = "com.android.systemui.recents";
@@ -939,7 +940,7 @@
final long thisTime = curTime - fullyDrawnStartTime;
final long totalTime = stack.mFullyDrawnStartTime != 0
? (curTime - stack.mFullyDrawnStartTime) : thisTime;
- if (ActivityManagerService.SHOW_ACTIVITY_START_TIME) {
+ if (SHOW_ACTIVITY_START_TIME) {
Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER, "drawing", 0);
EventLog.writeEvent(EventLogTags.AM_ACTIVITY_FULLY_DRAWN_TIME,
userId, System.identityHashCode(this), shortComponentName,
@@ -973,7 +974,7 @@
final long thisTime = curTime - displayStartTime;
final long totalTime = stack.mLaunchStartTime != 0
? (curTime - stack.mLaunchStartTime) : thisTime;
- if (ActivityManagerService.SHOW_ACTIVITY_START_TIME) {
+ if (SHOW_ACTIVITY_START_TIME) {
Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER, "launching", 0);
EventLog.writeEvent(EventLogTags.AM_ACTIVITY_LAUNCH_TIME,
userId, System.identityHashCode(this), shortComponentName,
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 203c724..4bb265d 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -17,7 +17,6 @@
package com.android.server.am;
import static com.android.server.am.ActivityManagerDebugConfig.*;
-import static com.android.server.am.ActivityManagerService.DEBUG_CONFIGURATION;
import static com.android.server.am.ActivityManagerService.DEBUG_PAUSE;
import static com.android.server.am.ActivityManagerService.DEBUG_RESULTS;
import static com.android.server.am.ActivityManagerService.DEBUG_STACK;
@@ -26,7 +25,6 @@
import static com.android.server.am.ActivityManagerService.DEBUG_TRANSITION;
import static com.android.server.am.ActivityManagerService.DEBUG_USER_LEAVING;
import static com.android.server.am.ActivityManagerService.DEBUG_VISBILITY;
-import static com.android.server.am.ActivityManagerService.VALIDATE_TOKENS;
import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE;
import static com.android.server.am.ActivityRecord.APPLICATION_ACTIVITY_TYPE;
@@ -97,6 +95,9 @@
private static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityStack" : TAG_AM;
private static final String TAG_CLEANUP = TAG + POSTFIX_CLEANUP;
+ private static final String TAG_CONFIGURATION = TAG + POSTFIX_CONFIGURATION;
+
+ private static final boolean VALIDATE_TOKENS = false;
// Ticks during which we check progress while waiting for an app to launch.
static final int LAUNCH_TICK = 500;
@@ -3747,12 +3748,12 @@
final boolean ensureActivityConfigurationLocked(ActivityRecord r,
int globalChanges) {
if (mConfigWillChange) {
- if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
+ if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
"Skipping config check (will change): " + r);
return true;
}
- if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
+ if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
"Ensuring correct configuration: " + r);
// Make sure the current stack override configuration is supported by the top task
@@ -3765,7 +3766,7 @@
mWindowManager.forceStackToFullscreen(mStackId, !topTask.mResizeable);
updateOverrideConfiguration(newOverrideConfig);
mForcedFullscreen = !prevFullscreen && mFullscreen;
- if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
+ if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
"Updated stack config to support task=" + topTask
+ " resizeable=" + topTask.mResizeable
+ " mForcedFullscreen=" + mForcedFullscreen
@@ -3779,14 +3780,14 @@
if (r.configuration == newConfig
&& r.stackConfigOverride == mOverrideConfig
&& !r.forceNewConfig) {
- if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
+ if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
"Configuration unchanged in " + r);
return true;
}
// We don't worry about activities that are finishing.
if (r.finishing) {
- if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
+ if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
"Configuration doesn't matter in finishing " + r);
r.stopFreezingScreenLocked(false);
return true;
@@ -3820,7 +3821,7 @@
}
final int changes = oldConfig.diff(newConfig) | stackChanges;
if (changes == 0 && !r.forceNewConfig) {
- if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
+ if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
"Configuration no differences in " + r);
return true;
}
@@ -3828,7 +3829,7 @@
// If the activity isn't currently running, just leave the new
// configuration and it will pick that up next time it starts.
if (r.app == null || r.app.thread == null) {
- if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
+ if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
"Configuration doesn't matter not running " + r);
r.stopFreezingScreenLocked(false);
r.forceNewConfig = false;
@@ -3836,26 +3837,25 @@
}
// Figure out how to handle the changes between the configurations.
- if (DEBUG_SWITCH || DEBUG_CONFIGURATION) {
- Slog.v(TAG, "Checking to restart " + r.info.name + ": changed=0x"
- + Integer.toHexString(changes) + ", handles=0x"
- + Integer.toHexString(r.info.getRealConfigChanged())
- + ", newConfig=" + newConfig);
- }
+ if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
+ "Checking to restart " + r.info.name + ": changed=0x"
+ + Integer.toHexString(changes) + ", handles=0x"
+ + Integer.toHexString(r.info.getRealConfigChanged()) + ", newConfig=" + newConfig);
+
if ((changes&(~r.info.getRealConfigChanged())) != 0 || r.forceNewConfig) {
// Aha, the activity isn't handling the change, so DIE DIE DIE.
r.configChangeFlags |= changes;
r.startFreezingScreenLocked(r.app, globalChanges);
r.forceNewConfig = false;
if (r.app == null || r.app.thread == null) {
- if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
+ if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
"Config is destroying non-running " + r);
destroyActivityLocked(r, true, "config");
} else if (r.state == ActivityState.PAUSING) {
// A little annoying: we are waiting for this activity to
// finish pausing. Let's not do anything now, but just
// flag that it needs to be restarted when done pausing.
- if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
+ if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
"Config is skipping already pausing " + r);
r.configDestroy = true;
return true;
@@ -3864,12 +3864,12 @@
// and we need to restart the top, resumed activity.
// Instead of doing the normal handshaking, just say
// "restart!".
- if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
+ if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
"Config is relaunching resumed " + r);
relaunchActivityLocked(r, r.configChangeFlags, true);
r.configChangeFlags = 0;
} else {
- if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
+ if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
"Config is relaunching non-resumed " + r);
relaunchActivityLocked(r, r.configChangeFlags, false);
r.configChangeFlags = 0;
@@ -3886,7 +3886,7 @@
// system level configuration it last got.
if (r.app != null && r.app.thread != null) {
try {
- if (DEBUG_CONFIGURATION) Slog.v(TAG, "Sending new config to " + r);
+ if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Sending new config to " + r);
r.app.thread.scheduleActivityConfigurationChanged(
r.appToken, new Configuration(mOverrideConfig));
} catch (RemoteException e) {
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 9472707..80664f5 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -23,8 +23,6 @@
import static android.content.Intent.FLAG_ACTIVITY_TASK_ON_HOME;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static com.android.server.am.ActivityManagerDebugConfig.*;
-import static com.android.server.am.ActivityManagerService.DEBUG_CONFIGURATION;
-import static com.android.server.am.ActivityManagerService.DEBUG_FOCUS;
import static com.android.server.am.ActivityManagerService.DEBUG_PAUSE;
import static com.android.server.am.ActivityManagerService.DEBUG_RECENTS;
import static com.android.server.am.ActivityManagerService.DEBUG_RESULTS;
@@ -119,6 +117,8 @@
public final class ActivityStackSupervisor implements DisplayListener {
private static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityStackSupervisor" : TAG_AM;
+ private static final String TAG_CONFIGURATION = TAG + POSTFIX_CONFIGURATION;
+ private static final String TAG_FOCUS = TAG + POSTFIX_FOCUS;
static final boolean DEBUG = DEBUG_ALL || false;
static final boolean DEBUG_ADD_REMOVE = DEBUG || false;
@@ -917,7 +917,7 @@
stack = container.mStack;
}
stack.mConfigWillChange = config != null && mService.mConfiguration.diff(config) != 0;
- if (DEBUG_CONFIGURATION) Slog.v(TAG,
+ if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
"Starting activity when config will change = " + stack.mConfigWillChange);
final long origId = Binder.clearCallingIdentity();
@@ -1007,7 +1007,7 @@
mService.enforceCallingPermission(android.Manifest.permission.CHANGE_CONFIGURATION,
"updateConfiguration()");
stack.mConfigWillChange = false;
- if (DEBUG_CONFIGURATION) Slog.v(TAG,
+ if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION,
"Updating to new configuration after starting activity.");
mService.updateConfigurationLocked(config, null, false, false);
}
@@ -1584,10 +1584,11 @@
stack = task.stack;
if (stack.isOnHomeDisplay()) {
if (mFocusedStack != stack) {
- if (DEBUG_FOCUS || DEBUG_STACK) Slog.d(TAG, "computeStackFocus: Setting " +
- "focused stack to r=" + r + " task=" + task);
+ if (DEBUG_FOCUS || DEBUG_STACK) Slog.d(TAG_FOCUS,
+ "computeStackFocus: Setting " + "focused stack to r=" + r
+ + " task=" + task);
} else {
- if (DEBUG_FOCUS || DEBUG_STACK) Slog.d(TAG,
+ if (DEBUG_FOCUS || DEBUG_STACK) Slog.d(TAG_FOCUS,
"computeStackFocus: Focused stack already=" + mFocusedStack);
}
}
@@ -1603,7 +1604,7 @@
if (mFocusedStack != mHomeStack && (!newTask ||
mFocusedStack.mActivityContainer.isEligibleForNewTasks())) {
- if (DEBUG_FOCUS || DEBUG_STACK) Slog.d(TAG,
+ if (DEBUG_FOCUS || DEBUG_STACK) Slog.d(TAG_FOCUS,
"computeStackFocus: Have a focused stack=" + mFocusedStack);
return mFocusedStack;
}
@@ -1612,7 +1613,7 @@
for (int stackNdx = homeDisplayStacks.size() - 1; stackNdx >= 0; --stackNdx) {
stack = homeDisplayStacks.get(stackNdx);
if (!stack.isHomeStack()) {
- if (DEBUG_FOCUS || DEBUG_STACK) Slog.d(TAG,
+ if (DEBUG_FOCUS || DEBUG_STACK) Slog.d(TAG_FOCUS,
"computeStackFocus: Setting focused stack=" + stack);
return stack;
}
@@ -1620,8 +1621,8 @@
// Need to create an app stack for this user.
stack = createStackOnDisplay(getNextStackId(), Display.DEFAULT_DISPLAY);
- if (DEBUG_FOCUS || DEBUG_STACK) Slog.d(TAG, "computeStackFocus: New stack r=" + r +
- " stackId=" + stack.mStackId);
+ if (DEBUG_FOCUS || DEBUG_STACK) Slog.d(TAG_FOCUS, "computeStackFocus: New stack r="
+ + r + " stackId=" + stack.mStackId);
return stack;
}
return mHomeStack;
diff --git a/services/core/java/com/android/server/am/CompatModePackages.java b/services/core/java/com/android/server/am/CompatModePackages.java
index ce63d75..0fe9231 100644
--- a/services/core/java/com/android/server/am/CompatModePackages.java
+++ b/services/core/java/com/android/server/am/CompatModePackages.java
@@ -46,7 +46,7 @@
public final class CompatModePackages {
private static final String TAG = TAG_WITH_CLASS_NAME ? "CompatModePackages" : TAG_AM;
- private final boolean DEBUG_CONFIGURATION = ActivityManagerService.DEBUG_CONFIGURATION;
+ private static final String TAG_CONFIGURATION = TAG + POSTFIX_CONFIGURATION;
private final ActivityManagerService mService;
private final AtomicFile mFile;
@@ -334,7 +334,7 @@
}
try {
if (app.thread != null) {
- if (DEBUG_CONFIGURATION) Slog.v(TAG, "Sending to proc "
+ if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Sending to proc "
+ app.processName + " new compat " + ci);
app.thread.updatePackageCompatibilityInfo(packageName, ci);
}
diff --git a/services/core/java/com/android/server/audio/MediaFocusControl.java b/services/core/java/com/android/server/audio/MediaFocusControl.java
index fcdd9d9..f05e6aa 100644
--- a/services/core/java/com/android/server/audio/MediaFocusControl.java
+++ b/services/core/java/com/android/server/audio/MediaFocusControl.java
@@ -653,6 +653,7 @@
return;
} else {
mFocusFollowers.add(ff);
+ notifyExtPolicyCurrentFocusAsync(ff);
}
}
}
@@ -672,6 +673,32 @@
}
/**
+ * @param pcb non null
+ */
+ void notifyExtPolicyCurrentFocusAsync(IAudioPolicyCallback pcb) {
+ final IAudioPolicyCallback pcb2 = pcb;
+ final Thread thread = new Thread() {
+ @Override
+ public void run() {
+ synchronized(mAudioFocusLock) {
+ if (mFocusStack.isEmpty()) {
+ return;
+ }
+ try {
+ pcb2.notifyAudioFocusGrant(mFocusStack.peek().toAudioFocusInfo(),
+ // top of focus stack always has focus
+ AudioManager.AUDIOFOCUS_REQUEST_GRANTED);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Can't call notifyAudioFocusGrant() on IAudioPolicyCallback "
+ + pcb2.asBinder(), e);
+ }
+ }
+ }
+ };
+ thread.start();
+ }
+
+ /**
* Called synchronized on mAudioFocusLock
*/
void notifyExtPolicyFocusGrant_syncAf(AudioFocusInfo afi, int requestResult) {
@@ -680,7 +707,7 @@
// oneway
pcb.notifyAudioFocusGrant(afi, requestResult);
} catch (RemoteException e) {
- Log.e(TAG, "Can't call newAudioFocusLoser() on IAudioPolicyCallback "
+ Log.e(TAG, "Can't call notifyAudioFocusGrant() on IAudioPolicyCallback "
+ pcb.asBinder(), e);
}
}
@@ -695,7 +722,7 @@
// oneway
pcb.notifyAudioFocusLoss(afi, wasDispatched);
} catch (RemoteException e) {
- Log.e(TAG, "Can't call newAudioFocusLoser() on IAudioPolicyCallback "
+ Log.e(TAG, "Can't call notifyAudioFocusLoss() on IAudioPolicyCallback "
+ pcb.asBinder(), e);
}
}
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index cdd6c7f..dfac6cf 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -176,6 +176,9 @@
static final int DOUBLE_TAP_HOME_NOTHING = 0;
static final int DOUBLE_TAP_HOME_RECENT_SYSTEM_UI = 1;
+ static final int SHORT_PRESS_SLEEP_GO_TO_SLEEP = 0;
+ static final int SHORT_PRESS_SLEEP_GO_TO_SLEEP_AND_GO_HOME = 1;
+
static final int APPLICATION_MEDIA_SUBLAYER = -2;
static final int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1;
static final int APPLICATION_PANEL_SUBLAYER = 1;
@@ -371,6 +374,7 @@
int mLongPressOnPowerBehavior;
int mDoublePressOnPowerBehavior;
int mTriplePressOnPowerBehavior;
+ int mShortPressOnSleepBehavior;
boolean mAwake;
boolean mScreenOnEarly;
boolean mScreenOnFully;
@@ -1057,6 +1061,20 @@
}
}
+ private void sleepPress(KeyEvent event) {
+ switch (mShortPressOnSleepBehavior) {
+ case SHORT_PRESS_SLEEP_GO_TO_SLEEP:
+ mPowerManager.goToSleep(event.getEventTime(),
+ PowerManager.GO_TO_SLEEP_REASON_SLEEP_BUTTON, 0);
+ break;
+ case SHORT_PRESS_SLEEP_GO_TO_SLEEP_AND_GO_HOME:
+ launchHomeFromHotKey(false /* awakenDreams */);
+ mPowerManager.goToSleep(event.getEventTime(),
+ PowerManager.GO_TO_SLEEP_REASON_SLEEP_BUTTON, 0);
+ break;
+ }
+ }
+
private int getResolvedLongPressOnPowerBehavior() {
if (FactoryTest.isLongPressOnPowerOffEnabled()) {
return LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM;
@@ -1321,6 +1339,8 @@
com.android.internal.R.integer.config_doublePressOnPowerBehavior);
mTriplePressOnPowerBehavior = mContext.getResources().getInteger(
com.android.internal.R.integer.config_triplePressOnPowerBehavior);
+ mShortPressOnSleepBehavior = mContext.getResources().getInteger(
+ com.android.internal.R.integer.config_shortPressOnSleepBehavior);
mUseTvRouting = AudioSystem.getPlatformType(mContext) == AudioSystem.PLATFORM_TELEVISION;
@@ -3028,11 +3048,15 @@
}
}
+ void launchHomeFromHotKey() {
+ launchHomeFromHotKey(true /* awakenFromDreams */);
+ }
+
/**
* A home key -> launch home action was detected. Take the appropriate action
* given the situation with the keyguard.
*/
- void launchHomeFromHotKey() {
+ void launchHomeFromHotKey(final boolean awakenFromDreams) {
if (isKeyguardShowingAndNotOccluded()) {
// don't launch home if keyguard showing
} else if (!mHideLockScreen && mKeyguardDelegate.isInputRestricted()) {
@@ -3047,7 +3071,7 @@
} catch (RemoteException e) {
}
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
- startDockOrHome(true /*fromHomeKey*/);
+ startDockOrHome(true /*fromHomeKey*/, awakenFromDreams);
}
}
});
@@ -3059,13 +3083,15 @@
}
if (mRecentsVisible) {
// Hide Recents and notify it to launch Home
- awakenDreams();
+ if (awakenFromDreams) {
+ awakenDreams();
+ }
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
hideRecentApps(false, true);
} else {
// Otherwise, just launch Home
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY);
- startDockOrHome(true /*fromHomeKey*/);
+ startDockOrHome(true /*fromHomeKey*/, awakenFromDreams);
}
}
}
@@ -4712,12 +4738,11 @@
case KeyEvent.KEYCODE_SLEEP: {
result &= ~ACTION_PASS_TO_USER;
+ isWakeKey = false;
if (!mPowerManager.isInteractive()) {
useHapticFeedback = false; // suppress feedback if already non-interactive
}
- mPowerManager.goToSleep(event.getEventTime(),
- PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0);
- isWakeKey = false;
+ sleepPress(event);
break;
}
@@ -4905,7 +4930,8 @@
return;
}
int keyCode = event.getKeyCode();
- int flags = AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND;
+ int flags = AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND
+ | AudioManager.FLAG_FROM_KEY;
String pkgName = mContext.getOpPackageName();
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
@@ -5896,8 +5922,10 @@
return null;
}
- void startDockOrHome(boolean fromHomeKey) {
- awakenDreams();
+ void startDockOrHome(boolean fromHomeKey, boolean awakenFromDreams) {
+ if (awakenFromDreams) {
+ awakenDreams();
+ }
Intent dock = createHomeDockIntent();
if (dock != null) {
@@ -5935,7 +5963,7 @@
} catch (RemoteException e) {
}
sendCloseSystemWindows();
- startDockOrHome(false /*fromHomeKey*/);
+ startDockOrHome(false /*fromHomeKey*/, true /* awakenFromDreams */);
} else {
// This code brings home to the front or, if it is already
// at the front, puts the device to sleep.
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index 66c2f5f..9e373b7 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -1080,6 +1080,9 @@
case PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON:
Slog.i(TAG, "Going to sleep due to power button (uid " + uid +")...");
break;
+ case PowerManager.GO_TO_SLEEP_REASON_SLEEP_BUTTON:
+ Slog.i(TAG, "Going to sleep due to sleep button (uid " + uid +")...");
+ break;
case PowerManager.GO_TO_SLEEP_REASON_HDMI:
Slog.i(TAG, "Going to sleep due to HDMI standby (uid " + uid +")...");
break;