Merge "Fix face unlock does not work for top app in split screen" into tm-dev
This commit is contained in:
@@ -39,6 +39,7 @@ import static com.android.server.biometrics.PreAuthInfo.CREDENTIAL_NOT_ENROLLED;
|
|||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
|
import android.app.ActivityTaskManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
@@ -544,4 +545,37 @@ public class Utils {
|
|||||||
throw new IllegalArgumentException("Unknown strength: " + strength);
|
throw new IllegalArgumentException("Unknown strength: " + strength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a client package is running in the background.
|
||||||
|
*
|
||||||
|
* @param clientPackage The name of the package to be checked.
|
||||||
|
* @return Whether the client package is running in background
|
||||||
|
*/
|
||||||
|
public static boolean isBackground(String clientPackage) {
|
||||||
|
Slog.v(TAG, "Checking if the authenticating is in background,"
|
||||||
|
+ " clientPackage:" + clientPackage);
|
||||||
|
final List<ActivityManager.RunningTaskInfo> tasks =
|
||||||
|
ActivityTaskManager.getInstance().getTasks(Integer.MAX_VALUE);
|
||||||
|
|
||||||
|
if (tasks == null || tasks.isEmpty()) {
|
||||||
|
Slog.d(TAG, "No running tasks reported");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ActivityManager.RunningTaskInfo taskInfo : tasks) {
|
||||||
|
final ComponentName topActivity = taskInfo.topActivity;
|
||||||
|
if (topActivity != null) {
|
||||||
|
final String topPackage = topActivity.getPackageName();
|
||||||
|
if (topPackage.contentEquals(clientPackage) && taskInfo.isVisible()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Slog.i(TAG, "Running task, top: " + topPackage
|
||||||
|
+ ", isVisible: " + taskInfo.isVisible());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,8 @@ package com.android.server.biometrics.sensors;
|
|||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.app.ActivityManager;
|
|
||||||
import android.app.ActivityTaskManager;
|
import android.app.ActivityTaskManager;
|
||||||
import android.app.TaskStackListener;
|
import android.app.TaskStackListener;
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.hardware.biometrics.BiometricAuthenticator;
|
import android.hardware.biometrics.BiometricAuthenticator;
|
||||||
@@ -42,7 +40,6 @@ import com.android.server.biometrics.log.BiometricContext;
|
|||||||
import com.android.server.biometrics.log.BiometricLogger;
|
import com.android.server.biometrics.log.BiometricLogger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -202,25 +199,7 @@ public abstract class AuthenticationClient<T> extends AcquisitionClient<T>
|
|||||||
if (!mAllowBackgroundAuthentication && authenticated
|
if (!mAllowBackgroundAuthentication && authenticated
|
||||||
&& !Utils.isKeyguard(getContext(), getOwnerString())
|
&& !Utils.isKeyguard(getContext(), getOwnerString())
|
||||||
&& !Utils.isSystem(getContext(), getOwnerString())) {
|
&& !Utils.isSystem(getContext(), getOwnerString())) {
|
||||||
final List<ActivityManager.RunningTaskInfo> tasks =
|
isBackgroundAuth = Utils.isBackground(getOwnerString());
|
||||||
mActivityTaskManager.getTasks(1);
|
|
||||||
if (tasks == null || tasks.isEmpty()) {
|
|
||||||
Slog.e(TAG, "No running tasks reported");
|
|
||||||
isBackgroundAuth = true;
|
|
||||||
} else {
|
|
||||||
final ComponentName topActivity = tasks.get(0).topActivity;
|
|
||||||
if (topActivity == null) {
|
|
||||||
Slog.e(TAG, "Unable to get top activity");
|
|
||||||
isBackgroundAuth = true;
|
|
||||||
} else {
|
|
||||||
final String topPackage = topActivity.getPackageName();
|
|
||||||
if (!topPackage.contentEquals(getOwnerString())) {
|
|
||||||
Slog.e(TAG, "Background authentication detected, top: " + topPackage
|
|
||||||
+ ", client: " + getOwnerString());
|
|
||||||
isBackgroundAuth = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fail authentication if we can't confirm the client activity is on top.
|
// Fail authentication if we can't confirm the client activity is on top.
|
||||||
@@ -465,7 +444,6 @@ public abstract class AuthenticationClient<T> extends AcquisitionClient<T>
|
|||||||
@Override
|
@Override
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
super.cancel();
|
super.cancel();
|
||||||
|
|
||||||
if (mTaskStackListener != null) {
|
if (mTaskStackListener != null) {
|
||||||
mActivityTaskManager.unregisterTaskStackListener(mTaskStackListener);
|
mActivityTaskManager.unregisterTaskStackListener(mTaskStackListener);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,24 +104,19 @@ public class FaceProvider implements IBinder.DeathRecipient, ServiceProvider {
|
|||||||
Slog.e(getTag(), "Task stack changed for client: " + client);
|
Slog.e(getTag(), "Task stack changed for client: " + client);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (Utils.isKeyguard(mContext, client.getOwnerString())) {
|
if (Utils.isKeyguard(mContext, client.getOwnerString())
|
||||||
|
|| Utils.isSystem(mContext, client.getOwnerString())) {
|
||||||
continue; // Keyguard is always allowed
|
continue; // Keyguard is always allowed
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<ActivityManager.RunningTaskInfo> runningTasks =
|
if (Utils.isBackground(client.getOwnerString())
|
||||||
mActivityTaskManager.getTasks(1);
|
|
||||||
if (!runningTasks.isEmpty()) {
|
|
||||||
final String topPackage =
|
|
||||||
runningTasks.get(0).topActivity.getPackageName();
|
|
||||||
if (!topPackage.contentEquals(client.getOwnerString())
|
|
||||||
&& !client.isAlreadyDone()) {
|
&& !client.isAlreadyDone()) {
|
||||||
Slog.e(getTag(), "Stopping background authentication, top: "
|
Slog.e(getTag(), "Stopping background authentication,"
|
||||||
+ topPackage + " currentClient: " + client);
|
+ " currentClient: " + client);
|
||||||
mSensors.valueAt(i).getScheduler().cancelAuthenticationOrDetection(
|
mSensors.valueAt(i).getScheduler().cancelAuthenticationOrDetection(
|
||||||
client.getToken(), client.getRequestId());
|
client.getToken(), client.getRequestId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,20 +122,14 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
|||||||
continue; // Keyguard is always allowed
|
continue; // Keyguard is always allowed
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<ActivityManager.RunningTaskInfo> runningTasks =
|
if (Utils.isBackground(client.getOwnerString())
|
||||||
mActivityTaskManager.getTasks(1);
|
|
||||||
if (!runningTasks.isEmpty()) {
|
|
||||||
final String topPackage =
|
|
||||||
runningTasks.get(0).topActivity.getPackageName();
|
|
||||||
if (!topPackage.contentEquals(client.getOwnerString())
|
|
||||||
&& !client.isAlreadyDone()) {
|
&& !client.isAlreadyDone()) {
|
||||||
Slog.e(getTag(), "Stopping background authentication, top: "
|
Slog.e(getTag(), "Stopping background authentication,"
|
||||||
+ topPackage + " currentClient: " + client);
|
+ " currentClient: " + client);
|
||||||
mSensors.valueAt(i).getScheduler().cancelAuthenticationOrDetection(
|
mSensors.valueAt(i).getScheduler().cancelAuthenticationOrDetection(
|
||||||
client.getToken(), client.getRequestId());
|
client.getToken(), client.getRequestId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,18 +142,13 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
|||||||
return; // Keyguard is always allowed
|
return; // Keyguard is always allowed
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<ActivityManager.RunningTaskInfo> runningTasks =
|
if (Utils.isBackground(client.getOwnerString())
|
||||||
mActivityTaskManager.getTasks(1);
|
|
||||||
if (!runningTasks.isEmpty()) {
|
|
||||||
final String topPackage = runningTasks.get(0).topActivity.getPackageName();
|
|
||||||
if (!topPackage.contentEquals(client.getOwnerString())
|
|
||||||
&& !client.isAlreadyDone()) {
|
&& !client.isAlreadyDone()) {
|
||||||
Slog.e(TAG, "Stopping background authentication, top: "
|
Slog.e(TAG, "Stopping background authentication,"
|
||||||
+ topPackage + " currentClient: " + client);
|
+ " currentClient: " + client);
|
||||||
mScheduler.cancelAuthenticationOrDetection(
|
mScheduler.cancelAuthenticationOrDetection(
|
||||||
client.getToken(), client.getRequestId());
|
client.getToken(), client.getRequestId());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user