From 23df75fd15b4c2d107fd35c8761855526b6df630 Mon Sep 17 00:00:00 2001 From: Greg Date: Wed, 20 Nov 2019 16:44:28 -0500 Subject: [PATCH] Add permissions request, comment out debug print statements. --- PgpConnect.java | 11 +++++++++-- impl_android.go | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/PgpConnect.java b/PgpConnect.java index ecad887..5253833 100644 --- a/PgpConnect.java +++ b/PgpConnect.java @@ -27,6 +27,8 @@ import android.content.IntentSender; import android.content.IntentSender.OnFinished; import android.content.IntentSender.SendIntentException; import android.os.Bundle; +import android.Manifest; +import android.content.pm.PackageManager; public class PgpConnect extends Fragment { Activity act; @@ -34,6 +36,7 @@ public class PgpConnect extends Fragment { Handler handler; OpenPgpServiceConnection mServiceConnection; ClipboardManager cb; + final int PERMISSIONS_REQUEST = 1; public PgpConnect(Activity act) { Log.d("gio", "PgpConnect(Activity)"); @@ -49,6 +52,10 @@ public class PgpConnect extends Fragment { FragmentTransaction ft = fm.beginTransaction(); ft.add(frag, "PgpConnect"); ft.commitNow(); + + if (ctx.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ctx.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSIONS_REQUEST); + } } }); } @@ -160,7 +167,7 @@ public class PgpConnect extends Fragment { Log.d("gio","_getid: success"); try { String ret = os.toString("UTF-8"); - Log.d(OpenPgpApi.TAG, "output: " + ret); + //Log.d(OpenPgpApi.TAG, "output: " + ret); stringResult(chint, ret); } catch (UnsupportedEncodingException e) { Log.e("gio", "UnsupportedEncodingException", e); @@ -197,7 +204,7 @@ public class PgpConnect extends Fragment { case OpenPgpApi.RESULT_CODE_SUCCESS: { try { String ret = os.toString("UTF-8"); - Log.d(OpenPgpApi.TAG, "output: " + ret); + //Log.d(OpenPgpApi.TAG, "output: " + ret); stringResult(chint, ret); } catch (UnsupportedEncodingException e) { Log.e("gio", "UnsupportedEncodingException", e); diff --git a/impl_android.go b/impl_android.go index badac3f..8fe0e75 100644 --- a/impl_android.go +++ b/impl_android.go @@ -77,18 +77,18 @@ func (s *Store) nativeDecrypt(name string) (string, error) { return "", fmt.Errorf("Error reading file: %s", err) } ret, err := pgp.Decrypt(string(data)) - log.Printf("nativeDecrypt(): got %s", ret) return ret, err } func (s *Store) nativeEncrypt(pw string) ([]byte, error) { connect() ret, err := pgp.Encrypt(s.Id, pw) - log.Printf("nativeEncrypt(): got %s", ret) return []byte(ret), err } func nativeIdentities() ([]string, error) { + //NOT IMPLEMENTED ON ANDROID + return []string{}, nil log.Printf("nativeIdentities()") connect() log.Printf("calling pgp.GetId()")