Merge "Add ICompanionDeviceManager.getAssociation overload with explicit userId" into oc-dev

This commit is contained in:
TreeHugger Robot
2017-04-10 15:06:05 +00:00
committed by Android (Google) Code Review
4 changed files with 57 additions and 11 deletions

View File

@@ -167,7 +167,7 @@ public final class CompanionDeviceManager {
return Collections.emptyList();
}
try {
return mService.getAssociations(mContext.getPackageName());
return mService.getAssociations(mContext.getPackageName(), mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}

View File

@@ -29,7 +29,7 @@ interface ICompanionDeviceManager {
in IFindDeviceCallback callback,
in String callingPackage);
List<String> getAssociations(String callingPackage);
List<String> getAssociations(String callingPackage, int userId);
void disassociate(String deviceMacAddress, String callingPackage);
//TODO add these

View File

@@ -113,6 +113,26 @@ public class Preconditions {
return reference;
}
/**
* Ensures that an object reference passed as a parameter to the calling
* method is not null.
*
* @param reference an object reference
* @param messageTemplate a printf-style message template to use if the check fails; will
* be converted to a string using {@link String#format(String, Object...)}
* @param messageArgs arguments for {@code messageTemplate}
* @return the non-null reference that was validated
* @throws NullPointerException if {@code reference} is null
*/
public static @NonNull <T> T checkNotNull(final T reference,
final String messageTemplate,
final Object... messageArgs) {
if (reference == null) {
throw new NullPointerException(String.format(messageTemplate, messageArgs));
}
return reference;
}
/**
* Ensures the truth of an expression involving the state of the calling
* instance, but not involving any parameters to the calling method.