Add the interface to check the status of location setting.

Bug: 30790766
Test: ag/1346969

Change-Id: Id6de284ba90f75015372dbe28805bdc0d94a0723
This commit is contained in:
jackqdyulei
2016-08-18 11:07:23 -07:00
parent 5d4dc3748d
commit 348bcc1e81
4 changed files with 44 additions and 1 deletions

View File

@@ -57,6 +57,7 @@ import com.android.settings.applications.InstalledAppDetails;
import com.android.settings.applications.LayoutPreference;
import com.android.settings.bluetooth.BluetoothSettings;
import com.android.settings.location.LocationSettings;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.wifi.WifiSettings;
import java.io.PrintWriter;
@@ -328,6 +329,7 @@ public class PowerUsageDetail extends PowerUsageBase implements Button.OnClickLi
private long mStartTime;
private BatterySipper.DrainType mDrainType;
private double mNoCoverage; // Percentage of time that there was no coverage
private PowerUsageFeatureProvider mPowerUsageFeatureProvider;
private PreferenceCategory mDetailsParent;
private PreferenceCategory mControlsParent;
@@ -355,6 +357,9 @@ public class PowerUsageDetail extends PowerUsageBase implements Button.OnClickLi
mMessagesParent = (PreferenceCategory) findPreference(KEY_MESSAGES_PARENT);
mPackagesParent = (PreferenceCategory) findPreference(KEY_PACKAGES_PARENT);
mPowerUsageFeatureProvider =
FeatureFactory.getFactory(getActivity()).getPowerUsageFeatureProvider();
createDetails();
}
@@ -604,9 +609,11 @@ public class PowerUsageDetail extends PowerUsageBase implements Button.OnClickLi
// If the application has a settings screen, jump to that
// TODO:
}
// If power usage detail page is launched from location page, suppress "Location"
// button to prevent circular loops.
if (mUsesGps && mShowLocationButton) {
if (mUsesGps && mShowLocationButton
&& mPowerUsageFeatureProvider.isLocationSettingEnabled(packages)) {
addControl(R.string.location_settings_title,
R.string.battery_sugg_apps_gps, ACTION_LOCATION_SETTINGS);
removeHeader = false;

View File

@@ -0,0 +1,27 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.fuelgauge;
/**
* Feature Provider used in power usage
*/
public interface PowerUsageFeatureProvider {
/**
* Check whether location setting is enabled
*/
boolean isLocationSettingEnabled(String[] packages);
}