GIDMDMPasscodeState.m 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2021 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import <TargetConditionals.h>
  15. #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
  16. #import "GoogleSignIn/Sources/GIDMDMPasscodeState.h"
  17. #import "GoogleSignIn/Sources/GIDMDMPasscodeState_Private.h"
  18. #import <Foundation/Foundation.h>
  19. #import "GoogleSignIn/Sources/GIDMDMPasscodeCache.h"
  20. NS_ASSUME_NONNULL_BEGIN
  21. @implementation GIDMDMPasscodeState
  22. - (instancetype)initWithStatus:(NSString *)status info:(NSString *)info {
  23. self = [super init];
  24. if (self) {
  25. _status = [status copy];
  26. _info = [info copy];
  27. }
  28. return self;
  29. }
  30. + (instancetype)passcodeState {
  31. #if DEBUG
  32. NSDate *start = [NSDate date];
  33. #endif
  34. GIDMDMPasscodeState *passcodeState = [[GIDMDMPasscodeCache sharedInstance] passcodeState];
  35. #if DEBUG
  36. NSTimeInterval timeElapsed = [[NSDate date] timeIntervalSinceDate:start];
  37. NSLog(@"Retrieved device passcode state in %dms.", (int)round(timeElapsed * 1000));
  38. #endif
  39. return passcodeState;
  40. }
  41. @end
  42. NS_ASSUME_NONNULL_END
  43. #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST