Skip to content

Commit e9a4e90

Browse files
committed
Link to new app notification settings from the inspector.
Also hide the inspector whenever the keyguard changes state, to make sure we don't leave any notification guts lying around when you turn the screen on and off or unlock. Bug: 16208321 Change-Id: I47cf6a0cb82e765eb6b50984972f57616b534ed3
1 parent 5f2220d commit e9a4e90

7 files changed

Lines changed: 63 additions & 94 deletions

File tree

File renamed without changes.

packages/SystemUI/res/layout/notification_guts.xml

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -77,30 +77,14 @@
7777
/>
7878
</LinearLayout>
7979

80-
<LinearLayout
81-
android:layout_width="wrap_content"
82-
android:layout_height="wrap_content"
83-
android:padding="8dp"
80+
<ImageButton style="@android:style/Widget.Material.Light.Button.Borderless.Small"
81+
android:id="@+id/notification_inspect_item"
82+
android:layout_width="52dp"
83+
android:layout_height="match_parent"
8484
android:layout_weight="0"
85-
android:orientation="horizontal"
86-
android:showDividers="beginning|middle"
87-
android:divider="@*android:drawable/list_divider_holo_dark"
88-
android:dividerPadding="8dp"
89-
>
90-
<Button style="@android:style/Widget.Material.Light.Button.Borderless.Small"
91-
android:id="@+id/notification_inspect_item"
92-
android:layout_width="0dp"
93-
android:layout_height="match_parent"
94-
android:layout_weight="1"
95-
android:gravity="start|center_vertical"
96-
android:drawablePadding="8dp"
97-
android:paddingStart="8dp"
98-
android:textColor="@color/notification_guts_btn_color"
99-
android:textSize="14dp"
100-
android:singleLine="true"
101-
android:ellipsize="end"
102-
android:text="@string/status_bar_notification_inspect_item_title"
103-
/>
104-
</LinearLayout>
85+
android:gravity="center"
86+
android:contentDescription="@string/status_bar_notification_inspect_item_title"
87+
android:src="@drawable/ic_settings"
88+
/>
10589
</LinearLayout>
10690
</FrameLayout>

packages/SystemUI/res/layout/status_bar_expanded_header.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
android:layout_width="48dp"
5151
android:layout_height="@dimen/status_bar_header_height"
5252
android:background="@drawable/ripple_drawable"
53-
android:src="@drawable/ic_settings_24dp"
53+
android:src="@drawable/ic_settings"
5454
android:contentDescription="@string/accessibility_desc_quick_settings"/>
5555

5656
<LinearLayout android:id="@+id/system_icons_super_container"

packages/SystemUI/res/layout/zen_mode_panel.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
android:clickable="true"
7979
android:contentDescription="@null"
8080
android:scaleType="center"
81-
android:src="@drawable/ic_settings_24dp" />
81+
android:src="@drawable/ic_settings" />
8282
</FrameLayout>
8383

8484
<LinearLayout
@@ -98,4 +98,4 @@
9898
android:paddingTop="4dp"
9999
android:paddingBottom="4dp"
100100
android:textAppearance="@style/TextAppearance.QS.Subhead" />
101-
</com.android.systemui.volume.ZenModePanel>
101+
</com.android.systemui.volume.ZenModePanel>

packages/SystemUI/res/values/strings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@
454454
<string name="accessibility_clear_all">Clear all notifications.</string>
455455

456456
<!-- Title shown in notification popup for inspecting the responsible
457-
application -->
458-
<string name="status_bar_notification_inspect_item_title">App info</string>
457+
application [CHAR LIMIT=30] -->
458+
<string name="status_bar_notification_inspect_item_title">Settings</string>
459459

460460
<!-- Description of the button in the phone-style notification panel that controls auto-rotation, when auto-rotation is on. [CHAR LIMIT=NONE] -->
461461
<string name="accessibility_rotation_lock_off">Screen will rotate automatically.</string>

packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java

