0

Well, the bigger question is that how can a public class {AccountManagerService} be made inaccessible?

[EDIT]

If I am developing an android app, I can only access AccountManager but not AccountManagerService that is being used internally by AccountManager. If I look it up, I can find com.android.server.accounts. AccountManagerService class and that is declared public. But, still, I cannot import it and neither create its reference.

Nishant Soni
  • 658
  • 1
  • 9
  • 19
  • inaccessible to what? – President James K. Polk Aug 31 '17 at 22:32
  • If I am developing an android app, I can only access AccountManager but not AccountManagerService that is being used internally by AccountManager. If I look it up, I can find `com.android.server.accounts. AccountManagerService` class and that is declared public. But, still, I cannot import it and neither create its reference. – Nishant Soni Aug 31 '17 at 22:40
  • You may not be able to get access to this object. Even if you do, bear in mind that its API and implementation can vary between Android versions and between device manufacturers. – CommonsWare Aug 31 '17 at 23:16
  • Thx @CommonsWare, the real problem is that some Android Nougat 7.0 and 7.1.1 upgrade messed up Accounts in the AccountManager and the reason was that Nougat has changed the way accounts data is stored in the database. They introduced 2 database database_ce(credential encrypted) and database_de(device encrypted) and it requires syncing between the two. And some of the device manufacturers somehow corrupt database_de that causes disappearance of the account and then user tries to login, addAccountExplicitly returns false. So wanted to clear out both db to fix the issue. – Nishant Soni Sep 06 '17 at 19:33

1 Answers1

0

Accessing private methods of another class can only be achieved by using reflection like this:

Method m = SomeClass.class.getDeclaredMethod("methodName", paramClasses);
m.setAccessible(true);
m.invoke(params);

This can be prevented by the creator of such classes and I expect that to be the case with internal Android classes.

Making public classes unaccessible can be done by setting your own SecurityManager and deny access to this class. I'm not going into detail with this since it's quite unlikely that you're able to set your own SecurityManager when running on Android.

Lothar
  • 5,323
  • 1
  • 11
  • 27