From 91fe8455d66ef4ac000ba3ba0fb043dd1fbaee49 Mon Sep 17 00:00:00 2001 From: Daniel Sandler Date: Mon, 8 Apr 2013 12:23:27 -0400 Subject: Clean up language in forced foreground service notifications. Old: [ IC ] %s running [ ON ] %s is running New: [ IC ] %s is running [ ON ] Touch for more information or to stop the app. Additionally, disallow these misbehaving services from supplying their own content views; if you attempt to run a foreground service with icon == 0, this is the notification you will get, period. Bug: 8525548 Change-Id: I2bfd7340396ef925885e8c2160a720f9eff07a35 --- core/res/res/values/strings.xml | 6 +-- .../java/com/android/server/am/ServiceRecord.java | 62 +++++++++++----------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 1995670..a0e1603 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -2997,11 +2997,11 @@ %1$s - running + is running - %1$s - is currently running + Touch for more information + or to stop the app. OK diff --git a/services/java/com/android/server/am/ServiceRecord.java b/services/java/com/android/server/am/ServiceRecord.java index 8ff1c7d..fccaab5 100644 --- a/services/java/com/android/server/am/ServiceRecord.java +++ b/services/java/com/android/server/am/ServiceRecord.java @@ -376,37 +376,37 @@ class ServiceRecord extends Binder { // 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; - } + + // Do not allow apps to present a sneaky invisible content view either. + foregroundNoti.contentView = null; + foregroundNoti.bigContentView = null; + 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) { -- cgit v1.1