Lines changed: 49 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import android.animation.TimeInterpolator;
2222
import android.app.ActivityManager;
2323
import android.app.ActivityManagerNative;
24+
import android.app.ActivityThread;
2425
import android.app.Notification;
2526
import android.app.PendingIntent;
2627
import android.app.TaskStackBuilder;
@@ -30,6 +31,8 @@
3031
import android.content.Intent;
3132
import android.content.IntentFilter;
3233
import android.content.pm.ApplicationInfo;
34+
import android.content.pm.IPackageManager;
35+
import android.content.pm.PackageInfo;
3336
import android.content.pm.PackageManager;
3437
import android.content.pm.PackageManager.NameNotFoundException;
3538
import android.content.pm.UserInfo;
@@ -585,31 +588,12 @@ public boolean isMediaNotification(NotificationData.Entry entry) {
585588
entry.expandedBig.findViewById(com.android.internal.R.id.media_action_area) != null;
586589
}
587590

588-
private void startApplicationDetailsActivity(String packageName) {
589-
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
590-
Uri.fromParts("package", packageName, null));
591-
intent.setComponent(intent.resolveActivity(mContext.getPackageManager()));
592-
TaskStackBuilder.create(mContext).addNextIntentWithParentStack(intent).startActivities(
593-
null, UserHandle.CURRENT);
594-
}
595-
596-
private static final int max(int...args) {
597-
switch (args.length) {
598-
case 0:
599-
return 0;
600-
case 1:
601-
return args[0];
602-
case 2:
603-
return args[1] > args[0] ? args[1] : args[0];
604-
default:
605-
int m = args[0];
606-
for (int i = 0; i < args.length; i++) {
607-
if (args[i] > m) {
608-
m = args[i];
609-
}
610-
}
611-
return m;
612-
}
591+
private void startAppNotificationSettingsActivity(String packageName, int appUid) {
592+
Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
593+
intent.putExtra(Settings.EXTRA_APP_PACKAGE, packageName);
594+
intent.putExtra(Settings.EXTRA_APP_UID, appUid);
595+
TaskStackBuilder.create(mContext).addNextIntentWithParentStack(intent)
596+
.startActivities(null, new UserHandle(UserHandle.getUserId(appUid)));
613597
}
614598

615599
protected SwipeHelper.LongPressListener getNotificationLongClicker() {
@@ -618,8 +602,6 @@ protected SwipeHelper.LongPressListener getNotificationLongClicker() {
618602
public boolean onLongPress(View v, int x, int y) {
619603
dismissPopups();
620604

621-
final String packageNameF = (String) v.getTag();
622-
if (packageNameF == null) return false;
623605
if (v.getWindowToken() == null) return false;
624606

625607
// Assume we are a status_bar_notification_row
@@ -629,14 +611,6 @@ public boolean onLongPress(View v, int x, int y) {
629611
// Already showing?
630612
if (guts.getVisibility() == View.VISIBLE) return false;
631613

632-
final View button = guts.findViewById(R.id.notification_inspect_item);
633-
button.setOnClickListener(new View.OnClickListener() {
634-
public void onClick(View v) {
635-
startApplicationDetailsActivity(packageNameF);
636-
animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
637-
}
638-
});
639-
640614
guts.setVisibility(View.VISIBLE);
641615
final double horz = Math.max(v.getWidth() - x, x);
642616
final double vert = Math.max(v.getHeight() - y, y);
@@ -959,28 +933,10 @@ protected boolean inflateViewsForHeadsUp(NotificationData.Entry entry, ViewGroup
959933
return inflateViews(entry, parent, true);
960934
}
961935

962-
private Drawable loadPackageIconDrawable(String pkg, int userId) {
963-
Drawable icon = null;
964-
try {
965-
icon = mContext.getPackageManager().getApplicationIcon(pkg);
966-
} catch (PackageManager.NameNotFoundException e) {
967-
}
968-
969-
return icon;
970-
}
971-
972-
private CharSequence loadPackageName(String pkg) {
973-
final PackageManager pm = mContext.getPackageManager();
974-
try {
975-
ApplicationInfo info = pm.getApplicationInfo(pkg,
976-
PackageManager.GET_UNINSTALLED_PACKAGES);
977-
if (info != null) return pm.getApplicationLabel(info);
978-
} catch (PackageManager.NameNotFoundException e) {
979-
}
980-
return pkg;
981-
}
982-
983936
private boolean inflateViews(NotificationData.Entry entry, ViewGroup parent, boolean isHeadsUp) {
937+
PackageManager pmUser = getPackageManagerForUser(
938+
entry.notification.getUser().getIdentifier());
939+
984940
int maxHeight = mRowMaxHeight;
985941
StatusBarNotification sbn = entry.notification;
986942
RemoteViews contentView = sbn.getNotification().contentView;
@@ -1031,12 +987,43 @@ private boolean inflateViews(NotificationData.Entry entry, ViewGroup parent, boo
1031987
// the notification inspector (see SwipeHelper.setLongPressListener)
1032988
row.setTag(sbn.getPackageName());
1033989
final View guts = row.findViewById(R.id.notification_guts);
1034-
final Drawable pkgicon = loadPackageIconDrawable(entry.notification.getPackageName(),
1035-
entry.notification.getUserId());
1036-
final String pkgname = loadPackageName(entry.notification.getPackageName()).toString();
990+
final String pkg = entry.notification.getPackageName();
991+
String appname = pkg;
992+
Drawable pkgicon = null;
993+
int appUid = -1;
994+
try {
995+
final ApplicationInfo info = pmUser.getApplicationInfo(pkg,
996+
PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS);
997+
if (info != null) {
998+
appname = String.valueOf(pmUser.getApplicationLabel(info));
999+
pkgicon = pmUser.getApplicationIcon(info);
1000+
appUid = info.uid;
1001+
}
1002+
} catch (NameNotFoundException e) {
1003+
// app is gone, just show package name and generic icon
1004+
pkgicon = pmUser.getDefaultActivityIcon();
1005+
}
10371006
((ImageView) row.findViewById(android.R.id.icon)).setImageDrawable(pkgicon);
10381007
((DateTimeView) row.findViewById(R.id.timestamp)).setTime(entry.notification.getPostTime());
1039-
((TextView) row.findViewById(R.id.pkgname)).setText(pkgname);
1008+
((TextView) row.findViewById(R.id.pkgname)).setText(appname);
1009+
final View settingsButton = guts.findViewById(R.id.notification_inspect_item);
1010+
if (appUid >= 0) {
1011+
final int appUidF = appUid;
1012+
settingsButton.setOnClickListener(new View.OnClickListener() {
1013+
public void onClick(View v) {
1014+
dismissKeyguardThenExecute(new OnDismissAction() {
1015+
public boolean onDismiss() {
1016+
startAppNotificationSettingsActivity(pkg, appUidF);
1017+
animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE);
1018+
visibilityChanged(false);
1019+
return DELAY_DISMISS_TO_ACTIVITY_LAUNCH;
1020+
}
1021+
});
1022+
}
1023+
});
1024+
} else {
1025+
settingsButton.setVisibility(View.GONE);
1026+
}
10401027

10411028
workAroundBadLayerDrawableOpacity(row);
10421029
View vetoButton = updateNotificationVetoButton(row, sbn);
@@ -1108,18 +1095,15 @@ private boolean inflateViews(NotificationData.Entry entry, ViewGroup parent, boo
11081095
}
11091096

11101097
if (publicViewLocal == null) {
1111-
PackageManager pm = getPackageManagerForUser(
1112-
entry.notification.getUser().getIdentifier());
1113-
11141098
// Add a basic notification template
11151099
publicViewLocal = LayoutInflater.from(mContext).inflate(
11161100
com.android.internal.R.layout.notification_template_material_base,
11171101
expandedPublic, true);
11181102

11191103
final TextView title = (TextView) publicViewLocal.findViewById(com.android.internal.R.id.title);
11201104
try {
1121-
title.setText(pm.getApplicationLabel(
1122-
pm.getApplicationInfo(entry.notification.getPackageName(), 0)));
1105+
title.setText(pmUser.getApplicationLabel(
1106+
pmUser.getApplicationInfo(entry.notification.getPackageName(), 0)));
11231107
} catch (NameNotFoundException e) {
11241108
title.setText(entry.notification.getPackageName());
11251109
}

packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ public void resetViews() {
359359
mUnlockIconActive = false;
360360
mAfforanceHelper.reset(true);
361361
closeQs();
362+
mStatusBar.dismissPopups();
362363
mNotificationStackScroller.setOverScrollAmount(0f, true /* onTop */, false /* animate */,
363364
true /* cancelAnimators */);
364365
}

0 commit comments

Comments
 (0)