diff options
author | zachh <zachh@google.com> | 2017-09-27 17:26:01 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-09-27 17:26:01 +0000 |
commit | c648f2d6259dc269da9b023379b80cf7494eede0 (patch) | |
tree | ffb91bba5083265917080da7480ebf1a541370da | |
parent | 386d3ab387c211c88989bafe36474b9bf0fd929e (diff) | |
parent | 6502bb4961ed98e41f77bfdf1a20921763b7588c (diff) |
Merge "Bypassed some strict mode violations."
am: 6502bb4961
Change-Id: I6ce51d3d82f2bb5fe7c169341ffd29e037f0578e
-rw-r--r-- | java/com/android/dialer/app/settings/DialerSettingsActivity.java | 2 | ||||
-rw-r--r-- | java/com/android/incallui/calllocation/impl/GoogleLocationSettingHelper.java | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/java/com/android/dialer/app/settings/DialerSettingsActivity.java b/java/com/android/dialer/app/settings/DialerSettingsActivity.java index 6286bfc88..10ef9ed60 100644 --- a/java/com/android/dialer/app/settings/DialerSettingsActivity.java +++ b/java/com/android/dialer/app/settings/DialerSettingsActivity.java @@ -52,7 +52,7 @@ public class DialerSettingsActivity extends AppCompatPreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mPreferences = PreferenceManager.getDefaultSharedPreferences(this); + mPreferences = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()); } @Override diff --git a/java/com/android/incallui/calllocation/impl/GoogleLocationSettingHelper.java b/java/com/android/incallui/calllocation/impl/GoogleLocationSettingHelper.java index 18a80b8ce..ed2e84368 100644 --- a/java/com/android/incallui/calllocation/impl/GoogleLocationSettingHelper.java +++ b/java/com/android/incallui/calllocation/impl/GoogleLocationSettingHelper.java @@ -26,6 +26,7 @@ import android.net.Uri; import android.provider.Settings.Secure; import android.provider.Settings.SettingNotFoundException; import com.android.dialer.common.LogUtil; +import com.android.dialer.strictmode.DialerStrictMode; /** * Helper class to check if Google Location Services is enabled. This class is based on @@ -48,7 +49,7 @@ public class GoogleLocationSettingHelper { private static final String USE_LOCATION_FOR_SERVICES = "use_location_for_services"; /** Determine if Google apps need to conform to the USE_LOCATION_FOR_SERVICES setting. */ - public static boolean isEnforceable(Context context) { + private static boolean isEnforceable(Context context) { final ResolveInfo ri = context .getPackageManager() @@ -102,7 +103,7 @@ public class GoogleLocationSettingHelper { } /** Whether or not the system location setting is enable */ - public static boolean isSystemLocationSettingEnabled(Context context) { + static boolean isSystemLocationSettingEnabled(Context context) { try { return Secure.getInt(context.getContentResolver(), Secure.LOCATION_MODE) != Secure.LOCATION_MODE_OFF; @@ -116,8 +117,11 @@ public class GoogleLocationSettingHelper { } /** Convenience method that returns true is GLS is ON or if it's not enforceable. */ - public static boolean isGoogleLocationServicesEnabled(Context context) { - return !isEnforceable(context) - || getUseLocationForServices(context) == USE_LOCATION_FOR_SERVICES_ON; + static boolean isGoogleLocationServicesEnabled(Context context) { + if (!isEnforceable(context)) { + return true; + } + int locationServiceStatus = DialerStrictMode.bypass(() -> getUseLocationForServices(context)); + return locationServiceStatus == USE_LOCATION_FOR_SERVICES_ON; } } |