public override void OnFillRequest(FillRequest request, CancellationSignal cancellationSignal, FillCallback callback) { bool isManual = (request.Flags & FillRequest.FlagManualRequest) != 0; CommonUtil.logd("onFillRequest " + (isManual ? "manual" : "auto")); var structure = request.FillContexts[request.FillContexts.Count - 1].Structure; //TODO support package signature verification as soon as this is supported in Keepass storage var clientState = request.ClientState; CommonUtil.logd("onFillRequest(): data=" + CommonUtil.BundleToString(clientState)); cancellationSignal.CancelEvent += (sender, e) => { Log.Warn(CommonUtil.Tag, "Cancel autofill not implemented yet."); }; // Parse AutoFill data in Activity string query = null; var parser = new StructureParser(this, structure); try { query = parser.ParseForFill(isManual); } catch (Java.Lang.SecurityException e) { Log.Warn(CommonUtil.Tag, "Security exception handling request"); callback.OnFailure(e.Message); return; } AutofillFieldMetadataCollection autofillFields = parser.AutofillFields; var autofillIds = autofillFields.GetAutofillIds(); if (autofillIds.Length != 0 && CanAutofill(query, isManual)) { var responseBuilder = new FillResponse.Builder(); var entryDataset = AddEntryDataset(query, parser); bool hasEntryDataset = entryDataset != null; if (entryDataset != null) { responseBuilder.AddDataset(entryDataset); } AddQueryDataset(query, isManual, autofillIds, responseBuilder, !hasEntryDataset); AddDisableDataset(query, autofillIds, responseBuilder, isManual); responseBuilder.SetSaveInfo(new SaveInfo.Builder(parser.AutofillFields.SaveType, parser.AutofillFields.GetAutofillIds()).Build()); callback.OnSuccess(responseBuilder.Build()); } else { callback.OnSuccess(null); } }
internal void CancelAuthentication() { cancellationSignal?.Cancel(); newCancelSignal?.Cancel(); newCancelSignal = null; cancellationSignal = null; }
public bool Login() { var retVal = true; Android.Content.PM.Permission permissionResult = ContextCompat.CheckSelfPermission(context, Manifest.Permission.UseFingerprint); if (permissionResult == Android.Content.PM.Permission.Granted) { } else { // No permission. // https://developer.android.com/training/permissions/requesting.html } FingerprintManagerCompat fingerprintManager = FingerprintManagerCompat.From(context); const int flags = 0; CryptoObjectHelper cryptoHelper = new CryptoObjectHelper(); // cancellationSignal - stop scanning _cancellationSignal = new Android.Support.V4.OS.CancellationSignal(); fingerprintManager = FingerprintManagerCompat.From(context); // Callback method FingerprintManagerCompat.AuthenticationCallback authenticationCallback = new AuthResultsCallback(); // Start scanning fingerprintManager.Authenticate(cryptoHelper.BuildCryptoObject(), flags, _cancellationSignal, authenticationCallback, null); return(retVal); }
public override void OnWrite (PageRange[] pages, ParcelFileDescriptor destination, CancellationSignal cancellationSignal, Android.Print.PrintDocumentAdapter.WriteResultCallback callback) { InputStream input = null; OutputStream output = null; try { input = new FileInputStream (PathToDoc); output = new FileOutputStream (destination.FileDescriptor); byte[] buf = new byte[1024]; int bytesRead; while ((bytesRead = input.Read (buf)) > 0) { output.Write (buf, 0, bytesRead); } callback.OnWriteFinished (new PageRange[]{ PageRange.AllPages }); } catch (System.IO.FileNotFoundException ee) { Insights.Report (ee); } catch (Exception e) { Insights.Report (e); } finally { try { input.Close (); output.Close (); } catch (Java.IO.IOException e) { e.PrintStackTrace (); } } }
public MyClass() { _cancellationSignal = new CancellationSignal(new WeakReference(this)); Thread t = new Thread(Worker); t.Start(_cancellationSignal); }
public void StopListening() { if (mCancellationSignal != null) { mSelfCancelled = true; mCancellationSignal.Cancel(); mCancellationSignal = null; } }
public void StopListening() { if (_cancellationSignal != null) { _selfCancelled = true; _cancellationSignal.Cancel(); _cancellationSignal = null; } }
public void StopScanning() { if (cancellationSignal != null) { cancellationSignal.Cancel(); cancellationSignal = null; System.Diagnostics.Debug.WriteLine("Stop scanning..."); } }
public override void OnFillRequest(FillRequest request, CancellationSignal cancellationSignal, FillCallback callback) { var structure = request.FillContexts?.LastOrDefault()?.Structure; if (structure == null) { return; } var clientState = request.ClientState; var parser = new StructureParser(structure); parser.ParseForFill(); // build response var responseBuilder = new FillResponse.Builder(); var username1 = new FilledAutofillField { TextValue = "username1" }; var password1 = new FilledAutofillField { TextValue = "pass1" }; var login1 = new Dictionary <string, FilledAutofillField> { { View.AutofillHintUsername, username1 }, { View.AutofillHintPassword, password1 } }; var coll = new FilledAutofillFieldCollection("Login 1 Name", login1); var username2 = new FilledAutofillField { TextValue = "username2" }; var password2 = new FilledAutofillField { TextValue = "pass2" }; var login2 = new Dictionary <string, FilledAutofillField> { { View.AutofillHintUsername, username2 }, { View.AutofillHintPassword, password2 } }; var col2 = new FilledAutofillFieldCollection("Login 2 Name", login2); var clientFormDataMap = new Dictionary <string, FilledAutofillFieldCollection> { { "login-1-guid", coll }, { "login-2-guid", col2 } }; var response = AutofillHelper.NewResponse(this, false, parser.AutofillFields, clientFormDataMap); // end build response callback.OnSuccess(response); }
public MyOnLayoutAsyncTask(MyPrintDocumentAdapter self, PrintAttributes newAttributes, CancellationSignal cancellationSignal, LayoutResultCallback callback) { this.self = self; this.newAttributes = newAttributes; this.cancellationSignal = cancellationSignal; this.callback = callback; items = ((MotoGpStatAdapter)self.pcc.ListAdapter).CloneItems(); }
public override async Task <FingerprintAuthenticationResult> AuthenticateNoDialogAsync(IAuthenticationFailedListener failedListener, CancellationToken cancellationToken) { using (var cancellationSignal = new CancellationSignal()) using (cancellationToken.Register(() => cancellationSignal.Cancel())) { var callback = new FingerprintAuthenticationCallback(failedListener); GetService().Authenticate(null, cancellationSignal, FingerprintAuthenticationFlags.None, callback, null); return(await callback.GetTask()); } }
public void StartListening (FingerprintManager.CryptoObject cryptoObject) { if (!IsFingerprintAuthAvailable) return; mCancellationSignal = new CancellationSignal (); mSelfCancelled = false; mFingerprintManager.Authenticate (cryptoObject, mCancellationSignal, 0 /* flags */, this, null); mIcon.SetImageResource (Resource.Drawable.ic_fp_40px); }
public void StopListening() { if (_cancellationSignal != null) { Kp2aLog.Log("FP: StopListening "); _selfCancelled = true; _cancellationSignal.Cancel(); _cancellationSignal = null; } }
internal void _startAutentificare(FingerprintManager amp, FingerprintManager.CryptoObject criptat) { CancellationSignal _semnal = new CancellationSignal(); if (Android.Support.V4.Content.ContextCompat.CheckSelfPermission(_amprenta, Manifest.Permission.UseFingerprint) != (int)Android.Content.PM.Permission.Granted) { return; } amp.Authenticate(criptat, _semnal, 0, this, null); }
internal void StartAuthentication(FingerprintManager fingerprintManager, FingerprintManager.CryptoObject cryptoObject) { CancellationSignal cancellationSignal = new CancellationSignal(); if (ActivityCompat.CheckSelfPermission(mainActivity, Manifest.Permission.UseFingerprint) != (int)Android.Content.PM.Permission.Granted) { return; } fingerprintManager.Authenticate(cryptoObject, cancellationSignal, 0, this, null); }
internal static async Task <FingerprintAuthenticationResult> AuthenticateNoDialogAsync(CancellationToken cancellationToken, FingerprintAuthenticationCallback callback) { var cancellationSignal = new CancellationSignal(); cancellationToken.Register(() => cancellationSignal.Cancel()); CrossFingerprint.GetService().Authenticate(null, cancellationSignal, FingerprintAuthenticationFlags.None, callback, null); return(await callback.GetTask()); }
private async Task ProgressBarUpdater(CancellationSignal cancellationSignal) { while (_timeoutManager.Running || !cancellationSignal.IsCanceled) { RunOnUiThread(() => { _progressBar.Progress = (int)_timeoutManager.ProgressPercentage; }); await Task.Delay(10); } }
private void OnClickFaceAuthWithCrpObj(object sender, EventArgs e) { string Tag = "FaceAuthWithCrpObj"; Android.Content.PM.Permission permissionCheck = Android.Content.PM.Permission.Granted; if (Build.VERSION.SdkInt >= BuildVersionCodes.M) { permissionCheck = CheckSelfPermission(Manifest.Permission.Camera); } if (permissionCheck != Android.Content.PM.Permission.Granted) { log.Info(Tag, "The camera permission is not enabled. Please enable it."); // request camera permissions if (Build.VERSION.SdkInt >= BuildVersionCodes.M) { RequestPermissions(new string[] { Manifest.Permission.Camera }, 1); } return; } BioAuthnCallback callback = new FidoBioAuthnCallback(); // Cancellation Signal CancellationSignal cancellationSignal = new CancellationSignal(); FaceManager faceManager = new FaceManager(this); Log.Info("HasEnrolledTemplates", faceManager.HasEnrolledTemplates.ToString()); Log.Info("IsHardwareDetected", faceManager.IsHardwareDetected.ToString()); Log.Info("CanAuth", faceManager.CanAuth().ToString()); log.Info(Tag, $"IsHardwareDetected:{faceManager.IsHardwareDetected}"); // Checks whether 3D facial authentication can be used. int errorCode = faceManager.CanAuth(); if (errorCode != 0) { log.Info(Tag, "Can not authenticate. errorCode=" + errorCode); return; } // flags int flags = 0; // Authentication messsage handler. Handler handler = null; // Recommended CryptoObject to be set to null. KeyStore is not associated with face authentication in current // version. KeyGenParameterSpec.Builder.SetUserAuthenticationRequired() must be set false in this scenario. CryptoObject crypto = null; log.Info(Tag, "Start face authentication.\nAuthenticating......\n"); faceManager.Auth(crypto, cancellationSignal, flags, callback, handler); }
public void StartListening(FingerprintManager.CryptoObject cryptoObject) { if (!IsFingerprintAuthAvailable) { return; } mCancellationSignal = new CancellationSignal(); mSelfCancelled = false; mFingerprintManager.Authenticate(cryptoObject, mCancellationSignal, 0 /* flags */, this, null); mIcon.SetImageResource(Resource.Drawable.ic_fp_40px); }
public void StartListening(FingerprintManager.AuthenticationCallback callback) { if (!IsFingerprintAuthAvailable) { return; } _cancellationSignal = new CancellationSignal(); _selfCancelled = false; _callback = callback; _fingerprintManager.Authenticate(_cryptoObject, _cancellationSignal, 0 /* flags */, this, null); }
public MyOnWriteAsyncTask(MyPrintDocumentAdapter self, PageRange[] pages, ParcelFileDescriptor destination, CancellationSignal cancellationSignal, WriteResultCallback callback) { this.self = self; this.pages = pages; this.destination = destination; this.cancellationSignal = cancellationSignal; this.callback = callback; items = ((MotoGpStatAdapter)self.pcc.ListAdapter).CloneItems(); mPdfDocument = new PrintedPdfDocument(self.mPrintContext, self.mPrintAttributes); }
public async override void OnFillRequest(FillRequest request, CancellationSignal cancellationSignal, FillCallback callback) { var structure = request.FillContexts?.LastOrDefault()?.Structure; if (structure == null) { return; } var parser = new Parser(structure, ApplicationContext); parser.Parse(); if (_storageService == null) { _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); } var shouldAutofill = await parser.ShouldAutofillAsync(_storageService); if (!shouldAutofill) { return; } var inlineAutofillEnabled = await _storageService.GetAsync <bool?>(Constants.InlineAutofillEnabledKey) ?? true; if (_vaultTimeoutService == null) { _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); } List <FilledItem> items = null; await _vaultTimeoutService.CheckVaultTimeoutAsync(); var locked = await _vaultTimeoutService.IsLockedAsync(); if (!locked) { if (_cipherService == null) { _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); } items = await AutofillHelpers.GetFillItemsAsync(parser, _cipherService); } // build response var response = AutofillHelpers.BuildFillResponse(parser, items, locked, inlineAutofillEnabled, request); callback.OnSuccess(response); }
private void Start() { RunOnUiThread(() => { _mainButton.Text = "Stop"; _progressBar.Visibility = ViewStates.Visible; }); _progressBarUpdaterCancellation = new CancellationSignal(); _timeoutManager.Start(); _progressBarUpdater = ProgressBarUpdater(_progressBarUpdaterCancellation); }
public override void OnWrite(PageRange[] pages, ParcelFileDescriptor destination, CancellationSignal cancellationSignal, WriteResultCallback callback) { // If we are already cancelled, don't do any work. if (cancellationSignal.IsCanceled) { callback.OnWriteCancelled(); return; } var onWriteAsyncTask = new MyOnWriteAsyncTask(this, pages, destination, cancellationSignal, callback); onWriteAsyncTask.ExecuteOnExecutor(AsyncTask.ThreadPoolExecutor, (Java.Lang.Void[])null); }
public override void OnLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes, CancellationSignal cancellationSignal, LayoutResultCallback callback, Bundle extras) { document = new PrintedPdfDocument(context, newAttributes); CalculateScale(newAttributes); var printInfo = new PrintDocumentInfo .Builder("pdf-test.pdf") .SetContentType(PrintContentType.Document) .SetPageCount(1) .Build(); callback.OnLayoutFinished(printInfo, true); }
public static async Task PulseLike(ImageButton likeOrFlag, bool isFlag, CancellationSignal signal) { try { likeOrFlag.ScaleX = 0.7f; likeOrFlag.ScaleY = 0.7f; if (isFlag) { likeOrFlag.SetImageResource(Resource.Drawable.ic_flag_active); } else { likeOrFlag.SetImageResource(Resource.Drawable.ic_new_like_filled); } var tick = 0; do { if (signal.IsCanceled) { return; } tick++; var mod = tick % 6; if (mod != 5) { likeOrFlag.ScaleX += 0.05f; likeOrFlag.ScaleY += 0.05f; } else { likeOrFlag.ScaleX = 0.7f; likeOrFlag.ScaleY = 0.7f; } await Task.Delay(100); } while (true); } catch { //todo nothing } }
public void StopListening() { if (_cancellationSignal != null) { Kp2aLog.Log("FP: StopListening "); _selfCancelled = true; try { _cancellationSignal.Cancel(); } catch (System.ObjectDisposedException e) { Kp2aLog.LogUnexpectedError(e); } _cancellationSignal = null; } }
private void Authenticate() { FingerprintManager fingerprint = this.GetSystemService(FingerprintService) as FingerprintManager; KeyguardManager keyGuard = GetSystemService(KeyguardService) as KeyguardManager; Android.Content.PM.Permission permission = CheckSelfPermission(Android.Manifest.Permission.UseFingerprint); if (fingerprint.IsHardwareDetected && keyGuard.IsKeyguardSecure && fingerprint.HasEnrolledFingerprints && permission == Android.Content.PM.Permission.Granted) { const int flags = 0; CryptoObjectFactory cryptoObject = new CryptoObjectFactory(); CancellationSignal cancellationSignal = new CancellationSignal(); FingerprintManager.AuthenticationCallback authCallback = new AuthCallback(this); fingerprint.Authenticate(cryptoObject.BuildCryptoObject(), cancellationSignal, flags, authCallback, null); } }
public override void OnWrite(PageRange[] pages, ParcelFileDescriptor destination, CancellationSignal cancellationSignal, WriteResultCallback callback) { PrintedPdfDocument.Page page = document.StartPage(0); page.Canvas.Scale(scale, scale); page.Canvas.DrawText(text, page.Canvas.ClipBounds.Right / 2, page.Canvas.ClipBounds.Bottom / 2, new Android.Graphics.Paint()); document.FinishPage(page); WritePrintedPdfDoc(destination); document.Close(); document.Dispose(); callback.OnWriteFinished(pages); }
public override void OnWrite(PageRange[] pages, ParcelFileDescriptor destination, CancellationSignal cancellationSignal, WriteResultCallback callback) { PrintedPdfDocument.Page page = document.StartPage(0); page.Canvas.Scale(scale, scale); view.Draw(page.Canvas); document.FinishPage(page); WritePrintedPdfDoc(destination); document.Close(); document.Dispose(); callback.OnWriteFinished(pages); }
public async override void OnFillRequest(FillRequest request, CancellationSignal cancellationSignal, FillCallback callback) { var structure = request.FillContexts?.LastOrDefault()?.Structure; if (structure == null) { return; } var parser = new Parser(structure); parser.Parse(); if (string.IsNullOrWhiteSpace(parser.Uri) || parser.Uri == "androidapp://com.x8bit.bitwarden" || parser.Uri == "androidapp://android" || !parser.FieldCollection.Fillable) { return; } if (_lockService == null) { _lockService = Resolver.Resolve <ILockService>(); } List <FilledItem> items = null; var locked = (await _lockService.GetLockTypeAsync(false)) != LockType.None; if (!locked) { if (_cipherService == null) { _cipherService = Resolver.Resolve <ICipherService>(); } items = await AutofillHelpers.GetFillItemsAsync(parser, _cipherService); } // build response var response = AutofillHelpers.BuildFillResponse(this, parser, items, locked); callback.OnSuccess(response); }
public void StartScanning() { const int flags = 0; /* always zero (0) */ CryptoObjectHelper cryptoHelper = new CryptoObjectHelper(); // cancellationSignal can be used to manually stop the fingerprint scanner. // On: cancellationSignal.Cancel(); cancellationSignal = new CancellationSignal(); // NOTE: For more security, like online transactions,etc... // Consider using Asymmetric keys // Send public key to server to identity user // When bio-auth succeed, send private to server to decrypted // https://android-developers.googleblog.com/2015/10/new-in-android-samples-authenticating.html // Start the fingerprint scanner. fingerprintManager.Authenticate(cryptoHelper.BuildCryptoObject(), flags, cancellationSignal, RegisterAuthCallback(), null); System.Diagnostics.Debug.WriteLine("Start scanning..."); }
private void upload(HttpFormFile fFile, string key, string token, UploadOptions uploadOptions, UpCompletionHandler upCompletionHandler) { string uploadHost = "<UPLOAD_HOST>"; string uploadHostRetry = "<UPLOAD_HOST_RETRY>"; if(Config.UploadFromCDN) { uploadHost = Config.ZONE.UploadHost; uploadHostRetry = Config.ZONE.UpHost; } else { uploadHost = Config.ZONE.UpHost; uploadHostRetry = Config.ZONE.UploadHost; } if (uploadOptions == null) { uploadOptions = UploadOptions.defaultOptions(); } Dictionary<string, string> vPostParams = new Dictionary<string, string>(); //设置key if (!string.IsNullOrEmpty(key)) { vPostParams.Add("key", key); } //设置token vPostParams.Add("token", token); //设置crc32校验 if (uploadOptions.CheckCrc32) { switch (fFile.BodyType) { case HttpFileType.DATA_SLICE: vPostParams.Add("crc32", string.Format("{0}", CRC32.CheckSumSlice(fFile.BodyBytes, fFile.Offset, fFile.Count))); break; case HttpFileType.DATA_BYTES: vPostParams.Add("crc32", string.Format("{0}", CRC32.CheckSumBytes(fFile.BodyBytes))); break; case HttpFileType.FILE_STREAM: long streamLength = fFile.BodyStream.Length; byte[] buffer = new byte[streamLength]; int cnt = fFile.BodyStream.Read(buffer, 0, (int)streamLength); vPostParams.Add("crc32", string.Format("{0}", CRC32.CheckSumSlice(buffer, 0, cnt))); fFile.BodyStream.Seek(0, SeekOrigin.Begin); break; case HttpFileType.FILE_PATH: vPostParams.Add("crc32", string.Format("{0}", CRC32.CheckSumFile(fFile.BodyFile))); break; } } //设置MimeType // FIX: (添加了下一行代码) // 修正上传文件MIME总为octect-stream(原因:未初始化FormFile.ContentType)的问题 // @fengyh 2016-08-17 14:50 fFile.ContentType = uploadOptions.MimeType; //设置扩展参数 foreach (KeyValuePair<string, string> kvp in uploadOptions.ExtraParams) { vPostParams.Add(kvp.Key, kvp.Value); } //设置进度处理和取消信号 ProgressHandler fUpProgressHandler = new ProgressHandler(delegate (long bytesWritten, long totalBytes) { double percent = (double)bytesWritten / totalBytes; //这样做是为了等待回复 if (percent > 0.95) { percent = 0.95; } uploadOptions.ProgressHandler(key, percent); }); CancellationSignal fCancelSignal = new CancellationSignal(delegate () { return uploadOptions.CancellationSignal(); }); // 第一次失败后使用备用域名重试一次 CompletionHandler fUpCompletionHandler = new CompletionHandler(delegate (ResponseInfo respInfo, string response) { Console.WriteLine("form upload result, {0}",respInfo.StatusCode); if (respInfo.needRetry()) // 需要重试 { Console.WriteLine(string.Format("form upload retry")); if (Config.RetryWaitForNext) { Console.WriteLine(string.Format("wait for {0} milisecond(s)", Config.RETRY_INTERVAL_MILISEC)); System.Threading.Thread.Sleep(Config.RETRY_INTERVAL_MILISEC); } if (fFile.BodyStream != null) { fFile.BodyStream.Seek(0, SeekOrigin.Begin); } CompletionHandler retried = new CompletionHandler(delegate (ResponseInfo retryRespInfo, string retryResponse) { Console.WriteLine("form upload retry result, {0}",retryRespInfo.StatusCode); if (respInfo.isOk()) { uploadOptions.ProgressHandler(key, 1.0); } if (fFile.BodyStream != null) { fFile.BodyStream.Close(); } if (upCompletionHandler != null) { try { upCompletionHandler(key, retryRespInfo, retryResponse); } catch (Exception ex) { Console.WriteLine("form upload retry completion error, {0}", ex.Message); } } }); // 使用UPLOAD_HOST_RETRY重试 this.mHttpManager.postMultipartDataForm(uploadHostRetry, null, vPostParams, fFile, fUpProgressHandler, retried); } else // 不需要重试 { if (respInfo.isOk()) { uploadOptions.ProgressHandler(key, 1.0); } if (fFile.BodyStream != null) { fFile.BodyStream.Close(); } if (upCompletionHandler != null) { try { upCompletionHandler(key, respInfo, response); } catch (Exception ex) { Console.WriteLine("form upload completion error, {0}", ex.Message); } } } }); // 使用UPLOAD_HOST上传 this.mHttpManager.postMultipartDataForm(uploadHost, null, vPostParams, fFile, fUpProgressHandler, fUpCompletionHandler); }
public override AssetFileDescriptor OpenDocumentThumbnail (string documentId, Android.Graphics.Point sizeHint, CancellationSignal signal) { Log.Verbose (TAG, "openDocumentThumbnail"); File file = GetFileForDocId (documentId); var pfd = ParcelFileDescriptor.Open (file, ParcelFileMode.ReadOnly); return new AssetFileDescriptor (pfd, 0, AssetFileDescriptor.UnknownLength); }
public override void OnLayout (PrintAttributes oldAttributes, PrintAttributes newAttributes, CancellationSignal cancellationSignal, Android.Print.PrintDocumentAdapter.LayoutResultCallback callback, Bundle extras) { if (cancellationSignal.IsCanceled) { callback.OnLayoutCancelled (); return; } PrintDocumentInfo pdi = new PrintDocumentInfo.Builder (PrintService.pdfName).SetContentType (Android.Print.PrintContentType.Document).Build (); callback.OnLayoutFinished (pdi, true); }
public override void OnWrite (PageRange[] pages, ParcelFileDescriptor destination, CancellationSignal cancellationSignal, WriteResultCallback callback) { mWrappedInstance.OnWrite (pages, destination, cancellationSignal, callback); }
public override void OnLayout (PrintAttributes oldAttributes, PrintAttributes newAttributes, CancellationSignal cancellationSignal, LayoutResultCallback callback, Bundle extras) { mWrappedInstance.OnLayout(oldAttributes, newAttributes, cancellationSignal, callback, extras); }
public override ParcelFileDescriptor OpenDocument (string documentId, string mode, CancellationSignal signal) { Log.Verbose (TAG, "openDocument, mode: " + mode); // It's OK to do network operations in this method to download the document, as long as you // periodically check the CancellationSignal. If you have an extremely large file to // transfer from the network, a better solution may be pipes or sockets // (see ParcelFileDescriptor for helper methods). File file = GetFileForDocId (documentId); var accessMode = ParcelFileDescriptor.ParseMode (mode); bool isWrite = (mode.IndexOf ('w') != -1); if (isWrite) { // Attach a close listener if the document is opened in write mode. try { var handler = new Handler (Context.MainLooper); return ParcelFileDescriptor.Open (file, accessMode, handler, new MyOnCloseListener (documentId)); } catch (IOException) { throw new FileNotFoundException ("Failed to open document with id " + documentId + " and mode " + mode); } } else { return ParcelFileDescriptor.Open (file, accessMode); } }
public void StopListening () { if (mCancellationSignal != null) { mSelfCancelled = true; mCancellationSignal.Cancel (); mCancellationSignal = null; } }