ADD week 5
This commit is contained in:
		| @@ -0,0 +1,55 @@ | ||||
| package androidx.core.hardware.display; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.hardware.display.DisplayManager; | ||||
| import android.view.Display; | ||||
| import java.util.WeakHashMap; | ||||
|  | ||||
| /* loaded from: classes.dex */ | ||||
| public final class DisplayManagerCompat { | ||||
|     public static final String DISPLAY_CATEGORY_PRESENTATION = "android.hardware.display.category.PRESENTATION"; | ||||
|     private static final WeakHashMap<Context, DisplayManagerCompat> sInstances = new WeakHashMap<>(); | ||||
|     private final Context mContext; | ||||
|  | ||||
|     private DisplayManagerCompat(Context context) { | ||||
|         this.mContext = context; | ||||
|     } | ||||
|  | ||||
|     public static DisplayManagerCompat getInstance(Context context) { | ||||
|         DisplayManagerCompat displayManagerCompat; | ||||
|         WeakHashMap<Context, DisplayManagerCompat> weakHashMap = sInstances; | ||||
|         synchronized (weakHashMap) { | ||||
|             displayManagerCompat = weakHashMap.get(context); | ||||
|             if (displayManagerCompat == null) { | ||||
|                 displayManagerCompat = new DisplayManagerCompat(context); | ||||
|                 weakHashMap.put(context, displayManagerCompat); | ||||
|             } | ||||
|         } | ||||
|         return displayManagerCompat; | ||||
|     } | ||||
|  | ||||
|     public Display getDisplay(int i) { | ||||
|         return Api17Impl.getDisplay((DisplayManager) this.mContext.getSystemService("display"), i); | ||||
|     } | ||||
|  | ||||
|     public Display[] getDisplays() { | ||||
|         return Api17Impl.getDisplays((DisplayManager) this.mContext.getSystemService("display")); | ||||
|     } | ||||
|  | ||||
|     public Display[] getDisplays(String str) { | ||||
|         return Api17Impl.getDisplays((DisplayManager) this.mContext.getSystemService("display")); | ||||
|     } | ||||
|  | ||||
|     static class Api17Impl { | ||||
|         private Api17Impl() { | ||||
|         } | ||||
|  | ||||
|         static Display getDisplay(DisplayManager displayManager, int i) { | ||||
|             return displayManager.getDisplay(i); | ||||
|         } | ||||
|  | ||||
|         static Display[] getDisplays(DisplayManager displayManager) { | ||||
|             return displayManager.getDisplays(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,204 @@ | ||||
| package androidx.core.hardware.fingerprint; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.hardware.fingerprint.FingerprintManager; | ||||
| import android.os.Build; | ||||
| import android.os.Handler; | ||||
| import androidx.core.os.CancellationSignal; | ||||
| import java.security.Signature; | ||||
| import javax.crypto.Cipher; | ||||
| import javax.crypto.Mac; | ||||
|  | ||||
| @Deprecated | ||||
| /* loaded from: classes.dex */ | ||||
| public class FingerprintManagerCompat { | ||||
|     private final Context mContext; | ||||
|  | ||||
|     public static abstract class AuthenticationCallback { | ||||
|         public void onAuthenticationError(int i, CharSequence charSequence) { | ||||
|         } | ||||
|  | ||||
|         public void onAuthenticationFailed() { | ||||
|         } | ||||
|  | ||||
|         public void onAuthenticationHelp(int i, CharSequence charSequence) { | ||||
|         } | ||||
|  | ||||
|         public void onAuthenticationSucceeded(AuthenticationResult authenticationResult) { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public static FingerprintManagerCompat from(Context context) { | ||||
|         return new FingerprintManagerCompat(context); | ||||
|     } | ||||
|  | ||||
|     private FingerprintManagerCompat(Context context) { | ||||
|         this.mContext = context; | ||||
|     } | ||||
|  | ||||
|     public boolean hasEnrolledFingerprints() { | ||||
|         FingerprintManager fingerprintManagerOrNull; | ||||
|         return Build.VERSION.SDK_INT >= 23 && (fingerprintManagerOrNull = getFingerprintManagerOrNull(this.mContext)) != null && Api23Impl.hasEnrolledFingerprints(fingerprintManagerOrNull); | ||||
|     } | ||||
|  | ||||
|     public boolean isHardwareDetected() { | ||||
|         FingerprintManager fingerprintManagerOrNull; | ||||
|         return Build.VERSION.SDK_INT >= 23 && (fingerprintManagerOrNull = getFingerprintManagerOrNull(this.mContext)) != null && Api23Impl.isHardwareDetected(fingerprintManagerOrNull); | ||||
|     } | ||||
|  | ||||
|     public void authenticate(CryptoObject cryptoObject, int i, CancellationSignal cancellationSignal, AuthenticationCallback authenticationCallback, Handler handler) { | ||||
|         FingerprintManager fingerprintManagerOrNull; | ||||
|         if (Build.VERSION.SDK_INT < 23 || (fingerprintManagerOrNull = getFingerprintManagerOrNull(this.mContext)) == null) { | ||||
|             return; | ||||
|         } | ||||
|         Api23Impl.authenticate(fingerprintManagerOrNull, wrapCryptoObject(cryptoObject), cancellationSignal != null ? (android.os.CancellationSignal) cancellationSignal.getCancellationSignalObject() : null, i, wrapCallback(authenticationCallback), handler); | ||||
|     } | ||||
|  | ||||
|     private static FingerprintManager getFingerprintManagerOrNull(Context context) { | ||||
|         return Api23Impl.getFingerprintManagerOrNull(context); | ||||
|     } | ||||
|  | ||||
|     private static FingerprintManager.CryptoObject wrapCryptoObject(CryptoObject cryptoObject) { | ||||
|         return Api23Impl.wrapCryptoObject(cryptoObject); | ||||
|     } | ||||
|  | ||||
|     static CryptoObject unwrapCryptoObject(FingerprintManager.CryptoObject cryptoObject) { | ||||
|         return Api23Impl.unwrapCryptoObject(cryptoObject); | ||||
|     } | ||||
|  | ||||
|     private static FingerprintManager.AuthenticationCallback wrapCallback(final AuthenticationCallback authenticationCallback) { | ||||
|         return new FingerprintManager.AuthenticationCallback() { // from class: androidx.core.hardware.fingerprint.FingerprintManagerCompat.1 | ||||
|             @Override // android.hardware.fingerprint.FingerprintManager.AuthenticationCallback | ||||
|             public void onAuthenticationError(int i, CharSequence charSequence) { | ||||
|                 AuthenticationCallback.this.onAuthenticationError(i, charSequence); | ||||
|             } | ||||
|  | ||||
|             @Override // android.hardware.fingerprint.FingerprintManager.AuthenticationCallback | ||||
|             public void onAuthenticationHelp(int i, CharSequence charSequence) { | ||||
|                 AuthenticationCallback.this.onAuthenticationHelp(i, charSequence); | ||||
|             } | ||||
|  | ||||
|             @Override // android.hardware.fingerprint.FingerprintManager.AuthenticationCallback | ||||
|             public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult authenticationResult) { | ||||
|                 AuthenticationCallback.this.onAuthenticationSucceeded(new AuthenticationResult(FingerprintManagerCompat.unwrapCryptoObject(Api23Impl.getCryptoObject(authenticationResult)))); | ||||
|             } | ||||
|  | ||||
|             @Override // android.hardware.fingerprint.FingerprintManager.AuthenticationCallback | ||||
|             public void onAuthenticationFailed() { | ||||
|                 AuthenticationCallback.this.onAuthenticationFailed(); | ||||
|             } | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     public static class CryptoObject { | ||||
|         private final Cipher mCipher; | ||||
|         private final Mac mMac; | ||||
|         private final Signature mSignature; | ||||
|  | ||||
|         public Cipher getCipher() { | ||||
|             return this.mCipher; | ||||
|         } | ||||
|  | ||||
|         public Mac getMac() { | ||||
|             return this.mMac; | ||||
|         } | ||||
|  | ||||
|         public Signature getSignature() { | ||||
|             return this.mSignature; | ||||
|         } | ||||
|  | ||||
|         public CryptoObject(Signature signature) { | ||||
|             this.mSignature = signature; | ||||
|             this.mCipher = null; | ||||
|             this.mMac = null; | ||||
|         } | ||||
|  | ||||
|         public CryptoObject(Cipher cipher) { | ||||
|             this.mCipher = cipher; | ||||
|             this.mSignature = null; | ||||
|             this.mMac = null; | ||||
|         } | ||||
|  | ||||
|         public CryptoObject(Mac mac) { | ||||
|             this.mMac = mac; | ||||
|             this.mCipher = null; | ||||
|             this.mSignature = null; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public static final class AuthenticationResult { | ||||
|         private final CryptoObject mCryptoObject; | ||||
|  | ||||
|         public CryptoObject getCryptoObject() { | ||||
|             return this.mCryptoObject; | ||||
|         } | ||||
|  | ||||
|         public AuthenticationResult(CryptoObject cryptoObject) { | ||||
|             this.mCryptoObject = cryptoObject; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     static class Api23Impl { | ||||
|         private Api23Impl() { | ||||
|         } | ||||
|  | ||||
|         static boolean hasEnrolledFingerprints(Object obj) { | ||||
|             return ((FingerprintManager) obj).hasEnrolledFingerprints(); | ||||
|         } | ||||
|  | ||||
|         static boolean isHardwareDetected(Object obj) { | ||||
|             return ((FingerprintManager) obj).isHardwareDetected(); | ||||
|         } | ||||
|  | ||||
|         static void authenticate(Object obj, Object obj2, android.os.CancellationSignal cancellationSignal, int i, Object obj3, Handler handler) { | ||||
|             ((FingerprintManager) obj).authenticate((FingerprintManager.CryptoObject) obj2, cancellationSignal, i, (FingerprintManager.AuthenticationCallback) obj3, handler); | ||||
|         } | ||||
|  | ||||
|         static FingerprintManager.CryptoObject getCryptoObject(Object obj) { | ||||
|             return ((FingerprintManager.AuthenticationResult) obj).getCryptoObject(); | ||||
|         } | ||||
|  | ||||
|         public static FingerprintManager getFingerprintManagerOrNull(Context context) { | ||||
|             if (Build.VERSION.SDK_INT == 23) { | ||||
|                 return (FingerprintManager) context.getSystemService(FingerprintManager.class); | ||||
|             } | ||||
|             if (Build.VERSION.SDK_INT <= 23 || !context.getPackageManager().hasSystemFeature("android.hardware.fingerprint")) { | ||||
|                 return null; | ||||
|             } | ||||
|             return (FingerprintManager) context.getSystemService(FingerprintManager.class); | ||||
|         } | ||||
|  | ||||
|         public static FingerprintManager.CryptoObject wrapCryptoObject(CryptoObject cryptoObject) { | ||||
|             if (cryptoObject == null) { | ||||
|                 return null; | ||||
|             } | ||||
|             if (cryptoObject.getCipher() != null) { | ||||
|                 return new FingerprintManager.CryptoObject(cryptoObject.getCipher()); | ||||
|             } | ||||
|             if (cryptoObject.getSignature() != null) { | ||||
|                 return new FingerprintManager.CryptoObject(cryptoObject.getSignature()); | ||||
|             } | ||||
|             if (cryptoObject.getMac() != null) { | ||||
|                 return new FingerprintManager.CryptoObject(cryptoObject.getMac()); | ||||
|             } | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         public static CryptoObject unwrapCryptoObject(Object obj) { | ||||
|             FingerprintManager.CryptoObject cryptoObject = (FingerprintManager.CryptoObject) obj; | ||||
|             if (cryptoObject == null) { | ||||
|                 return null; | ||||
|             } | ||||
|             if (cryptoObject.getCipher() != null) { | ||||
|                 return new CryptoObject(cryptoObject.getCipher()); | ||||
|             } | ||||
|             if (cryptoObject.getSignature() != null) { | ||||
|                 return new CryptoObject(cryptoObject.getSignature()); | ||||
|             } | ||||
|             if (cryptoObject.getMac() != null) { | ||||
|                 return new CryptoObject(cryptoObject.getMac()); | ||||
|             } | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user