Merge "Optimize checking if package defines companion services in CDM" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ba88e17064
@@ -108,8 +108,16 @@ class CompanionApplicationController {
|
|||||||
|
|
||||||
final List<ComponentName> companionServices =
|
final List<ComponentName> companionServices =
|
||||||
mCompanionServicesRegister.forPackage(userId, packageName);
|
mCompanionServicesRegister.forPackage(userId, packageName);
|
||||||
final List<CompanionDeviceServiceConnector> serviceConnectors;
|
if (companionServices.isEmpty()) {
|
||||||
|
Slog.w(TAG, "Can not bind companion applications u" + userId + "/" + packageName + ": "
|
||||||
|
+ "eligible CompanionDeviceService not found.\n"
|
||||||
|
+ "A CompanionDeviceService should declare an intent-filter for "
|
||||||
|
+ "\"android.companion.CompanionDeviceService\" action and require "
|
||||||
|
+ "\"android.permission.BIND_COMPANION_DEVICE_SERVICE\" permission.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<CompanionDeviceServiceConnector> serviceConnectors;
|
||||||
synchronized (mBoundCompanionApplications) {
|
synchronized (mBoundCompanionApplications) {
|
||||||
if (mBoundCompanionApplications.containsValueForPackage(userId, packageName)) {
|
if (mBoundCompanionApplications.containsValueForPackage(userId, packageName)) {
|
||||||
if (DEBUG) Log.e(TAG, "u" + userId + "/" + packageName + " is ALREADY bound.");
|
if (DEBUG) Log.e(TAG, "u" + userId + "/" + packageName + " is ALREADY bound.");
|
||||||
@@ -118,13 +126,6 @@ class CompanionApplicationController {
|
|||||||
|
|
||||||
serviceConnectors = CollectionUtils.map(companionServices, componentName ->
|
serviceConnectors = CollectionUtils.map(companionServices, componentName ->
|
||||||
new CompanionDeviceServiceConnector(mContext, userId, componentName));
|
new CompanionDeviceServiceConnector(mContext, userId, componentName));
|
||||||
|
|
||||||
if (serviceConnectors.isEmpty()) {
|
|
||||||
Slog.e(TAG, "Can't find CompanionDeviceService implementer in package: "
|
|
||||||
+ packageName + ". Please check if they are correctly declared.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mBoundCompanionApplications.setValueForPackage(userId, packageName, serviceConnectors);
|
mBoundCompanionApplications.setValueForPackage(userId, packageName, serviceConnectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +146,11 @@ class CompanionApplicationController {
|
|||||||
serviceConnectors = mBoundCompanionApplications.removePackage(userId, packageName);
|
serviceConnectors = mBoundCompanionApplications.removePackage(userId, packageName);
|
||||||
}
|
}
|
||||||
if (serviceConnectors == null) {
|
if (serviceConnectors == null) {
|
||||||
if (DEBUG) Log.e(TAG, "u" + userId + "/" + packageName + " is NOT bound");
|
if (DEBUG) {
|
||||||
|
Log.e(TAG, "unbindCompanionApplication(): "
|
||||||
|
+ "u" + userId + "/" + packageName + " is NOT bound");
|
||||||
|
Log.d(TAG, "Stacktrace", new Throwable());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +196,11 @@ class CompanionApplicationController {
|
|||||||
final CompanionDeviceServiceConnector primaryServiceConnector =
|
final CompanionDeviceServiceConnector primaryServiceConnector =
|
||||||
getPrimaryServiceConnector(userId, packageName);
|
getPrimaryServiceConnector(userId, packageName);
|
||||||
if (primaryServiceConnector == null) {
|
if (primaryServiceConnector == null) {
|
||||||
if (DEBUG) Log.e(TAG, "u" + userId + "/" + packageName + " is NOT bound.");
|
if (DEBUG) {
|
||||||
|
Log.e(TAG, "notify_CompanionApplicationDevice_Appeared(): "
|
||||||
|
+ "u" + userId + "/" + packageName + " is NOT bound.");
|
||||||
|
Log.d(TAG, "Stacktrace", new Throwable());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +218,11 @@ class CompanionApplicationController {
|
|||||||
final CompanionDeviceServiceConnector primaryServiceConnector =
|
final CompanionDeviceServiceConnector primaryServiceConnector =
|
||||||
getPrimaryServiceConnector(userId, packageName);
|
getPrimaryServiceConnector(userId, packageName);
|
||||||
if (primaryServiceConnector == null) {
|
if (primaryServiceConnector == null) {
|
||||||
if (DEBUG) Log.e(TAG, "u" + userId + "/" + packageName + " is NOT bound.");
|
if (DEBUG) {
|
||||||
|
Log.e(TAG, "notify_CompanionApplicationDevice_Disappeared(): "
|
||||||
|
+ "u" + userId + "/" + packageName + " is NOT bound.");
|
||||||
|
Log.d(TAG, "Stacktrace", new Throwable());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,12 +266,6 @@ class CompanionApplicationController {
|
|||||||
return forUser(userId).getOrDefault(packageName, Collections.emptyList());
|
return forUser(userId).getOrDefault(packageName, Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized @NonNull ComponentName primaryForPackage(
|
|
||||||
@UserIdInt int userId, @NonNull String packageName) {
|
|
||||||
// The primary service is always at the head of the list.
|
|
||||||
return forPackage(userId, packageName).get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized void invalidate(@UserIdInt int userId) {
|
synchronized void invalidate(@UserIdInt int userId) {
|
||||||
remove(userId);
|
remove(userId);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user