Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37e2e248 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Merge cherrypicks of [3134552, 3130583, 3131953, 3131954, 3131955, 3131956,...

Merge cherrypicks of [3134552, 3130583, 3131953, 3131954, 3131955, 3131956, 3131957, 3131958, 3131959, 3132062, 3132336, 3131074, 3133939, 3131024, 3131025, 3131026, 3130584, 3130879, 3130880] into oc-mr1-release

Change-Id: I345643be0750801a95bd6a61a235f1576501807f
parents 4745025d ee62f699
Loading
Loading
Loading
Loading
+12 −4
Original line number Original line Diff line number Diff line
@@ -34,6 +34,10 @@ import java.util.Arrays;
 */
 */
public class ForegroundServiceControllerImpl
public class ForegroundServiceControllerImpl
        implements ForegroundServiceController {
        implements ForegroundServiceController {
  
    // shelf life of foreground services before they go bad
    public static final long FG_SERVICE_GRACE_MILLIS = 5000;

    private static final String TAG = "FgServiceController";
    private static final String TAG = "FgServiceController";
    private static final boolean DBG = false;
    private static final boolean DBG = false;


@@ -72,7 +76,7 @@ public class ForegroundServiceControllerImpl
            if (isDungeonNotification(sbn)) {
            if (isDungeonNotification(sbn)) {
                // if you remove the dungeon entirely, we take that to mean there are
                // if you remove the dungeon entirely, we take that to mean there are
                // no running services
                // no running services
                userServices.setRunningServices(null);
                userServices.setRunningServices(null, 0);
                return true;
                return true;
            } else {
            } else {
                // this is safe to call on any notification, not just FLAG_FOREGROUND_SERVICE
                // this is safe to call on any notification, not just FLAG_FOREGROUND_SERVICE
@@ -94,7 +98,7 @@ public class ForegroundServiceControllerImpl
                final Bundle extras = sbn.getNotification().extras;
                final Bundle extras = sbn.getNotification().extras;
                if (extras != null) {
                if (extras != null) {
                    final String[] svcs = extras.getStringArray(Notification.EXTRA_FOREGROUND_APPS);
                    final String[] svcs = extras.getStringArray(Notification.EXTRA_FOREGROUND_APPS);
                    userServices.setRunningServices(svcs); // null ok
                    userServices.setRunningServices(svcs, sbn.getNotification().when);
                }
                }
            } else {
            } else {
                userServices.removeNotification(sbn.getPackageName(), sbn.getKey());
                userServices.removeNotification(sbn.getPackageName(), sbn.getKey());
@@ -118,9 +122,11 @@ public class ForegroundServiceControllerImpl
     */
     */
    private static class UserServices {
    private static class UserServices {
        private String[] mRunning = null;
        private String[] mRunning = null;
        private long mServiceStartTime = 0;
        private ArrayMap<String, ArraySet<String>> mNotifications = new ArrayMap<>(1);
        private ArrayMap<String, ArraySet<String>> mNotifications = new ArrayMap<>(1);
        public void setRunningServices(String[] pkgs) {
        public void setRunningServices(String[] pkgs, long serviceStartTime) {
            mRunning = pkgs != null ? Arrays.copyOf(pkgs, pkgs.length) : null;
            mRunning = pkgs != null ? Arrays.copyOf(pkgs, pkgs.length) : null;
            mServiceStartTime = serviceStartTime;
        }
        }
        public void addNotification(String pkg, String key) {
        public void addNotification(String pkg, String key) {
            if (mNotifications.get(pkg) == null) {
            if (mNotifications.get(pkg) == null) {
@@ -142,7 +148,9 @@ public class ForegroundServiceControllerImpl
            return found;
            return found;
        }
        }
        public boolean isDungeonNeeded() {
        public boolean isDungeonNeeded() {
            if (mRunning != null) {
            if (mRunning != null
                && System.currentTimeMillis() - mServiceStartTime >= FG_SERVICE_GRACE_MILLIS) {

                for (String pkg : mRunning) {
                for (String pkg : mRunning) {
                    final ArraySet<String> set = mNotifications.get(pkg);
                    final ArraySet<String> set = mNotifications.get(pkg);
                    if (set == null || set.size() == 0) {
                    if (set == null || set.size() == 0) {
+1 −0
Original line number Original line Diff line number Diff line
@@ -287,6 +287,7 @@ public class ForegroundServiceControllerTest extends SysuiTestCase {
        final Bundle extras = new Bundle();
        final Bundle extras = new Bundle();
        if (pkgs != null) extras.putStringArray(Notification.EXTRA_FOREGROUND_APPS, pkgs);
        if (pkgs != null) extras.putStringArray(Notification.EXTRA_FOREGROUND_APPS, pkgs);
        n.extras = extras;
        n.extras = extras;
        n.when = System.currentTimeMillis() - 10000; // ten seconds ago
        final StatusBarNotification sbn = makeMockSBN(userid, "android",
        final StatusBarNotification sbn = makeMockSBN(userid, "android",
                SystemMessageProto.SystemMessage.NOTE_FOREGROUND_SERVICES,
                SystemMessageProto.SystemMessage.NOTE_FOREGROUND_SERVICES,
                null, n);
                null, n);
+4 −7
Original line number Original line Diff line number Diff line
@@ -3794,19 +3794,16 @@ public class PackageManagerService extends IPackageManager.Stub
     * <p>
     * <p>
     * Currently, there are three cases in which this can occur:
     * Currently, there are three cases in which this can occur:
     * <ol>
     * <ol>
     * <li>The calling application is a "special" process. The special
     * <li>The calling application is a "special" process. Special processes
     *     processes are {@link Process#SYSTEM_UID}, {@link Process#SHELL_UID}
     *     are those with a UID < {@link Process#FIRST_APPLICATION_UID}.</li>
     *     and {@code 0}</li>
     * <li>The calling application has the permission
     * <li>The calling application has the permission
     *     {@link android.Manifest.permission#ACCESS_INSTANT_APPS}</li>
     *     {@link android.Manifest.permission#ACCESS_INSTANT_APPS}.</li>
     * <li>The calling application is the default launcher on the
     * <li>The calling application is the default launcher on the
     *     system partition.</li>
     *     system partition.</li>
     * </ol>
     * </ol>
     */
     */
    private boolean canViewInstantApps(int callingUid, int userId) {
    private boolean canViewInstantApps(int callingUid, int userId) {
        if (callingUid == Process.SYSTEM_UID
        if (callingUid < Process.FIRST_APPLICATION_UID) {
                || callingUid == Process.SHELL_UID
                || callingUid == Process.ROOT_UID) {
            return true;
            return true;
        }
        }
        if (mContext.checkCallingOrSelfPermission(
        if (mContext.checkCallingOrSelfPermission(
+6 −5
Original line number Original line Diff line number Diff line
@@ -757,12 +757,8 @@ int doDump(Bundle* bundle)


    AssetManager assets;
    AssetManager assets;
    int32_t assetsCookie;
    int32_t assetsCookie;
    if (!assets.addAssetPath(String8(filename), &assetsCookie)) {
        fprintf(stderr, "ERROR: dump failed because assets could not be loaded\n");
        return 1;
    }


    // Now add any dependencies passed in.
    // Add any dependencies passed in.
    for (size_t i = 0; i < bundle->getPackageIncludes().size(); i++) {
    for (size_t i = 0; i < bundle->getPackageIncludes().size(); i++) {
      const String8& assetPath = bundle->getPackageIncludes()[i];
      const String8& assetPath = bundle->getPackageIncludes()[i];
      if (!assets.addAssetPath(assetPath, NULL)) {
      if (!assets.addAssetPath(assetPath, NULL)) {
@@ -771,6 +767,11 @@ int doDump(Bundle* bundle)
      }
      }
    }
    }


    if (!assets.addAssetPath(String8(filename), &assetsCookie)) {
        fprintf(stderr, "ERROR: dump failed because assets could not be loaded\n");
        return 1;
    }

    // Make a dummy config for retrieving resources...  we need to supply
    // Make a dummy config for retrieving resources...  we need to supply
    // non-default values for some configs so that we can retrieve resources
    // non-default values for some configs so that we can retrieve resources
    // in the app that don't have a default.  The most important of these is
    // in the app that don't have a default.  The most important of these is
+3 −1
Original line number Original line Diff line number Diff line
@@ -4847,6 +4847,7 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle,
    const String16 animatedVector16("animated-vector");
    const String16 animatedVector16("animated-vector");
    const String16 pathInterpolator16("pathInterpolator");
    const String16 pathInterpolator16("pathInterpolator");
    const String16 objectAnimator16("objectAnimator");
    const String16 objectAnimator16("objectAnimator");
    const String16 gradient16("gradient");


    const int minSdk = getMinSdkVersion(bundle);
    const int minSdk = getMinSdkVersion(bundle);
    if (minSdk >= SDK_LOLLIPOP_MR1) {
    if (minSdk >= SDK_LOLLIPOP_MR1) {
@@ -4874,7 +4875,8 @@ status_t ResourceTable::modifyForCompat(const Bundle* bundle,
        if (bundle->getNoVersionVectors() && (node->getElementName() == vector16 ||
        if (bundle->getNoVersionVectors() && (node->getElementName() == vector16 ||
                    node->getElementName() == animatedVector16 ||
                    node->getElementName() == animatedVector16 ||
                    node->getElementName() == objectAnimator16 ||
                    node->getElementName() == objectAnimator16 ||
                    node->getElementName() == pathInterpolator16)) {
                    node->getElementName() == pathInterpolator16 ||
                    node->getElementName() == gradient16)) {
            // We were told not to version vector tags, so skip the children here.
            // We were told not to version vector tags, so skip the children here.
            continue;
            continue;
        }
        }
Loading