Update strings in special app access and dev options
- Change all yes/no or on/off strings in special app access to Allowed/Not allowed - Remove some dead code in related files - Add a toast string in DevelopmentSettingsDisabledActivity to prompt user enable dev options before use. - Add search in SpecialAccessSettings Change-Id: I8b2535e037a86e76bdbcd3fb6e1cf2e0347bedbf Fix: 38290299 Fix: 37469224 Test: make RunSettingsRoboTests
This commit is contained in:
@@ -43,6 +43,9 @@
|
|||||||
<!-- [CHAR LIMIT=NONE] Device Info screen. Okay we get it, stop pressing, you already have it on -->
|
<!-- [CHAR LIMIT=NONE] Device Info screen. Okay we get it, stop pressing, you already have it on -->
|
||||||
<string name="show_dev_already">No need, you are already a developer.</string>
|
<string name="show_dev_already">No need, you are already a developer.</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=NONE] Toast message when user attemps to launch developer otions before enabling it. -->
|
||||||
|
<string name="dev_settings_disabled_warning">Please enable developer options first.</string>
|
||||||
|
|
||||||
<!-- Category headings in left-pane header menu --> <skip />
|
<!-- Category headings in left-pane header menu --> <skip />
|
||||||
<!-- Settings main menu category heading. Wireless and networks (Wi-Fi, Bluetooth, data usage...). [CHAR LIMIT=40] -->
|
<!-- Settings main menu category heading. Wireless and networks (Wi-Fi, Bluetooth, data usage...). [CHAR LIMIT=40] -->
|
||||||
<string name="header_category_wireless_networks">Wireless & networks</string>
|
<string name="header_category_wireless_networks">Wireless & networks</string>
|
||||||
@@ -6737,12 +6740,6 @@
|
|||||||
<!-- Apps > App Details > Picture-in-picture > Description. [CHAR LIMIT=NONE] -->
|
<!-- Apps > App Details > Picture-in-picture > Description. [CHAR LIMIT=NONE] -->
|
||||||
<string name="picture_in_picture_app_detail_summary">Allow this app to create a picture-in-picture window while the app is open or after you leave it (for example, to continue watching a video). This window displays on top of other apps you're using.</string>
|
<string name="picture_in_picture_app_detail_summary">Allow this app to create a picture-in-picture window while the app is open or after you leave it (for example, to continue watching a video). This window displays on top of other apps you're using.</string>
|
||||||
|
|
||||||
<!-- Summary of app allowed to enter picture-in-picture. [CHAR LIMIT=60] -->
|
|
||||||
<string name="picture_in_picture_on">Yes</string>
|
|
||||||
|
|
||||||
<!-- Summary of app not allowed to enter picture-in-picture. [CHAR LIMIT=60] -->
|
|
||||||
<string name="picture_in_picture_off">No</string>
|
|
||||||
|
|
||||||
<!-- Sound & notification > Advanced section: Title for managing Do Not Disturb access option. [CHAR LIMIT=40] -->
|
<!-- Sound & notification > Advanced section: Title for managing Do Not Disturb access option. [CHAR LIMIT=40] -->
|
||||||
<string name="manage_zen_access_title">Do Not Disturb access</string>
|
<string name="manage_zen_access_title">Do Not Disturb access</string>
|
||||||
|
|
||||||
@@ -7703,10 +7700,12 @@
|
|||||||
|
|
||||||
<!-- Label for showing apps that can display over other apps [CHAR LIMIT=45] -->
|
<!-- Label for showing apps that can display over other apps [CHAR LIMIT=45] -->
|
||||||
<string name="filter_overlay_apps">Apps with permission</string>
|
<string name="filter_overlay_apps">Apps with permission</string>
|
||||||
<!-- Summary of app allowed to display over other apps [CHAR LIMIT=60] -->
|
|
||||||
<string name="system_alert_window_on">Yes</string>
|
<!-- Preference summary text for an app when it is allowed for a permission. [CHAR LIMIT=45] -->
|
||||||
<!-- Summary of app not allowed to display over other apps [CHAR LIMIT=60] -->
|
<string name="app_permission_summary_allowed">Allowed</string>
|
||||||
<string name="system_alert_window_off">No</string>
|
|
||||||
|
<!-- Preference summary text for an app when it is disallowed for a permission. [CHAR LIMIT=45] -->
|
||||||
|
<string name="app_permission_summary_not_allowed">Not allowed</string>
|
||||||
|
|
||||||
<!-- Title for settings screen for controlling apps that can install other apps on device [CHAR LIMIT=50] -->
|
<!-- Title for settings screen for controlling apps that can install other apps on device [CHAR LIMIT=50] -->
|
||||||
<string name="install_other_apps">Install unknown apps</string>
|
<string name="install_other_apps">Install unknown apps</string>
|
||||||
@@ -7735,14 +7734,6 @@
|
|||||||
<string name="permit_write_settings">Allow modify system settings</string>
|
<string name="permit_write_settings">Allow modify system settings</string>
|
||||||
<!-- Description of the write system settings [CHAR LIMIT=NONE] -->
|
<!-- Description of the write system settings [CHAR LIMIT=NONE] -->
|
||||||
<string name="write_settings_description">This permission allows an app to modify system settings.</string>
|
<string name="write_settings_description">This permission allows an app to modify system settings.</string>
|
||||||
<!-- Summary of app allowed to write system settings [CHAR LIMIT=45] -->
|
|
||||||
<string name="write_settings_on">Yes</string>
|
|
||||||
<!-- Summary of app not allowed to write system settings [CHAR LIMIT=45] -->
|
|
||||||
<string name="write_settings_off">No</string>
|
|
||||||
<!-- Summary of app trusted to install apps [CHAR LIMIT=45] -->
|
|
||||||
<string name="external_source_trusted">Allowed</string>
|
|
||||||
<!-- Summary of app not trusted to install apps [CHAR LIMIT=45] -->
|
|
||||||
<string name="external_source_untrusted">Not allowed</string>
|
|
||||||
<!-- Title of switch preference that controls whether an external app source is trusted or not [CHAR LIMIT=50] -->
|
<!-- Title of switch preference that controls whether an external app source is trusted or not [CHAR LIMIT=50] -->
|
||||||
<string name="external_source_switch_title">Allow from this source</string>
|
<string name="external_source_switch_title">Allow from this source</string>
|
||||||
|
|
||||||
|
@@ -20,8 +20,6 @@ import android.app.AppOpsManager;
|
|||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -206,33 +204,6 @@ public class DrawOverlayDetails extends AppInfoWithHeader implements OnPreferenc
|
|||||||
|
|
||||||
public static CharSequence getSummary(Context context, OverlayState overlayState) {
|
public static CharSequence getSummary(Context context, OverlayState overlayState) {
|
||||||
return context.getString(overlayState.isPermissible() ?
|
return context.getString(overlayState.isPermissible() ?
|
||||||
R.string.system_alert_window_on : R.string.system_alert_window_off);
|
R.string.app_permission_summary_allowed : R.string.app_permission_summary_not_allowed);
|
||||||
}
|
|
||||||
|
|
||||||
public static CharSequence getSummary(Context context, String pkg) {
|
|
||||||
// first check if pkg is a system pkg
|
|
||||||
PackageManager packageManager = context.getPackageManager();
|
|
||||||
int uid = -1;
|
|
||||||
try {
|
|
||||||
ApplicationInfo appInfo = packageManager.getApplicationInfo(pkg, 0);
|
|
||||||
uid = appInfo.uid;
|
|
||||||
if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
|
|
||||||
return context.getString(R.string.system_alert_window_on);
|
|
||||||
}
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
|
||||||
// pkg doesn't even exist?
|
|
||||||
Log.w(LOG_TAG, "Package " + pkg + " not found", e);
|
|
||||||
return context.getString(R.string.system_alert_window_off);
|
|
||||||
}
|
|
||||||
|
|
||||||
AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService(Context
|
|
||||||
.APP_OPS_SERVICE);
|
|
||||||
if (uid == -1) {
|
|
||||||
return context.getString(R.string.system_alert_window_off);
|
|
||||||
}
|
|
||||||
|
|
||||||
int mode = appOpsManager.noteOpNoThrow(AppOpsManager.OP_SYSTEM_ALERT_WINDOW, uid, pkg);
|
|
||||||
return context.getString((mode == AppOpsManager.MODE_ALLOWED) ?
|
|
||||||
R.string.system_alert_window_on : R.string.system_alert_window_off);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,11 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications;
|
||||||
|
|
||||||
import static android.app.Activity.RESULT_CANCELED;
|
|
||||||
import static android.app.Activity.RESULT_OK;
|
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.AppOpsManager;
|
import android.app.AppOpsManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -29,12 +24,16 @@ import android.os.UserManager;
|
|||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
|
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
|
||||||
|
|
||||||
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Settings;
|
import com.android.settings.Settings;
|
||||||
import com.android.settings.applications.AppStateInstallAppsBridge.InstallAppsState;
|
import com.android.settings.applications.AppStateInstallAppsBridge.InstallAppsState;
|
||||||
import com.android.settingslib.RestrictedSwitchPreference;
|
import com.android.settingslib.RestrictedSwitchPreference;
|
||||||
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||||
|
|
||||||
|
import static android.app.Activity.RESULT_CANCELED;
|
||||||
|
import static android.app.Activity.RESULT_OK;
|
||||||
|
|
||||||
public class ExternalSourcesDetails extends AppInfoWithHeader
|
public class ExternalSourcesDetails extends AppInfoWithHeader
|
||||||
implements OnPreferenceChangeListener {
|
implements OnPreferenceChangeListener {
|
||||||
|
|
||||||
@@ -97,8 +96,9 @@ public class ExternalSourcesDetails extends AppInfoWithHeader
|
|||||||
appsState = new AppStateInstallAppsBridge(context, null, null)
|
appsState = new AppStateInstallAppsBridge(context, null, null)
|
||||||
.createInstallAppsStateFor(entry.info.packageName, entry.info.uid);
|
.createInstallAppsStateFor(entry.info.packageName, entry.info.uid);
|
||||||
}
|
}
|
||||||
return context.getString(appsState.canInstallApps() ? R.string.external_source_trusted
|
return context.getString(appsState.canInstallApps()
|
||||||
: R.string.external_source_untrusted);
|
? R.string.app_permission_summary_allowed
|
||||||
|
: R.string.app_permission_summary_not_allowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCanInstallApps(boolean newState) {
|
private void setCanInstallApps(boolean newState) {
|
||||||
|
@@ -1367,8 +1367,9 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
|||||||
case LIST_TYPE_USAGE_ACCESS:
|
case LIST_TYPE_USAGE_ACCESS:
|
||||||
if (holder.entry.extraInfo != null) {
|
if (holder.entry.extraInfo != null) {
|
||||||
holder.summary.setText((new UsageState((PermissionState) holder.entry
|
holder.summary.setText((new UsageState((PermissionState) holder.entry
|
||||||
.extraInfo)).isPermissible() ? R.string.switch_on_text :
|
.extraInfo)).isPermissible()
|
||||||
R.string.switch_off_text);
|
? R.string.app_permission_summary_allowed
|
||||||
|
: R.string.app_permission_summary_not_allowed);
|
||||||
} else {
|
} else {
|
||||||
holder.summary.setText(null);
|
holder.summary.setText(null);
|
||||||
}
|
}
|
||||||
|
@@ -15,10 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications;
|
||||||
|
|
||||||
import static android.app.AppOpsManager.MODE_ALLOWED;
|
|
||||||
import static android.app.AppOpsManager.MODE_ERRORED;
|
|
||||||
import static android.app.AppOpsManager.OP_PICTURE_IN_PICTURE;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.AppOpsManager;
|
import android.app.AppOpsManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -34,6 +30,10 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
|
|
||||||
|
import static android.app.AppOpsManager.MODE_ALLOWED;
|
||||||
|
import static android.app.AppOpsManager.MODE_ERRORED;
|
||||||
|
import static android.app.AppOpsManager.OP_PICTURE_IN_PICTURE;
|
||||||
|
|
||||||
public class PictureInPictureDetails extends AppInfoWithHeader
|
public class PictureInPictureDetails extends AppInfoWithHeader
|
||||||
implements OnPreferenceChangeListener {
|
implements OnPreferenceChangeListener {
|
||||||
|
|
||||||
@@ -124,7 +124,8 @@ public class PictureInPictureDetails extends AppInfoWithHeader
|
|||||||
static int getPreferenceSummary(Context context, int uid, String packageName) {
|
static int getPreferenceSummary(Context context, int uid, String packageName) {
|
||||||
final boolean enabled = PictureInPictureDetails.getEnterPipStateForPackage(context, uid,
|
final boolean enabled = PictureInPictureDetails.getEnterPipStateForPackage(context, uid,
|
||||||
packageName);
|
packageName);
|
||||||
return enabled ? R.string.picture_in_picture_on : R.string.picture_in_picture_off;
|
return enabled ? R.string.app_permission_summary_allowed
|
||||||
|
: R.string.app_permission_summary_not_allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
@@ -14,20 +14,54 @@
|
|||||||
|
|
||||||
package com.android.settings.applications;
|
package com.android.settings.applications;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.content.Context;
|
||||||
|
import android.provider.SearchIndexableResource;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.core.PreferenceController;
|
||||||
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
|
import com.android.settings.search.Indexable;
|
||||||
|
|
||||||
public class SpecialAccessSettings extends SettingsPreferenceFragment {
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class SpecialAccessSettings extends DashboardFragment {
|
||||||
|
|
||||||
|
private static final String TAG = "SpecialAccessSettings";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
protected String getLogTag() {
|
||||||
addPreferencesFromResource(R.xml.special_access);
|
return TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getPreferenceScreenResId() {
|
||||||
|
return R.xml.special_access;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<PreferenceController> getPreferenceControllers(Context context) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsEvent.SPECIAL_ACCESS;
|
return MetricsEvent.SPECIAL_ACCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
|
new BaseSearchIndexProvider() {
|
||||||
|
@Override
|
||||||
|
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||||
|
boolean enabled) {
|
||||||
|
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||||
|
|
||||||
|
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||||
|
sir.xmlResId = R.xml.special_access;
|
||||||
|
result.add(sir);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@@ -20,8 +20,6 @@ import android.app.AppOpsManager;
|
|||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -38,8 +36,6 @@ import com.android.settings.applications.AppStateWriteSettingsBridge.WriteSettin
|
|||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class WriteSettingsDetails extends AppInfoWithHeader implements OnPreferenceChangeListener,
|
public class WriteSettingsDetails extends AppInfoWithHeader implements OnPreferenceChangeListener,
|
||||||
OnPreferenceClickListener {
|
OnPreferenceClickListener {
|
||||||
|
|
||||||
@@ -182,47 +178,8 @@ public class WriteSettingsDetails extends AppInfoWithHeader implements OnPrefere
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static CharSequence getSummary(Context context, WriteSettingsState writeSettingsState) {
|
public static CharSequence getSummary(Context context, WriteSettingsState writeSettingsState) {
|
||||||
return context.getString(writeSettingsState.isPermissible() ? R.string.write_settings_on :
|
return context.getString(writeSettingsState.isPermissible()
|
||||||
R.string.write_settings_off);
|
? R.string.app_permission_summary_allowed
|
||||||
}
|
: R.string.app_permission_summary_not_allowed);
|
||||||
|
|
||||||
public static CharSequence getSummary(Context context, String pkg) {
|
|
||||||
// first check if pkg is a system pkg
|
|
||||||
boolean isSystem = false;
|
|
||||||
PackageManager packageManager = context.getPackageManager();
|
|
||||||
try {
|
|
||||||
ApplicationInfo appInfo = packageManager.getApplicationInfo(pkg, 0);
|
|
||||||
if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
|
|
||||||
isSystem = true;
|
|
||||||
}
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
|
||||||
// pkg doesn't even exist?
|
|
||||||
Log.w(LOG_TAG, "Package " + pkg + " not found", e);
|
|
||||||
return context.getString(R.string.write_settings_off);
|
|
||||||
}
|
|
||||||
|
|
||||||
AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService(Context
|
|
||||||
.APP_OPS_SERVICE);
|
|
||||||
List<AppOpsManager.PackageOps> packageOps = appOpsManager.getPackagesForOps(
|
|
||||||
APP_OPS_OP_CODE);
|
|
||||||
if (packageOps == null) {
|
|
||||||
return context.getString(R.string.write_settings_off);
|
|
||||||
}
|
|
||||||
|
|
||||||
int uid = isSystem ? 0 : -1;
|
|
||||||
for (AppOpsManager.PackageOps packageOp : packageOps) {
|
|
||||||
if (pkg.equals(packageOp.getPackageName())) {
|
|
||||||
uid = packageOp.getUid();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uid == -1) {
|
|
||||||
return context.getString(R.string.write_settings_off);
|
|
||||||
}
|
|
||||||
|
|
||||||
int mode = appOpsManager.noteOpNoThrow(AppOpsManager.OP_WRITE_SETTINGS, uid, pkg);
|
|
||||||
return context.getString((mode == AppOpsManager.MODE_ALLOWED) ?
|
|
||||||
R.string.write_settings_on : R.string.write_settings_off);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.datausage;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.NetworkPolicy;
|
|
||||||
import android.net.NetworkTemplate;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.RemoteException;
|
|
||||||
import android.support.v7.preference.Preference;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.Utils;
|
|
||||||
import com.android.settings.datausage.CellDataPreference.DataStateListener;
|
|
||||||
|
|
||||||
public class BillingCyclePreference extends Preference implements TemplatePreference {
|
|
||||||
|
|
||||||
private NetworkTemplate mTemplate;
|
|
||||||
private NetworkServices mServices;
|
|
||||||
private NetworkPolicy mPolicy;
|
|
||||||
private int mSubId;
|
|
||||||
|
|
||||||
public BillingCyclePreference(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttached() {
|
|
||||||
super.onAttached();
|
|
||||||
mListener.setListener(true, mSubId, getContext());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDetached() {
|
|
||||||
mListener.setListener(false, mSubId, getContext());
|
|
||||||
super.onDetached();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTemplate(NetworkTemplate template, int subId,
|
|
||||||
NetworkServices services) {
|
|
||||||
mTemplate = template;
|
|
||||||
mSubId = subId;
|
|
||||||
mServices = services;
|
|
||||||
mPolicy = services.mPolicyEditor.getPolicy(mTemplate);
|
|
||||||
setSummary(getContext().getString(R.string.billing_cycle_fragment_summary, mPolicy != null
|
|
||||||
? mPolicy.cycleDay
|
|
||||||
: "1"));
|
|
||||||
setIntent(getIntent());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateEnabled() {
|
|
||||||
try {
|
|
||||||
setEnabled(mPolicy != null && mServices.mNetworkService.isBandwidthControlEnabled()
|
|
||||||
&& mServices.mTelephonyManager.getDataEnabled(mSubId)
|
|
||||||
&& mServices.mUserManager.isAdminUser());
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Intent getIntent() {
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putParcelable(DataUsageList.EXTRA_NETWORK_TEMPLATE, mTemplate);
|
|
||||||
return Utils.onBuildStartFragmentIntent(getContext(), BillingCycleSettings.class.getName(),
|
|
||||||
args, null, 0, getTitle(), false, MetricsProto.MetricsEvent.VIEW_UNKNOWN);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final DataStateListener mListener = new DataStateListener() {
|
|
||||||
@Override
|
|
||||||
public void onChange(boolean selfChange) {
|
|
||||||
updateEnabled();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
@@ -18,11 +18,15 @@ package com.android.settings.development;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
public class DevelopmentSettingsDisabledActivity extends Activity {
|
public class DevelopmentSettingsDisabledActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Toast.makeText(this, R.string.dev_settings_disabled_warning, Toast.LENGTH_SHORT).show();
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -133,8 +133,7 @@ public final class SearchIndexableResources {
|
|||||||
R.xml.battery_saver_settings, R.drawable.ic_settings_battery);
|
R.xml.battery_saver_settings, R.drawable.ic_settings_battery);
|
||||||
addIndex(AdvancedAppSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_applications);
|
addIndex(AdvancedAppSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_applications);
|
||||||
addIndex(ManageAssist.class, NO_DATA_RES_ID, R.drawable.ic_settings_applications);
|
addIndex(ManageAssist.class, NO_DATA_RES_ID, R.drawable.ic_settings_applications);
|
||||||
addIndex(SpecialAccessSettings.class,
|
addIndex(SpecialAccessSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_applications);
|
||||||
R.xml.special_access, R.drawable.ic_settings_applications);
|
|
||||||
addIndex(UserSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_multiuser);
|
addIndex(UserSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_multiuser);
|
||||||
addIndex(AssistGestureSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_gestures);
|
addIndex(AssistGestureSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_gestures);
|
||||||
addIndex(PickupGestureSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_gestures);
|
addIndex(PickupGestureSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_gestures);
|
||||||
|
@@ -47,7 +47,6 @@ com.android.settings.notification.ZenModeScheduleRuleSettings
|
|||||||
com.android.settings.datausage.BillingCycleSettings
|
com.android.settings.datausage.BillingCycleSettings
|
||||||
com.android.settings.notification.NotificationStation
|
com.android.settings.notification.NotificationStation
|
||||||
com.android.settings.print.PrintJobSettingsFragment
|
com.android.settings.print.PrintJobSettingsFragment
|
||||||
com.android.settings.applications.SpecialAccessSettings
|
|
||||||
com.android.settings.accessibility.ToggleScreenReaderPreferenceFragmentForSetupWizard
|
com.android.settings.accessibility.ToggleScreenReaderPreferenceFragmentForSetupWizard
|
||||||
com.android.settings.accessibility.ToggleSelectToSpeakPreferenceFragmentForSetupWizard
|
com.android.settings.accessibility.ToggleSelectToSpeakPreferenceFragmentForSetupWizard
|
||||||
com.android.settings.accounts.AccountSyncSettings
|
com.android.settings.accounts.AccountSyncSettings
|
||||||
|
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 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.development;
|
||||||
|
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.SettingsRobolectricTestRunner;
|
||||||
|
import com.android.settings.TestConfig;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.Robolectric;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
import org.robolectric.shadows.ShadowToast;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||||
|
public class DevelopmentSettingsDisabledActivityTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void launchActivity_shouldShowToast() {
|
||||||
|
Robolectric.setupActivity(DevelopmentSettingsDisabledActivity.class);
|
||||||
|
|
||||||
|
assertThat(ShadowToast.getTextOfLatestToast()).isEqualTo(
|
||||||
|
RuntimeEnvironment.application.getString(R.string.dev_settings_disabled_warning));
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user