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

Commit 95686694 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "A little more work on issue ##16907799." into lmp-dev

parents 670288c2 24c98e8c
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -2104,7 +2104,26 @@ public final class ActiveServices {
                // don't want to be thrashing around restarting processes that are only
                // there to be cached.
                for (int appi=b.apps.size()-1; appi>=0; appi--) {
                    ProcessRecord proc = b.apps.keyAt(appi);
                    final ProcessRecord proc = b.apps.keyAt(appi);
                    // If the process is already gone, skip it.
                    if (proc.killedByAm || proc.thread == null) {
                        continue;
                    }
                    // Only do this for processes that have an auto-create binding;
                    // otherwise the binding can be left, because it won't cause the
                    // service to restart.
                    final AppBindRecord abind = b.apps.valueAt(appi);
                    boolean hasCreate = false;
                    for (int conni=abind.connections.size()-1; conni>=0; conni--) {
                        ConnectionRecord conn = abind.connections.valueAt(conni);
                        if ((conn.flags&Context.BIND_AUTO_CREATE) != 0) {
                            hasCreate = true;
                            break;
                        }
                    }
                    if (!hasCreate) {
                        continue;
                    }
                    if (proc != null && !proc.persistent && proc.thread != null
                            && proc.pid != 0 && proc.pid != ActivityManagerService.MY_PID
                            && proc.setProcState >= ActivityManager.PROCESS_STATE_LAST_ACTIVITY) {
+7 −6
Original line number Diff line number Diff line
@@ -16,8 +16,9 @@

package com.android.server.am;

import android.util.ArraySet;

import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Iterator;

/**
@@ -28,7 +29,7 @@ final class AppBindRecord {
    final IntentBindRecord intent;  // The intent we are bound to.
    final ProcessRecord client;     // Who has started/bound the service.

    final HashSet<ConnectionRecord> connections = new HashSet<ConnectionRecord>();
    final ArraySet<ConnectionRecord> connections = new ArraySet<>();
                                    // All ConnectionRecord for this client.

    void dump(PrintWriter pw, String prefix) {
@@ -38,11 +39,11 @@ final class AppBindRecord {
    }

    void dumpInIntentBind(PrintWriter pw, String prefix) {
        if (connections.size() > 0) {
        final int N = connections.size();
        if (N > 0) {
            pw.println(prefix + "Per-process Connections:");
            Iterator<ConnectionRecord> it = connections.iterator();
            while (it.hasNext()) {
                ConnectionRecord c = it.next();
            for (int i=0; i<N; i++) {
                ConnectionRecord c = connections.valueAt(i);
                pw.println(prefix + "  " + c);
            }
        }
+4 −5
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.util.ArrayMap;
import android.util.ArraySet;

import java.io.PrintWriter;

@@ -78,11 +79,9 @@ final class IntentBindRecord {
    int collectFlags() {
        int flags = 0;
        for (int i=apps.size()-1; i>=0; i--) {
            AppBindRecord app = apps.valueAt(i);
            if (app.connections.size() > 0) {
                for (ConnectionRecord conn : app.connections) {
                    flags |= conn.flags;
                }
            final ArraySet<ConnectionRecord> connections = apps.valueAt(i).connections;
            for (int j=connections.size()-1; j>=0; j--) {
                flags |= connections.valueAt(j).flags;
            }
        }
        return flags;