Merge "Implement issue #10895990: Better durations for proc stats" into klp-dev
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index a727b07..7d4d57c 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -152,7 +152,7 @@
int startFlags = data.readInt();
String profileFile = data.readString();
ParcelFileDescriptor profileFd = data.readInt() != 0
- ? data.readFileDescriptor() : null;
+ ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null;
Bundle options = data.readInt() != 0
? Bundle.CREATOR.createFromParcel(data) : null;
int userId = data.readInt();
@@ -178,7 +178,7 @@
int startFlags = data.readInt();
String profileFile = data.readString();
ParcelFileDescriptor profileFd = data.readInt() != 0
- ? data.readFileDescriptor() : null;
+ ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null;
Bundle options = data.readInt() != 0
? Bundle.CREATOR.createFromParcel(data) : null;
int userId = data.readInt();
@@ -1354,7 +1354,7 @@
int profileType = data.readInt();
String path = data.readString();
ParcelFileDescriptor fd = data.readInt() != 0
- ? data.readFileDescriptor() : null;
+ ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null;
boolean res = profileControl(process, userId, start, path, fd, profileType);
reply.writeNoException();
reply.writeInt(res ? 1 : 0);
@@ -1608,7 +1608,7 @@
boolean managed = data.readInt() != 0;
String path = data.readString();
ParcelFileDescriptor fd = data.readInt() != 0
- ? data.readFileDescriptor() : null;
+ ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null;
boolean res = dumpHeap(process, userId, managed, path, fd);
reply.writeNoException();
reply.writeInt(res ? 1 : 0);
diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java
index 876bf78..e40a04b 100644
--- a/core/java/android/app/ApplicationThreadNative.java
+++ b/core/java/android/app/ApplicationThreadNative.java
@@ -143,7 +143,7 @@
boolean isForward = data.readInt() != 0;
String profileName = data.readString();
ParcelFileDescriptor profileFd = data.readInt() != 0
- ? data.readFileDescriptor() : null;
+ ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null;
boolean autoStopProfiler = data.readInt() != 0;
scheduleLaunchActivity(intent, b, ident, info, curConfig, compatInfo, procState, state,
ri, pi, notResumed, isForward, profileName, profileFd, autoStopProfiler);
@@ -267,7 +267,7 @@
? new ComponentName(data) : null;
String profileName = data.readString();
ParcelFileDescriptor profileFd = data.readInt() != 0
- ? data.readFileDescriptor() : null;
+ ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null;
boolean autoStopProfiler = data.readInt() != 0;
Bundle testArgs = data.readBundle();
IBinder binder = data.readStrongBinder();
@@ -418,7 +418,7 @@
int profileType = data.readInt();
String path = data.readString();
ParcelFileDescriptor fd = data.readInt() != 0
- ? data.readFileDescriptor() : null;
+ ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null;
profilerControl(start, path, fd, profileType);
return true;
}
@@ -473,7 +473,7 @@
boolean managed = data.readInt() != 0;
String path = data.readString();
ParcelFileDescriptor fd = data.readInt() != 0
- ? data.readFileDescriptor() : null;
+ ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null;
dumpHeap(managed, path, fd);
return true;
}
diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java
index 165c3db..800ead9 100644
--- a/core/java/android/app/DownloadManager.java
+++ b/core/java/android/app/DownloadManager.java
@@ -150,6 +150,11 @@
public static final String COLUMN_MEDIAPROVIDER_URI = Downloads.Impl.COLUMN_MEDIAPROVIDER_URI;
/**
+ * @hide
+ */
+ public final static String COLUMN_ALLOW_WRITE = Downloads.Impl.COLUMN_ALLOW_WRITE;
+
+ /**
* Value of {@link #COLUMN_STATUS} when the download is waiting to start.
*/
public final static int STATUS_PENDING = 1 << 0;
@@ -315,6 +320,7 @@
Downloads.Impl.COLUMN_TOTAL_BYTES + " AS " + COLUMN_TOTAL_SIZE_BYTES,
Downloads.Impl.COLUMN_LAST_MODIFICATION + " AS " + COLUMN_LAST_MODIFIED_TIMESTAMP,
Downloads.Impl.COLUMN_CURRENT_BYTES + " AS " + COLUMN_BYTES_DOWNLOADED_SO_FAR,
+ Downloads.Impl.COLUMN_ALLOW_WRITE,
/* add the following 'computed' columns to the cursor.
* they are not 'returned' by the database, but their inclusion
* eliminates need to have lot of methods in CursorTranslator
@@ -1185,6 +1191,14 @@
public long addCompletedDownload(String title, String description,
boolean isMediaScannerScannable, String mimeType, String path, long length,
boolean showNotification) {
+ return addCompletedDownload(title, description, isMediaScannerScannable, mimeType, path,
+ length, showNotification, false);
+ }
+
+ /** {@hide} */
+ public long addCompletedDownload(String title, String description,
+ boolean isMediaScannerScannable, String mimeType, String path, long length,
+ boolean showNotification, boolean allowWrite) {
// make sure the input args are non-null/non-zero
validateArgumentIsNonEmpty("title", title);
validateArgumentIsNonEmpty("description", description);
@@ -1210,12 +1224,14 @@
Request.SCANNABLE_VALUE_NO);
values.put(Downloads.Impl.COLUMN_VISIBILITY, (showNotification) ?
Request.VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION : Request.VISIBILITY_HIDDEN);
+ values.put(Downloads.Impl.COLUMN_ALLOW_WRITE, allowWrite ? 1 : 0);
Uri downloadUri = mResolver.insert(Downloads.Impl.CONTENT_URI, values);
if (downloadUri == null) {
return -1;
}
return Long.parseLong(downloadUri.getLastPathSegment());
}
+
private static final String NON_DOWNLOADMANAGER_DOWNLOAD =
"non-dwnldmngr-download-dont-retry2download";
@@ -1227,8 +1243,10 @@
/**
* Get the DownloadProvider URI for the download with the given ID.
+ *
+ * @hide
*/
- Uri getDownloadUri(long id) {
+ public Uri getDownloadUri(long id) {
return ContentUris.withAppendedId(mBaseUri, id);
}
diff --git a/core/java/android/preference/PreferenceActivity.java b/core/java/android/preference/PreferenceActivity.java
index a99705b..2ab5a91 100644
--- a/core/java/android/preference/PreferenceActivity.java
+++ b/core/java/android/preference/PreferenceActivity.java
@@ -887,8 +887,9 @@
/**
* Subclasses should override this method and verify that the given fragment is a valid type
- * to be attached to this activity. The default implementation returns <code>true</code> prior
- * to Key Lime Pie, <code>false</code> otherwise.
+ * to be attached to this activity. The default implementation returns <code>true</code> for
+ * apps built for <code>android:targetSdkVersion</code> older than
+ * {@link android.os.Build.VERSION_CODES#KITKAT}. For later versions, it will throw an exception.
* @param fragmentName the class name of the Fragment about to be attached to this activity.
* @return true if the fragment class name is valid for this Activity and false otherwise.
*/
diff --git a/core/java/android/provider/Downloads.java b/core/java/android/provider/Downloads.java
index 9999760..b2d9b934 100644
--- a/core/java/android/provider/Downloads.java
+++ b/core/java/android/provider/Downloads.java
@@ -410,6 +410,8 @@
/** The column that is used to count retries */
public static final String COLUMN_FAILED_CONNECTIONS = "numfailed";
+ public static final String COLUMN_ALLOW_WRITE = "allow_write";
+
/**
* default value for {@link #COLUMN_LAST_UPDATESRC}.
* This value is used when this column's value is not relevant.
diff --git a/core/jni/android/graphics/Typeface.cpp b/core/jni/android/graphics/Typeface.cpp
index ff62fff..a7a0bb2 100644
--- a/core/jni/android/graphics/Typeface.cpp
+++ b/core/jni/android/graphics/Typeface.cpp
@@ -44,7 +44,13 @@
}
static SkTypeface* Typeface_createFromTypeface(JNIEnv* env, jobject, SkTypeface* family, int style) {
- return SkTypeface::CreateFromTypeface(family, (SkTypeface::Style)style);
+ SkTypeface* face = SkTypeface::CreateFromTypeface(family, (SkTypeface::Style)style);
+ // return the default font at the best style if the requested style does not
+ // exist in the provided family
+ if (NULL == face) {
+ face = SkTypeface::CreateFromName(NULL, (SkTypeface::Style)style);
+ }
+ return face;
}
static void Typeface_unref(JNIEnv* env, jobject obj, SkTypeface* face) {
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 0adda56..84a0d37 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -582,9 +582,12 @@
<!-- Don't show lock screen before unlock screen (PIN/pattern/password) -->
<bool name="config_enableLockBeforeUnlockScreen">false</bool>
- <!-- Diable lockscreen rotation by default -->
+ <!-- Disable lockscreen rotation by default -->
<bool name="config_enableLockScreenRotation">false</bool>
+ <!-- Disable lockscreen transparent bars by default -->
+ <bool name="config_enableLockScreenTransparentBars">false</bool>
+
<!-- Enable puk unlockscreen by default.
If unlock screen is disabled, the puk should be unlocked through Emergency Dialer -->
<bool name="config_enable_puk_unlock_screen">true</bool>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 8370b9f..14b319f 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1282,6 +1282,7 @@
<java-symbol type="bool" name="config_disableMenuKeyInLockScreen" />
<java-symbol type="bool" name="config_enableLockBeforeUnlockScreen" />
<java-symbol type="bool" name="config_enableLockScreenRotation" />
+ <java-symbol type="bool" name="config_enableLockScreenTransparentBars" />
<java-symbol type="bool" name="config_lidControlsSleep" />
<java-symbol type="bool" name="config_reverseDefaultRotation" />
<java-symbol type="bool" name="config_showNavigationBar" />
diff --git a/docs/downloads/training/Scheduler.zip b/docs/downloads/training/Scheduler.zip
new file mode 100644
index 0000000..81dfb5f
--- /dev/null
+++ b/docs/downloads/training/Scheduler.zip
Binary files differ
diff --git a/docs/html/training/best-background.jd b/docs/html/training/best-background.jd
new file mode 100644
index 0000000..917eabb
--- /dev/null
+++ b/docs/html/training/best-background.jd
@@ -0,0 +1,8 @@
+page.title=Best Practices for Background Jobs
+page.trainingcourse=true
+
+@jd:body
+
+
+<p>These classes show you how to run jobs in the background to boost your
+application's performance and minimize its drain on the battery.</p>
diff --git a/docs/html/training/scheduling/alarms.jd b/docs/html/training/scheduling/alarms.jd
new file mode 100644
index 0000000..758dc95
--- /dev/null
+++ b/docs/html/training/scheduling/alarms.jd
@@ -0,0 +1,312 @@
+page.title=Scheduling Repeating Alarms
+parent.title=Using Wake Locks
+parent.link=index.html
+
+trainingnavtop=true
+
+@jd:body
+
+<div id="tb-wrapper">
+<div id="tb">
+
+<!-- table of contents -->
+<h2>This lesson teaches you to</h2>
+<ol>
+ <li><a href="#set">Set a Repeating Alarm</a></li>
+ <li><a href="#cancel">Cancel an Alarm</a></li>
+ <li><a href="#boot">Start an Alarm When the Device Boots</a></li>
+</ol>
+
+<h2>Try it out</h2>
+
+<div class="download-box">
+ <a href="{@docRoot}shareables/training/Scheduler.zip"
+class="button">Download the sample</a>
+ <p class="filename">Scheduler.zip</p>
+</div>
+
+</div>
+</div>
+
+<p>Alarms (based on the {@link android.app.AlarmManager} class) give you a way to perform
+time-based operations outside the lifetime of your application.
+For example, you could use an alarm to initiate a long-running operation, such
+as starting a service once a day to download a weather forecast.</p>
+
+<p>Alarms have these characteristics:</p>
+<ul>
+
+<li>They let you fire Intents at set times and/or intervals.</li>
+
+<li>You can use them in conjunction with broadcast receivers to start services and perform
+other operations.</li>
+
+<li>They operate outside of your application, so you can use them to trigger events or
+actions even when your app is not running, and even if the device itself is asleep.</li>
+
+<li>They help you to minimize your app's resource requirements. You can schedule operations
+without relying on timers or continuously running background services.</li>
+
+</ul>
+
+<p class="note"><strong>Note:</strong> For timing operations that are guaranteed to occur
+<em>during</em> the lifetime of your application,
+instead consider using the {@link android.os.Handler} class in conjunction with
+{@link java.util.Timer} and {@link java.lang.Thread}. This approach gives Android better
+control over system resources.</p>
+
+<h2 id="set">Set a Repeating Alarm</h2>
+
+<p>As described above, repeating alarms are a good choice for scheduling regular events or
+data lookups. A repeating alarm has the following characteristics:</p>
+
+<ul>
+<li>A alarm type. For more discussion, see <a href="#type">Choose an alarm type</a>.</li>
+<li>A trigger time. If the trigger time you specify is in the past, the alarm triggers
+immediately.</li>
+<li>The alarm's interval. For example, once a day, every hour, every 5 seconds, and so on.</li>
+<li>A pending intent that fires when the alarm is triggered. When you set a second alarm
+that uses the same pending intent, it replaces the original alarm.</li>
+</ul>
+
+<p>Every choice you make in designing your repeating alarm can have consequences in how your
+app uses (or abuses) system resources. Even a carefully managed alarm can have a major impact
+on battery life. Follow these guidelines as you design your app:</p>
+
+<ul>
+<li>Keep your alarm frequency to a minimum.</li>
+<li>Don't wake up the device unnecessarily (this behavior is determined by the alarm type,
+as described in <a href="#type">Choose an alarm type</a>).</li>
+<li>Don't make your alarm's trigger time any more precise than it has to be:
+
+<ul>
+<li>Use {@link android.app.AlarmManager#setInexactRepeating setInexactRepeating()} instead
+of {@link android.app.AlarmManager#setRepeating setRepeating()} whenever possible.
+When you use {@link android.app.AlarmManager#setInexactRepeating setInexactRepeating()},
+Android synchronizes multiple inexact repeating alarms and fires
+them at the same time. This reduces the drain on the battery.</li>
+<li>If your alarm's behavior is based on an interval (for example, your alarm
+fires once an hour) rather than a precise trigger time (for example, your alarm fires at
+7 a.m. sharp and every 20 minutes after that), use an {@code ELAPSED_REALTIME}
+alarm type.</li>
+</ul></li>
+
+</ul>
+
+<h3 id="type">Choose an alarm type</h3>
+
+<p>One of the first considerations in using a repeating alarm is what its type should be.</p>
+
+
+<p>There are two general clock types for alarms: "elapsed real time" and "real time clock"
+(RTC).
+Elapsed real time uses the "time since system boot" as a
+reference, and real time clock uses UTC (wall clock) time. This means that
+elapsed real time is suited to setting an alarm based on the passage of time (for
+example, an alarm that fires every 30 seconds) since it isn't affected by
+time zone/locale. The real time clock type is better suited for alarms that are dependent
+on current locale.</p>
+
+<p>Both types have a "wakeup" version, which says to wake up the device's CPU if the
+screen is off. This ensures that the alarm will fire at the scheduled time. This is useful
+if your app has a time dependency—for example, if it has a limited window to perform a
+particular operation. If you don't use the wakeup version of your alarm type, then
+all the repeating alarms will fire when your device is next awake.</p>
+
+<p>If you simply need your alarm to fire at a particular interval (for example, every half
+hour), use one of the elapsed real time types. In general, this is the better choice.</p>
+
+<p>If you need your alarm to fire at a particular time of day,
+then choose one of the clock-based real time clock types. Note, however, that this approach can
+have some drawbacks—the app may not translate well to other locales, and if the user
+changes the device's time setting, it could cause unexpected behavior in your app.</p>
+
+<p>Here is the list of types:</p>
+
+<ul>
+
+<li>{@link android.app.AlarmManager#ELAPSED_REALTIME}—Fires the pending intent based
+on the amount of time since the device was booted, but doesn't wake up the device. The
+elapsed time includes any time during which the device was asleep.</li>
+
+<li>{@link android.app.AlarmManager#ELAPSED_REALTIME_WAKEUP}—Wakes up the device and
+fires the pending intent after the specified length of time has elapsed since device
+boot.</li>
+
+<li>{@link android.app.AlarmManager#RTC}—Fires the pending intent
+at the specified time but does not wake up the device.</li>
+
+<li>{@link android.app.AlarmManager#RTC_WAKEUP}—Wakes up the
+device to fire the pending intent at the specified time.</li>
+</ul>
+
+<h4>ELAPSED_REALTIME_WAKEUP examples</h3>
+
+<p>Here are some examples of using {@link android.app.AlarmManager#ELAPSED_REALTIME_WAKEUP}.
+</p>
+
+<p>Wake up the device to fire the alarm in 30 minutes, and every 30 minutes
+after that:</p>
+
+<pre>
+// Hopefully your alarm will have a lower frequency than this!
+alarmMgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
+ AlarmManager.INTERVAL_HALF_HOUR,
+ AlarmManager.INTERVAL_HALF_HOUR, alarmIntent);</pre>
+
+<p>Wake up the device to fire a one-time (non-repeating) alarm in one minute:</p>
+
+<pre>private AlarmManager alarmMgr;
+private PendingIntent alarmIntent;
+...
+alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
+Intent intent = new Intent(context, AlarmReceiver.class);
+alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
+
+alarmMgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
+ SystemClock.elapsedRealtime() +
+ 60 * 1000, alarmIntent);</pre>
+
+
+<h4>RTC examples</h3>
+
+<p>Here are some examples of using {@link android.app.AlarmManager#RTC_WAKEUP}.</p>
+
+<p>Wake up the device to fire the alarm at approximately 2:00 p.m., and repeat once a day
+at the same time:</p>
+
+<pre>// Set the alarm to start at approximately 2:00 p.m.
+Calendar calendar = Calendar.getInstance();
+calendar.setTimeInMillis(System.currentTimeMillis());
+calendar.set(Calendar.HOUR_OF_DAY, 14);
+
+// With setInexactRepeating(), you have to use one of the AlarmManager interval
+// constants--in this case, AlarmManager.INTERVAL_DAY.
+alarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
+ AlarmManager.INTERVAL_DAY, alarmIntent);</pre>
+
+<p>Wake up the device to fire the alarm at precisely 8:30 a.m., and every 20 minutes
+thereafter:</p>
+
+<pre>private AlarmManager alarmMgr;
+private PendingIntent alarmIntent;
+...
+alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
+Intent intent = new Intent(context, AlarmReceiver.class);
+alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
+
+// Set the alarm to start at 8:30 a.m.
+Calendar calendar = Calendar.getInstance();
+calendar.setTimeInMillis(System.currentTimeMillis());
+calendar.set(Calendar.HOUR_OF_DAY, 8);
+calendar.set(Calendar.MINUTE, 30);
+
+// setRepeating() lets you specify a precise custom interval--in this case,
+// 20 minutes.
+alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
+ 1000 * 60 * 20, alarmIntent);</pre>
+
+<h3>Decide how precise your alarm needs to be</h3>
+
+<p>As described above, choosing the alarm type is often the first step in creating an alarm.
+A further distinction is how precise you need your alarm to be. For most apps,
+{@link android.app.AlarmManager#setInexactRepeating setInexactRepeating()} is the right
+choice.
+When you use this method, Android synchronizes multiple inexact repeating alarms and fires
+them at the same time. This reduces the drain on the battery.</p>
+
+<p>For the rare app that has rigid time requirements—for example, the alarm needs to
+fire precisely at 8:30 a.m., and every hour on the hour
+thereafter—use {@link android.app.AlarmManager#setRepeating setRepeating()}. But you
+should avoid using exact alarms if possible.</p>
+
+<p>With {@link android.app.AlarmManager#setInexactRepeating setInexactRepeating()},
+you can't specify a custom interval the way you can with
+{@link android.app.AlarmManager#setRepeating setRepeating()}. You have to use one of the
+interval constants, such as {@link android.app.AlarmManager#INTERVAL_FIFTEEN_MINUTES},
+{@link android.app.AlarmManager#INTERVAL_DAY}, and so on. See {@link android.app.AlarmManager}
+for the complete list.
+</p>
+
+<h2 id="cancel">Cancel an Alarm</h2>
+
+<p>Depending on your app, you may want to include the ability to cancel the alarm.
+To cancel an alarm, call {@link android.app.AlarmManager#cancel cancel()} on the Alarm
+Manager, passing in the {@link android.app.PendingIntent} you no longer want to fire. For
+example:</p>
+
+<pre>// If the alarm has been set, cancel it.
+if (alarmMgr!= null) {
+ alarmMgr.cancel(alarmIntent);
+}</pre>
+
+<h2 id="boot">Start an Alarm When the Device Boots</h2>
+
+<p>By default, all alarms are canceled when a device shuts down.
+To prevent this from happening, you can design your application
+to automatically restart a repeating alarm if the user reboots the device. This ensures
+that the {@link android.app.AlarmManager} will continue doing its task without the user
+needing to manually restart the alarm.</p>
+
+
+<p>Here are the steps:</p>
+<ol>
+<li>Set the <a href="{@docRoot}reference/android/Manifest.permission.html#RECEIVE_BOOT_COMPLETED">
+{@code RECEIVE_BOOT_COMPLETED}</a> permission in your application's manifest. This allows
+your app to receive the
+{@link android.content.Intent#ACTION_BOOT_COMPLETED} that is broadcast after the system
+finishes booting (this only works if the app has already been launched by the user at least once):
+<pre>
+<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/></pre>
+</li>
+
+<li>Implement a {@link android.content.BroadcastReceiver} to receive the broadcast:
+<pre>public class SampleBootReceiver extends BroadcastReceiver {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
+ // Set the alarm here.
+ }
+ }
+}</pre></li>
+
+<li>Add the receiver to your app's manifest file with an intent filter that filters on
+the {@link android.content.Intent#ACTION_BOOT_COMPLETED} action:
+
+<pre><receiver android:name=".SampleBootReceiver"
+ android:enabled="false">
+ <intent-filter>
+ <action android:name="android.intent.action.BOOT_COMPLETED"></action>
+ </intent-filter>
+</receiver></pre>
+
+
+<p>Notice that in the manifest, the boot receiver is set to
+{@code android:enabled="false"}. This means that the receiver will not be called
+unless the application explicitly enables it. This prevents the boot receiver from being
+called unnecessarily. You can enable a receiver (for example, if the user sets an alarm)
+as follows:</p>
+
+<pre>ComponentName receiver = new ComponentName(context, SampleBootReceiver.class);
+PackageManager pm = context.getPackageManager();
+
+pm.setComponentEnabledSetting(receiver,
+ PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
+ PackageManager.DONT_KILL_APP);
+</pre>
+
+<p>Once you enable the receiver this way, it will stay enabled, even if the user reboots
+the device. In other words, programmatically enabling the receiver overrides the
+manifest setting, even across reboots. The receiver will stay enabled until your app disables it.
+You can disable a receiver (for example, if the user cancels an alarm) as follows:</p>
+
+<pre>ComponentName receiver = new ComponentName(context, SampleBootReceiver.class);
+PackageManager pm = context.getPackageManager();
+
+pm.setComponentEnabledSetting(receiver,
+ PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
+ PackageManager.DONT_KILL_APP);</pre>
+
+</li>
+</ol>
diff --git a/docs/html/training/scheduling/index.jd b/docs/html/training/scheduling/index.jd
new file mode 100644
index 0000000..9ffbc16
--- /dev/null
+++ b/docs/html/training/scheduling/index.jd
@@ -0,0 +1,66 @@
+page.title=Managing Device Awake State
+page.tags=""
+
+trainingnavtop=true
+startpage=true
+
+
+@jd:body
+<div id="tb-wrapper">
+<div id="tb">
+
+<!-- Required platform, tools, add-ons, devices, knowledge, etc. -->
+<h2>Dependencies and prerequisites</h2>
+
+<ul>
+ <li>Android 1.6 (API Level 4) or higher</li>
+</ul>
+
+<h2>Try it out</h2>
+
+<div class="download-box">
+ <a href="{@docRoot}shareables/training/Scheduler.zip"
+class="button">Download the sample</a>
+ <p class="filename">Scheduler.zip</p>
+</div>
+
+</div>
+</div>
+
+<p>
+When an Android device is left idle, it will first dim, then turn off the screen, and
+ultimately turn off the CPU. This prevents the device's battery from quickly getting
+drained. Yet there are times when your application might require a different behavior:</p>
+
+<ul>
+
+<li>Apps such as games or movie apps may need to keep the screen turned on.</p>
+
+<li>Other applications may not need the screen to remain on, but they may require the CPU
+ to keep running until a critical operation finishes.</p>
+
+</ul>
+
+<p>
+This class describes how to keep a device awake when necessary without draining
+its battery.
+</p>
+<h2>Lessons</h2>
+
+<dl>
+ <dt>
+ <strong><a href="wakelock.html">Keeping the Device Awake</a></strong>
+ </dt>
+ <dd>
+ Learn how to keep the screen or CPU awake as needed, while minimizing the impact
+ on battery life.
+ </dd>
+ <dt>
+ <strong><a href="alarms.html">Scheduling Repeating Alarms</a></strong>
+ </dt>
+ <dd>
+ Learn how to use repeating alarms to schedule operations that take place outside
+ of the lifetime of the application, even if the application is not running and/or the
+ device is asleep.
+ </dd>
+</dl>
diff --git a/docs/html/training/scheduling/wakelock.jd b/docs/html/training/scheduling/wakelock.jd
new file mode 100644
index 0000000..0fab7be
--- /dev/null
+++ b/docs/html/training/scheduling/wakelock.jd
@@ -0,0 +1,215 @@
+page.title=Keeping the Device Awake
+
+trainingnavtop=true
+
+@jd:body
+
+<div id="tb-wrapper">
+<div id="tb">
+
+<!-- table of contents -->
+<h2>This lesson teaches you to</h2>
+<ol>
+ <li><a href="#screen">Keep the Screen On</a></li>
+ <li><a href="#cpu">Keep the CPU On</a></li>
+</ol>
+
+<h2>Try it out</h2>
+
+<div class="download-box">
+ <a href="{@docRoot}shareables/training/Scheduler.zip"
+class="button">Download the sample</a>
+ <p class="filename">Scheduler.zip</p>
+</div>
+
+</div>
+</div>
+
+
+<p>To avoid draining the battery, an Android device that is left idle quickly falls asleep.
+However, there are times when an application needs to wake up the screen or the CPU
+and keep it awake to complete some work.</p>
+
+<p>The approach you take depends on the needs of your app. However, a general rule of thumb
+is that you should use the most lightweight approach possible for your app, to minimize your
+app's impact on system resources. The following sections describe how to handle the cases
+where the device's default sleep behavior is incompatible with the requirements of your app.</p>
+
+<h2 id="screen">Keep the Screen On</h2>
+
+<p>Certain apps need to keep the screen turned on, such as games or movie apps. The best
+way to do this is to use the
+{@link android.view.WindowManager.LayoutParams#FLAG_KEEP_SCREEN_ON FLAG_KEEP_SCREEN_ON}
+in your activity (and only in an activity, never in a service or
+other app component). For example:</p>
+
+<pre>public class MainActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ <strong>getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);</strong>
+ }</pre>
+
+<p>The advantage of this approach is that unlike wake locks (discussed in <a href="#cpu">
+Keep the CPU On</a>), it doesn't require special permission, and the platform correctly
+manages the user moving between applications, without your app needing to worry about
+releasing unused resources.</p>
+
+<p>Another way to implement this is in your application's layout XML file, by using the
+{@link android.R.attr#keepScreenOn android:keepScreenOn} attribute:</p>
+
+<pre><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ <strong>android:keepScreenOn="true"></strong>
+ ...
+</RelativeLayout></pre>
+
+<p>Using <code>android:keepScreenOn="true"</code> is equivalent to using
+{@link android.view.WindowManager.LayoutParams#FLAG_KEEP_SCREEN_ON FLAG_KEEP_SCREEN_ON}.
+You can use whichever approach is best for your app. The advantage of setting the flag
+programmatically in your activity is that it gives you the option of programmatically
+clearing the flag later and thereby allowing the screen to turn off.</p>
+
+<p class="note"><strong>Note:</strong> You don't need to clear the
+{@link android.view.WindowManager.LayoutParams#FLAG_KEEP_SCREEN_ON FLAG_KEEP_SCREEN_ON}
+flag unless you no longer want the screen to
+stay on in your running application (for example, if you want the screen to time out
+after a certain period of inactivity). The window manager takes care of
+ensuring that the right things happen when the app goes into the background or returns to
+the foreground. But if you want to explicitly clear the flag and thereby allow the screen to
+turn off again, use {@link android.view.Window#clearFlags clearFlags()}:
+{@code getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)}.</p>
+
+<h2 id="cpu">Keep the CPU On</h2>
+
+<div class="sidebox-wrapper">
+<div class="sidebox">
+ <h2>Alternatives to using wake locks</h2>
+
+<ul>
+
+<li>If your app is performing long-running HTTP downloads, consider using
+{@link android.app.DownloadManager}.</li>
+
+<li>If your app is synchronizing data from an external server, consider creating a
+<a href="{@docRoot}training/sync-adapters/index.html">sync
+adapter</a>.</li>
+
+<li>If your app relies on background services, consider using
+<a href="{@docRoot}training/scheduling/alarms.html">repeating alarms</a>
+or <a href="{@docRoot}google/gcm/index.html">Google Cloud Messaging</a> to trigger these
+services at specific intervals.</li>
+
+</ul>
+</div>
+</div>
+
+
+<p>If you need to keep the CPU running in order to complete some work before the device goes
+to sleep, you can use a {@link android.os.PowerManager} system service feature called
+wake locks. Wake locks allow your application to control the power state of the host device.</p>
+
+<p>Creating and holding wake locks can have a dramatic impact on the host device's battery
+life. Thus you should use wake locks only when strictly necessary
+and hold them for as short a time as possible. For example, you should never need to use a
+wake lock in an activity. As described above, if you want
+to keep the screen on in your activity, use
+{@link android.view.WindowManager.LayoutParams#FLAG_KEEP_SCREEN_ON FLAG_KEEP_SCREEN_ON}.</p>
+
+
+<p>One legitimate case for using a wake lock might be a background service
+that needs to grab a wake lock to keep the CPU running to do work while the screen is off.
+Again, though, this practice should be minimized because of its impact on battery life.</p>
+
+<p>To use a wake lock, the first step is to add the {@link android.Manifest.permission#WAKE_LOCK}
+ permission to your application's manifest file:</p>
+
+<pre><uses-permission android:name="android.permission.WAKE_LOCK" /></pre>
+
+<p>If your app includes a broadcast receiver that uses a service to do some
+work, you can manage your wake lock through a
+{@link android.support.v4.content.WakefulBroadcastReceiver}, as described in
+<a href="#wakeful">Using a WakefulBroadcastReceiver</a>. This is the preferred approach.
+If your app doesn't follow that pattern, here is how you set a wake lock
+directly:</p>
+
+<pre>
+PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
+Wakelock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
+ "MyWakelockTag");
+wakeLock.acquire();</pre>
+
+<p>To release the wake lock, call
+{@link android.os.PowerManager.WakeLock#release wakelock.release()}. This releases your
+claim to the CPU. It's important to release a wake lock as soon as your app is finished
+using it to avoid draining the battery.</p>
+
+<h3 id="wakeful">Using WakefulBroadcastReceiver</h3>
+
+<p>Using a broadcast receiver in conjunction with a service lets you manage the life cycle
+of a background task.</p>
+
+<p>A {@link android.support.v4.content.WakefulBroadcastReceiver} is a special type of
+broadcast receiver that takes care of
+creating and managing a
+{@link android.os.PowerManager#PARTIAL_WAKE_LOCK} for your app. A
+{@link android.support.v4.content.WakefulBroadcastReceiver}
+passes off the work to a {@link android.app.Service}
+(typically an
+{@link android.app.IntentService}), while ensuring that the device does not
+go back to sleep in the transition. If you don't hold a wake lock while transitioning
+the work to a service, you are effectively allowing the device to go back to sleep before
+the work completes. The net result is that the app might not finish doing the work until
+some arbitrary point in the future, which is not what you want.</p>
+
+<p>The first step in using a
+{@link android.support.v4.content.WakefulBroadcastReceiver} is to add it to your
+manifest, as with any other broadcast receiver:</p>
+
+<pre><receiver android:name=".MyWakefulReceiver"></receiver></pre>
+
+<p>The following code starts {@code MyIntentService} with the method
+{@link android.support.v4.content.WakefulBroadcastReceiver#startWakefulService startWakefulService()}.
+This method is comparable to {@link android.content.Context#startService startService()}, except that
+the {@link android.support.v4.content.WakefulBroadcastReceiver} is holding a
+wake lock when the service starts. The intent that is passed with
+{@link android.support.v4.content.WakefulBroadcastReceiver#startWakefulService startWakefulService()}
+holds an extra identifying the wake lock:</p>
+
+<pre>public class MyWakefulReceiver extends WakefulBroadcastReceiver {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+
+ // Start the service, keeping the device awake while the service is
+ // launching. This is the Intent to deliver to the service.
+ Intent service = new Intent(context, MyIntentService.class);
+ startWakefulService(context, service);
+ }
+}</pre>
+
+<p>When the service is finished, it calls
+{@link android.support.v4.content.WakefulBroadcastReceiver#completeWakefulIntent MyWakefulReceiver.completeWakefulIntent()}
+to release the wake lock. The
+{@link android.support.v4.content.WakefulBroadcastReceiver#completeWakefulIntent completeWakefulIntent()}
+method has as its parameter the same intent that was
+passed in from the {@link android.support.v4.content.WakefulBroadcastReceiver}:</p>
+<pre>
+public class MyIntentService extends IntentService {
+ public static final int NOTIFICATION_ID = 1;
+ private NotificationManager mNotificationManager;
+ NotificationCompat.Builder builder;
+ public MyIntentService() {
+ super("MyIntentService");
+ }
+ @Override
+ protected void onHandleIntent(Intent intent) {
+ Bundle extras = intent.getExtras();
+ // Do the work that requires your app to keep the CPU running.
+ // ...
+ // Release the wake lock provided by the WakefulBroadcastReceiver.
+ MyWakefulReceiver.completeWakefulIntent(intent);
+ }
+}</pre>
diff --git a/docs/html/training/training_toc.cs b/docs/html/training/training_toc.cs
index 8c2752e..a3c9dac 100644
--- a/docs/html/training/training_toc.cs
+++ b/docs/html/training/training_toc.cs
@@ -993,6 +993,75 @@
<li class="nav-section">
<div class="nav-section-header">
+ <a href="<?cs var:toroot ?>training/best-background.html">
+ <span class="small">Best Practices for</span><br/>
+ Background Jobs
+ </a>
+ </div>
+ <ul>
+
+ <li class="nav-section">
+ <div class="nav-section-header">
+ <a href="<?cs var:toroot ?>training/run-background-service/index.html"
+ description=
+ "How to improve UI performance and responsiveness by sending work to a
+ Service running in the background"
+ >Running in a Background Service</a>
+ </div>
+ <ul>
+ <li><a href="<?cs var:toroot ?>training/run-background-service/create-service.html">
+ Creating a Background Service
+ </a>
+ </li>
+ <li><a href="<?cs var:toroot ?>training/run-background-service/send-request.html">
+ Sending Work Requests to the Background Service
+ </a>
+ </li>
+ <li><a href="<?cs var:toroot ?>training/run-background-service/report-status.html">
+ Reporting Work Status
+ </a>
+ </li>
+ </ul>
+ </li>
+
+ <li class="nav-section">
+ <div class="nav-section-header">
+ <a href="<?cs var:toroot ?>training/load-data-background/index.html"
+ description="How to use CursorLoader to query data without
+ affecting UI responsiveness."
+ >Loading Data in the Background</a>
+ </div>
+ <ul>
+ <li><a href="<?cs var:toroot ?>training/load-data-background/setup-loader.html">
+ Running a Query with a CursorLoader</a>
+ </li>
+ <li><a href="<?cs var:toroot ?>training/load-data-background/handle-results.html">
+ Handling the Results</a>
+ </li>
+ </ul>
+ </li>
+
+ <li class="nav-section">
+ <div class="nav-section-header">
+ <a href="<?cs var:toroot ?>training/scheduling/index.html"
+ description="How to use repeating alarms and wake locks
+ to run background jobs."
+ >Managing Device Awake State</a>
+ </div>
+ <ul>
+ <li><a href="<?cs var:toroot ?>training/scheduling/wakelock.html">
+ Keeping the Device Awake</a>
+ </li>
+ <li><a href="<?cs var:toroot ?>training/scheduling/alarms.html">
+ Scheduling Repeating Alarms</a>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li> <!-- end of Background Jobs -->
+
+ <li class="nav-section">
+ <div class="nav-section-header">
<a href="<?cs var:toroot ?>training/best-performance.html">
<span class="small">Best Practices for</span><br/>
Performance
@@ -1038,47 +1107,6 @@
<li class="nav-section">
<div class="nav-section-header">
- <a href="<?cs var:toroot ?>training/run-background-service/index.html"
- description=
- "How to improve UI performance and responsiveness by sending work to a
- Service running in the background"
- >Running in a Background Service</a>
- </div>
- <ul>
- <li><a href="<?cs var:toroot ?>training/run-background-service/create-service.html">
- Creating a Background Service
- </a>
- </li>
- <li><a href="<?cs var:toroot ?>training/run-background-service/send-request.html">
- Sending Work Requests to the Background Service
- </a>
- </li>
- <li><a href="<?cs var:toroot ?>training/run-background-service/report-status.html">
- Reporting Work Status
- </a>
- </li>
- </ul>
- </li>
-
- <li class="nav-section">
- <div class="nav-section-header">
- <a href="<?cs var:toroot ?>training/load-data-background/index.html"
- description="How to use CursorLoader to query data without
- affecting UI responsiveness."
- >Loading Data in the Background</a>
- </div>
- <ul>
- <li><a href="<?cs var:toroot ?>training/load-data-background/setup-loader.html">
- Running a Query with a CursorLoader</a>
- </li>
- <li><a href="<?cs var:toroot ?>training/load-data-background/handle-results.html">
- Handling the Results</a>
- </li>
- </ul>
- </li>
-
- <li class="nav-section">
- <div class="nav-section-header">
<a href="/training/monitoring-device-state/index.html"
zh-cn-lang="优化电池使用时间"
ja-lang="電池消費量の最適化"
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java
index 8eb121a..de1f130 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java
@@ -17,6 +17,7 @@
package com.android.documentsui;
import static com.android.documentsui.DocumentsActivity.TAG;
+import static com.android.documentsui.DocumentsActivity.State.ACTION_CREATE;
import static com.android.documentsui.DocumentsActivity.State.ACTION_MANAGE;
import static com.android.documentsui.DocumentsActivity.State.MODE_GRID;
import static com.android.documentsui.DocumentsActivity.State.MODE_LIST;
@@ -887,8 +888,14 @@
line2.setVisibility(hasLine2 ? View.VISIBLE : View.GONE);
}
- final boolean enabled = Document.MIME_TYPE_DIR.equals(docMimeType)
+ boolean enabled = Document.MIME_TYPE_DIR.equals(docMimeType)
|| MimePredicate.mimeMatches(state.acceptMimes, docMimeType);
+
+ // Read-only files aren't actually enabled when creating
+ if (state.action == ACTION_CREATE && (docFlags & Document.FLAG_SUPPORTS_WRITE) == 0) {
+ enabled = false;
+ }
+
if (enabled) {
setEnabledRecursive(convertView, true);
icon.setAlpha(1f);
diff --git a/packages/Keyguard/res/layout-land/keyguard_host_view.xml b/packages/Keyguard/res/layout-land/keyguard_host_view.xml
index eeb9ee7..87b8b59 100644
--- a/packages/Keyguard/res/layout-land/keyguard_host_view.xml
+++ b/packages/Keyguard/res/layout-land/keyguard_host_view.xml
@@ -51,11 +51,6 @@
androidprv:layout_maxHeight="480dp" />
<include layout="@layout/keyguard_multi_user_selector"/>
- <View android:layout_width="match_parent"
- android:layout_height="match_parent"
- androidprv:layout_childType="scrim"
- android:background="#99000000" />
-
<com.android.keyguard.KeyguardSecurityContainer
android:id="@+id/keyguard_security_container"
android:layout_width="wrap_content"
diff --git a/packages/Keyguard/res/layout-port/keyguard_host_view.xml b/packages/Keyguard/res/layout-port/keyguard_host_view.xml
index 8498dcf..355739e 100644
--- a/packages/Keyguard/res/layout-port/keyguard_host_view.xml
+++ b/packages/Keyguard/res/layout-port/keyguard_host_view.xml
@@ -55,11 +55,6 @@
android:layout_gravity="center"/>
</FrameLayout>
- <View android:layout_width="match_parent"
- android:layout_height="match_parent"
- androidprv:layout_childType="scrim"
- android:background="#99000000" />
-
<com.android.keyguard.KeyguardSecurityContainer
android:id="@+id/keyguard_security_container"
android:layout_width="wrap_content"
diff --git a/packages/Keyguard/res/layout-sw600dp-port/keyguard_host_view.xml b/packages/Keyguard/res/layout-sw600dp-port/keyguard_host_view.xml
index 77bc9b5..42dbe9d 100644
--- a/packages/Keyguard/res/layout-sw600dp-port/keyguard_host_view.xml
+++ b/packages/Keyguard/res/layout-sw600dp-port/keyguard_host_view.xml
@@ -52,11 +52,6 @@
<include layout="@layout/keyguard_multi_user_selector"/>
- <View android:layout_width="match_parent"
- android:layout_height="match_parent"
- androidprv:layout_childType="scrim"
- android:background="#99000000" />
-
<com.android.keyguard.KeyguardSecurityContainer
android:id="@+id/keyguard_security_container"
android:layout_width="wrap_content"
diff --git a/packages/Keyguard/res/values/alias.xml b/packages/Keyguard/res/values/alias.xml
index 47291b2..c964391 100644
--- a/packages/Keyguard/res/values/alias.xml
+++ b/packages/Keyguard/res/values/alias.xml
@@ -46,6 +46,9 @@
<!-- Alias used to reference framework configuration for screen rotation. -->
<item type="bool" name="config_enableLockScreenRotation">@*android:bool/config_enableLockScreenRotation</item>
+ <!-- Alias used to reference framework configuration for transparent bars. -->
+ <item type="bool" name="config_enableLockScreenTransparentBars">@*android:bool/config_enableLockScreenTransparentBars</item>
+
<!-- Alias used to reference framework activity duration. -->
<item type="integer" name="config_activityDefaultDur">@*android:integer/config_activityDefaultDur</item>
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
index 0787286..aa43711 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java
@@ -319,6 +319,7 @@
}
private SlidingChallengeLayout mSlidingChallengeLayout;
+ private MultiPaneChallengeLayout mMultiPaneChallengeLayout;
@Override
public boolean onTouchEvent(MotionEvent ev) {
@@ -372,8 +373,10 @@
mAppWidgetContainer.setViewStateManager(mViewStateManager);
mAppWidgetContainer.setLockPatternUtils(mLockPatternUtils);
+ mMultiPaneChallengeLayout =
+ (MultiPaneChallengeLayout) findViewById(R.id.multi_pane_challenge);
ChallengeLayout challenge = mSlidingChallengeLayout != null ? mSlidingChallengeLayout :
- (ChallengeLayout) findViewById(R.id.multi_pane_challenge);
+ mMultiPaneChallengeLayout;
challenge.setOnBouncerStateChangedListener(mViewStateManager);
mAppWidgetContainer.setBouncerAnimationDuration(challenge.getBouncerAnimationDuration());
mViewStateManager.setPagedView(mAppWidgetContainer);
@@ -399,6 +402,11 @@
updateSecurityViews();
}
+ public void setScrimView(View scrim) {
+ if (mSlidingChallengeLayout != null) mSlidingChallengeLayout.setScrimView(scrim);
+ if (mMultiPaneChallengeLayout != null) mMultiPaneChallengeLayout.setScrimView(scrim);
+ }
+
private void setBackButtonEnabled(boolean enabled) {
if (mContext instanceof Activity) return; // always enabled in activity mode
setSystemUiVisibility(enabled ?
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java
index 893562e..bff1f93 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java
@@ -18,11 +18,6 @@
import android.app.Activity;
import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.ColorFilter;
-import android.graphics.PixelFormat;
-import android.graphics.PorterDuff;
-import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.media.IAudioService;
import android.os.RemoteException;
@@ -45,7 +40,6 @@
*/
public abstract class KeyguardViewBase extends FrameLayout {
- private static final int BACKGROUND_COLOR = 0x70000000;
private AudioManager mAudioManager;
private TelephonyManager mTelephonyManager = null;
protected KeyguardViewMediator.ViewMediatorCallback mViewMediatorCallback;
@@ -55,38 +49,12 @@
// the audio service will bring up the volume dialog.
private static final boolean KEYGUARD_MANAGES_VOLUME = true;
- // This is a faster way to draw the background on devices without hardware acceleration
- private static final Drawable mBackgroundDrawable = new Drawable() {
- @Override
- public void draw(Canvas canvas) {
- canvas.drawColor(BACKGROUND_COLOR, PorterDuff.Mode.SRC);
- }
-
- @Override
- public void setAlpha(int alpha) {
- }
-
- @Override
- public void setColorFilter(ColorFilter cf) {
- }
-
- @Override
- public int getOpacity() {
- return PixelFormat.TRANSLUCENT;
- }
- };
-
public KeyguardViewBase(Context context) {
this(context, null);
}
public KeyguardViewBase(Context context, AttributeSet attrs) {
super(context, attrs);
- resetBackground();
- }
-
- public void resetBackground() {
- setBackground(mBackgroundDrawable);
}
/**
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java
index 4837458..177e0f8 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java
@@ -26,8 +26,12 @@
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.graphics.Canvas;
+import android.graphics.ColorFilter;
import android.graphics.PixelFormat;
+import android.graphics.PorterDuff;
import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcelable;
@@ -67,7 +71,7 @@
private WindowManager.LayoutParams mWindowLayoutParams;
private boolean mNeedsInput = false;
- private FrameLayout mKeyguardHost;
+ private ViewManagerHost mKeyguardHost;
private KeyguardHostView mKeyguardView;
private boolean mScreenOn = false;
@@ -108,7 +112,11 @@
// useful on any keyguard screen but can be re-shown by dialogs or SHOW_WHEN_LOCKED
// activities. Other disabled bits are handled by the KeyguardViewMediator talking
// directly to the status bar service.
- final int visFlags = View.STATUS_BAR_DISABLE_HOME;
+ int visFlags = View.STATUS_BAR_DISABLE_HOME;
+ if (shouldEnableTransparentBars()) {
+ visFlags |= View.SYSTEM_UI_FLAG_TRANSPARENT_STATUS
+ | View.SYSTEM_UI_FLAG_TRANSPARENT_NAVIGATION;
+ }
if (DEBUG) Log.v(TAG, "show:setSystemUiVisibility(" + Integer.toHexString(visFlags)+")");
mKeyguardHost.setSystemUiVisibility(visFlags);
@@ -124,16 +132,81 @@
|| res.getBoolean(R.bool.config_enableLockScreenRotation);
}
+ private boolean shouldEnableTransparentBars() {
+ Resources res = mContext.getResources();
+ return res.getBoolean(R.bool.config_enableLockScreenTransparentBars);
+ }
+
class ViewManagerHost extends FrameLayout {
- public ViewManagerHost(Context context) {
+ private static final int BACKGROUND_COLOR = 0x70000000;
+ // This is a faster way to draw the background on devices without hardware acceleration
+ private final Drawable mBackgroundDrawable = new Drawable() {
+ @Override
+ public void draw(Canvas canvas) {
+ canvas.drawColor(BACKGROUND_COLOR, PorterDuff.Mode.SRC);
+ }
+
+ @Override
+ public void setAlpha(int alpha) {
+ }
+
+ @Override
+ public void setColorFilter(ColorFilter cf) {
+ }
+
+ @Override
+ public int getOpacity() {
+ return PixelFormat.TRANSLUCENT;
+ }
+ };
+ private final View mScrimView;
+ private boolean mExtendIntoPadding;
+ public ViewManagerHost(Context context, boolean extendIntoPadding) {
super(context);
+ mExtendIntoPadding = extendIntoPadding;
setFitsSystemWindows(true);
+ setClipToPadding(!mExtendIntoPadding);
+ setBackground(mBackgroundDrawable);
+
+ mScrimView = new View(context);
+ mScrimView.setVisibility(View.GONE);
+ mScrimView.setBackgroundColor(0x99000000);
+ addView(mScrimView);
+ }
+
+ private boolean considerPadding(View child) {
+ return !mExtendIntoPadding || child instanceof KeyguardHostView;
}
@Override
- protected boolean fitSystemWindows(Rect insets) {
- Log.v("TAG", "bug 7643792: fitSystemWindows(" + insets.toShortString() + ")");
- return super.fitSystemWindows(insets);
+ protected void measureChildWithMargins(View child,
+ int parentWidthMeasureSpec, int widthUsed,
+ int parentHeightMeasureSpec, int heightUsed) {
+ if (considerPadding(child)) {
+ // don't extend into padding (default behavior)
+ super.measureChildWithMargins(child,
+ parentWidthMeasureSpec, widthUsed,
+ parentHeightMeasureSpec, heightUsed);
+ } else {
+ // allowed to extend into padding (scrim / camera preview)
+ child.measure(parentWidthMeasureSpec, parentHeightMeasureSpec);
+ }
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ final int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ final View child = getChildAt(i);
+ int cl = l, ct = t, cr = r, cb = b;
+ if (considerPadding(child)) {
+ cl += mPaddingLeft;
+ ct += mPaddingTop;
+ cr -= mPaddingRight;
+ cb -= mPaddingBottom;
+ }
+ child.layout(cl, ct, cr, cb);
+ }
}
@Override
@@ -179,7 +252,7 @@
if (mKeyguardHost == null) {
if (DEBUG) Log.d(TAG, "keyguard host is null, creating it...");
- mKeyguardHost = new ViewManagerHost(mContext);
+ mKeyguardHost = new ViewManagerHost(mContext, shouldEnableTransparentBars());
int flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
@@ -233,6 +306,7 @@
mKeyguardView.setViewMediatorCallback(mViewMediatorCallback);
mKeyguardView.initializeSwitchingUserState(options != null &&
options.getBoolean(IS_SWITCHING_USER));
+ mKeyguardView.setScrimView(mKeyguardHost.mScrimView);
// HACK
// The keyguard view will have set up window flags in onFinishInflate before we set
diff --git a/packages/Keyguard/src/com/android/keyguard/MultiPaneChallengeLayout.java b/packages/Keyguard/src/com/android/keyguard/MultiPaneChallengeLayout.java
index 8fd39c0..76a7fe3 100644
--- a/packages/Keyguard/src/com/android/keyguard/MultiPaneChallengeLayout.java
+++ b/packages/Keyguard/src/com/android/keyguard/MultiPaneChallengeLayout.java
@@ -172,10 +172,12 @@
mScrimView.setOnClickListener(null);
}
mScrimView = scrim;
- mScrimView.setAlpha(mIsBouncing ? 1.0f : 0.0f);
- mScrimView.setVisibility(mIsBouncing ? VISIBLE : INVISIBLE);
- mScrimView.setFocusable(true);
- mScrimView.setOnClickListener(mScrimClickListener);
+ if (mScrimView != null) {
+ mScrimView.setAlpha(mIsBouncing ? 1.0f : 0.0f);
+ mScrimView.setVisibility(mIsBouncing ? VISIBLE : INVISIBLE);
+ mScrimView.setFocusable(true);
+ mScrimView.setOnClickListener(mScrimClickListener);
+ }
}
private int getVirtualHeight(LayoutParams lp, int height, int heightUsed) {
diff --git a/packages/Keyguard/src/com/android/keyguard/SlidingChallengeLayout.java b/packages/Keyguard/src/com/android/keyguard/SlidingChallengeLayout.java
index 05b35a1..4a4e7fa 100644
--- a/packages/Keyguard/src/com/android/keyguard/SlidingChallengeLayout.java
+++ b/packages/Keyguard/src/com/android/keyguard/SlidingChallengeLayout.java
@@ -367,9 +367,11 @@
mScrimView.setOnClickListener(null);
}
mScrimView = scrim;
- mScrimView.setVisibility(mIsBouncing ? VISIBLE : GONE);
- mScrimView.setFocusable(true);
- mScrimView.setOnClickListener(mScrimClickListener);
+ if (mScrimView != null) {
+ mScrimView.setVisibility(mIsBouncing ? VISIBLE : GONE);
+ mScrimView.setFocusable(true);
+ mScrimView.setOnClickListener(mScrimClickListener);
+ }
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
index a600aae..e77b420 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.phone;
+import android.app.StatusBarManager;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
@@ -111,6 +112,10 @@
if (!handled) {
handled = super.onTouchEvent(ev);
}
+ final int action = ev.getAction();
+ if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
+ mService.setInteracting(StatusBarManager.WINDOW_STATUS_BAR, false);
+ }
return handled;
}
diff --git a/services/java/com/android/server/BootReceiver.java b/services/java/com/android/server/BootReceiver.java
index 3dade37..da1b254 100644
--- a/services/java/com/android/server/BootReceiver.java
+++ b/services/java/com/android/server/BootReceiver.java
@@ -127,6 +127,7 @@
addFileToDropBox(db, prefs, headers, "/data/dontpanic/apanic_threads",
-LOG_SIZE, "APANIC_THREADS");
addAuditErrorsToDropBox(db, prefs, headers, -LOG_SIZE, "SYSTEM_AUDIT");
+ addFsckErrorsToDropBox(db, prefs, headers, -LOG_SIZE, "SYSTEM_FSCK");
} else {
if (db != null) db.addText("SYSTEM_RESTART", headers);
}
@@ -203,4 +204,31 @@
Slog.i(TAG, "Copied " + sb.toString().length() + " worth of audits to DropBox");
db.addText(tag, headers + sb.toString());
}
+
+ private static void addFsckErrorsToDropBox(DropBoxManager db, SharedPreferences prefs,
+ String headers, int maxSize, String tag) throws IOException {
+ boolean upload_needed = false;
+ if (db == null || !db.isTagEnabled(tag)) return; // Logging disabled
+ Slog.i(TAG, "Checking for fsck errors");
+
+ File file = new File("/dev/fscklogs/log");
+ long fileTime = file.lastModified();
+ if (fileTime <= 0) return; // File does not exist
+
+ String log = FileUtils.readTextFile(file, maxSize, "[[TRUNCATED]]\n");
+ StringBuilder sb = new StringBuilder();
+ for (String line : log.split("\n")) {
+ if (line.contains("FILE SYSTEM WAS MODIFIED")) {
+ upload_needed = true;
+ break;
+ }
+ }
+
+ if (upload_needed) {
+ addFileToDropBox(db, prefs, headers, "/dev/fscklogs/log", maxSize, tag);
+ }
+
+ // Remove the file so we don't re-upload if the runtime restarts.
+ file.delete();
+ }
}
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index ee329fc..808bf88 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -2241,8 +2241,9 @@
int lrui = mLruProcesses.lastIndexOf(app);
if (lrui < 0) {
- throw new IllegalStateException("Adding dependent process " + app
- + " not on LRU list: " + what + obj + " from " + srcApp);
+ Log.wtf(TAG, "Adding dependent process " + app + " not on LRU list: "
+ + what + " " + obj + " from " + srcApp);
+ return index;
}
if (lrui >= mLruProcessActivityStart) {
@@ -2307,7 +2308,7 @@
// bump those processes as well.
for (int j=app.connections.size()-1; j>=0; j--) {
ConnectionRecord cr = app.connections.valueAt(j);
- if (cr.binding != null && cr.binding.service != null
+ if (cr.binding != null && !cr.serviceDead && cr.binding.service != null
&& cr.binding.service.app != null
&& cr.binding.service.app.lruSeq != mLruSeq) {
nextIndex = updateLruProcessInternalLocked(cr.binding.service.app, now, nextIndex,
diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java
index 9650b99..923fef2 100644
--- a/telephony/java/com/android/internal/telephony/RILConstants.java
+++ b/telephony/java/com/android/internal/telephony/RILConstants.java
@@ -262,6 +262,7 @@
int RIL_REQUEST_VOICE_RADIO_TECH = 108;
int RIL_REQUEST_GET_CELL_INFO_LIST = 109;
int RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE = 110;
+ int RIL_REQUEST_SET_INITIAL_ATTACH_APN = 111;
int RIL_UNSOL_RESPONSE_BASE = 1000;
int RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED = 1000;
int RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED = 1001;