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);
}

View File

@@ -21,6 +21,7 @@ import android.text.TextUtils;
import android.util.Log;
import com.android.settings.R;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
/**
* Abstract class for creating feature controllers. Allows OEM implementations to define their own
@@ -61,6 +62,8 @@ public abstract class FeatureFactory {
public abstract SupportFeatureProvider getSupportFeatureProvider(Context context);
public abstract PowerUsageFeatureProvider getPowerUsageFeatureProvider();
public static final class FactoryNotFoundException extends RuntimeException {
public FactoryNotFoundException(Throwable throwable) {
super("Unable to create factory. Did you misconfigure Proguard?", throwable);

View File

@@ -18,6 +18,7 @@ package com.android.settings.overlay;
import android.content.Context;
import android.support.annotation.Keep;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
/**
* {@link FeatureFactory} implementation for AOSP Settings.
@@ -30,4 +31,9 @@ public final class FeatureFactoryImpl extends FeatureFactory {
return null;
}
@Override
public PowerUsageFeatureProvider getPowerUsageFeatureProvider() {
return null;
}
}