Loading services/core/java/com/android/server/appbinding/AppBindingService.java +22 −20 Original line number Original line Diff line number Diff line Loading @@ -161,7 +161,7 @@ public class AppBindingService extends Binder { if (app.getClass() != appServiceFinderClass) { if (app.getClass() != appServiceFinderClass) { continue; continue; } } serviceConnections.addAll(getBoundConnectionsLocked(userId, app)); serviceConnections.addAll(getConnectionsLocked(userId, app)); } } } } Loading @@ -181,30 +181,16 @@ public class AppBindingService extends Binder { /** /** * Get the connection bound to a specific finder or create one if it does not exist. * Get the connection bound to a specific finder or create one if it does not exist. */ */ private List<AppServiceConnection> getBoundConnectionsLocked(int userId, private List<AppServiceConnection> getConnectionsLocked(int userId, AppServiceFinder app) { AppServiceFinder app) { Set<String> targetPackages = app.getTargetPackages(userId); Set<String> targetPackages = app.getTargetPackages(userId); List<AppServiceConnection> connections = new ArrayList<>(); List<AppServiceConnection> connections = new ArrayList<>(); for (String targetPackage : targetPackages) { for (String targetPackage : targetPackages) { AppServiceConnection conn = findConnectionLock(userId, app, targetPackage); AppServiceConnection conn = getOrCreateConnectionLocked(userId, app, targetPackage); if (conn == null) { if (conn != null) { final ServiceInfo service = app.findService(userId, mIPackageManager, mConstants, targetPackage); if (service != null) { conn = new AppServiceConnection( mContext, userId, mConstants, mHandler, app, targetPackage, service.getComponentName()); mConnections.add(conn); connections.add(conn); connections.add(conn); } } } } } return connections; return connections; } } Loading Loading @@ -480,7 +466,7 @@ public class AppBindingService extends Binder { } } @Nullable @Nullable private AppServiceConnection findConnectionLock( private AppServiceConnection getOrCreateConnectionLocked( int userId, @NonNull AppServiceFinder target, String targetPackage) { int userId, @NonNull AppServiceFinder target, String targetPackage) { for (int i = 0; i < mConnections.size(); i++) { for (int i = 0; i < mConnections.size(); i++) { final AppServiceConnection conn = mConnections.get(i); final AppServiceConnection conn = mConnections.get(i); Loading @@ -490,6 +476,22 @@ public class AppBindingService extends Binder { return conn; return conn; } } } } final ServiceInfo service = target.findService(userId, mIPackageManager, mConstants, targetPackage); if (service != null) { final AppServiceConnection conn = new AppServiceConnection( mContext, userId, mConstants, mHandler, target, targetPackage, service.getComponentName()); mConnections.add(conn); return conn; } return null; return null; } } Loading Loading
services/core/java/com/android/server/appbinding/AppBindingService.java +22 −20 Original line number Original line Diff line number Diff line Loading @@ -161,7 +161,7 @@ public class AppBindingService extends Binder { if (app.getClass() != appServiceFinderClass) { if (app.getClass() != appServiceFinderClass) { continue; continue; } } serviceConnections.addAll(getBoundConnectionsLocked(userId, app)); serviceConnections.addAll(getConnectionsLocked(userId, app)); } } } } Loading @@ -181,30 +181,16 @@ public class AppBindingService extends Binder { /** /** * Get the connection bound to a specific finder or create one if it does not exist. * Get the connection bound to a specific finder or create one if it does not exist. */ */ private List<AppServiceConnection> getBoundConnectionsLocked(int userId, private List<AppServiceConnection> getConnectionsLocked(int userId, AppServiceFinder app) { AppServiceFinder app) { Set<String> targetPackages = app.getTargetPackages(userId); Set<String> targetPackages = app.getTargetPackages(userId); List<AppServiceConnection> connections = new ArrayList<>(); List<AppServiceConnection> connections = new ArrayList<>(); for (String targetPackage : targetPackages) { for (String targetPackage : targetPackages) { AppServiceConnection conn = findConnectionLock(userId, app, targetPackage); AppServiceConnection conn = getOrCreateConnectionLocked(userId, app, targetPackage); if (conn == null) { if (conn != null) { final ServiceInfo service = app.findService(userId, mIPackageManager, mConstants, targetPackage); if (service != null) { conn = new AppServiceConnection( mContext, userId, mConstants, mHandler, app, targetPackage, service.getComponentName()); mConnections.add(conn); connections.add(conn); connections.add(conn); } } } } } return connections; return connections; } } Loading Loading @@ -480,7 +466,7 @@ public class AppBindingService extends Binder { } } @Nullable @Nullable private AppServiceConnection findConnectionLock( private AppServiceConnection getOrCreateConnectionLocked( int userId, @NonNull AppServiceFinder target, String targetPackage) { int userId, @NonNull AppServiceFinder target, String targetPackage) { for (int i = 0; i < mConnections.size(); i++) { for (int i = 0; i < mConnections.size(); i++) { final AppServiceConnection conn = mConnections.get(i); final AppServiceConnection conn = mConnections.get(i); Loading @@ -490,6 +476,22 @@ public class AppBindingService extends Binder { return conn; return conn; } } } } final ServiceInfo service = target.findService(userId, mIPackageManager, mConstants, targetPackage); if (service != null) { final AppServiceConnection conn = new AppServiceConnection( mContext, userId, mConstants, mHandler, target, targetPackage, service.getComponentName()); mConnections.add(conn); return conn; } return null; return null; } } Loading