Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bfa96c3b authored by Lifu Tang's avatar Lifu Tang
Browse files

Supress Location button when coming from Location

Change-Id: Ie1f1aed17206530ec7c8a1cde43a4380b7232823
parent 55fe056d
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -175,7 +175,8 @@ public class BatteryStatsHelper {
        }
    }

    public void startBatteryDetailPage(PreferenceActivity caller, BatterySipper sipper) {
    public void startBatteryDetailPage(
            PreferenceActivity caller, BatterySipper sipper, boolean showLocationButton) {
        // Initialize mStats if necessary.
        getStats();

@@ -193,6 +194,7 @@ public class BatteryStatsHelper {
            args.putInt(PowerUsageDetail.EXTRA_UID, sipper.uidObj.getUid());
        }
        args.putSerializable(PowerUsageDetail.EXTRA_DRAIN_TYPE, sipper.drainType);
        args.putBoolean(PowerUsageDetail.EXTRA_SHOW_LOCATION_BUTTON, showLocationButton);

        int[] types;
        double[] values;
+7 −2
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener
    public static final String EXTRA_ICON_PACKAGE = "iconPackage"; // String
    public static final String EXTRA_NO_COVERAGE = "noCoverage";
    public static final String EXTRA_ICON_ID = "iconId"; // Int
    public static final String EXTRA_SHOW_LOCATION_BUTTON = "showLocationButton";  // Boolean

    private PackageManager mPm;
    private DevicePolicyManager mDpm;
@@ -128,6 +129,7 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener
    private double mNoCoverage; // Percentage of time that there was no coverage

    private boolean mUsesGps;
    private boolean mShowLocationButton;

    private static final String TAG = "PowerUsageDetail";
    private String[] mPackages;
@@ -176,6 +178,7 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener
        mNoCoverage = args.getDouble(EXTRA_NO_COVERAGE, 0);
        String iconPackage = args.getString(EXTRA_ICON_PACKAGE);
        int iconId = args.getInt(EXTRA_ICON_ID, 0);
        mShowLocationButton = args.getBoolean(EXTRA_SHOW_LOCATION_BUTTON);
        if (!TextUtils.isEmpty(iconPackage)) {
            try {
                final PackageManager pm = getActivity().getPackageManager();
@@ -362,7 +365,9 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener
                    // If the application has a settings screen, jump to  that
                    // TODO:
                }
                if (mUsesGps) {
                // If power usage detail page is launched from location page, suppress "Location"
                // button to prevent circular loops.
                if (mUsesGps && mShowLocationButton) {
                    addControl(R.string.location_settings_title,
                            R.string.battery_sugg_apps_gps, ACTION_LOCATION_SETTINGS);
                    removeHeader = false;
+1 −1
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ public class PowerUsageSummary extends PreferenceFragment {
        }
        PowerGaugePreference pgp = (PowerGaugePreference) preference;
        BatterySipper sipper = pgp.getInfo();
        mStatsHelper.startBatteryDetailPage((PreferenceActivity) getActivity(), sipper);
        mStatsHelper.startBatteryDetailPage((PreferenceActivity) getActivity(), sipper, true);
        return super.onPreferenceTreeClick(preferenceScreen, preference);
    }

+1 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ public class RecentLocationApps {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            mStatsHelper.startBatteryDetailPage(mActivity, mSipper);
            mStatsHelper.startBatteryDetailPage(mActivity, mSipper, false);
            return true;
        }
    }