Merge "Hide memory setting in app detail unless dev option is on."
This commit is contained in:
committed by
Android (Google) Code Review
commit
09304ec2fd
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications;
|
||||||
|
|
||||||
|
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||||
|
|
||||||
import android.Manifest.permission;
|
import android.Manifest.permission;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
@@ -83,6 +85,7 @@ import com.android.settings.applications.instantapps.InstantAppButtonsController
|
|||||||
import com.android.settings.datausage.AppDataUsage;
|
import com.android.settings.datausage.AppDataUsage;
|
||||||
import com.android.settings.datausage.DataUsageList;
|
import com.android.settings.datausage.DataUsageList;
|
||||||
import com.android.settings.datausage.DataUsageSummary;
|
import com.android.settings.datausage.DataUsageSummary;
|
||||||
|
import com.android.settings.development.DevelopmentSettingsEnabler;
|
||||||
import com.android.settings.fuelgauge.AdvancedPowerUsageDetail;
|
import com.android.settings.fuelgauge.AdvancedPowerUsageDetail;
|
||||||
import com.android.settings.fuelgauge.BatteryEntry;
|
import com.android.settings.fuelgauge.BatteryEntry;
|
||||||
import com.android.settings.fuelgauge.BatteryStatsHelperLoader;
|
import com.android.settings.fuelgauge.BatteryStatsHelperLoader;
|
||||||
@@ -109,8 +112,6 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity to display application information from Settings. This activity presents
|
* Activity to display application information from Settings. This activity presents
|
||||||
* extended information associated with a package like code, data, total size, permissions
|
* extended information associated with a package like code, data, total size, permissions
|
||||||
@@ -176,7 +177,7 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
private Preference mMemoryPreference;
|
private Preference mMemoryPreference;
|
||||||
private Preference mVersionPreference;
|
private Preference mVersionPreference;
|
||||||
private AppDomainsPreference mInstantAppDomainsPreference;
|
private AppDomainsPreference mInstantAppDomainsPreference;
|
||||||
|
private DevelopmentSettingsEnabler mDevelopmentSettingsEnabler;
|
||||||
private boolean mDisableAfterUninstall;
|
private boolean mDisableAfterUninstall;
|
||||||
|
|
||||||
// Used for updating notification preference.
|
// Used for updating notification preference.
|
||||||
@@ -376,6 +377,7 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
|
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
addPreferencesFromResource(R.xml.installed_app_details);
|
addPreferencesFromResource(R.xml.installed_app_details);
|
||||||
|
|
||||||
addDynamicPrefs();
|
addDynamicPrefs();
|
||||||
if (Utils.isBandwidthControlEnabled()) {
|
if (Utils.isBandwidthControlEnabled()) {
|
||||||
INetworkStatsService statsService = INetworkStatsService.Stub.asInterface(
|
INetworkStatsService statsService = INetworkStatsService.Stub.asInterface(
|
||||||
@@ -389,6 +391,8 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
removePreference(KEY_DATA);
|
removePreference(KEY_DATA);
|
||||||
}
|
}
|
||||||
mBatteryUtils = BatteryUtils.getInstance(getContext());
|
mBatteryUtils = BatteryUtils.getInstance(getContext());
|
||||||
|
mDevelopmentSettingsEnabler = new DevelopmentSettingsEnabler(
|
||||||
|
activity, null /* lifecycle */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -412,7 +416,9 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
loaderManager.restartLoader(LOADER_STORAGE, Bundle.EMPTY, this);
|
loaderManager.restartLoader(LOADER_STORAGE, Bundle.EMPTY, this);
|
||||||
}
|
}
|
||||||
restartBatteryStatsLoader();
|
restartBatteryStatsLoader();
|
||||||
new MemoryUpdater().execute();
|
if (mDevelopmentSettingsEnabler.getLastEnabledState()) {
|
||||||
|
new MemoryUpdater().execute();
|
||||||
|
}
|
||||||
updateDynamicPrefs();
|
updateDynamicPrefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -466,6 +472,7 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
mBatteryPreference.setOnPreferenceClickListener(this);
|
mBatteryPreference.setOnPreferenceClickListener(this);
|
||||||
mMemoryPreference = findPreference(KEY_MEMORY);
|
mMemoryPreference = findPreference(KEY_MEMORY);
|
||||||
mMemoryPreference.setOnPreferenceClickListener(this);
|
mMemoryPreference.setOnPreferenceClickListener(this);
|
||||||
|
mMemoryPreference.setVisible(mDevelopmentSettingsEnabler.getLastEnabledState());
|
||||||
mVersionPreference = findPreference(KEY_VERSION);
|
mVersionPreference = findPreference(KEY_VERSION);
|
||||||
mInstantAppDomainsPreference =
|
mInstantAppDomainsPreference =
|
||||||
(AppDomainsPreference) findPreference(KEY_INSTANT_APP_SUPPORTED_LINKS);
|
(AppDomainsPreference) findPreference(KEY_INSTANT_APP_SUPPORTED_LINKS);
|
||||||
|
@@ -34,6 +34,7 @@ public class DevelopmentSettingsEnabler implements LifecycleObserver, OnResume {
|
|||||||
mContext = context;
|
mContext = context;
|
||||||
mDevelopmentPreferences = context.getSharedPreferences(DevelopmentSettings.PREF_FILE,
|
mDevelopmentPreferences = context.getSharedPreferences(DevelopmentSettings.PREF_FILE,
|
||||||
Context.MODE_PRIVATE);
|
Context.MODE_PRIVATE);
|
||||||
|
updateEnabledState();
|
||||||
if (lifecycle != null) {
|
if (lifecycle != null) {
|
||||||
lifecycle.addObserver(this);
|
lifecycle.addObserver(this);
|
||||||
}
|
}
|
||||||
@@ -41,8 +42,7 @@ public class DevelopmentSettingsEnabler implements LifecycleObserver, OnResume {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
mLastEnabledState = Settings.Global.getInt(mContext.getContentResolver(),
|
updateEnabledState();
|
||||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean enableDevelopmentSettings(Context context, SharedPreferences prefs) {
|
public static boolean enableDevelopmentSettings(Context context, SharedPreferences prefs) {
|
||||||
@@ -53,6 +53,11 @@ public class DevelopmentSettingsEnabler implements LifecycleObserver, OnResume {
|
|||||||
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateEnabledState() {
|
||||||
|
mLastEnabledState = Settings.Global.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getLastEnabledState() {
|
public boolean getLastEnabledState() {
|
||||||
return mLastEnabledState;
|
return mLastEnabledState;
|
||||||
}
|
}
|
||||||
|
@@ -16,12 +16,14 @@
|
|||||||
|
|
||||||
package com.android.settings.development;
|
package com.android.settings.development;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
|
||||||
import com.android.settings.TestConfig;
|
import com.android.settings.TestConfig;
|
||||||
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -33,8 +35,6 @@ import org.robolectric.RuntimeEnvironment;
|
|||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.util.ReflectionHelpers;
|
import org.robolectric.util.ReflectionHelpers;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||||
public class DevelopmentSettingsEnablerTest {
|
public class DevelopmentSettingsEnablerTest {
|
||||||
@@ -52,6 +52,16 @@ public class DevelopmentSettingsEnablerTest {
|
|||||||
ReflectionHelpers.setField(mEnabler, "mDevelopmentPreferences", mDevelopmentPreferences);
|
ReflectionHelpers.setField(mEnabler, "mDevelopmentPreferences", mDevelopmentPreferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void constructor_shouldInitEnabledState() {
|
||||||
|
Settings.Global.putInt(mContext.getContentResolver(),
|
||||||
|
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||||
|
|
||||||
|
mEnabler = new DevelopmentSettingsEnabler(mContext, null);
|
||||||
|
|
||||||
|
assertThat(mEnabler.getLastEnabledState()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onResume_shouldReadStateFromSettingProvider() {
|
public void onResume_shouldReadStateFromSettingProvider() {
|
||||||
Settings.Global.putInt(mContext.getContentResolver(),
|
Settings.Global.putInt(mContext.getContentResolver(),
|
||||||
|
Reference in New Issue
Block a user