Merge "Remove permissin check from provider service process" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f806e9d7e7
@@ -75,12 +75,13 @@ public final class CredentialProviderInfoFactory {
|
||||
/**
|
||||
* Constructs an information instance of the credential provider.
|
||||
*
|
||||
* @param context the context object
|
||||
* @param context the context object
|
||||
* @param serviceComponent the serviceComponent of the provider service
|
||||
* @param userId the android userId for which the current process is running
|
||||
* @param userId the android userId for which the current process is running
|
||||
* @param isSystemProvider whether this provider is a system provider
|
||||
* @throws PackageManager.NameNotFoundException If provider service is not found
|
||||
* @throws SecurityException If provider does not require the relevant permission
|
||||
* @throws SecurityException If provider does not require the relevant
|
||||
* permission
|
||||
*/
|
||||
public static CredentialProviderInfo create(
|
||||
@NonNull Context context,
|
||||
@@ -99,13 +100,15 @@ public final class CredentialProviderInfoFactory {
|
||||
/**
|
||||
* Constructs an information instance of the credential provider.
|
||||
*
|
||||
* @param context the context object
|
||||
* @param serviceInfo the service info for the provider app. This must be retrieved from the
|
||||
* {@code PackageManager}
|
||||
* @param isSystemProvider whether the provider app is a system provider
|
||||
* @param context the context object
|
||||
* @param serviceInfo the service info for the provider app. This must
|
||||
* be retrieved from the
|
||||
* {@code PackageManager}
|
||||
* @param isSystemProvider whether the provider app is a system provider
|
||||
* @param disableSystemAppVerificationForTests whether to disable system app permission
|
||||
* verification so that tests can install system providers
|
||||
* @param isEnabled whether the user enabled this provider
|
||||
* verification so that tests can install system
|
||||
* providers
|
||||
* @param isEnabled whether the user enabled this provider
|
||||
* @throws SecurityException If provider does not require the relevant permission
|
||||
*/
|
||||
public static CredentialProviderInfo create(
|
||||
@@ -374,7 +377,6 @@ public final class CredentialProviderInfoFactory {
|
||||
if (appInfo == null || serviceInfo == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
services.add(serviceInfo);
|
||||
} catch (SecurityException | PackageManager.NameNotFoundException e) {
|
||||
Slog.e(TAG, "Error getting info for " + serviceInfo, e);
|
||||
|
||||
@@ -18,7 +18,6 @@ package android.service.credentials;
|
||||
|
||||
import static com.android.internal.util.function.pooled.PooledLambda.obtainMessage;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.CallSuper;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.SdkConstant;
|
||||
@@ -35,7 +34,7 @@ import android.os.ICancellationSignal;
|
||||
import android.os.Looper;
|
||||
import android.os.OutcomeReceiver;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -226,7 +225,7 @@ public abstract class CredentialProviderService extends Service {
|
||||
if (SERVICE_INTERFACE.equals(intent.getAction())) {
|
||||
return mInterface.asBinder();
|
||||
}
|
||||
Log.d(TAG, "Failed to bind with intent: " + intent);
|
||||
Slog.w(TAG, "Failed to bind with intent: " + intent);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -252,11 +251,6 @@ public abstract class CredentialProviderService extends Service {
|
||||
GetCredentialException>() {
|
||||
@Override
|
||||
public void onResult(BeginGetCredentialResponse result) {
|
||||
// If provider service does not possess the HYBRID permission, this
|
||||
// check will throw an exception in the provider process.
|
||||
if (result.getRemoteCredentialEntry() != null) {
|
||||
enforceRemoteEntryPermission();
|
||||
}
|
||||
try {
|
||||
callback.onSuccess(result);
|
||||
} catch (RemoteException e) {
|
||||
@@ -274,15 +268,6 @@ public abstract class CredentialProviderService extends Service {
|
||||
}
|
||||
));
|
||||
}
|
||||
private void enforceRemoteEntryPermission() {
|
||||
String permission =
|
||||
Manifest.permission.PROVIDE_REMOTE_CREDENTIALS;
|
||||
getApplicationContext().enforceCallingOrSelfPermission(
|
||||
permission,
|
||||
String.format("Provider must have %s, in order to set a "
|
||||
+ "remote entry", permission)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBeginCreateCredential(BeginCreateCredentialRequest request,
|
||||
@@ -305,11 +290,6 @@ public abstract class CredentialProviderService extends Service {
|
||||
BeginCreateCredentialResponse, CreateCredentialException>() {
|
||||
@Override
|
||||
public void onResult(BeginCreateCredentialResponse result) {
|
||||
// If provider service does not possess the HYBRID permission, this
|
||||
// check will throw an exception in the provider process.
|
||||
if (result.getRemoteCreateEntry() != null) {
|
||||
enforceRemoteEntryPermission();
|
||||
}
|
||||
try {
|
||||
callback.onSuccess(result);
|
||||
} catch (RemoteException e) {
|
||||
|
||||
@@ -40,7 +40,6 @@ import android.service.credentials.CredentialEntry;
|
||||
import android.service.credentials.CredentialProviderService;
|
||||
import android.service.credentials.GetCredentialRequest;
|
||||
import android.service.credentials.RemoteEntry;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.util.Slog;
|
||||
|
||||
@@ -413,11 +412,9 @@ public final class ProviderGetSession extends ProviderSession<BeginGetCredential
|
||||
*/
|
||||
private boolean onAuthenticationEntrySelected(
|
||||
@Nullable ProviderPendingIntentResponse providerPendingIntentResponse) {
|
||||
Log.i(TAG, "onAuthenticationEntrySelected");
|
||||
// Authentication entry is expected to have a BeginGetCredentialResponse instance. If it
|
||||
// does not have it, we remove the authentication entry and do not add any more content.
|
||||
if (providerPendingIntentResponse == null) {
|
||||
Log.i(TAG, "providerPendingIntentResponse is null");
|
||||
// Nothing received. This is equivalent to no content received.
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -268,12 +268,9 @@ public abstract class ProviderSession<T, R>
|
||||
/*pId=*/-1, appInfo.uid) == PackageManager.PERMISSION_GRANTED) {
|
||||
return true;
|
||||
}
|
||||
} catch (SecurityException e) {
|
||||
} catch (SecurityException | PackageManager.NameNotFoundException e) {
|
||||
Slog.e(TAG, "Error getting info for " + mComponentName.flattenToString(), e);
|
||||
return false;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Slog.i(TAG, "Error getting info for " + mComponentName.flattenToString(), e);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user