0

In all related discussions, people mentioned get/setMobileDataEnabled is private function and needs to be accessed by using reflection. For example, this one How to tell if 'Mobile Network Data' is enabled or disabled (even when connected by WiFi)?.

However, I found the Settings app (package/apps/Settings/src/com/android/settings/DataUsageSummary.java) does not use reflection at all. Anybody knows the reason?

private ConnectivityManager mConnService;

mConnService = ConnectivityManager.from(context);

private void setMobileDataEnabled(boolean enabled) {
     if (LOGD) Log.d(TAG, "setMobileDataEnabled()");
     mConnService.setMobileDataEnabled(enabled);
     mMobileDataEnabled = enabled;
     updatePolicy(false);
}
Community
  • 1
  • 1
Shoumeng
  • 3
  • 3

1 Answers1

0

The Settings app is built as part of a full firmware build. The Settings app is not an Android SDK application and therefore is not subject to the limitations imposed by the Android SDK, such as not having access to @hide classes and methods.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491