aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/cyanogenmod/profiles
diff options
context:
space:
mode:
authorAdnan Begovic <adnan@cyngn.com>2016-04-01 12:21:24 -0700
committerAdnan Begovic <adnan@cyngn.com>2016-04-01 12:22:14 -0700
commit5f6c9f40c7bb8c442849fe5cd64305fe4b7c3f9f (patch)
tree386106bf2d1a2eb1cd18b90a2b6396f2997980e4 /src/java/cyanogenmod/profiles
parent1ee5f204cc7a8b2ce869897c28145b38cc06e629 (diff)
downloadvendor_cmsdk-5f6c9f40c7bb8c442849fe5cd64305fe4b7c3f9f.zip
vendor_cmsdk-5f6c9f40c7bb8c442849fe5cd64305fe4b7c3f9f.tar.gz
vendor_cmsdk-5f6c9f40c7bb8c442849fe5cd64305fe4b7c3f9f.tar.bz2
cmsdk: Move sdk classes under new sdk directory.
TICKET: CYNGNOS-2299 Change-Id: Ia6c6a1ee901f4f94446c379cbceabfdfced651ef
Diffstat (limited to 'src/java/cyanogenmod/profiles')
-rw-r--r--src/java/cyanogenmod/profiles/AirplaneModeSettings.java224
-rw-r--r--src/java/cyanogenmod/profiles/BrightnessSettings.java222
-rw-r--r--src/java/cyanogenmod/profiles/ConnectionSettings.java475
-rw-r--r--src/java/cyanogenmod/profiles/LockSettings.java179
-rw-r--r--src/java/cyanogenmod/profiles/RingModeSettings.java214
-rw-r--r--src/java/cyanogenmod/profiles/StreamSettings.java216
6 files changed, 0 insertions, 1530 deletions
diff --git a/src/java/cyanogenmod/profiles/AirplaneModeSettings.java b/src/java/cyanogenmod/profiles/AirplaneModeSettings.java
deleted file mode 100644
index a9b828f..0000000
--- a/src/java/cyanogenmod/profiles/AirplaneModeSettings.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright (C) 2015 The CyanogenMod 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 cyanogenmod.profiles;
-
-import android.content.Context;
-import android.content.Intent;
-import android.provider.Settings;
-import android.os.Parcel;
-import android.os.Parcelable;
-
-import cyanogenmod.os.Build;
-import cyanogenmod.os.Concierge;
-import cyanogenmod.os.Concierge.ParcelInfo;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-
-import java.io.IOException;
-
-/**
- * The {@link AirplaneModeSettings} class allows for overriding and setting the airplane mode.
- *
- * <p>Example for setting the airplane mode to enabled:
- * <pre class="prettyprint">
- * AirplaneModeSettings airplaneMode = new AirplaneModeSettings(BooleanState.STATE_ENABLED, true)
- * profile.setAirplaneMode(airplaneMode);
- * </pre>
- */
-public final class AirplaneModeSettings implements Parcelable {
-
- private int mValue;
- private boolean mOverride;
- private boolean mDirty;
-
- /** @hide */
- public static final Parcelable.Creator<AirplaneModeSettings> CREATOR =
- new Parcelable.Creator<AirplaneModeSettings>() {
- public AirplaneModeSettings createFromParcel(Parcel in) {
- return new AirplaneModeSettings(in);
- }
-
- @Override
- public AirplaneModeSettings[] newArray(int size) {
- return new AirplaneModeSettings[size];
- }
- };
-
- /**
- * BooleanStates for specific {@link AirplaneModeSettings}
- */
- public static class BooleanState {
- /** Disabled state */
- public static final int STATE_DISALED = 0;
- /** Enabled state */
- public static final int STATE_ENABLED = 1;
- }
-
- /**
- * Unwrap {@link AirplaneModeSettings} from a parcel.
- * @param parcel
- */
- public AirplaneModeSettings(Parcel parcel) {
- readFromParcel(parcel);
- }
-
- /**
- * Construct a {@link AirplaneModeSettings} with a default value of
- * {@link BooleanState#STATE_DISALED}.
- */
- public AirplaneModeSettings() {
- this(BooleanState.STATE_DISALED, false);
- }
-
- /**
- * Construct a {@link AirplaneModeSettings} with a default value and whether or not it should
- * override user settings.
- * @param value ex: {@link BooleanState#STATE_DISALED}
- * @param override whether or not the setting should override user settings
- */
- public AirplaneModeSettings(int value, boolean override) {
- mValue = value;
- mOverride = override;
- mDirty = false;
- }
-
- /**
- * Get the default value for the {@link AirplaneModeSettings}
- * @return integer value corresponding with its brightness value
- */
- public int getValue() {
- return mValue;
- }
-
- /**
- * Set the default value for the {@link AirplaneModeSettings}
- * @param value {@link BooleanState#STATE_DISALED}
- */
- public void setValue(int value) {
- mValue = value;
- mDirty = true;
- }
-
- /**
- * Set whether or not the {@link AirplaneModeSettings} should override default user values
- * @param override boolean override
- */
- public void setOverride(boolean override) {
- mOverride = override;
- mDirty = true;
- }
-
- /**
- * Check whether or not the {@link AirplaneModeSettings} overrides user settings.
- * @return true if override
- */
- public boolean isOverride() {
- return mOverride;
- }
-
- /** @hide */
- public boolean isDirty() {
- return mDirty;
- }
-
- /** @hide */
- public void processOverride(Context context) {
- if (isOverride()) {
- int current = Settings.Global.getInt(context.getContentResolver(),
- Settings.Global.AIRPLANE_MODE_ON, 0);
- if (current != mValue) {
- Settings.Global.putInt(context.getContentResolver(),
- Settings.Global.AIRPLANE_MODE_ON, mValue);
- Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
- intent.putExtra("state", mValue == 1);
- context.sendBroadcast(intent);
- }
- }
- }
-
- /** @hide */
- public static AirplaneModeSettings fromXml(XmlPullParser xpp, Context context)
- throws XmlPullParserException, IOException {
- int event = xpp.next();
- AirplaneModeSettings airplaneModeDescriptor = new AirplaneModeSettings();
- while ((event != XmlPullParser.END_TAG && event != XmlPullParser.END_DOCUMENT) ||
- !xpp.getName().equals("airplaneModeDescriptor")) {
- if (event == XmlPullParser.START_TAG) {
- String name = xpp.getName();
- if (name.equals("value")) {
- airplaneModeDescriptor.mValue = Integer.parseInt(xpp.nextText());
- } else if (name.equals("override")) {
- airplaneModeDescriptor.mOverride = Boolean.parseBoolean(xpp.nextText());
- }
- } else if (event == XmlPullParser.END_DOCUMENT) {
- throw new IOException("Premature end of file while parsing airplane mode settings");
- }
- event = xpp.next();
- }
- return airplaneModeDescriptor;
- }
-
- /** @hide */
- public void getXmlString(StringBuilder builder, Context context) {
- builder.append("<airplaneModeDescriptor>\n<value>");
- builder.append(mValue);
- builder.append("</value>\n<override>");
- builder.append(mOverride);
- builder.append("</override>\n</airplaneModeDescriptor>\n");
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- /** @hide */
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- // Tell the concierge to prepare the parcel
- ParcelInfo parcelInfo = Concierge.prepareParcel(dest);
-
- // === BOYSENBERRY ===
- dest.writeInt(mOverride ? 1 : 0);
- dest.writeInt(mValue);
- dest.writeInt(mDirty ? 1 : 0);
-
- // Complete the parcel info for the concierge
- parcelInfo.complete();
- }
-
- /** @hide */
- public void readFromParcel(Parcel in) {
- // Read parcelable version via the Concierge
- ParcelInfo parcelInfo = Concierge.receiveParcel(in);
- int parcelableVersion = parcelInfo.getParcelVersion();
-
- // Pattern here is that all new members should be added to the end of
- // the writeToParcel method. Then we step through each version, until the latest
- // API release to help unravel this parcel
- if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) {
- mOverride = in.readInt() != 0;
- mValue = in.readInt();
- mDirty = in.readInt() != 0;
- }
-
- // Complete parcel info for the concierge
- parcelInfo.complete();
- }
-}
diff --git a/src/java/cyanogenmod/profiles/BrightnessSettings.java b/src/java/cyanogenmod/profiles/BrightnessSettings.java
deleted file mode 100644
index 0786a72..0000000
--- a/src/java/cyanogenmod/profiles/BrightnessSettings.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (C) 2015 The CyanogenMod 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 cyanogenmod.profiles;
-
-import android.content.Context;
-import android.provider.Settings;
-import android.os.Parcel;
-import android.os.Parcelable;
-
-import cyanogenmod.os.Build;
-import cyanogenmod.os.Concierge;
-import cyanogenmod.os.Concierge.ParcelInfo;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-
-import java.io.IOException;
-
-/**
- * The {@link BrightnessSettings} class allows for overriding and setting the brightness level
- * of the display. The range for brightness is between 0 -> 255.
- *
- * <p>Example for setting the brightness to ~25% (255 * .25):
- * <pre class="prettyprint">
- * BrightnessSettings twentyFivePercent = new BrightnessSettings(63, true)
- * profile.setBrightness(twentyFivePercent);
- * </pre>
- */
-public final class BrightnessSettings implements Parcelable {
-
- private int mValue;
- private boolean mOverride;
- private boolean mDirty;
-
- /** @hide */
- public static final Parcelable.Creator<BrightnessSettings> CREATOR
- = new Parcelable.Creator<BrightnessSettings>() {
- public BrightnessSettings createFromParcel(Parcel in) {
- return new BrightnessSettings(in);
- }
-
- @Override
- public BrightnessSettings[] newArray(int size) {
- return new BrightnessSettings[size];
- }
- };
-
- /**
- * Unwrap {@link BrightnessSettings} from a parcel.
- * @param parcel
- */
- public BrightnessSettings(Parcel parcel) {
- readFromParcel(parcel);
- }
-
- /**
- * Construct a {@link BrightnessSettings} with a default value of 0.
- */
- public BrightnessSettings() {
- this(0, false);
- }
-
- /**
- * Construct a {@link BrightnessSettings} with a default value and whether or not it should
- * override user settings.
- * @param value ex: 255 (MAX)
- * @param override whether or not the setting should override user settings
- */
- public BrightnessSettings(int value, boolean override) {
- mValue = value;
- mOverride = override;
- mDirty = false;
- }
-
- /**
- * Get the default value for the {@link BrightnessSettings}
- * @return integer value corresponding with its brightness value
- */
- public int getValue() {
- return mValue;
- }
-
- /**
- * Set the default value for the {@link BrightnessSettings}
- * @param value ex: 255 (MAX)
- */
- public void setValue(int value) {
- mValue = value;
- mDirty = true;
- }
-
- /**
- * Set whether or not the {@link BrightnessSettings} should override default user values
- * @param override boolean override
- */
- public void setOverride(boolean override) {
- mOverride = override;
- mDirty = true;
- }
-
- /**
- * Check whether or not the {@link BrightnessSettings} overrides user settings.
- * @return true if override
- */
- public boolean isOverride() {
- return mOverride;
- }
-
- /** @hide */
- public boolean isDirty() {
- return mDirty;
- }
-
- /** @hide */
- public void processOverride(Context context) {
- if (isOverride()) {
- final boolean automatic = Settings.System.getInt(context.getContentResolver(),
- Settings.System.SCREEN_BRIGHTNESS_MODE,
- Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL)
- == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
- if (automatic) {
- final float current = Settings.System.getFloat(context.getContentResolver(),
- Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ, -2f);
- // Convert from [0, 255] to [-1, 1] for SCREEN_AUTO_BRIGHTNESS_ADJ
- final float adj = mValue / (255 / 2f) - 1;
- if (current != adj) {
- Settings.System.putFloat(context.getContentResolver(),
- Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ, adj);
- }
- } else {
- final int current = Settings.System.getInt(context.getContentResolver(),
- Settings.System.SCREEN_BRIGHTNESS, -1);
- if (current != mValue) {
- Settings.System.putInt(context.getContentResolver(),
- Settings.System.SCREEN_BRIGHTNESS, mValue);
- }
- }
- }
- }
-
- /** @hide */
- public static BrightnessSettings fromXml(XmlPullParser xpp, Context context)
- throws XmlPullParserException, IOException {
- int event = xpp.next();
- BrightnessSettings brightnessDescriptor = new BrightnessSettings();
- while (event != XmlPullParser.END_TAG || !xpp.getName().equals("brightnessDescriptor")) {
- if (event == XmlPullParser.START_TAG) {
- String name = xpp.getName();
- if (name.equals("value")) {
- brightnessDescriptor.mValue = Integer.parseInt(xpp.nextText());
- } else if (name.equals("override")) {
- brightnessDescriptor.mOverride = Boolean.parseBoolean(xpp.nextText());
- }
- }
- event = xpp.next();
- }
- return brightnessDescriptor;
- }
-
- /** @hide */
- public void getXmlString(StringBuilder builder, Context context) {
- builder.append("<brightnessDescriptor>\n<value>");
- builder.append(mValue);
- builder.append("</value>\n<override>");
- builder.append(mOverride);
- builder.append("</override>\n</brightnessDescriptor>\n");
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- /** @hide */
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- // Tell the concierge to prepare the parcel
- ParcelInfo parcelInfo = Concierge.prepareParcel(dest);
-
- // === BOYSENBERRY ===
- dest.writeInt(mOverride ? 1 : 0);
- dest.writeInt(mValue);
- dest.writeInt(mDirty ? 1 : 0);
-
- // Complete the parcel info for the concierge
- parcelInfo.complete();
- }
-
- /** @hide */
- public void readFromParcel(Parcel in) {
- // Read parcelable version via the Concierge
- ParcelInfo parcelInfo = Concierge.receiveParcel(in);
- int parcelableVersion = parcelInfo.getParcelVersion();
-
- // Pattern here is that all new members should be added to the end of
- // the writeToParcel method. Then we step through each version, until the latest
- // API release to help unravel this parcel
- if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) {
- mOverride = in.readInt() != 0;
- mValue = in.readInt();
- mDirty = in.readInt() != 0;
- }
-
- // Complete parcel info for the concierge
- parcelInfo.complete();
- }
-}
diff --git a/src/java/cyanogenmod/profiles/ConnectionSettings.java b/src/java/cyanogenmod/profiles/ConnectionSettings.java
deleted file mode 100644
index 19954dd..0000000
--- a/src/java/cyanogenmod/profiles/ConnectionSettings.java
+++ /dev/null
@@ -1,475 +0,0 @@
-/*
- * Copyright (C) 2015 The CyanogenMod 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 cyanogenmod.profiles;
-
-import android.bluetooth.BluetoothAdapter;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.Intent;
-import android.location.LocationManager;
-import android.net.wifi.WifiManager;
-import android.net.wimax.WimaxHelper;
-import android.nfc.NfcAdapter;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.provider.Settings;
-import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
-import com.android.internal.telephony.RILConstants;
-
-import cyanogenmod.os.Build;
-import cyanogenmod.os.Concierge;
-import cyanogenmod.os.Concierge.ParcelInfo;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-
-/**
- * The {@link ConnectionSettings} class allows for creating Network/Hardware overrides
- * depending on their capabilities.
- *
- * <p>Example for enabling/disabling sync settings:
- * <pre class="prettyprint">
- * ConnectionSettings connectionSettings =
- * new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_SYNC,
- * shouldBeEnabled() ?
- * {@link BooleanState#STATE_ENABLED} : {@link BooleanState#STATE_DISALED},
- * true)
- * profile.setConnectionSettings(connectionSettings);
- * </pre>
- */
-public final class ConnectionSettings implements Parcelable {
-
- private int mConnectionId;
- private int mValue;
- private boolean mOverride;
- private boolean mDirty;
-
- /**
- * For use with {@link #PROFILE_CONNECTION_2G3G4G} to determine what subscription to control.
- */
- private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
-
- /**
- * The {@link #PROFILE_CONNECTION_MOBILEDATA} allows for enabling and disabling the mobile
- * data connection. Boolean connection settings {@link BooleanState}
- */
- public static final int PROFILE_CONNECTION_MOBILEDATA = 0;
-
- /**
- * The {@link #PROFILE_CONNECTION_WIFI} allows for enabling and disabling the WiFi connection
- * on the device. Boolean connection settings {@link BooleanState}
- */
- public static final int PROFILE_CONNECTION_WIFI = 1;
-
- /**
- * The {@link #PROFILE_CONNECTION_WIFIAP} allows for enabling and disabling the WiFi hotspot
- * on the device. Boolean connection settings {@link BooleanState}
- */
- public static final int PROFILE_CONNECTION_WIFIAP = 2;
-
- /**
- * The {@link #PROFILE_CONNECTION_WIMAX} allows for enabling and disabling the WIMAX radio (if exists)
- * on the device. Boolean connection settings {@link BooleanState}
- */
- public static final int PROFILE_CONNECTION_WIMAX = 3;
-
- /**
- * The {@link #PROFILE_CONNECTION_GPS} allows for enabling and disabling the GPS radio (if exists)
- * on the device. Boolean connection settings {@link BooleanState}
- */
- public static final int PROFILE_CONNECTION_GPS = 4;
-
- /**
- * The {@link #PROFILE_CONNECTION_SYNC} allows for enabling and disabling the global sync state
- * on the device. Boolean connection settings {@link BooleanState}
- */
- public static final int PROFILE_CONNECTION_SYNC = 5;
-
- /**
- * The {@link #PROFILE_CONNECTION_BLUETOOTH} allows for enabling and disabling the Bluetooth device
- * (if exists) on the device. Boolean connection settings {@link BooleanState}
- */
- public static final int PROFILE_CONNECTION_BLUETOOTH = 7;
-
- /**
- * The {@link #PROFILE_CONNECTION_NFC} allows for enabling and disabling the NFC device
- * (if exists) on the device. Boolean connection settings {@link BooleanState}
- */
- public static final int PROFILE_CONNECTION_NFC = 8;
-
- /**
- * The {@link #PROFILE_CONNECTION_2G3G4G} allows for flipping between 2G/3G/4G (if exists)
- * on the device.
- */
- public static final int PROFILE_CONNECTION_2G3G4G = 9;
-
- // retrieved from Phone.apk
- private static final String ACTION_MODIFY_NETWORK_MODE =
- "com.android.internal.telephony.MODIFY_NETWORK_MODE";
- private static final String EXTRA_NETWORK_MODE = "networkMode";
- private static final String EXTRA_SUB_ID = "subId";
-
- /**
- * BooleanStates for specific {@link ConnectionSettings}
- */
- public static class BooleanState {
- /** Disabled state */
- public static final int STATE_DISALED = 0;
- /** Enabled state */
- public static final int STATE_ENABLED = 1;
- }
-
- private static final int CM_MODE_2G = 0;
- private static final int CM_MODE_3G = 1;
- private static final int CM_MODE_4G = 2;
- private static final int CM_MODE_2G3G = 3;
- private static final int CM_MODE_ALL = 4;
-
- /** @hide */
- public static final Parcelable.Creator<ConnectionSettings> CREATOR =
- new Parcelable.Creator<ConnectionSettings>() {
- public ConnectionSettings createFromParcel(Parcel in) {
- return new ConnectionSettings(in);
- }
-
- @Override
- public ConnectionSettings[] newArray(int size) {
- return new ConnectionSettings[size];
- }
- };
-
- /**
- * Unwrap {@link ConnectionSettings} from a parcel.
- * @param parcel
- */
- public ConnectionSettings(Parcel parcel) {
- readFromParcel(parcel);
- }
-
- /**
- * Construct a {@link ConnectionSettings} with a connection id and default states.
- * @param connectionId ex: #PROFILE_CONNECTION_NFC
- */
- public ConnectionSettings(int connectionId) {
- this(connectionId, 0, false);
- }
-
- /**
- * Construct a {@link ConnectionSettings} with a connection id, default value
- * {@see BooleanState}, and if the setting should override the user defaults.
- * @param connectionId an identifier for the ConnectionSettings (ex:#PROFILE_CONNECTION_WIFI)
- * @param value default value for the ConnectionSettings (ex:{@link BooleanState#STATE_ENABLED})
- * @param override whether or not the {@link ConnectionSettings} should override user defaults
- */
- public ConnectionSettings(int connectionId, int value, boolean override) {
- mConnectionId = connectionId;
- mValue = value;
- mOverride = override;
- mDirty = false;
- }
-
- /**
- * Retrieve the connection id associated with the {@link ConnectionSettings}
- * @return an integer identifier
- */
- public int getConnectionId() {
- return mConnectionId;
- }
-
- /**
- * Get the default value for the {@link ConnectionSettings}
- * @return integer value corresponding with its state
- */
- public int getValue() {
- return mValue;
- }
-
- /**
- * Set the default value for the {@link ConnectionSettings}
- * @param value {@link BooleanState}
- */
- public void setValue(int value) {
- mValue = value;
- mDirty = true;
- }
-
- /**
- * Set whether or not the {@link ConnectionSettings} should override default user values
- * @param override boolean override
- */
- public void setOverride(boolean override) {
- mOverride = override;
- mDirty = true;
- }
-
- public void setSubId(int subId) {
- mSubId = subId;
- mDirty = true;
- }
-
- /**
- * Check whether or not the {@link ConnectionSettings} overrides user settings.
- * @return true if override
- */
- public boolean isOverride() {
- return mOverride;
- }
-
- /**
- * Get the subscription id which this {@link ConnectionSettings} should apply to.
- * @return
- */
- public int getSubId() {
- return mSubId;
- }
-
- /** @hide */
- public boolean isDirty() {
- return mDirty;
- }
-
- /** @hide */
- public void processOverride(Context context) {
- BluetoothAdapter bta = BluetoothAdapter.getDefaultAdapter();
- LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
- WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
- TelephonyManager tm = (TelephonyManager)
- context.getSystemService(Context.TELEPHONY_SERVICE);
- NfcAdapter nfcAdapter = null;
- try {
- nfcAdapter = NfcAdapter.getNfcAdapter(context);
- } catch (UnsupportedOperationException e) {
- //Nfc not available
- }
-
- boolean forcedState = getValue() == 1;
- boolean currentState;
-
- switch (getConnectionId()) {
- case PROFILE_CONNECTION_MOBILEDATA:
- currentState = tm.getDataEnabled();
- if (forcedState != currentState) {
- int phoneCount = tm.getPhoneCount();
- for (int i = 0; i < phoneCount; i++) {
- Settings.Global.putInt(context.getContentResolver(),
- Settings.Global.MOBILE_DATA + i, (forcedState) ? 1 : 0);
- int[] subId = SubscriptionManager.getSubId(i);
- tm.setDataEnabled(subId[0], forcedState);
- }
- }
- break;
- case PROFILE_CONNECTION_2G3G4G:
- if (Build.CM_VERSION.SDK_INT >= Build.CM_VERSION_CODES.ELDERBERRY) {
- Intent intent = new Intent(ACTION_MODIFY_NETWORK_MODE);
- intent.putExtra(EXTRA_NETWORK_MODE, getValue());
- intent.putExtra(EXTRA_SUB_ID, getSubId());
- context.sendBroadcast(intent, "com.android.phone.CHANGE_NETWORK_MODE");
- } else {
- Intent intent = new Intent(ACTION_MODIFY_NETWORK_MODE);
- switch(getValue()) {
- case CM_MODE_2G:
- intent.putExtra(EXTRA_NETWORK_MODE, RILConstants.NETWORK_MODE_GSM_ONLY);
- break;
- case CM_MODE_3G:
- intent.putExtra(EXTRA_NETWORK_MODE, RILConstants.NETWORK_MODE_WCDMA_ONLY);
- break;
- case CM_MODE_4G:
- intent.putExtra(EXTRA_NETWORK_MODE, RILConstants.NETWORK_MODE_LTE_ONLY);
- break;
- case CM_MODE_2G3G:
- intent.putExtra(EXTRA_NETWORK_MODE, RILConstants.NETWORK_MODE_WCDMA_PREF);
- break;
- case CM_MODE_ALL:
- intent.putExtra(EXTRA_NETWORK_MODE,
- RILConstants.NETWORK_MODE_LTE_GSM_WCDMA);
- break;
- default:
- return;
- }
- context.sendBroadcast(intent);
- }
- break;
- case PROFILE_CONNECTION_BLUETOOTH:
- int btstate = bta.getState();
- if (forcedState && (btstate == BluetoothAdapter.STATE_OFF
- || btstate == BluetoothAdapter.STATE_TURNING_OFF)) {
- bta.enable();
- } else if (!forcedState && (btstate == BluetoothAdapter.STATE_ON
- || btstate == BluetoothAdapter.STATE_TURNING_ON)) {
- bta.disable();
- }
- break;
- case PROFILE_CONNECTION_GPS:
- currentState = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
- if (currentState != forcedState) {
- Settings.Secure.setLocationProviderEnabled(context.getContentResolver(),
- LocationManager.GPS_PROVIDER, forcedState);
- }
- break;
- case PROFILE_CONNECTION_SYNC:
- currentState = ContentResolver.getMasterSyncAutomatically();
- if (forcedState != currentState) {
- ContentResolver.setMasterSyncAutomatically(forcedState);
- }
- break;
- case PROFILE_CONNECTION_WIFI:
- int wifiApState = wm.getWifiApState();
- currentState = wm.isWifiEnabled();
- if (currentState != forcedState) {
- // Disable wifi tether
- if (forcedState && (wifiApState == WifiManager.WIFI_AP_STATE_ENABLING) ||
- (wifiApState == WifiManager.WIFI_AP_STATE_ENABLED)) {
- wm.setWifiApEnabled(null, false);
- }
- wm.setWifiEnabled(forcedState);
- }
- break;
- case PROFILE_CONNECTION_WIFIAP:
- int wifiState = wm.getWifiState();
- currentState = wm.isWifiApEnabled();
- if (currentState != forcedState) {
- // Disable wifi
- if (forcedState && (wifiState == WifiManager.WIFI_STATE_ENABLING) ||
- (wifiState == WifiManager.WIFI_STATE_ENABLED)) {
- wm.setWifiEnabled(false);
- }
- wm.setWifiApEnabled(null, forcedState);
- }
- break;
- case PROFILE_CONNECTION_WIMAX:
- if (WimaxHelper.isWimaxSupported(context)) {
- currentState = WimaxHelper.isWimaxEnabled(context);
- if (currentState != forcedState) {
- WimaxHelper.setWimaxEnabled(context, forcedState);
- }
- }
- break;
- case PROFILE_CONNECTION_NFC:
- if (nfcAdapter != null) {
- int adapterState = nfcAdapter.getAdapterState();
- currentState = (adapterState == NfcAdapter.STATE_ON ||
- adapterState == NfcAdapter.STATE_TURNING_ON);
- if (currentState != forcedState) {
- if (forcedState) {
- nfcAdapter.enable();
- } else if (!forcedState && adapterState != NfcAdapter.STATE_TURNING_OFF) {
- nfcAdapter.disable();
- }
- }
- }
- break;
- }
- }
-
- /** @hide */
- public static ConnectionSettings fromXml(XmlPullParser xpp, Context context)
- throws XmlPullParserException, IOException {
- int event = xpp.next();
- ConnectionSettings connectionDescriptor = new ConnectionSettings(0);
- while (event != XmlPullParser.END_TAG || !xpp.getName().equals("connectionDescriptor")) {
- if (event == XmlPullParser.START_TAG) {
- String name = xpp.getName();
- if (name.equals("connectionId")) {
- connectionDescriptor.mConnectionId = Integer.parseInt(xpp.nextText());
- } else if (name.equals("value")) {
- connectionDescriptor.mValue = Integer.parseInt(xpp.nextText());
- } else if (name.equals("override")) {
- connectionDescriptor.mOverride = Boolean.parseBoolean(xpp.nextText());
- } else if (name.equals("subId")) {
- connectionDescriptor.mSubId = Integer.parseInt(xpp.nextText());
- }
- } else if (event == XmlPullParser.END_DOCUMENT) {
- throw new IOException("Premature end of file while parsing connection settings");
- }
- event = xpp.next();
- }
- return connectionDescriptor;
- }
-
- /** @hide */
- public void getXmlString(StringBuilder builder, Context context) {
- builder.append("<connectionDescriptor>\n<connectionId>");
- builder.append(mConnectionId);
- builder.append("</connectionId>\n<value>");
- builder.append(mValue);
- builder.append("</value>\n<override>");
- builder.append(mOverride);
- builder.append("</override>\n");
- if (Build.CM_VERSION.SDK_INT >= Build.CM_VERSION_CODES.ELDERBERRY) {
- if (mConnectionId == PROFILE_CONNECTION_2G3G4G
- && mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
- builder.append("<subId>").append(mSubId).append("</subId>\n");
- }
- }
- builder.append("</connectionDescriptor>\n");
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- /** @hide */
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- // Tell the concierge to prepare the parcel
- ParcelInfo parcelInfo = Concierge.prepareParcel(dest);
-
- // === BOYSENBERRY ===
- dest.writeInt(mConnectionId);
- dest.writeInt(mOverride ? 1 : 0);
- dest.writeInt(mValue);
- dest.writeInt(mDirty ? 1 : 0);
-
- // === ELDERBERRY ===
- if (mConnectionId == PROFILE_CONNECTION_2G3G4G) {
- dest.writeInt(mSubId);
- }
-
- // Complete the parcel info for the concierge
- parcelInfo.complete();
- }
-
- /** @hide */
- public void readFromParcel(Parcel in) {
- // Read parcelable version via the Concierge
- ParcelInfo parcelInfo = Concierge.receiveParcel(in);
- int parcelableVersion = parcelInfo.getParcelVersion();
-
- // Pattern here is that all new members should be added to the end of
- // the writeToParcel method. Then we step through each version, until the latest
- // API release to help unravel this parcel
- if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) {
- mConnectionId = in.readInt();
- mOverride = in.readInt() != 0;
- mValue = in.readInt();
- mDirty = in.readInt() != 0;
- }
-
- if (parcelableVersion >= Build.CM_VERSION_CODES.ELDERBERRY) {
- if (mConnectionId == PROFILE_CONNECTION_2G3G4G) {
- mSubId = in.readInt();
- }
- }
-
- // Complete parcel info for the concierge
- parcelInfo.complete();
- }
-}
diff --git a/src/java/cyanogenmod/profiles/LockSettings.java b/src/java/cyanogenmod/profiles/LockSettings.java
deleted file mode 100644
index 2be3725..0000000
--- a/src/java/cyanogenmod/profiles/LockSettings.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (C) 2015 The CyanogenMod 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 cyanogenmod.profiles;
-
-import android.app.admin.DevicePolicyManager;
-import android.content.Context;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.os.RemoteException;
-import android.util.Log;
-/* import android.view.WindowManagerPolicyControl; */
-import com.android.internal.policy.IKeyguardService;
-/* import com.android.internal.policy.PolicyManager; */
-
-import cyanogenmod.app.Profile;
-import cyanogenmod.os.Build;
-import cyanogenmod.os.Concierge;
-import cyanogenmod.os.Concierge.ParcelInfo;
-
-/**
- * The {@link LockSettings} class allows for overriding and setting the
- * current Lock screen state/security level. Value should be one a constant from
- * of {@link Profile.LockMode}
- *
- * <p>Example for disabling lockscreen security:
- * <pre class="prettyprint">
- * LockSettings lock = new LockSettings(Profile.LockMode.INSECURE);
- * profile.setScreenLockMode(lock);
- * </pre>
- */
-public final class LockSettings implements Parcelable {
-
- private static final String TAG = LockSettings.class.getSimpleName();
-
- private int mValue;
- private boolean mDirty;
-
- /** @hide */
- public static final Creator<LockSettings> CREATOR
- = new Creator<LockSettings>() {
- public LockSettings createFromParcel(Parcel in) {
- return new LockSettings(in);
- }
-
- @Override
- public LockSettings[] newArray(int size) {
- return new LockSettings[size];
- }
- };
-
- /**
- * Unwrap {@link LockSettings} from a parcel.
- * @param parcel
- */
- public LockSettings(Parcel parcel) {
- readFromParcel(parcel);
- }
-
- /**
- * Construct a {@link LockSettings} with a default value of {@link Profile.LockMode.DEFAULT}.
- */
- public LockSettings() {
- this(Profile.LockMode.DEFAULT);
- }
-
- /**
- * Construct a {@link LockSettings} with a default value.
- */
- public LockSettings(int value) {
- mValue = value;
- mDirty = false;
- }
-
- /**
- * Get the value for the {@link LockSettings}
- * @return a constant from {@link Profile.LockMode}
- */
- public int getValue() {
- return mValue;
- }
-
- /**
- * Set the value for the {@link LockSettings}
- *
- * see {@link Profile.LockMode}
- */
- public void setValue(int value) {
- mValue = value;
- mDirty = true;
- }
-
- /** @hide */
- public boolean isDirty() {
- return mDirty;
- }
-
- /** @hide */
- public void processOverride(Context context, IKeyguardService keyguard) {
- boolean enable;
- final DevicePolicyManager devicePolicyManager =
- (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
- if (devicePolicyManager != null && devicePolicyManager.requireSecureKeyguard()) {
- enable = true;
- } else {
- switch (mValue) {
- default:
- case Profile.LockMode.DEFAULT:
- case Profile.LockMode.INSECURE:
- enable = true;
- break;
- case Profile.LockMode.DISABLE:
- enable = false;
- break;
- }
- }
-
- try {
- keyguard.setKeyguardEnabled(enable);
- } catch (RemoteException e) {
- Log.w(TAG, "unable to set keyguard enabled state to: " + enable, e);
- }
- }
-
- /** @hide */
- public void writeXmlString(StringBuilder builder, Context context) {
- builder.append(mValue);
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- /** @hide */
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- // Tell the concierge to prepare the parcel
- ParcelInfo parcelInfo = Concierge.prepareParcel(dest);
-
- // === BOYSENBERRY ===
- dest.writeInt(mValue);
- dest.writeInt(mDirty ? 1 : 0);
-
- // Complete the parcel info for the concierge
- parcelInfo.complete();
- }
-
- /** @hide */
- public void readFromParcel(Parcel in) {
- // Read parcelable version via the Concierge
- ParcelInfo parcelInfo = Concierge.receiveParcel(in);
- int parcelableVersion = parcelInfo.getParcelVersion();
-
- // Pattern here is that all new members should be added to the end of
- // the writeToParcel method. Then we step through each version, until the latest
- // API release to help unravel this parcel
- if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) {
- mValue = in.readInt();
- mDirty = in.readInt() != 0;
- }
-
- // Complete parcel info for the concierge
- parcelInfo.complete();
- }
-}
diff --git a/src/java/cyanogenmod/profiles/RingModeSettings.java b/src/java/cyanogenmod/profiles/RingModeSettings.java
deleted file mode 100644
index bab74ac..0000000
--- a/src/java/cyanogenmod/profiles/RingModeSettings.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (C) 2015 The CyanogenMod 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 cyanogenmod.profiles;
-
-import android.content.Context;
-import android.media.AudioManager;
-import android.os.Parcel;
-import android.os.Parcelable;
-
-import cyanogenmod.os.Build;
-import cyanogenmod.os.Concierge;
-import cyanogenmod.os.Concierge.ParcelInfo;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-
-/**
- * The {@link StreamSettings} class allows for creating various {@link android.media.AudioManager}
- * overrides on the device depending on their capabilities.
- *
- * <p>Example for setting the default ring mode to muted:
- * <pre class="prettyprint">
- * RingModeSettings ringSettings = new RingModeSettings(RING_MODE_MUTE, true));
- * profile.setRingMode(ringSettings);
- * </pre>
- */
-public final class RingModeSettings implements Parcelable {
- public static final String RING_MODE_NORMAL = "normal";
- public static final String RING_MODE_VIBRATE = "vibrate";
- public static final String RING_MODE_MUTE = "mute";
-
- private String mValue;
- private boolean mOverride;
- private boolean mDirty;
-
- /** @hide */
- public static final Parcelable.Creator<RingModeSettings> CREATOR
- = new Parcelable.Creator<RingModeSettings>() {
- public RingModeSettings createFromParcel(Parcel in) {
- return new RingModeSettings(in);
- }
-
- @Override
- public RingModeSettings[] newArray(int size) {
- return new RingModeSettings[size];
- }
- };
-
- /**
- * Unwrap {@link RingModeSettings} from a parcel.
- * @param parcel
- */
- public RingModeSettings(Parcel parcel) {
- readFromParcel(parcel);
- }
-
- /**
- * Construct a {@link RingModeSettings} with a default state of #RING_MODE_NORMAL.
- */
- public RingModeSettings() {
- this(RING_MODE_NORMAL, false);
- }
-
- /**
- * Construct a {@link RingModeSettings} with a default value and whether or not it should
- * override user settings.
- * @param value ex: {@link #RING_MODE_VIBRATE}
- * @param override whether or not the setting should override user settings
- */
- public RingModeSettings(String value, boolean override) {
- mValue = value;
- mOverride = override;
- mDirty = false;
- }
-
- /**
- * Get the default value for the {@link RingModeSettings}
- * @return integer value corresponding with its type
- */
- public String getValue() {
- return mValue;
- }
-
- /**
- * Set the default value for the {@link RingModeSettings}
- * @param value ex: {@link #RING_MODE_VIBRATE}
- */
- public void setValue(String value) {
- mValue = value;
- mDirty = true;
- }
-
- /**
- * Set whether or not the {@link RingModeSettings} should override default user values
- * @param override boolean override
- */
- public void setOverride(boolean override) {
- mOverride = override;
- mDirty = true;
- }
-
- /**
- * Check whether or not the {@link RingModeSettings} overrides user settings.
- * @return true if override
- */
- public boolean isOverride() {
- return mOverride;
- }
-
- /** @hide */
- public boolean isDirty() {
- return mDirty;
- }
-
- /** @hide */
- public void processOverride(Context context) {
- if (isOverride()) {
- int ringerMode = AudioManager.RINGER_MODE_NORMAL;
- if (mValue.equals(RING_MODE_MUTE)) {
- ringerMode = AudioManager.RINGER_MODE_SILENT;
- } else if (mValue.equals(RING_MODE_VIBRATE)) {
- ringerMode = AudioManager.RINGER_MODE_VIBRATE;
- }
- AudioManager amgr = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
- amgr.setRingerModeInternal(ringerMode);
- }
- }
-
- /** @hide */
- public static RingModeSettings fromXml(XmlPullParser xpp, Context context)
- throws XmlPullParserException, IOException {
- int event = xpp.next();
- RingModeSettings ringModeDescriptor = new RingModeSettings();
- while ((event != XmlPullParser.END_TAG && event != XmlPullParser.END_DOCUMENT) ||
- !xpp.getName().equals("ringModeDescriptor")) {
- if (event == XmlPullParser.START_TAG) {
- String name = xpp.getName();
- if (name.equals("value")) {
- ringModeDescriptor.mValue = xpp.nextText();
- } else if (name.equals("override")) {
- ringModeDescriptor.mOverride = Boolean.parseBoolean(xpp.nextText());
- }
- } else if (event == XmlPullParser.END_DOCUMENT) {
- throw new IOException("Premature end of file while parsing ring mode settings");
- }
- event = xpp.next();
- }
- return ringModeDescriptor;
- }
-
- /** @hide */
- public void getXmlString(StringBuilder builder, Context context) {
- builder.append("<ringModeDescriptor>\n<value>");
- builder.append(mValue);
- builder.append("</value>\n<override>");
- builder.append(mOverride);
- builder.append("</override>\n</ringModeDescriptor>\n");
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- /** @hide */
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- // Tell the concierge to prepare the parcel
- ParcelInfo parcelInfo = Concierge.prepareParcel(dest);
-
- // === BOYSENBERRY ===
- dest.writeInt(mOverride ? 1 : 0);
- dest.writeString(mValue);
- dest.writeInt(mDirty ? 1 : 0);
-
- // Complete the parcel info for the concierge
- parcelInfo.complete();
- }
-
- /** @hide */
- public void readFromParcel(Parcel in) {
- // Read parcelable version via the Concierge
- ParcelInfo parcelInfo = Concierge.receiveParcel(in);
- int parcelableVersion = parcelInfo.getParcelVersion();
-
- // Pattern here is that all new members should be added to the end of
- // the writeToParcel method. Then we step through each version, until the latest
- // API release to help unravel this parcel
- if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) {
- mOverride = in.readInt() != 0;
- mValue = in.readString();
- mDirty = in.readInt() != 0;
- }
-
- // Complete parcel info for the concierge
- parcelInfo.complete();
- }
-}
diff --git a/src/java/cyanogenmod/profiles/StreamSettings.java b/src/java/cyanogenmod/profiles/StreamSettings.java
deleted file mode 100644
index 9ce9415..0000000
--- a/src/java/cyanogenmod/profiles/StreamSettings.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (C) 2015 The CyanogenMod 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 cyanogenmod.profiles;
-
-import android.content.Context;
-import android.os.Parcel;
-import android.os.Parcelable;
-
-
-import cyanogenmod.os.Build;
-import cyanogenmod.os.Concierge;
-import cyanogenmod.os.Concierge.ParcelInfo;
-
-import java.io.IOException;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-/**
- * The {@link StreamSettings} class allows for creating various {@link android.media.AudioManager}
- * overrides on the device depending on their capabilities.
- *
- * <p>Example for setting the alarm stream defaults and override:
- * <pre class="prettyprint">
- * StreamSettings alarmStreamSettings = new StreamSettings(AudioManager.STREAM_ALARM,
- * am.getStreamVolume(AudioManager.STREAM_ALARM), true));
- * profile.setStreamSettings(alarmStreamSettings);
- * </pre>
- */
-public final class StreamSettings implements Parcelable{
-
- private int mStreamId;
- private int mValue;
- private boolean mOverride;
- private boolean mDirty;
-
- /** @hide */
- public static final Parcelable.Creator<StreamSettings> CREATOR =
- new Parcelable.Creator<StreamSettings>() {
- public StreamSettings createFromParcel(Parcel in) {
- return new StreamSettings(in);
- }
-
- @Override
- public StreamSettings[] newArray(int size) {
- return new StreamSettings[size];
- }
- };
-
- /**
- * Unwrap {@link StreamSettings} from a parcel.
- * @param parcel
- */
- public StreamSettings(Parcel parcel) {
- readFromParcel(parcel);
- }
-
- /**
- * Construct a {@link StreamSettings} with a stream id and default states.
- * @param streamId ex: {@link android.media.AudioManager#STREAM_ALARM}
- */
- public StreamSettings(int streamId) {
- this(streamId, 0, false);
- }
-
- /**
- * Construct a {@link StreamSettings} with a stream id, default value,
- * and if the setting should override the user defaults.
- * @param streamId ex: {@link android.media.AudioManager#STREAM_ALARM}
- * @param value default value for the {@link StreamSettings}
- * @param override whether or not the {@link StreamSettings} should override user defaults
- */
- public StreamSettings(int streamId, int value, boolean override) {
- mStreamId = streamId;
- mValue = value;
- mOverride = override;
- mDirty = false;
- }
-
- /**
- * Retrieve the stream id id associated with the {@link StreamSettings}
- * @return an integer identifier
- */
- public int getStreamId() {
- return mStreamId;
- }
-
- /**
- * Get the default value for the {@link StreamSettings}
- * @return integer value corresponding with its state
- */
- public int getValue() {
- return mValue;
- }
-
- /**
- * Set the default value for the {@link StreamSettings}
- * @param value see {@link android.media.AudioManager} for viable values
- */
- public void setValue(int value) {
- mValue = value;
- mDirty = true;
- }
-
- /**
- * Set whether or not the {@link StreamSettings} should override default user values
- * @param override boolean override
- */
- public void setOverride(boolean override) {
- mOverride = override;
- mDirty = true;
- }
-
- /**
- * Check whether or not the {@link StreamSettings} overrides user settings.
- * @return true if override
- */
- public boolean isOverride() {
- return mOverride;
- }
-
- /** @hide */
- public boolean isDirty() {
- return mDirty;
- }
-
- /** @hide */
- public static StreamSettings fromXml(XmlPullParser xpp, Context context)
- throws XmlPullParserException, IOException {
- int event = xpp.next();
- StreamSettings streamDescriptor = new StreamSettings(0);
- while (event != XmlPullParser.END_TAG || !xpp.getName().equals("streamDescriptor")) {
- if (event == XmlPullParser.START_TAG) {
- String name = xpp.getName();
- if (name.equals("streamId")) {
- streamDescriptor.mStreamId = Integer.parseInt(xpp.nextText());
- } else if (name.equals("value")) {
- streamDescriptor.mValue = Integer.parseInt(xpp.nextText());
- } else if (name.equals("override")) {
- streamDescriptor.mOverride = Boolean.parseBoolean(xpp.nextText());
- }
- } else if (event == XmlPullParser.END_DOCUMENT) {
- throw new IOException("Premature end of file while parsing stream settings");
- }
- event = xpp.next();
- }
- return streamDescriptor;
- }
-
- /** @hide */
- public void getXmlString(StringBuilder builder, Context context) {
- builder.append("<streamDescriptor>\n<streamId>");
- builder.append(mStreamId);
- builder.append("</streamId>\n<value>");
- builder.append(mValue);
- builder.append("</value>\n<override>");
- builder.append(mOverride);
- builder.append("</override>\n</streamDescriptor>\n");
- mDirty = false;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- /** @hide */
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- // Tell the concierge to prepare the parcel
- ParcelInfo parcelInfo = Concierge.prepareParcel(dest);
-
- // === BOYSENBERRY ===
- dest.writeInt(mStreamId);
- dest.writeInt(mOverride ? 1 : 0);
- dest.writeInt(mValue);
- dest.writeInt(mDirty ? 1 : 0);
-
- // Complete the parcel info for the concierge
- parcelInfo.complete();
- }
-
- /** @hide */
- public void readFromParcel(Parcel in) {
- // Read parcelable version via the Concierge
- ParcelInfo parcelInfo = Concierge.receiveParcel(in);
- int parcelableVersion = parcelInfo.getParcelVersion();
-
- // Pattern here is that all new members should be added to the end of
- // the writeToParcel method. Then we step through each version, until the latest
- // API release to help unravel this parcel
- if (parcelableVersion >= Build.CM_VERSION_CODES.BOYSENBERRY) {
- mStreamId = in.readInt();
- mOverride = in.readInt() != 0;
- mValue = in.readInt();
- mDirty = in.readInt() != 0;
- }
-
- // Complete parcel info for the concierge
- parcelInfo.complete();
- }
-}