Merge "Pause watchdog triggering on the main thread during package scan" into qt-dev
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 7a3609a..3adddc7 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -2002,18 +2002,9 @@
mDisplay.getRealSize(size);
desiredWindowWidth = size.x;
desiredWindowHeight = size.y;
- } else if (lp.width == ViewGroup.LayoutParams.WRAP_CONTENT
- || lp.height == ViewGroup.LayoutParams.WRAP_CONTENT) {
- // For wrap content, we have to remeasure later on anyways. Use size consistent with
- // below so we get best use of the measure cache.
- desiredWindowWidth = dipToPx(config.screenWidthDp);
- desiredWindowHeight = dipToPx(config.screenHeightDp);
} else {
- // After addToDisplay, the frame contains the frameHint from window manager, which
- // for most windows is going to be the same size as the result of relayoutWindow.
- // Using this here allows us to avoid remeasuring after relayoutWindow
- desiredWindowWidth = frame.width();
- desiredWindowHeight = frame.height();
+ desiredWindowWidth = mWinFrame.width();
+ desiredWindowHeight = mWinFrame.height();
}
// We used to use the following condition to choose 32 bits drawing caches:
diff --git a/data/keyboards/Vendor_045e_Product_028e.kl b/data/keyboards/Vendor_045e_Product_028e.kl
index 301601a..e4f48f9 100644
--- a/data/keyboards/Vendor_045e_Product_028e.kl
+++ b/data/keyboards/Vendor_045e_Product_028e.kl
@@ -22,9 +22,7 @@
key 308 BUTTON_Y
key 310 BUTTON_L1
key 311 BUTTON_R1
-key 314 BACK
-key 315 BUTTON_START
-key 316 HOME
+
key 317 BUTTON_THUMBL
key 318 BUTTON_THUMBR
@@ -44,3 +42,14 @@
# Hat.
axis 0x10 HAT_X
axis 0x11 HAT_Y
+
+# Mapping according to https://www.kernel.org/doc/Documentation/input/gamepad.txt
+
+# Button labeled as "BACK" (left-pointing triangle)
+key 314 BUTTON_SELECT
+
+# The branded "X" button in the center of the controller
+key 316 BUTTON_MODE
+
+# Button labeled as "START" (right-pointing triangle)
+key 315 BUTTON_START
diff --git a/data/keyboards/Vendor_057e_Product_2009.kl b/data/keyboards/Vendor_057e_Product_2009.kl
new file mode 100644
index 0000000..b36e946
--- /dev/null
+++ b/data/keyboards/Vendor_057e_Product_2009.kl
@@ -0,0 +1,68 @@
+# Copyright (C) 2019 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.
+
+#
+# Nintendo Switch Pro Controller - HAC-013 - Bluetooth
+#
+
+
+# Mapping according to https://developer.android.com/training/game-controllers/controller-input.html
+
+# Button labeled as "Y" but should really produce keycode "X"
+key 0x132 BUTTON_X
+# Button labeled as "B" but should really produce keycode "A"
+key 0x130 BUTTON_A
+# Button labeled as "A" but should really produce keycode "B"
+key 0x131 BUTTON_B
+# Button labeled as "X" but should really product keycode "Y"
+key 0x133 BUTTON_Y
+
+# Button labeled as "L"
+key 0x134 BUTTON_L1
+# Button labeled as "R"
+key 0x135 BUTTON_R1
+
+# No LT / RT axes on this controller. Instead, there are keys.
+# Trigger labeled as "ZL"
+key 0x136 BUTTON_L2
+# Trigger labeled as "ZR"
+key 0x137 BUTTON_R2
+
+# Left Analog Stick
+axis 0x00 X
+axis 0x01 Y
+# Right Analog Stick
+axis 0x03 Z
+axis 0x04 RZ
+
+# Left stick click (generates linux BTN_SELECT)
+key 0x13a BUTTON_THUMBL
+# Right stick click (generates linux BTN_START)
+key 0x13b BUTTON_THUMBR
+
+# Hat
+axis 0x10 HAT_X
+axis 0x11 HAT_Y
+
+# Mapping according to https://www.kernel.org/doc/Documentation/input/gamepad.txt
+# Minus
+key 0x138 BUTTON_SELECT
+# Plus
+key 0x139 BUTTON_START
+
+# Circle
+key 0x13d BUTTON_MODE
+
+# Home key
+key 0x13c HOME
diff --git a/packages/SystemUI/res/layout/status_bar_notification_section_header.xml b/packages/SystemUI/res/layout/status_bar_notification_section_header.xml
index d3eb9ae..eabc5c5 100644
--- a/packages/SystemUI/res/layout/status_bar_notification_section_header.xml
+++ b/packages/SystemUI/res/layout/status_bar_notification_section_header.xml
@@ -49,6 +49,7 @@
android:text="@string/notification_section_header_gentle"
android:textSize="12sp"
android:textColor="@color/notification_section_header_label_color"
+ android:fontFamily="@*android:string/config_headlineFontFamilyMedium"
/>
<ImageView
android:id="@+id/btn_clear_all"
diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
index eff7054..73e57de 100644
--- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
+++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
@@ -768,6 +768,10 @@
@Override
public void onDarkIntensity(float darkIntensity) {
+ if (!mHandler.getLooper().isCurrentThread()) {
+ mHandler.post(() -> onDarkIntensity(darkIntensity));
+ return;
+ }
if (mOverlay != null) {
CornerHandleView assistHintTopLeft = mOverlay.findViewById(R.id.assist_hint_left);
CornerHandleView assistHintTopRight = mOverlay.findViewById(R.id.assist_hint_right);
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistHandleReminderExpBehavior.java b/packages/SystemUI/src/com/android/systemui/assist/AssistHandleReminderExpBehavior.java
index 87fb28b..909b68b 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/AssistHandleReminderExpBehavior.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/AssistHandleReminderExpBehavior.java
@@ -16,14 +16,13 @@
package com.android.systemui.assist;
-import static com.android.systemui.shared.system.PackageManagerWrapper.ACTION_PREFERRED_ACTIVITY_CHANGED;
-
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.ResolveInfo;
import android.os.Handler;
import android.os.SystemClock;
import android.provider.Settings;
@@ -44,6 +43,7 @@
import java.io.PrintWriter;
import java.time.LocalDate;
import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.TimeUnit;
/**
@@ -68,6 +68,14 @@
private static final boolean DEFAULT_SUPPRESS_ON_LAUNCHER = false;
private static final boolean DEFAULT_SUPPRESS_ON_APPS = false;
+ private static final String[] DEFAULT_HOME_CHANGE_ACTIONS = new String[] {
+ PackageManagerWrapper.ACTION_PREFERRED_ACTIVITY_CHANGED,
+ Intent.ACTION_BOOT_COMPLETED,
+ Intent.ACTION_PACKAGE_ADDED,
+ Intent.ACTION_PACKAGE_CHANGED,
+ Intent.ACTION_PACKAGE_REMOVED
+ };
+
private final StatusBarStateController.StateListener mStatusBarStateListener =
new StatusBarStateController.StateListener() {
@Override
@@ -110,8 +118,7 @@
mDefaultHome = getCurrentDefaultHome();
}
};
- private final IntentFilter mDefaultHomeIntentFilter =
- new IntentFilter(ACTION_PREFERRED_ACTIVITY_CHANGED);
+ private final IntentFilter mDefaultHomeIntentFilter;
private final Runnable mResetConsecutiveTaskSwitches = this::resetConsecutiveTaskSwitches;
private final Handler mHandler;
@@ -146,6 +153,10 @@
mStatusBarStateController = Dependency.get(StatusBarStateController.class);
mActivityManagerWrapper = ActivityManagerWrapper.getInstance();
mOverviewProxyService = Dependency.get(OverviewProxyService.class);
+ mDefaultHomeIntentFilter = new IntentFilter();
+ for (String action : DEFAULT_HOME_CHANGE_ACTIONS) {
+ mDefaultHomeIntentFilter.addAction(action);
+ }
}
@Override
@@ -205,7 +216,24 @@
@Nullable
private static ComponentName getCurrentDefaultHome() {
- return PackageManagerWrapper.getInstance().getHomeActivities(new ArrayList<>());
+ List<ResolveInfo> homeActivities = new ArrayList<>();
+ ComponentName defaultHome =
+ PackageManagerWrapper.getInstance().getHomeActivities(homeActivities);
+ if (defaultHome != null) {
+ return defaultHome;
+ }
+
+ int topPriority = Integer.MIN_VALUE;
+ ComponentName topComponent = null;
+ for (ResolveInfo resolveInfo : homeActivities) {
+ if (resolveInfo.priority > topPriority) {
+ topComponent = resolveInfo.activityInfo.getComponentName();
+ topPriority = resolveInfo.priority;
+ } else if (resolveInfo.priority == topPriority) {
+ topComponent = null;
+ }
+ }
+ return topComponent;
}
private void handleStatusBarStateChanged(int newState) {
diff --git a/packages/SystemUI/src/com/android/systemui/assist/PhoneStateMonitor.java b/packages/SystemUI/src/com/android/systemui/assist/PhoneStateMonitor.java
index 1fd3089..e73dc4a 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/PhoneStateMonitor.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/PhoneStateMonitor.java
@@ -16,8 +16,6 @@
package com.android.systemui.assist;
-import static com.android.systemui.shared.system.PackageManagerWrapper.ACTION_PREFERRED_ACTIVITY_CHANGED;
-
import android.app.ActivityManager;
import android.app.KeyguardManager;
import android.content.BroadcastReceiver;
@@ -25,6 +23,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.ResolveInfo;
import androidx.annotation.Nullable;
@@ -38,6 +37,7 @@
import com.android.systemui.statusbar.phone.StatusBar;
import java.util.ArrayList;
+import java.util.List;
/** Class to monitor and report the state of the phone. */
final class PhoneStateMonitor {
@@ -53,6 +53,14 @@
private static final int PHONE_STATE_APP_IMMERSIVE = 9;
private static final int PHONE_STATE_APP_FULLSCREEN = 10;
+ private static final String[] DEFAULT_HOME_CHANGE_ACTIONS = new String[] {
+ PackageManagerWrapper.ACTION_PREFERRED_ACTIVITY_CHANGED,
+ Intent.ACTION_BOOT_COMPLETED,
+ Intent.ACTION_PACKAGE_ADDED,
+ Intent.ACTION_PACKAGE_CHANGED,
+ Intent.ACTION_PACKAGE_REMOVED
+ };
+
private final Context mContext;
private final StatusBarStateController mStatusBarStateController;
@@ -64,14 +72,17 @@
mStatusBarStateController = Dependency.get(StatusBarStateController.class);
ActivityManagerWrapper activityManagerWrapper = ActivityManagerWrapper.getInstance();
- mDefaultHome = PackageManagerWrapper.getInstance().getHomeActivities(new ArrayList<>());
+ mDefaultHome = getCurrentDefaultHome();
+ IntentFilter intentFilter = new IntentFilter();
+ for (String action : DEFAULT_HOME_CHANGE_ACTIONS) {
+ intentFilter.addAction(action);
+ }
mContext.registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- mDefaultHome =
- PackageManagerWrapper.getInstance().getHomeActivities(new ArrayList<>());
+ mDefaultHome = getCurrentDefaultHome();
}
- }, new IntentFilter(ACTION_PREFERRED_ACTIVITY_CHANGED));
+ }, intentFilter);
mLauncherShowing = isLauncherShowing(activityManagerWrapper.getRunningTask());
activityManagerWrapper.registerTaskStackListener(new TaskStackChangeListener() {
@Override
@@ -93,6 +104,28 @@
return phoneState;
}
+ @Nullable
+ private static ComponentName getCurrentDefaultHome() {
+ List<ResolveInfo> homeActivities = new ArrayList<>();
+ ComponentName defaultHome =
+ PackageManagerWrapper.getInstance().getHomeActivities(homeActivities);
+ if (defaultHome != null) {
+ return defaultHome;
+ }
+
+ int topPriority = Integer.MIN_VALUE;
+ ComponentName topComponent = null;
+ for (ResolveInfo resolveInfo : homeActivities) {
+ if (resolveInfo.priority > topPriority) {
+ topComponent = resolveInfo.activityInfo.getComponentName();
+ topPriority = resolveInfo.priority;
+ } else if (resolveInfo.priority == topPriority) {
+ topComponent = null;
+ }
+ }
+ return topComponent;
+ }
+
private int getPhoneLockscreenState() {
if (isDozing()) {
return PHONE_STATE_AOD1;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java
index 443cc43..c0a1b12 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserSwitch.java
@@ -112,7 +112,9 @@
final boolean guestEnabled = !mContext.getSystemService(DevicePolicyManager.class)
.getGuestUserDisabled(null);
- return mUserSwitcherController.getSwitchableUserCount() > 1 || guestEnabled
+ return mUserSwitcherController.getSwitchableUserCount() > 1
+ // If we cannot add guests even if they are enabled, do not show
+ || (guestEnabled && !mUserManager.hasUserRestriction(UserManager.DISALLOW_ADD_USER))
|| mContext.getResources().getBoolean(R.bool.qs_show_user_switcher_for_single_user);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 80fbda0..1fdabc0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -317,17 +317,6 @@
/** If true, the lockscreen will show a distinct wallpaper */
public static final boolean ENABLE_LOCKSCREEN_WALLPAPER = true;
- private static final AudioAttributes AUDIO_ATTRIBUTES =
- new AudioAttributes.Builder()
- .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
- // Temporary fix for b/123870990. No time in this release to
- // introduce a new vibration type, but we need to distinguish these vibrations
- // from other haptic feedback vibrations. Fortunately, Alarm vibrations have
- // exactly the same behavior as we need
- // TODO: refactor within the scope of b/132170758
- .setUsage(AudioAttributes.USAGE_ALARM)
- .build();
-
static {
boolean onlyCoreApps;
try {
@@ -3699,7 +3688,7 @@
private void vibrateForCameraGesture() {
// Make sure to pass -1 for repeat so VibratorService doesn't stop us when going to sleep.
- mVibrator.vibrate(mCameraLaunchGestureVibePattern, -1 /* repeat */, AUDIO_ATTRIBUTES);
+ mVibrator.vibrate(mCameraLaunchGestureVibePattern, -1 /* repeat */);
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
index 2afe485..13f93b9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
@@ -545,7 +545,7 @@
}
private boolean isDataDisabled() {
- return !mPhone.getDataEnabled(mSubscriptionInfo.getSubscriptionId());
+ return !mPhone.isDataCapable();
}
@VisibleForTesting
@@ -566,6 +566,7 @@
pw.println(" mDataState=" + mDataState + ",");
pw.println(" mDataNetType=" + mDataNetType + ",");
pw.println(" mInflateSignalStrengths=" + mInflateSignalStrengths + ",");
+ pw.println(" isDataDisabled=" + isDataDisabled() + ",");
}
class MobilePhoneStateListener extends PhoneStateListener {
diff --git a/packages/SystemUI/src/com/android/systemui/util/leak/DumpTruck.java b/packages/SystemUI/src/com/android/systemui/util/leak/DumpTruck.java
index efd6e03..fa7af0b 100644
--- a/packages/SystemUI/src/com/android/systemui/util/leak/DumpTruck.java
+++ b/packages/SystemUI/src/com/android/systemui/util/leak/DumpTruck.java
@@ -16,6 +16,8 @@
package com.android.systemui.util.leak;
+import android.content.ClipData;
+import android.content.ClipDescription;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -47,10 +49,11 @@
private static final String FILEPROVIDER_PATH = "leak";
private static final String TAG = "DumpTruck";
- private static final int BUFSIZ = 512 * 1024; // 512K
+ private static final int BUFSIZ = 1024 * 1024; // 1MB
private final Context context;
private Uri hprofUri;
+ private long pss;
final StringBuilder body = new StringBuilder();
public DumpTruck(Context context) {
@@ -89,6 +92,7 @@
.append(info.currentPss)
.append(" uss=")
.append(info.currentUss);
+ pss = info.currentPss;
}
}
if (pid == myPid) {
@@ -114,6 +118,7 @@
if (DumpTruck.zipUp(zipfile, paths)) {
final File pathFile = new File(zipfile);
hprofUri = FileProvider.getUriForFile(context, FILEPROVIDER_AUTHORITY, pathFile);
+ Log.v(TAG, "Heap dump accessible at URI: " + hprofUri);
}
} catch (IOException e) {
Log.e(TAG, "unable to zip up heapdumps", e);
@@ -138,16 +143,27 @@
* @return share intent
*/
public Intent createShareIntent() {
- Intent shareIntent = new Intent(Intent.ACTION_SEND);
+ Intent shareIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- shareIntent.putExtra(Intent.EXTRA_SUBJECT, "SystemUI memory dump");
+ shareIntent.putExtra(Intent.EXTRA_SUBJECT,
+ String.format("SystemUI memory dump (pss=%dM)", pss / 1024));
shareIntent.putExtra(Intent.EXTRA_TEXT, body.toString());
if (hprofUri != null) {
+ final ArrayList<Uri> uriList = new ArrayList<>();
+ uriList.add(hprofUri);
shareIntent.setType("application/zip");
- shareIntent.putExtra(Intent.EXTRA_STREAM, hprofUri);
+ shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uriList);
+
+ // Include URI in ClipData also, so that grantPermission picks it up.
+ // We don't use setData here because some apps interpret this as "to:".
+ ClipData clipdata = new ClipData(new ClipDescription("content",
+ new String[]{ClipDescription.MIMETYPE_TEXT_PLAIN}),
+ new ClipData.Item(hprofUri));
+ shareIntent.setClipData(clipdata);
+ shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
}
return shareIntent;
}
diff --git a/packages/SystemUI/src/com/android/systemui/util/leak/GarbageMonitor.java b/packages/SystemUI/src/com/android/systemui/util/leak/GarbageMonitor.java
index aa3fd5f..583f6b3 100644
--- a/packages/SystemUI/src/com/android/systemui/util/leak/GarbageMonitor.java
+++ b/packages/SystemUI/src/com/android/systemui/util/leak/GarbageMonitor.java
@@ -16,9 +16,13 @@
package com.android.systemui.util.leak;
+import static android.service.quicksettings.Tile.STATE_ACTIVE;
+import static android.telephony.ims.feature.ImsFeature.STATE_UNAVAILABLE;
+
import static com.android.internal.logging.MetricsLogger.VIEW_UNKNOWN;
import static com.android.systemui.Dependency.BG_LOOPER_NAME;
+import android.annotation.Nullable;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
@@ -38,11 +42,11 @@
import android.os.Process;
import android.os.SystemProperties;
import android.provider.Settings;
-import android.service.quicksettings.Tile;
import android.text.format.DateUtils;
import android.util.Log;
import android.util.LongSparseArray;
+import com.android.systemui.Dumpable;
import com.android.systemui.R;
import com.android.systemui.SystemUI;
import com.android.systemui.SystemUIFactory;
@@ -50,6 +54,8 @@
import com.android.systemui.qs.QSHost;
import com.android.systemui.qs.tileimpl.QSTileImpl;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
import java.util.ArrayList;
import javax.inject.Inject;
@@ -59,7 +65,7 @@
/**
*/
@Singleton
-public class GarbageMonitor {
+public class GarbageMonitor implements Dumpable {
private static final boolean LEAK_REPORTING_ENABLED =
Build.IS_DEBUGGABLE
&& SystemProperties.getBoolean("debug.enable_leak_reporting", false);
@@ -77,12 +83,15 @@
private static final long GARBAGE_INSPECTION_INTERVAL =
15 * DateUtils.MINUTE_IN_MILLIS; // 15 min
private static final long HEAP_TRACK_INTERVAL = 1 * DateUtils.MINUTE_IN_MILLIS; // 1 min
+ private static final int HEAP_TRACK_HISTORY_LEN = 720; // 12 hours
private static final int DO_GARBAGE_INSPECTION = 1000;
private static final int DO_HEAP_TRACK = 3000;
private static final int GARBAGE_ALLOWANCE = 5;
+ private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+
private final Handler mHandler;
private final TrackedGarbage mTrackedGarbage;
private final LeakReporter mLeakReporter;
@@ -180,7 +189,7 @@
sb.append(p);
sb.append(" ");
}
- Log.v(TAG, sb.toString());
+ if (DEBUG) Log.v(TAG, sb.toString());
}
private void update() {
@@ -189,18 +198,18 @@
for (int i = 0; i < dinfos.length; i++) {
Debug.MemoryInfo dinfo = dinfos[i];
if (i > mPids.size()) {
- Log.e(TAG, "update: unknown process info received: " + dinfo);
+ if (DEBUG) Log.e(TAG, "update: unknown process info received: " + dinfo);
break;
}
final long pid = mPids.get(i).intValue();
final ProcessMemInfo info = mData.get(pid);
- info.head = (info.head + 1) % info.pss.length;
info.pss[info.head] = info.currentPss = dinfo.getTotalPss();
info.uss[info.head] = info.currentUss = dinfo.getTotalPrivateDirty();
+ info.head = (info.head + 1) % info.pss.length;
if (info.currentPss > info.max) info.max = info.currentPss;
if (info.currentUss > info.max) info.max = info.currentUss;
if (info.currentPss == 0) {
- Log.v(TAG, "update: pid " + pid + " has pss=0, it probably died");
+ if (DEBUG) Log.v(TAG, "update: pid " + pid + " has pss=0, it probably died");
mData.remove(pid);
}
}
@@ -230,11 +239,36 @@
return b + SUFFIXES[i];
}
- private void dumpHprofAndShare() {
- final Intent share = mDumpTruck.captureHeaps(getTrackedProcesses()).createShareIntent();
- mContext.startActivity(share);
+ private Intent dumpHprofAndGetShareIntent() {
+ return mDumpTruck.captureHeaps(getTrackedProcesses()).createShareIntent();
}
+ @Override
+ public void dump(@Nullable FileDescriptor fd, PrintWriter pw, @Nullable String[] args) {
+ pw.println("GarbageMonitor params:");
+ pw.println(String.format(" mHeapLimit=%d KB", mHeapLimit));
+ pw.println(String.format(" GARBAGE_INSPECTION_INTERVAL=%d (%.1f mins)",
+ GARBAGE_INSPECTION_INTERVAL,
+ (float) GARBAGE_INSPECTION_INTERVAL / DateUtils.MINUTE_IN_MILLIS));
+ final float htiMins = HEAP_TRACK_INTERVAL / DateUtils.MINUTE_IN_MILLIS;
+ pw.println(String.format(" HEAP_TRACK_INTERVAL=%d (%.1f mins)",
+ HEAP_TRACK_INTERVAL,
+ htiMins));
+ pw.println(String.format(" HEAP_TRACK_HISTORY_LEN=%d (%.1f hr total)",
+ HEAP_TRACK_HISTORY_LEN,
+ (float) HEAP_TRACK_HISTORY_LEN * htiMins / 60f));
+
+ pw.println("GarbageMonitor tracked processes:");
+
+ for (long pid : mPids) {
+ final ProcessMemInfo pmi = mData.get(pid);
+ if (pmi != null) {
+ pmi.dump(fd, pw, args);
+ }
+ }
+ }
+
+
private static class MemoryIconDrawable extends Drawable {
long pss, limit;
final Drawable baseIcon;
@@ -244,7 +278,7 @@
MemoryIconDrawable(Context context) {
baseIcon = context.getDrawable(R.drawable.ic_memory).mutate();
dp = context.getResources().getDisplayMetrics().density;
- paint.setColor(QSTileImpl.getColorForState(context, Tile.STATE_ACTIVE));
+ paint.setColor(QSTileImpl.getColorForState(context, STATE_ACTIVE));
}
public void setPss(long pss) {
@@ -354,6 +388,7 @@
private final GarbageMonitor gm;
private ProcessMemInfo pmi;
+ private boolean dumpInProgress;
@Inject
public MemoryTile(QSHost host) {
@@ -373,8 +408,26 @@
@Override
protected void handleClick() {
- getHost().collapsePanels();
- mHandler.post(gm::dumpHprofAndShare);
+ if (dumpInProgress) return;
+
+ dumpInProgress = true;
+ refreshState();
+ new Thread("HeapDumpThread") {
+ @Override
+ public void run() {
+ try {
+ // wait for animations & state changes
+ Thread.sleep(500);
+ } catch (InterruptedException ignored) { }
+ final Intent shareIntent = gm.dumpHprofAndGetShareIntent();
+ mHandler.post(() -> {
+ dumpInProgress = false;
+ refreshState();
+ getHost().collapsePanels();
+ mContext.startActivity(shareIntent);
+ });
+ }
+ }.start();
}
@Override
@@ -404,9 +457,12 @@
pmi = gm.getMemInfo(Process.myPid());
final MemoryGraphIcon icon = new MemoryGraphIcon();
icon.setHeapLimit(gm.mHeapLimit);
+ state.state = dumpInProgress ? STATE_UNAVAILABLE : STATE_ACTIVE;
+ state.label = dumpInProgress
+ ? "Dumping..."
+ : mContext.getString(R.string.heap_dump_tile_name);
if (pmi != null) {
icon.setPss(pmi.currentPss);
- state.label = mContext.getString(R.string.heap_dump_tile_name);
state.secondaryLabel =
String.format(
"pss: %s / %s",
@@ -414,7 +470,6 @@
formatBytes(gm.mHeapLimit * 1024));
} else {
icon.setPss(0);
- state.label = "Dump SysUI";
state.secondaryLabel = null;
}
state.icon = icon;
@@ -433,13 +488,14 @@
}
}
- public static class ProcessMemInfo {
+ /** */
+ public static class ProcessMemInfo implements Dumpable {
public long pid;
public String name;
public long startTime;
public long currentPss, currentUss;
- public long[] pss = new long[256];
- public long[] uss = new long[256];
+ public long[] pss = new long[HEAP_TRACK_HISTORY_LEN];
+ public long[] uss = new long[HEAP_TRACK_HISTORY_LEN];
public long max = 1;
public int head = 0;
@@ -452,9 +508,33 @@
public long getUptime() {
return System.currentTimeMillis() - startTime;
}
+
+ @Override
+ public void dump(@Nullable FileDescriptor fd, PrintWriter pw, @Nullable String[] args) {
+ pw.print("{ \"pid\": ");
+ pw.print(pid);
+ pw.print(", \"name\": \"");
+ pw.print(name.replace('"', '-'));
+ pw.print("\", \"start\": ");
+ pw.print(startTime);
+ pw.print(", \"pss\": [");
+ // write pss values starting from the oldest, which is pss[head], wrapping around to
+ // pss[(head-1) % pss.length]
+ for (int i = 0; i < pss.length; i++) {
+ if (i > 0) pw.print(",");
+ pw.print(pss[(head + i) % pss.length]);
+ }
+ pw.print("], \"uss\": [");
+ for (int i = 0; i < uss.length; i++) {
+ if (i > 0) pw.print(",");
+ pw.print(uss[(head + i) % uss.length]);
+ }
+ pw.println("] }");
+ }
}
- public static class Service extends SystemUI {
+ /** */
+ public static class Service extends SystemUI implements Dumpable {
private GarbageMonitor mGarbageMonitor;
@Override
@@ -472,6 +552,11 @@
mGarbageMonitor.startHeapTracking();
}
}
+
+ @Override
+ public void dump(@Nullable FileDescriptor fd, PrintWriter pw, @Nullable String[] args) {
+ if (mGarbageMonitor != null) mGarbageMonitor.dump(fd, pw, args);
+ }
}
private class BackgroundHeapCheckHandler extends Handler {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
index 616b46a..3464fe5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java
@@ -164,7 +164,7 @@
protected void setupNetworkController() {
// For now just pretend to be the data sim, so we can test that too.
mSubId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
- when(mMockTm.getDataEnabled(mSubId)).thenReturn(true);
+ when(mMockTm.isDataCapable()).thenReturn(true);
setDefaultSubId(mSubId);
setSubscriptions(mSubId);
mMobileSignalController = mNetworkController.mMobileSignalControllers.get(mSubId);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java
index cd0a0441..5128675 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerDataTest.java
@@ -119,7 +119,7 @@
@Test
public void testNoInternetIcon_withDefaultSub() {
setupNetworkController();
- when(mMockTm.getDataEnabled(mSubId)).thenReturn(false);
+ when(mMockTm.isDataCapable()).thenReturn(false);
setupDefaultSignal();
updateDataConnectionState(TelephonyManager.DATA_CONNECTED, 0);
setConnectivityViaBroadcast(NetworkCapabilities.TRANSPORT_CELLULAR, false, false);
@@ -133,7 +133,7 @@
@Test
public void testDataDisabledIcon_withDefaultSub() {
setupNetworkController();
- when(mMockTm.getDataEnabled(mSubId)).thenReturn(false);
+ when(mMockTm.isDataCapable()).thenReturn(false);
setupDefaultSignal();
updateDataConnectionState(TelephonyManager.DATA_DISCONNECTED, 0);
setConnectivityViaBroadcast(NetworkCapabilities.TRANSPORT_CELLULAR, false, false);
@@ -147,7 +147,7 @@
@Test
public void testNoInternetIcon_withoutDefaultSub() {
setupNetworkController();
- when(mMockTm.getDataEnabled(mSubId)).thenReturn(false);
+ when(mMockTm.isDataCapable()).thenReturn(false);
setupDefaultSignal();
setDefaultSubId(mSubId + 1);
updateDataConnectionState(TelephonyManager.DATA_CONNECTED, 0);
@@ -162,7 +162,7 @@
@Test
public void testDataDisabledIcon_withoutDefaultSub() {
setupNetworkController();
- when(mMockTm.getDataEnabled(mSubId)).thenReturn(false);
+ when(mMockTm.isDataCapable()).thenReturn(false);
setupDefaultSignal();
setDefaultSubId(mSubId + 1);
updateDataConnectionState(TelephonyManager.DATA_DISCONNECTED, 0);
@@ -218,7 +218,7 @@
@Test
public void testDataDisabledIcon_UserNotSetup() {
setupNetworkController();
- when(mMockTm.getDataEnabled(mSubId)).thenReturn(false);
+ when(mMockTm.isDataCapable()).thenReturn(false);
setupDefaultSignal();
updateDataConnectionState(TelephonyManager.DATA_DISCONNECTED, 0);
setConnectivityViaBroadcast(NetworkCapabilities.TRANSPORT_CELLULAR, false, false);
@@ -233,7 +233,7 @@
@Test
public void testAlwaysShowDataRatIcon() {
setupDefaultSignal();
- when(mMockTm.getDataEnabled(mSubId)).thenReturn(false);
+ when(mMockTm.isDataCapable()).thenReturn(false);
updateDataConnectionState(TelephonyManager.DATA_DISCONNECTED,
TelephonyManager.NETWORK_TYPE_GSM);
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index f14a3fd..627ca91 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -7299,6 +7299,13 @@
if (wasInLaunchingProviders) {
mHandler.removeMessages(CONTENT_PROVIDER_PUBLISH_TIMEOUT_MSG, r);
}
+ // Make sure the package is associated with the process.
+ // XXX We shouldn't need to do this, since we have added the package
+ // when we generated the providers in generateApplicationProvidersLocked().
+ // But for some reason in some cases we get here with the package no longer
+ // added... for now just patch it in to make things happy.
+ r.addPackage(dst.info.applicationInfo.packageName,
+ dst.info.applicationInfo.longVersionCode, mProcessStats);
synchronized (dst) {
dst.provider = src.provider;
dst.setProcess(r);
diff --git a/services/core/java/com/android/server/biometrics/ClientMonitor.java b/services/core/java/com/android/server/biometrics/ClientMonitor.java
index 421b3f5..942e050 100644
--- a/services/core/java/com/android/server/biometrics/ClientMonitor.java
+++ b/services/core/java/com/android/server/biometrics/ClientMonitor.java
@@ -42,12 +42,7 @@
private static final AudioAttributes FINGERPRINT_SONFICATION_ATTRIBUTES =
new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
- // Temporary fix for b/123870990. No time in this release to
- // introduce a new vibration type, but we need to distinguish these vibrations
- // from other haptic feedback vibrations. Fortunately, Alarm vibrations have
- // exactly the same behavior as we need
- // TODO: refactor within the scope of b/132170758
- .setUsage(AudioAttributes.USAGE_ALARM)
+ .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
.build();
private final Context mContext;
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index 4a9a3f7..9189279 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -1322,7 +1322,9 @@
if (prevDc == null || prevDc == mDisplayContent) {
return;
}
- if (prevDc.mChangingApps.contains(this)) {
+
+ prevDc.mOpeningApps.remove(this);
+ if (prevDc.mChangingApps.remove(this)) {
// This gets called *after* the AppWindowToken has been reparented to the new display.
// That reparenting resulted in this window changing modes (eg. FREEFORM -> FULLSCREEN),
// so this token is now "frozen" while waiting for the animation to start on prevDc
@@ -1331,6 +1333,8 @@
// so we need to cancel the change transition here.
clearChangeLeash(getPendingTransaction(), true /* cancel */);
}
+ prevDc.mClosingApps.remove(this);
+
if (prevDc.mFocusedApp == this) {
prevDc.setFocusedApp(null);
final TaskStack stack = dc.getTopStack();
@@ -3216,16 +3220,6 @@
true /* topToBottom */);
}
- void removeFromPendingTransition() {
- if (isWaitingForTransitionStart() && mDisplayContent != null) {
- mDisplayContent.mOpeningApps.remove(this);
- if (mDisplayContent.mChangingApps.remove(this)) {
- clearChangeLeash(getPendingTransaction(), true /* cancel */);
- }
- mDisplayContent.mClosingApps.remove(this);
- }
- }
-
private void updateColorTransform() {
if (mSurfaceControl != null && mLastAppSaturationInfo != null) {
getPendingTransaction().setColorTransform(mSurfaceControl,
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index c3a769b..80848a8f 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -2377,9 +2377,6 @@
+ " to its current displayId=" + mDisplayId);
}
- // Clean up all pending transitions when stack reparent to another display.
- stack.forAllAppWindows(AppWindowToken::removeFromPendingTransition);
-
prevDc.mTaskStackContainers.removeChild(stack);
mTaskStackContainers.addStackToDisplay(stack, onTop);
}