am c3ab03a9: Merge "Fix issue #8436951 JB-MR2: Compatibility: Audible, Pandora, ..." into jb-mr2-dev

* commit 'c3ab03a9f2c0bc2c4ce8ade6957bcfc30fe2f9ee':
  Fix issue #8436951 JB-MR2: Compatibility: Audible, Pandora, ...
This commit is contained in:
Dianne Hackborn
2013-03-21 22:01:31 +00:00
committed by Android Git Automerger
3 changed files with 52 additions and 0 deletions

View File

@@ -2989,6 +2989,15 @@
<!-- If the device is getting low on internal storage, a notification is shown to the user. This is the message of that notification. -->
<string name="low_internal_storage_view_text">Some system functions may not work</string>
<!-- [CHAR LIMIT=NONE] Stub notification title for an app running a service that has provided
a bad bad notification for itself. -->
<string name="app_running_notification_title"><xliff:g id="app_name">%1$s</xliff:g>
running</string>
<!-- [CHAR LIMIT=NONE] Stub notification text for an app running a service that has provided
a bad bad notification for itself. -->
<string name="app_running_notification_text"><xliff:g id="app_name">%1$s</xliff:g>
is currently running</string>
<!-- Preference framework strings. -->
<string name="ok">OK</string>
<!-- Preference framework strings. -->

View File

@@ -330,6 +330,8 @@
<java-symbol type="string" name="addToDictionary" />
<java-symbol type="string" name="action_bar_home_description" />
<java-symbol type="string" name="action_bar_up_description" />
<java-symbol type="string" name="app_running_notification_title" />
<java-symbol type="string" name="app_running_notification_text" />
<java-symbol type="string" name="delete" />
<java-symbol type="string" name="deleteText" />
<java-symbol type="string" name="ellipsis_two_dots" />

View File

@@ -16,6 +16,9 @@
package com.android.server.am;
import android.app.PendingIntent;
import android.net.Uri;
import android.provider.Settings;
import com.android.internal.os.BatteryStatsImpl;
import com.android.server.NotificationManagerService;
@@ -368,6 +371,44 @@ class ServiceRecord extends Binder {
return;
}
try {
if (foregroundNoti.icon == 0) {
// It is not correct for the caller to supply a notification
// icon, but this used to be able to slip through, so for
// those dirty apps give it the app's icon.
foregroundNoti.icon = appInfo.icon;
if (foregroundNoti.contentView == null) {
// In this case the app may not have specified a
// content view... so we'll give them something to show.
CharSequence appName = appInfo.loadLabel(
ams.mContext.getPackageManager());
if (appName == null) {
appName = appInfo.packageName;
}
Context ctx = null;
try {
ctx = ams.mContext.createPackageContext(
appInfo.packageName, 0);
Intent runningIntent = new Intent(
Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
runningIntent.setData(Uri.fromParts("package",
appInfo.packageName, null));
PendingIntent pi = PendingIntent.getActivity(ams.mContext, 0,
runningIntent, PendingIntent.FLAG_UPDATE_CURRENT);
foregroundNoti.setLatestEventInfo(ctx,
ams.mContext.getString(
com.android.internal.R.string
.app_running_notification_title,
appName),
ams.mContext.getString(
com.android.internal.R.string
.app_running_notification_text,
appName),
pi);
} catch (PackageManager.NameNotFoundException e) {
foregroundNoti.icon = 0;
}
}
}
if (foregroundNoti.icon == 0) {
// Notifications whose icon is 0 are defined to not show
// a notification, silently ignoring it. We don't want to