언어 설정

Menu
Sites
Language
AccountUpdate PermissionDenied even with account.write = allow

I have written an app for my Galaxy Watch and everything seems to be working except account.write is throwing an exception when I am trying to update the account. I have the privilege in the manifest and if I do not have it turned on the app does successfully request it. I am able to read the account that was created once, but it no longer seems to function. Anyone have any idea what I am doing wrong?  I have tried turning it on and off manually in settings and uninstalling and reinstalling the app.  I also see this behavior in 2 different apps I have, both had a write succeed once, but after that it fails.

 

<privileges>
  <privilege>http://tizen.org/privilege/account.read</privilege>
  <privilege>http://tizen.org/privilege/account.write</privilege>
  <privilege>http://tizen.org/privilege/internet</privilege>
  <privilege>http://tizen.org/privilege/network.get</privilege>
</privileges>
private bool EnsureAccountPermissions()
{
    var privilege = "http://tizen.org/privilege/account.write";
    var result = PrivacyPrivilegeManager.CheckPermission(privilege);
    if (result != CheckResult.Allow)
    {
        PrivacyPrivilegeManager.RequestPermission(privilege);
        return false;
    }
    privilege = "http://tizen.org/privilege/account.read";
    result = PrivacyPrivilegeManager.CheckPermission(privilege);
    if (result != CheckResult.Allow)
    {
        PrivacyPrivilegeManager.RequestPermission(privilege);
        return false;
    }
    return true;
}
            if (Account == null)
                Account = Account.CreateAccount();
            Account.PackageName = "MyDemoApp";
            Account.DisplayName = "MyDemoApp";
            Account.UserName = UserName;
            Account.AccessToken = AccessToken;
            Account.SetCustomValue("VehicleName", VehicleName);
            Account.SecrecyState = AccountSecrecyState.Invisible;
            if (Account.AccountId == 0)
            {
                try
                {
                    AccountService.AddAccount(Account);
                }
                catch (Exception e)
                {
                    Log.Error("MyDemoApp", "MyDemoApp " + e.Message);
                }
            }
            else
            {
                try
                {
                    AccountService.UpdateAccount(Account);
                }
                catch (Exception e)
                {
                    Log.Error("MyDemoApp", e.Message); Log.Error("MyDemoApp", "MyDemoApp " + e.Message);
                }
            }

 

Responses

6 댓글
Tizen .NET

Hi,
I've just tested UpdateAccount() api with account sample to check the permission denied error. In my case, there's no error.
Could you check if the account sample app works well or not? After then, please check the behavior of UpdateAccount() with a little bit modification as follows.
Please share your result with us. 
(How to check: 1. put name and password 2. click the "Sign in" button several times. You can see the account updated callback is invoked with log message.)
Thanks.

// Please check the part of using #region directive
// Accounts\Accounts\Views\AccountSignIn.xaml.cs file
        #region CHECK_ACCOUNT_UPDATE
        int i;

        private void AccountService_AccountUpdated(object sender, AccountSubscriberEventArgs e)
        {
            Console.WriteLine("[AccountService_AccountUpdated] Account ID:" + e.AccountId + ", EventType:" + e.EventType.ToString());
        }
        #endregion

        public AccountSignIn()
        {
            InitializeComponent();
            accountApi = new AccountApiManager();
            accountApi.CheckAccountPrivilege();
            #region CHECK_ACCOUNT_UPDATE
            i = 0;
            AccountService.AccountUpdated += AccountService_AccountUpdated;
            #endregion
        }
        
        public async void SignInClicked(object sender, EventArgs args)
        {
            int id = -1;

            // Set account item
            AccountItem account = new AccountItem
            {
                UserName = loginEntry.Text,
                UserPassword = passwordEntry.Text,
            };

            if (string.IsNullOrEmpty(account.UserName) || string.IsNullOrEmpty(account.UserPassword))
            {
                // Check wrong Input parameter
                Toast.DisplayText("Please fill in all fields");
                return;
            }

            if (accountApi.CheckIfAccountAlreadyExists(account))
            {
                // Validate login input
                id = accountApi.GetAccountId(account);

                if (id == -1)
                {
                    Toast.DisplayText("Incorrect password!");
                    return;
                }
                                  #region CHECK_ACCOUNT_UPDATE
                Account existingAccount = AccountService.GetAccountById(id);
                // e.g. update account with modified displayname
                existingAccount.DisplayName = existingAccount.DisplayName + i++;
                AccountService.UpdateAccount(existingAccount);
                                   #endregion
            }
            else
            {
                // Add account and receive account id.
                id = accountApi.AccountAdd(account);
            }
            #region CHECK_ACCOUNT_UPDATE
            // Load account sign out content page
            //AccountSignOut accountSignOut = new AccountSignOut(id, account.UserName);
            //await Navigation.PushAsync(accountSignOut);
            #endregion
        }

 

Jon Helms
The update code you pasted does not match signatures of what is in the Accounts\SampleAccount project and is missing CheckIfAccountAlreadyExists, you also appear to have added some references that are not present as other items throw compile errors. I just cloned from the GitHub you linked tonight, so I am not using an old published version. I did adjust the code enough to get it running and it appears the UpdateAccount works in the sample app. How do I get it working in mine?
Jon Helms
The only notable difference I can see is that I do not set a SyncState. Uninstalling does not remove accounts either.
Jon Helms
I did set new names and the SyncState to Idle and after a single write that stored everything except the access token, it is giving me permission denied again. It seems like I get one write, then it is broken.
Tizen .NET

Hello,
Regarding this, Account API maintainer cannot reproduce this issue.
He will update sample app using UpdateAccount() API. Please check this out with the updated sample app.
To find out more about the issue you are facing, please share the dump log file with us (tizen.net@samsung.com) and API maintainer can check it out.

How to get dump logs from Samsung Galaxy Watch devices
1. In the Phone app, enter *#9900#
2. Set Debug Mode Setting On (the device will restart)
3. After repoducing your issue, enter *#9900# in the Phone app
4. Select Run LOG_DUMP
5. log dump file will be created on your device and you can get it from /opt/usr/media/debug directory with sdb pull command.
Thanks.

Jon Helms
A few hours ago some changes seem to have it working now. The changes are: Removing PackageName Removing SecrecyState Removing SyncState (pretty sure not this as I didn't have this when I started getting the error) Removing AccessToken - now storing in a custom Setting EmailId I'm not sure which one or multiple of these were required to get it working, but those are the changes I made.