blob: 4e78d9b3d33c0dcb0426759ffbb48aab465ea281 [file] [log] [blame]
Tony Mantler4ca9ebd2017-07-31 10:54:20 -07001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.settingslib.development;
18
19import android.content.Context;
20import android.content.Intent;
21import android.os.Build;
22import android.provider.Settings;
23import android.support.v4.content.LocalBroadcastManager;
24
25public class DevelopmentSettingsEnabler {
26
27 public static final String DEVELOPMENT_SETTINGS_CHANGED_ACTION =
28 "com.android.settingslib.development.DevelopmentSettingsEnabler.SETTINGS_CHANGED";
29
30 private DevelopmentSettingsEnabler() {}
31
32 public static void setDevelopmentSettingsEnabled(Context context, boolean enable) {
33 Settings.Global.putInt(context.getContentResolver(),
34 Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, enable ? 1 : 0);
35 LocalBroadcastManager.getInstance(context)
36 .sendBroadcast(new Intent(DEVELOPMENT_SETTINGS_CHANGED_ACTION));
37 }
38
39 public static boolean isDevelopmentSettingsEnabled(Context context) {
40 return Settings.Global.getInt(context.getContentResolver(),
41 Settings.Global.DEVELOPMENT_SETTINGS_ENABLED,
42 Build.TYPE.equals("eng") ? 1 : 0) != 0;
43 }
44}