sdk: Get rid of lineageos.os.{Build,Concierge}

Change-Id: I7b781deb1330810caa193b822bcc02b9610e53b0
This commit is contained in:
Michael Bestas
2025-02-10 18:07:37 +02:00
parent cc0d50aac5
commit b9be94a473
13 changed files with 124 additions and 774 deletions

169
sdk/src/java/lineageos/app/Profile.java Executable file → Normal file
View File

@@ -1,5 +1,6 @@
/*
* SPDX-FileCopyrightText: 2015 The CyanogenMod Project
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
@@ -16,7 +17,7 @@ import android.text.TextUtils;
import android.util.Log;
import com.android.internal.policy.IKeyguardService;
import lineageos.os.Build;
import lineageos.profiles.AirplaneModeSettings;
import lineageos.profiles.BrightnessSettings;
import lineageos.profiles.ConnectionSettings;
@@ -24,9 +25,6 @@ import lineageos.profiles.LockSettings;
import lineageos.profiles.RingModeSettings;
import lineageos.profiles.StreamSettings;
import lineageos.os.Concierge;
import lineageos.os.Concierge.ParcelInfo;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -204,36 +202,18 @@ public final class Profile implements Parcelable, Comparable {
}
private ProfileTrigger(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.LINEAGE_VERSION_CODES.BOYSENBERRY) {
mType = in.readInt();
mId = in.readString();
mState = in.readInt();
mName = in.readString();
}
// Complete parcel info for the concierge
parcelInfo.complete();
mType = in.readInt();
mId = in.readString();
mState = in.readInt();
mName = in.readString();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
// Tell the concierge to prepare the parcel
ParcelInfo parcelInfo = Concierge.prepareParcel(dest);
dest.writeInt(mType);
dest.writeString(mId);
dest.writeInt(mState);
dest.writeString(mName);
// Complete the parcel info for the concierge
parcelInfo.complete();
}
@Override
@@ -513,10 +493,6 @@ public final class Profile implements Parcelable, Comparable {
/** @hide */
@Override
public void writeToParcel(Parcel dest, int flags) {
// Tell the concierge to prepare the parcel
ParcelInfo parcelInfo = Concierge.prepareParcel(dest);
// === BOYSENBERRY ===
if (!TextUtils.isEmpty(mName)) {
dest.writeInt(1);
dest.writeString(mName);
@@ -595,8 +571,6 @@ public final class Profile implements Parcelable, Comparable {
}
dest.writeTypedArray(mTriggers.values().toArray(new ProfileTrigger[0]), flags);
dest.writeInt(mDozeMode);
// === ELDERBERRY ===
dest.writeInt(mNotificationLightMode);
if (networkConnectionSubIds != null && !networkConnectionSubIds.isEmpty()) {
@@ -606,88 +580,68 @@ public final class Profile implements Parcelable, Comparable {
} else {
dest.writeInt(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.LINEAGE_VERSION_CODES.BOYSENBERRY) {
if (in.readInt() != 0) {
mName = in.readString();
}
if (in.readInt() != 0) {
mNameResId = in.readInt();
}
if (in.readInt() != 0) {
mUuid = ParcelUuid.CREATOR.createFromParcel(in).getUuid();
}
if (in.readInt() != 0) {
for (Parcelable parcel : in.readParcelableArray(null)) {
ParcelUuid u = (ParcelUuid) parcel;
mSecondaryUuids.add(u.getUuid());
}
}
mStatusBarIndicator = (in.readInt() == 1);
mProfileType = in.readInt();
mDirty = (in.readInt() == 1);
if (in.readInt() != 0) {
for (ProfileGroup group : in.createTypedArray(ProfileGroup.CREATOR)) {
profileGroups.put(group.getUuid(), group);
if (group.isDefaultGroup()) {
mDefaultGroup = group;
}
}
}
if (in.readInt() != 0) {
for (StreamSettings stream : in.createTypedArray(StreamSettings.CREATOR)) {
streams.put(stream.getStreamId(), stream);
}
}
if (in.readInt() != 0) {
for (ConnectionSettings connection :
in.createTypedArray(ConnectionSettings.CREATOR)) {
connections.put(connection.getConnectionId(), connection);
}
}
if (in.readInt() != 0) {
mRingMode = RingModeSettings.CREATOR.createFromParcel(in);
}
if (in.readInt() != 0) {
mAirplaneMode = AirplaneModeSettings.CREATOR.createFromParcel(in);
}
if (in.readInt() != 0) {
mBrightness = BrightnessSettings.CREATOR.createFromParcel(in);
}
if (in.readInt() != 0) {
mScreenLockMode = LockSettings.CREATOR.createFromParcel(in);
}
for (ProfileTrigger trigger : in.createTypedArray(ProfileTrigger.CREATOR)) {
mTriggers.put(trigger.mId, trigger);
}
mDozeMode = in.readInt();
if (in.readInt() != 0) {
mName = in.readString();
}
if (parcelableVersion >= Build.LINEAGE_VERSION_CODES.ELDERBERRY) {
mNotificationLightMode = in.readInt();
if (in.readInt() != 0) {
for (ConnectionSettings connection :
in.createTypedArray(ConnectionSettings.CREATOR)) {
// elderberry can do msim connections
networkConnectionSubIds.put(connection.getSubId(), connection);
if (in.readInt() != 0) {
mNameResId = in.readInt();
}
if (in.readInt() != 0) {
mUuid = ParcelUuid.CREATOR.createFromParcel(in).getUuid();
}
if (in.readInt() != 0) {
for (Parcelable parcel : in.readParcelableArray(null)) {
ParcelUuid u = (ParcelUuid) parcel;
mSecondaryUuids.add(u.getUuid());
}
}
mStatusBarIndicator = (in.readInt() == 1);
mProfileType = in.readInt();
mDirty = (in.readInt() == 1);
if (in.readInt() != 0) {
for (ProfileGroup group : in.createTypedArray(ProfileGroup.CREATOR)) {
profileGroups.put(group.getUuid(), group);
if (group.isDefaultGroup()) {
mDefaultGroup = group;
}
}
}
// Complete the parcel info for the concierge
parcelInfo.complete();
if (in.readInt() != 0) {
for (StreamSettings stream : in.createTypedArray(StreamSettings.CREATOR)) {
streams.put(stream.getStreamId(), stream);
}
}
if (in.readInt() != 0) {
for (ConnectionSettings connection : in.createTypedArray(ConnectionSettings.CREATOR)) {
connections.put(connection.getConnectionId(), connection);
}
}
if (in.readInt() != 0) {
mRingMode = RingModeSettings.CREATOR.createFromParcel(in);
}
if (in.readInt() != 0) {
mAirplaneMode = AirplaneModeSettings.CREATOR.createFromParcel(in);
}
if (in.readInt() != 0) {
mBrightness = BrightnessSettings.CREATOR.createFromParcel(in);
}
if (in.readInt() != 0) {
mScreenLockMode = LockSettings.CREATOR.createFromParcel(in);
}
for (ProfileTrigger trigger : in.createTypedArray(ProfileTrigger.CREATOR)) {
mTriggers.put(trigger.mId, trigger);
}
mDozeMode = in.readInt();
mNotificationLightMode = in.readInt();
if (in.readInt() != 0) {
for (ConnectionSettings connection : in.createTypedArray(ConnectionSettings.CREATOR)) {
networkConnectionSubIds.put(connection.getSubId(), connection);
}
}
}
/**
@@ -1150,8 +1104,7 @@ public final class Profile implements Parcelable, Comparable {
}
if (name.equals("connectionDescriptor")) {
ConnectionSettings cs = ConnectionSettings.fromXml(xpp, context);
if (Build.LINEAGE_VERSION.SDK_INT >= Build.LINEAGE_VERSION_CODES.ELDERBERRY
&& cs.getConnectionId() == ConnectionSettings.PROFILE_CONNECTION_2G3G4G) {
if (cs.getConnectionId() == ConnectionSettings.PROFILE_CONNECTION_2G3G4G) {
profile.networkConnectionSubIds.put(cs.getSubId(), cs);
} else {
profile.connections.put(cs.getConnectionId(), cs);

View File

@@ -1,5 +1,6 @@
/*
* SPDX-FileCopyrightText: 2015 The CyanogenMod Project
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
@@ -18,11 +19,6 @@ import android.os.ParcelUuid;
import android.text.TextUtils;
import android.util.Log;
import lineageos.os.Build;
import lineageos.os.Concierge;
import lineageos.os.Concierge.ParcelInfo;
import java.io.IOException;
import java.util.UUID;
@@ -258,10 +254,6 @@ public final class ProfileGroup implements Parcelable {
/** @hide */
@Override
public void writeToParcel(Parcel dest, int flags) {
// Tell the concierge to prepare the parcel
ParcelInfo parcelInfo = Concierge.prepareParcel(dest);
// === BOYSENBERRY ===
dest.writeString(mName);
new ParcelUuid(mUuid).writeToParcel(dest, 0);
dest.writeInt(mDefaultGroup ? 1 : 0);
@@ -272,36 +264,21 @@ public final class ProfileGroup implements Parcelable {
dest.writeString(mRingerMode.name());
dest.writeString(mVibrateMode.name());
dest.writeString(mLightsMode.name());
// 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();
mName = in.readString();
mUuid = ParcelUuid.CREATOR.createFromParcel(in).getUuid();
mDefaultGroup = in.readInt() != 0;
mDirty = in.readInt() != 0;
mSoundOverride = in.readParcelable(null);
mRingerOverride = in.readParcelable(null);
// 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.LINEAGE_VERSION_CODES.BOYSENBERRY) {
mName = in.readString();
mUuid = ParcelUuid.CREATOR.createFromParcel(in).getUuid();
mDefaultGroup = in.readInt() != 0;
mDirty = in.readInt() != 0;
mSoundOverride = in.readParcelable(null);
mRingerOverride = in.readParcelable(null);
mSoundMode = Mode.valueOf(Mode.class, in.readString());
mRingerMode = Mode.valueOf(Mode.class, in.readString());
mVibrateMode = Mode.valueOf(Mode.class, in.readString());
mLightsMode = Mode.valueOf(Mode.class, in.readString());
}
// Complete parcel info for the concierge
parcelInfo.complete();
mSoundMode = Mode.valueOf(Mode.class, in.readString());
mRingerMode = Mode.valueOf(Mode.class, in.readString());
mVibrateMode = Mode.valueOf(Mode.class, in.readString());
mLightsMode = Mode.valueOf(Mode.class, in.readString());
}
public enum Mode {

View File

@@ -1,5 +1,6 @@
/*
* SPDX-FileCopyrightText: 2015 The CyanogenMod Project
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
@@ -8,10 +9,6 @@ package lineageos.hardware;
import android.os.Parcel;
import android.os.Parcelable;
import lineageos.os.Build;
import lineageos.os.Concierge;
import lineageos.os.Concierge.ParcelInfo;
/**
* Display Modes API
*
@@ -36,27 +33,8 @@ public class DisplayMode implements Parcelable {
}
private DisplayMode(Parcel parcel) {
// Read parcelable version via the Concierge
ParcelInfo parcelInfo = Concierge.receiveParcel(parcel);
int parcelableVersion = parcelInfo.getParcelVersion();
// temp vars
int tmpId = -1;
String tmpName = null;
if (parcelableVersion >= Build.LINEAGE_VERSION_CODES.BOYSENBERRY) {
tmpId = parcel.readInt();
if (parcel.readInt() != 0) {
tmpName = parcel.readString();
}
}
// set temps
this.id = tmpId;
this.name = tmpName;
// Complete parcel info for the concierge
parcelInfo.complete();
this.id = parcel.readInt();
this.name = parcel.readInt() != 0 ? parcel.readString() : null;
}
@Override
@@ -66,10 +44,6 @@ public class DisplayMode implements Parcelable {
@Override
public void writeToParcel(Parcel out, int flags) {
// Tell the concierge to prepare the parcel
ParcelInfo parcelInfo = Concierge.prepareParcel(out);
// ==== BOYSENBERRY =====
out.writeInt(id);
if (name != null) {
out.writeInt(1);
@@ -77,9 +51,6 @@ public class DisplayMode implements Parcelable {
} else {
out.writeInt(0);
}
// Complete the parcel info for the concierge
parcelInfo.complete();
}
/** @hide */

View File

@@ -1,5 +1,6 @@
/*
* SPDX-FileCopyrightText: 2016 The CyanogenMod Project
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
package lineageos.hardware;
@@ -20,10 +21,6 @@ import java.util.Arrays;
import java.util.BitSet;
import java.util.List;
import lineageos.os.Build;
import lineageos.os.Concierge;
import lineageos.os.Concierge.ParcelInfo;
/**
* Holder class for LiveDisplay static configuration.
*
@@ -83,61 +80,25 @@ public class LiveDisplayConfig implements Parcelable {
}
private LiveDisplayConfig(Parcel parcel) {
// Read parcelable version via the Concierge
ParcelInfo parcelInfo = Concierge.receiveParcel(parcel);
int parcelableVersion = parcelInfo.getParcelVersion();
// temp vars
long capabilities = 0;
int defaultMode = 0;
int defaultDayTemperature = -1;
int defaultNightTemperature = -1;
boolean defaultAutoContrast = false;
boolean defaultAutoOutdoorMode = false;
boolean defaultCABC = false;
boolean defaultColorEnhancement = false;
int minColorTemperature = 0;
int maxColorTemperature = 0;
int minColorBalance = 0;
int maxColorBalance = 0;
float[] paRanges = new float[10];
if (parcelableVersion >= Build.LINEAGE_VERSION_CODES.FIG) {
capabilities = parcel.readLong();
defaultMode = parcel.readInt();
defaultDayTemperature = parcel.readInt();
defaultNightTemperature = parcel.readInt();
defaultAutoContrast = parcel.readInt() == 1;
defaultAutoOutdoorMode = parcel.readInt() == 1;
defaultCABC = parcel.readInt() == 1;
defaultColorEnhancement = parcel.readInt() == 1;
minColorTemperature = parcel.readInt();
maxColorTemperature = parcel.readInt();
minColorBalance = parcel.readInt();
maxColorBalance = parcel.readInt();
parcel.readFloatArray(paRanges);
}
// set temps
mCapabilities = BitSet.valueOf(new long[] { capabilities });
mCapabilities = BitSet.valueOf(new long[] { parcel.readLong() });
mAllModes.set(MODE_FIRST, MODE_LAST);
mDefaultMode = defaultMode;
mDefaultDayTemperature = defaultDayTemperature;
mDefaultNightTemperature = defaultNightTemperature;
mDefaultAutoContrast = defaultAutoContrast;
mDefaultAutoOutdoorMode = defaultAutoOutdoorMode;
mDefaultCABC = defaultCABC;
mDefaultColorEnhancement = defaultColorEnhancement;
mColorTemperatureRange = Range.create(minColorTemperature, maxColorTemperature);
mColorBalanceRange = Range.create(minColorBalance, maxColorBalance);
mDefaultMode = parcel.readInt();
mDefaultDayTemperature = parcel.readInt();
mDefaultNightTemperature = parcel.readInt();
mDefaultAutoContrast = parcel.readInt() == 1;
mDefaultAutoOutdoorMode = parcel.readInt() == 1;
mDefaultCABC = parcel.readInt() == 1;
mDefaultColorEnhancement = parcel.readInt() == 1;
mColorTemperatureRange = Range.create(parcel.readInt(), parcel.readInt());
mColorBalanceRange = Range.create(parcel.readInt(), parcel.readInt());
parcel.readFloatArray(paRanges);
mHueRange = Range.create(paRanges[0], paRanges[1]);
mSaturationRange = Range.create(paRanges[2], paRanges[3]);
mIntensityRange = Range.create(paRanges[4], paRanges[5]);
mContrastRange = Range.create(paRanges[6], paRanges[7]);
mSaturationThresholdRange = Range.create(paRanges[8], paRanges[9]);
// Complete parcel info for the concierge
parcelInfo.complete();
}
@Override
@@ -172,10 +133,6 @@ public class LiveDisplayConfig implements Parcelable {
@Override
public void writeToParcel(Parcel out, int flags) {
// Tell the concierge to prepare the parcel
ParcelInfo parcelInfo = Concierge.prepareParcel(out);
// ==== FIG =====
long[] caps = mCapabilities.toLongArray();
out.writeLong(caps != null && caps.length > 0 ? caps[0] : 0L);
out.writeInt(mDefaultMode);
@@ -195,9 +152,6 @@ public class LiveDisplayConfig implements Parcelable {
mIntensityRange.getLower(), mIntensityRange.getUpper(),
mContrastRange.getLower(), mContrastRange.getUpper(),
mSaturationThresholdRange.getLower(), mSaturationThresholdRange.getUpper() } );
// Complete the parcel info for the concierge
parcelInfo.complete();
}
/**

View File

@@ -1,189 +0,0 @@
/*
* SPDX-FileCopyrightText: 2015 The CyanogenMod Project
* SPDX-License-Identifier: Apache-2.0
*/
package lineageos.os;
import android.os.SystemProperties;
import android.text.TextUtils;
import android.util.SparseArray;
/**
* Information about the current LineageOS build, extracted from system properties.
*/
public class Build {
/** Value used for when a build property is unknown. */
public static final String UNKNOWN = "unknown";
/** A build ID utilized to distinguish lineageos versions */
public static final String LINEAGEOS_VERSION = getString("ro.lineage.version");
/** A build ID string meant for displaying to the user */
public static final String LINEAGEOS_DISPLAY_VERSION = getString("ro.lineage.display.version");
private static final SparseArray<String> sdkMap;
static
{
sdkMap = new SparseArray<String>();
sdkMap.put(LINEAGE_VERSION_CODES.APRICOT, "Apricot");
sdkMap.put(LINEAGE_VERSION_CODES.BOYSENBERRY, "Boysenberry");
sdkMap.put(LINEAGE_VERSION_CODES.CANTALOUPE, "Cantaloupe");
sdkMap.put(LINEAGE_VERSION_CODES.DRAGON_FRUIT, "Dragon Fruit");
sdkMap.put(LINEAGE_VERSION_CODES.ELDERBERRY, "Elderberry");
sdkMap.put(LINEAGE_VERSION_CODES.FIG, "Fig");
sdkMap.put(LINEAGE_VERSION_CODES.GUAVA, "Guava");
sdkMap.put(LINEAGE_VERSION_CODES.HACKBERRY, "Hackberry");
sdkMap.put(LINEAGE_VERSION_CODES.ILAMA, "Ilama");
}
/** Various version strings. */
public static class LINEAGE_VERSION {
/**
* The user-visible SDK version of the framework; its possible
* values are defined in {@link Build.LINEAGE_VERSION_CODES}.
*
* Will return 0 if the device does not support the Lineage SDK.
*/
public static final int SDK_INT = SystemProperties.getInt(
"ro.lineage.build.version.plat.sdk", 0);
}
/**
* Enumeration of the currently known SDK version codes. These are the
* values that can be found in {@link LINEAGE_VERSION#SDK_INT}. Version numbers
* increment monotonically with each official platform release.
*
* To programmatically validate that a given API is available for use on the device,
* you can quickly check if the SDK_INT from the OS is provided and is greater or equal
* to the API level that your application is targeting.
*
* <p>Example for validating that Profiles API is available
* <pre class="prettyprint">
* private void removeActiveProfile() {
* Make sure we're running on BoysenBerry or higher to use Profiles API
* if (Build.LINEAGE_VERSION.SDK_INT >= Build.LINEAGE_VERSION_CODES.BOYSENBERRY) {
* ProfileManager profileManager = ProfileManager.getInstance(this);
* Profile activeProfile = profileManager.getActiveProfile();
* if (activeProfile != null) {
* profileManager.removeProfile(activeProfile);
* }
* }
* }
* </pre>
*/
public static class LINEAGE_VERSION_CODES {
/**
* June 2015: The first version of the platform sdk for CyanogenMod
*/
public static final int APRICOT = 1;
/**
* September 2015: The second version of the platform sdk for CyanogenMod
*
* <p>Applications targeting this or a later release will get these
* new features:</p>
* <ul>
* <li>Profiles API via {@link lineageos.app.ProfileManager}
* <li>Hardware Abstraction Framework Access via
* {@link lineageos.hardware.LineageHardwareManager} (Not for use by 3rd parties)
* <li>Introductory Settings Provider {@link lineageos.providers.LineageSettings}
* </ul>
*/
public static final int BOYSENBERRY = 2;
/**
* November - December 2015: The third iteration of the platform sdk for CyanogenMod
* Transition api level that is mostly 1:1 to {@link #BOYSENBERRY}
*/
public static final int CANTALOUPE = 3;
/**
* January 2016: The 4th iteration of the platform sdk for CyanogenMod
*
* <p>Applications targeting this or a later version will get access to these
* new features:</p>
* <ul>
* <li>Inclusion of the PerformanceManager interfaces, allowing an application to specify
* the type of mode to have the device be placed in via
* {@link lineageos.power.PerformanceManager}</li>
* <li>Numerous new "System" settings exposed via the
* {@link lineageos.providers.LineageSettings.System} interface</li>
* </ul>
*/
public static final int DRAGON_FRUIT = 4;
/**
* April 2016: The 5th iteration of the platform sdk for CyanogenMod
*
* <p>Applications targeting this or a later version will get access to these
* new features!</p>
* <ul>
* <li>Weather request api to fetch weather data from providers on the device
* {@link lineageos.weather.LineageWeatherManager}</li>
* <li>Weather provider api to provide weather data to any listener on the device
* {@link lineageos.weatherservice.WeatherProviderService}</li>
* <li>Parceling helper class {@link lineageos.os.Concierge} to help with parcel
* headers and protocol revisions</li>
* </ul>
*/
public static final int ELDERBERRY = 5;
/**
* August 2016: The 6th iteration of the platform sdk for CyanogenMod
*
* <p>Applications targeting this or a later version will get access to these
* new features!</p>
* <ul>
* <li>Ability to query and color balance ranges from the
* {@link lineageos.hardware.LineageHardwareManager}, as well as do picture adjustment</li>
* <li>Extended capabilities of the LiveDisplay interfaces, now providing
* {@link lineageos.hardware.LiveDisplayConfig} and a dedicated
* {@link lineageos.hardware.LiveDisplayManager}</li>
* <li>Added new settings, such as LOCKSCREEN_ROTATION and DISPLAY_LOW_POWER
* to {@link lineageos.providers.LineageSettings}</li>
* </ul>
*
* Signing out, Adnan \u270C
*/
public static final int FIG = 6;
/**
* January 2017: Unreleased preliminary version starting from CM14
*/
public static final int GUAVA = 7;
/**
* February 2018: Unreleased preliminary version starting from LineageOS 15.1
* <p>Unused APIs have been removed.</p>
*/
public static final int HACKBERRY = 8;
/**
* March 2018: The 1st iteration of the platform sdk for LineageOS
* <p>Applications targeting this or a later version will get access to these
* new features!</p>
* <ul>
* <li>Styles API to customize the system and get customized basing on the system style
* </ul>
*/
public static final int ILAMA = 9;
}
/**
* Retrieve the name for the SDK int
* @param sdkInt
* @return name of the SDK int, {@link #UNKNOWN) if not known
*/
public static String getNameForSDKInt(int sdkInt) {
final String name = sdkMap.get(sdkInt);
if (TextUtils.isEmpty(name)) {
return UNKNOWN;
}
return name;
}
private static String getString(String property) {
return SystemProperties.get(property, UNKNOWN);
}
}

View File

@@ -1,142 +0,0 @@
/*
* SPDX-FileCopyrightText: 2016 The CyanogenMod Project
* SPDX-License-Identifier: Apache-2.0
*/
package lineageos.os;
import android.os.Parcel;
import lineageos.os.Build.LINEAGE_VERSION_CODES;
/**
* Simply, Concierge handles your parcels and makes sure they get marshalled and unmarshalled
* correctly when cross IPC boundaries even when there is a version mismatch between the client
* sdk level and the framework implementation.
*
* <p>On incoming parcel (to be unmarshalled):
*
* <pre class="prettyprint">
* ParcelInfo incomingParcelInfo = Concierge.receiveParcel(incomingParcel);
* int parcelableVersion = incomingParcelInfo.getParcelVersion();
*
* // Do unmarshalling steps here iterating over every plausible version
*
* // Complete the process
* incomingParcelInfo.complete();
* </pre>
*
* <p>On outgoing parcel (to be marshalled):
*
* <pre class="prettyprint">
* ParcelInfo outgoingParcelInfo = Concierge.prepareParcel(incomingParcel);
*
* // Do marshalling steps here iterating over every plausible version
*
* // Complete the process
* outgoingParcelInfo.complete();
* </pre>
*/
public final class Concierge {
/** Not instantiable */
private Concierge() {
// Don't instantiate
}
/**
* Since there might be a case where new versions of the lineage framework use applications running
* old versions of the protocol (and thus old versions of this class), we need a versioning
* system for the parcels sent between the core framework and its sdk users.
*
* This parcelable version should be the latest version API version listed in
* {@link LINEAGE_VERSION_CODES}
* @hide
*/
public static final int PARCELABLE_VERSION = LINEAGE_VERSION_CODES.ILAMA;
/**
* Tell the concierge to receive our parcel, so we can get information from it.
*
* MUST CALL {@link ParcelInfo#complete()} AFTER UNMARSHALLING.
*
* @param parcel Incoming parcel to be unmarshalled
* @return {@link ParcelInfo} containing parcel information, specifically the version.
*/
public static ParcelInfo receiveParcel(Parcel parcel) {
return new ParcelInfo(parcel);
}
/**
* Prepare a parcel for the Concierge.
*
* MUST CALL {@link ParcelInfo#complete()} AFTER MARSHALLING.
*
* @param parcel Outgoing parcel to be marshalled
* @return {@link ParcelInfo} containing parcel information, specifically the version.
*/
public static ParcelInfo prepareParcel(Parcel parcel) {
return new ParcelInfo(parcel, PARCELABLE_VERSION);
}
/**
* Parcel header info specific to the Parcel object that is passed in via
* {@link #prepareParcel(Parcel)} or {@link #receiveParcel(Parcel)}. The exposed method
* of {@link #getParcelVersion()} gets the api level of the parcel object.
*/
public final static class ParcelInfo {
private Parcel mParcel;
private int mParcelableVersion;
private int mParcelableSize;
private int mStartPosition;
private int mSizePosition;
private boolean mCreation = false;
ParcelInfo(Parcel parcel) {
mCreation = false;
mParcel = parcel;
mParcelableVersion = parcel.readInt();
mParcelableSize = parcel.readInt();
mStartPosition = parcel.dataPosition();
}
ParcelInfo(Parcel parcel, int parcelableVersion) {
mCreation = true;
mParcel = parcel;
mParcelableVersion = parcelableVersion;
// Write parcelable version, make sure to define explicit changes
// within {@link #PARCELABLE_VERSION);
mParcel.writeInt(mParcelableVersion);
// Inject a placeholder that will store the parcel size from this point on
// (not including the size itself).
mSizePosition = parcel.dataPosition();
mParcel.writeInt(0);
mStartPosition = parcel.dataPosition();
}
/**
* Get the parcel version from the {@link Parcel} received by the Concierge.
* @return {@link #PARCELABLE_VERSION} of the {@link Parcel}
*/
public int getParcelVersion() {
return mParcelableVersion;
}
/**
* Complete the {@link ParcelInfo} for the Concierge.
*/
public void complete() {
if (mCreation) {
// Go back and write size
mParcelableSize = mParcel.dataPosition() - mStartPosition;
mParcel.setDataPosition(mSizePosition);
mParcel.writeInt(mParcelableSize);
mParcel.setDataPosition(mStartPosition + mParcelableSize);
} else {
mParcel.setDataPosition(mStartPosition + mParcelableSize);
}
}
}
}

View File

@@ -1,6 +1,6 @@
/*
* SPDX-FileCopyrightText: 2015 The CyanogenMod Project
* SPDX-FileCopyrightText: 2020 The LineageOS Project
* SPDX-FileCopyrightText: 2020-2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
@@ -12,14 +12,9 @@ import android.provider.Settings;
import android.os.Parcel;
import android.os.Parcelable;
import lineageos.os.Build;
import lineageos.os.Concierge;
import lineageos.os.Concierge.ParcelInfo;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
/**
@@ -181,34 +176,15 @@ public final class AirplaneModeSettings implements Parcelable {
/** @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.LINEAGE_VERSION_CODES.BOYSENBERRY) {
mOverride = in.readInt() != 0;
mValue = in.readInt();
mDirty = in.readInt() != 0;
}
// Complete parcel info for the concierge
parcelInfo.complete();
mOverride = in.readInt() != 0;
mValue = in.readInt();
mDirty = in.readInt() != 0;
}
}

View File

@@ -1,5 +1,6 @@
/*
* SPDX-FileCopyrightText: 2015 The CyanogenMod Project
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
@@ -10,14 +11,9 @@ import android.provider.Settings;
import android.os.Parcel;
import android.os.Parcelable;
import lineageos.os.Build;
import lineageos.os.Concierge;
import lineageos.os.Concierge.ParcelInfo;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
/**
@@ -178,34 +174,15 @@ public final class BrightnessSettings implements Parcelable {
/** @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.LINEAGE_VERSION_CODES.BOYSENBERRY) {
mOverride = in.readInt() != 0;
mValue = in.readInt();
mDirty = in.readInt() != 0;
}
// Complete parcel info for the concierge
parcelInfo.complete();
mOverride = in.readInt() != 0;
mValue = in.readInt();
mDirty = in.readInt() != 0;
}
}

View File

@@ -1,6 +1,6 @@
/*
* SPDX-FileCopyrightText: 2015 The CyanogenMod Project
* SPDX-FileCopyrightText: 2020-2024 The LineageOS Project
* SPDX-FileCopyrightText: 2020-2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
@@ -24,10 +24,6 @@ import android.telephony.TelephonyManager;
import com.android.internal.telephony.RILConstants;
import lineageos.os.Build;
import lineageos.os.Concierge;
import lineageos.os.Concierge.ParcelInfo;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -271,35 +267,10 @@ public final class ConnectionSettings implements Parcelable {
}
break;
case PROFILE_CONNECTION_2G3G4G:
if (Build.LINEAGE_VERSION.SDK_INT >= Build.LINEAGE_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 LINEAGE_MODE_2G:
intent.putExtra(EXTRA_NETWORK_MODE, RILConstants.NETWORK_MODE_GSM_ONLY);
break;
case LINEAGE_MODE_3G:
intent.putExtra(EXTRA_NETWORK_MODE, RILConstants.NETWORK_MODE_WCDMA_ONLY);
break;
case LINEAGE_MODE_4G:
intent.putExtra(EXTRA_NETWORK_MODE, RILConstants.NETWORK_MODE_LTE_ONLY);
break;
case LINEAGE_MODE_2G3G:
intent.putExtra(EXTRA_NETWORK_MODE, RILConstants.NETWORK_MODE_WCDMA_PREF);
break;
case LINEAGE_MODE_ALL:
intent.putExtra(EXTRA_NETWORK_MODE,
RILConstants.NETWORK_MODE_LTE_GSM_WCDMA);
break;
default:
return;
}
context.sendBroadcast(intent);
}
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");
break;
case PROFILE_CONNECTION_BLUETOOTH:
int btstate = bta.getState();
@@ -399,11 +370,9 @@ public final class ConnectionSettings implements Parcelable {
builder.append("</value>\n<override>");
builder.append(mOverride);
builder.append("</override>\n");
if (Build.LINEAGE_VERSION.SDK_INT >= Build.LINEAGE_VERSION_CODES.ELDERBERRY) {
if (mConnectionId == PROFILE_CONNECTION_2G3G4G
&& mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
builder.append("<subId>").append(mSubId).append("</subId>\n");
}
if (mConnectionId == PROFILE_CONNECTION_2G3G4G
&& mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
builder.append("<subId>").append(mSubId).append("</subId>\n");
}
builder.append("</connectionDescriptor>\n");
}
@@ -416,48 +385,26 @@ public final class ConnectionSettings implements Parcelable {
/** @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();
mConnectionId = in.readInt();
mOverride = in.readInt() != 0;
mValue = in.readInt();
mDirty = in.readInt() != 0;
// 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.LINEAGE_VERSION_CODES.BOYSENBERRY) {
mConnectionId = in.readInt();
mOverride = in.readInt() != 0;
mValue = in.readInt();
mDirty = in.readInt() != 0;
if (mConnectionId == PROFILE_CONNECTION_2G3G4G) {
mSubId = in.readInt();
}
if (parcelableVersion >= Build.LINEAGE_VERSION_CODES.ELDERBERRY) {
if (mConnectionId == PROFILE_CONNECTION_2G3G4G) {
mSubId = in.readInt();
}
}
// Complete parcel info for the concierge
parcelInfo.complete();
}
private static final class OnStartTetheringCallback

View File

@@ -1,5 +1,6 @@
/*
* SPDX-FileCopyrightText: 2015 The CyanogenMod Project
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
@@ -11,14 +12,10 @@ 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 lineageos.app.Profile;
import lineageos.os.Build;
import lineageos.os.Concierge;
import lineageos.os.Concierge.ParcelInfo;
/**
* The {@link LockSettings} class allows for overriding and setting the
@@ -137,32 +134,13 @@ public final class LockSettings implements Parcelable {
/** @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.LINEAGE_VERSION_CODES.BOYSENBERRY) {
mValue = in.readInt();
mDirty = in.readInt() != 0;
}
// Complete parcel info for the concierge
parcelInfo.complete();
mValue = in.readInt();
mDirty = in.readInt() != 0;
}
}

View File

@@ -1,5 +1,6 @@
/*
* SPDX-FileCopyrightText: 2015 The CyanogenMod Project
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
@@ -10,10 +11,6 @@ import android.media.AudioManager;
import android.os.Parcel;
import android.os.Parcelable;
import lineageos.os.Build;
import lineageos.os.Concierge;
import lineageos.os.Concierge.ParcelInfo;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -170,34 +167,15 @@ public final class RingModeSettings implements Parcelable {
/** @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.LINEAGE_VERSION_CODES.BOYSENBERRY) {
mOverride = in.readInt() != 0;
mValue = in.readString();
mDirty = in.readInt() != 0;
}
// Complete parcel info for the concierge
parcelInfo.complete();
mOverride = in.readInt() != 0;
mValue = in.readString();
mDirty = in.readInt() != 0;
}
}

View File

@@ -1,5 +1,6 @@
/*
* SPDX-FileCopyrightText: 2015 The CyanogenMod Project
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
@@ -9,11 +10,6 @@ import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
import lineageos.os.Build;
import lineageos.os.Concierge;
import lineageos.os.Concierge.ParcelInfo;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParser;
@@ -170,36 +166,17 @@ public final class StreamSettings implements Parcelable{
/** @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.LINEAGE_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();
mStreamId = in.readInt();
mOverride = in.readInt() != 0;
mValue = in.readInt();
mDirty = in.readInt() != 0;
}
}