code
stringlengths 11
173k
| docstring
stringlengths 2
593k
| func_name
stringlengths 2
189
| language
stringclasses 1
value | repo
stringclasses 844
values | path
stringlengths 11
294
| url
stringlengths 60
339
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public boolean canBeSatisfiedBy(@Nullable NetworkCapabilities nc) {
return mNativeNetworkRequest.canBeSatisfiedBy(nc);
} |
@see NetworkRequest#canBeSatisfiedBy(NetworkCapabilities)
| TelephonyNetworkRequest::canBeSatisfiedBy | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | MIT |
public boolean hasAttribute(@NetCapabilityAttribute int capabilitiesAttributes) {
return (mCapabilitiesAttributes & capabilitiesAttributes) == capabilitiesAttributes;
} |
Check if the request's capabilities have certain attributes.
@param capabilitiesAttributes The attributes to check.
@return {@code true} if the capabilities have provided attributes.
@see NetCapabilityAttribute
| TelephonyNetworkRequest::hasAttribute | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | MIT |
public boolean canBeSatisfiedBy(@NonNull DataProfile dataProfile) {
// If the network request can be translated to OS/App id, then check if the data profile's
// OS/App id can satisfy it.
if (hasAttribute(CAPABILITY_ATTRIBUTE_TRAFFIC_DESCRIPTOR_OS_APP_ID)
&& getOsAppId() != null) {
// The network request has traffic descriptor type capabilities. Match the traffic
// descriptor.
if (dataProfile.getTrafficDescriptor() != null && Arrays.equals(getOsAppId().getBytes(),
dataProfile.getTrafficDescriptor().getOsAppId())) {
return true;
}
}
// If the network request can be translated to APN setting or DNN in traffic descriptor,
// then check if the data profile's APN setting can satisfy it.
if ((hasAttribute(CAPABILITY_ATTRIBUTE_APN_SETTING)
|| hasAttribute(CAPABILITY_ATTRIBUTE_TRAFFIC_DESCRIPTOR_DNN))
&& dataProfile.getApnSetting() != null) {
if (mFeatureFlags.satelliteInternet()) {
if (mNativeNetworkRequest.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)
&& !mNativeNetworkRequest.hasTransport(
NetworkCapabilities.TRANSPORT_SATELLITE)) {
if (Arrays.stream(getCapabilities()).noneMatch(mDataConfigManager
.getForcedCellularTransportCapabilities()::contains)) {
// If the request is explicitly for the cellular, then the data profile
// needs to support cellular.
if (!dataProfile.getApnSetting().isForInfrastructure(
ApnSetting.INFRASTRUCTURE_CELLULAR)) {
return false;
}
}
} else if (mNativeNetworkRequest.hasTransport(
NetworkCapabilities.TRANSPORT_SATELLITE)
&& !mNativeNetworkRequest.hasTransport(
NetworkCapabilities.TRANSPORT_CELLULAR)) {
// If the request is explicitly for the satellite, then the data profile needs
// to support satellite.
if (!dataProfile.getApnSetting().isForInfrastructure(
ApnSetting.INFRASTRUCTURE_SATELLITE)) {
return false;
}
}
}
// Fallback to the legacy APN type matching.
List<Integer> apnTypes = Arrays.stream(getCapabilities()).boxed()
.map(DataUtils::networkCapabilityToApnType)
.filter(apnType -> apnType != ApnSetting.TYPE_NONE)
.collect(Collectors.toList());
// In case of enterprise network request, the network request will have internet,
// but APN type will not have default type as the enterprise apn should not be used
// as default network. Ignore default type of the network request if it
// has enterprise type as well. This will make sure the network request with
// internet and enterprise will be satisfied with data profile with enterprise at the
// same time default network request will not get satisfied with enterprise data
// profile.
// TODO b/232264746
if (apnTypes.contains(ApnSetting.TYPE_ENTERPRISE)) {
apnTypes.remove((Integer) ApnSetting.TYPE_DEFAULT);
}
return apnTypes.stream().allMatch(dataProfile.getApnSetting()::canHandleType);
}
return false;
} |
Check if this network request can be satisfied by a data profile.
@param dataProfile The data profile to check.
@return {@code true} if this network request can be satisfied by the data profile.
| TelephonyNetworkRequest::canBeSatisfiedBy | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | MIT |
public int getPriority() {
return mPriority;
} |
Get the priority of the network request.
@return The priority from 0 to 100. 100 indicates the highest priority.
| TelephonyNetworkRequest::getPriority | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | MIT |
public void updatePriority() {
mPriority = Arrays.stream(mNativeNetworkRequest.getCapabilities())
.map(mDataConfigManager::getNetworkCapabilityPriority)
.max()
.orElse(0);
} |
Update the priority from data config manager.
| TelephonyNetworkRequest::updatePriority | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | MIT |
public @NetCapability int getApnTypeNetworkCapability() {
if (!hasAttribute(CAPABILITY_ATTRIBUTE_APN_SETTING)) return -1;
return Arrays.stream(getCapabilities()).boxed()
.filter(cap -> DataUtils.networkCapabilityToApnType(cap) != ApnSetting.TYPE_NONE)
.max(Comparator.comparingInt(mDataConfigManager::getNetworkCapabilityPriority))
.orElse(-1);
} |
Get the network capability which is APN-type based from the network request. If there are
multiple APN types capability, the highest priority one will be returned.
@return The highest priority APN type based network capability from this network request. -1
if there is no APN type capabilities in this network request.
| TelephonyNetworkRequest::getApnTypeNetworkCapability | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | MIT |
public @NonNull NetworkRequest getNativeNetworkRequest() {
return mNativeNetworkRequest;
} |
@return The native network request.
| TelephonyNetworkRequest::getNativeNetworkRequest | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | MIT |
public void setAttachedNetwork(@NonNull DataNetwork dataNetwork) {
mAttachedDataNetwork = dataNetwork;
} |
Set the attached data network.
@param dataNetwork The data network.
| TelephonyNetworkRequest::setAttachedNetwork | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | MIT |
public @Nullable DataNetwork getAttachedNetwork() {
return mAttachedDataNetwork;
} |
@return The attached network. {@code null} indicates the request is not attached to any
network (i.e. the request is unsatisfied).
| TelephonyNetworkRequest::getAttachedNetwork | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | MIT |
public void setState(@RequestState int state) {
mState = state;
} |
Set the state of the network request.
@param state The state.
| TelephonyNetworkRequest::setState | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | MIT |
public @RequestState int getState() {
return mState;
} |
@return The state of the network request.
| TelephonyNetworkRequest::getState | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | MIT |
public void setEvaluation(@NonNull DataEvaluation evaluation) {
mEvaluation = evaluation;
} |
Set the data evaluation result.
@param evaluation The data evaluation result.
| TelephonyNetworkRequest::setEvaluation | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | MIT |
public int getCapabilityDifferentiator() {
if (hasCapability(NetworkCapabilities.NET_CAPABILITY_ENTERPRISE)) {
int[] ids = mNativeNetworkRequest.getEnterpriseIds();
// No need to verify the range of the id. It has been done in NetworkCapabilities.
if (ids.length > 0) return ids[0];
}
return 0;
} |
Get the capability differentiator from the network request. Some capabilities
(e.g. {@link NetworkCapabilities#NET_CAPABILITY_ENTERPRISE} could support more than one
traffic (e.g. "ENTERPRISE2", "ENTERPRISE3"). This method returns that differentiator.
@return The differentiator. 0 if not found.
| TelephonyNetworkRequest::getCapabilityDifferentiator | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | MIT |
public boolean isMeteredRequest() {
return mDataConfigManager.isAnyMeteredCapability(
getCapabilities(), mPhone.getServiceState().getDataRoaming());
} |
@return {@code true} if this network request can result in bringing up a metered network.
| TelephonyNetworkRequest::isMeteredRequest | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | MIT |
public @Nullable OsAppId getOsAppId() {
if (!hasAttribute(CAPABILITY_ATTRIBUTE_TRAFFIC_DESCRIPTOR_OS_APP_ID)) return null;
// We do not support multiple network capabilities translated to Os/App id at this time.
// If someday this needs to be done, we need to expand TrafficDescriptor to support
// connection capabilities instead of using Os/App id to do the work.
int networkCapability = Arrays.stream(getCapabilities()).boxed()
.filter(cap -> (CAPABILITY_ATTRIBUTE_MAP.getOrDefault(
cap, CAPABILITY_ATTRIBUTE_NONE)
& CAPABILITY_ATTRIBUTE_TRAFFIC_DESCRIPTOR_OS_APP_ID) != 0)
.findFirst()
.orElse(-1);
if (networkCapability == -1) return null;
int differentiator = getCapabilityDifferentiator();
if (differentiator > 0) {
return new OsAppId(OsAppId.ANDROID_OS_ID,
DataUtils.networkCapabilityToString(networkCapability), differentiator);
} else {
return new OsAppId(OsAppId.ANDROID_OS_ID,
DataUtils.networkCapabilityToString(networkCapability));
}
} |
Get Os/App id from the network request.
@return Os/App id. {@code null} if the request does not have traffic descriptor based network
capabilities.
| TelephonyNetworkRequest::getOsAppId | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | MIT |
private static @NonNull String requestStateToString(
@TelephonyNetworkRequest.RequestState int state) {
switch (state) {
case TelephonyNetworkRequest.REQUEST_STATE_UNSATISFIED: return "UNSATISFIED";
case TelephonyNetworkRequest.REQUEST_STATE_SATISFIED: return "SATISFIED";
default: return "UNKNOWN(" + state + ")";
}
} |
Convert the telephony request state to string.
@param state The request state.
@return The request state in string format.
| TelephonyNetworkRequest::requestStateToString | java | Reginer/aosp-android-jar | android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/data/TelephonyNetworkRequest.java | MIT |
public PresenceSubscriber(SubscribePublisher subscriber, Context context,
String[] configVolteProvisionErrorOnSubscribeResponse,
String[] configRcsProvisionErrorOnSubscribeResponse){
super(context);
synchronized(mSubscriberLock) {
this.mSubscriber = subscriber;
}
mConfigVolteProvisionErrorOnSubscribeResponse
= configVolteProvisionErrorOnSubscribeResponse;
mConfigRcsProvisionErrorOnSubscribeResponse = configRcsProvisionErrorOnSubscribeResponse;
} | /*
Copyright (c) 2015, Motorola Mobility LLC
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of Motorola Mobility nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MOTOROLA MOBILITY LLC BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
package com.android.service.ims.presence;
import android.content.Context;
import android.net.Uri;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.ims.RcsContactUceCapability;
import android.telephony.ims.RcsContactUceCapability.PresenceBuilder;
import android.text.TextUtils;
import com.android.ims.ResultCode;
import com.android.ims.internal.ContactNumberUtils;
import com.android.ims.internal.Logger;
import com.android.service.ims.RcsSettingUtils;
import com.android.service.ims.Task;
import com.android.service.ims.TaskManager;
import java.util.ArrayList;
import java.util.List;
public class PresenceSubscriber extends PresenceBase {
private Logger logger = Logger.getLogger(this.getClass().getName());
private SubscribePublisher mSubscriber;
private final Object mSubscriberLock = new Object();
private String mAvailabilityRetryNumber = null;
private int mAssociatedSubscription = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
private final String[] mConfigVolteProvisionErrorOnSubscribeResponse;
private final String[] mConfigRcsProvisionErrorOnSubscribeResponse;
/*
Constructor
| PresenceSubscriber::PresenceSubscriber | java | Reginer/aosp-android-jar | android-35/src/com/android/service/ims/presence/PresenceSubscriber.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/service/ims/presence/PresenceSubscriber.java | MIT |
@NonNull public Builder setLatitudeDegrees(
@FloatRange(from = -90.0f, to = 90.0f) double latitudeDegrees) {
mLatitudeDegrees = latitudeDegrees;
return this;
} |
Gets the altitude in meters above the WGS 84 reference ellipsoid of the reflecting point
within the plane
@FloatRange(from = -1000.0f, to = 10000.0f)
public double getAltitudeMeters() {
return mAltitudeMeters;
}
/** Gets the azimuth clockwise from north of the reflecting plane in degrees.
@FloatRange(from = 0.0f, to = 360.0f)
public double getAzimuthDegrees() {
return mAzimuthDegrees;
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<GnssReflectingPlane> CREATOR =
new Creator<GnssReflectingPlane>() {
@Override
@NonNull
public GnssReflectingPlane createFromParcel(@NonNull Parcel parcel) {
GnssReflectingPlane reflectingPlane =
new Builder()
.setLatitudeDegrees(parcel.readDouble())
.setLongitudeDegrees(parcel.readDouble())
.setAltitudeMeters(parcel.readDouble())
.setAzimuthDegrees(parcel.readDouble())
.build();
return reflectingPlane;
}
@Override
public GnssReflectingPlane[] newArray(int i) {
return new GnssReflectingPlane[i];
}
};
@NonNull
@Override
public String toString() {
final String format = " %-29s = %s\n";
StringBuilder builder = new StringBuilder("ReflectingPlane:\n");
builder.append(String.format(format, "LatitudeDegrees = ", mLatitudeDegrees));
builder.append(String.format(format, "LongitudeDegrees = ", mLongitudeDegrees));
builder.append(String.format(format, "AltitudeMeters = ", mAltitudeMeters));
builder.append(String.format(format, "AzimuthDegrees = ", mAzimuthDegrees));
return builder.toString();
}
@Override
public void writeToParcel(@NonNull Parcel parcel, int flags) {
parcel.writeDouble(mLatitudeDegrees);
parcel.writeDouble(mLongitudeDegrees);
parcel.writeDouble(mAltitudeMeters);
parcel.writeDouble(mAzimuthDegrees);
}
/** Builder for {@link GnssReflectingPlane}
public static final class Builder {
/** For documentation, see corresponding fields in {@link GnssReflectingPlane}.
private double mLatitudeDegrees;
private double mLongitudeDegrees;
private double mAltitudeMeters;
private double mAzimuthDegrees;
/** Sets the latitude in degrees of the reflecting plane. | Builder::setLatitudeDegrees | java | Reginer/aosp-android-jar | android-31/src/android/location/GnssReflectingPlane.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/location/GnssReflectingPlane.java | MIT |
@NonNull public Builder setLongitudeDegrees(
@FloatRange(from = -180.0f, to = 180.0f) double longitudeDegrees) {
mLongitudeDegrees = longitudeDegrees;
return this;
} |
Gets the altitude in meters above the WGS 84 reference ellipsoid of the reflecting point
within the plane
@FloatRange(from = -1000.0f, to = 10000.0f)
public double getAltitudeMeters() {
return mAltitudeMeters;
}
/** Gets the azimuth clockwise from north of the reflecting plane in degrees.
@FloatRange(from = 0.0f, to = 360.0f)
public double getAzimuthDegrees() {
return mAzimuthDegrees;
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<GnssReflectingPlane> CREATOR =
new Creator<GnssReflectingPlane>() {
@Override
@NonNull
public GnssReflectingPlane createFromParcel(@NonNull Parcel parcel) {
GnssReflectingPlane reflectingPlane =
new Builder()
.setLatitudeDegrees(parcel.readDouble())
.setLongitudeDegrees(parcel.readDouble())
.setAltitudeMeters(parcel.readDouble())
.setAzimuthDegrees(parcel.readDouble())
.build();
return reflectingPlane;
}
@Override
public GnssReflectingPlane[] newArray(int i) {
return new GnssReflectingPlane[i];
}
};
@NonNull
@Override
public String toString() {
final String format = " %-29s = %s\n";
StringBuilder builder = new StringBuilder("ReflectingPlane:\n");
builder.append(String.format(format, "LatitudeDegrees = ", mLatitudeDegrees));
builder.append(String.format(format, "LongitudeDegrees = ", mLongitudeDegrees));
builder.append(String.format(format, "AltitudeMeters = ", mAltitudeMeters));
builder.append(String.format(format, "AzimuthDegrees = ", mAzimuthDegrees));
return builder.toString();
}
@Override
public void writeToParcel(@NonNull Parcel parcel, int flags) {
parcel.writeDouble(mLatitudeDegrees);
parcel.writeDouble(mLongitudeDegrees);
parcel.writeDouble(mAltitudeMeters);
parcel.writeDouble(mAzimuthDegrees);
}
/** Builder for {@link GnssReflectingPlane}
public static final class Builder {
/** For documentation, see corresponding fields in {@link GnssReflectingPlane}.
private double mLatitudeDegrees;
private double mLongitudeDegrees;
private double mAltitudeMeters;
private double mAzimuthDegrees;
/** Sets the latitude in degrees of the reflecting plane.
@NonNull public Builder setLatitudeDegrees(
@FloatRange(from = -90.0f, to = 90.0f) double latitudeDegrees) {
mLatitudeDegrees = latitudeDegrees;
return this;
}
/** Sets the longitude in degrees of the reflecting plane. | Builder::setLongitudeDegrees | java | Reginer/aosp-android-jar | android-31/src/android/location/GnssReflectingPlane.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/location/GnssReflectingPlane.java | MIT |
@NonNull public Builder setAltitudeMeters(
@FloatRange(from = -1000.0f, to = 10000.0f) double altitudeMeters) {
mAltitudeMeters = altitudeMeters;
return this;
} |
Sets the altitude in meters above the WGS 84 reference ellipsoid of the reflecting point
within the plane
| Builder::setAltitudeMeters | java | Reginer/aosp-android-jar | android-31/src/android/location/GnssReflectingPlane.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/location/GnssReflectingPlane.java | MIT |
@NonNull public Builder setAzimuthDegrees(
@FloatRange(from = 0.0f, to = 360.0f) double azimuthDegrees) {
mAzimuthDegrees = azimuthDegrees;
return this;
} |
Sets the altitude in meters above the WGS 84 reference ellipsoid of the reflecting point
within the plane
@NonNull public Builder setAltitudeMeters(
@FloatRange(from = -1000.0f, to = 10000.0f) double altitudeMeters) {
mAltitudeMeters = altitudeMeters;
return this;
}
/** Sets the azimuth clockwise from north of the reflecting plane in degrees. | Builder::setAzimuthDegrees | java | Reginer/aosp-android-jar | android-31/src/android/location/GnssReflectingPlane.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/location/GnssReflectingPlane.java | MIT |
@NonNull public GnssReflectingPlane build() {
return new GnssReflectingPlane(this);
} |
Sets the altitude in meters above the WGS 84 reference ellipsoid of the reflecting point
within the plane
@NonNull public Builder setAltitudeMeters(
@FloatRange(from = -1000.0f, to = 10000.0f) double altitudeMeters) {
mAltitudeMeters = altitudeMeters;
return this;
}
/** Sets the azimuth clockwise from north of the reflecting plane in degrees.
@NonNull public Builder setAzimuthDegrees(
@FloatRange(from = 0.0f, to = 360.0f) double azimuthDegrees) {
mAzimuthDegrees = azimuthDegrees;
return this;
}
/** Builds a {@link GnssReflectingPlane} object as specified by this builder. | Builder::build | java | Reginer/aosp-android-jar | android-31/src/android/location/GnssReflectingPlane.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/location/GnssReflectingPlane.java | MIT |
static CeDatabaseHelper create(
Context context,
File preNDatabaseFile,
File ceDatabaseFile) {
boolean newDbExists = ceDatabaseFile.exists();
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "CeDatabaseHelper.create ceDatabaseFile=" + ceDatabaseFile
+ " oldDbExists=" + preNDatabaseFile.exists()
+ " newDbExists=" + newDbExists);
}
boolean removeOldDb = false;
if (!newDbExists && preNDatabaseFile.exists()) {
removeOldDb = migratePreNDbToCe(preNDatabaseFile, ceDatabaseFile);
}
// Try to open and upgrade if necessary
CeDatabaseHelper ceHelper = new CeDatabaseHelper(context, ceDatabaseFile.getPath());
ceHelper.getWritableDatabase();
ceHelper.close();
if (removeOldDb) {
Slog.i(TAG, "Migration complete - removing pre-N db " + preNDatabaseFile);
if (!SQLiteDatabase.deleteDatabase(preNDatabaseFile)) {
Slog.e(TAG, "Cannot remove pre-N db " + preNDatabaseFile);
}
}
return ceHelper;
} |
Creates a new {@code CeDatabaseHelper}. If pre-N db file is present at the old location,
it also performs migration to the new CE database.
| CeDatabaseHelper::create | java | Reginer/aosp-android-jar | android-33/src/com/android/server/accounts/AccountsDb.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/accounts/AccountsDb.java | MIT |
Cursor findAuthtokenForAllAccounts(String accountType, String authToken) {
SQLiteDatabase db = mDeDatabase.getReadableDatabaseUserIsUnlocked();
return db.rawQuery(
"SELECT " + CE_TABLE_AUTHTOKENS + "." + AUTHTOKENS_ID
+ ", " + CE_TABLE_ACCOUNTS + "." + ACCOUNTS_NAME
+ ", " + CE_TABLE_AUTHTOKENS + "." + AUTHTOKENS_TYPE
+ " FROM " + CE_TABLE_ACCOUNTS
+ " JOIN " + CE_TABLE_AUTHTOKENS
+ " ON " + CE_TABLE_ACCOUNTS + "." + ACCOUNTS_ID
+ " = " + CE_TABLE_AUTHTOKENS + "." + AUTHTOKENS_ACCOUNTS_ID
+ " WHERE " + CE_TABLE_AUTHTOKENS + "." + AUTHTOKENS_AUTHTOKEN
+ " = ? AND " + CE_TABLE_ACCOUNTS + "." + ACCOUNTS_TYPE + " = ?",
new String[]{authToken, accountType});
} |
Returns information about auth tokens and their account for the specified query
parameters.
Output is in the format:
<pre><code> | AUTHTOKEN_ID | ACCOUNT_NAME | AUTH_TOKEN_TYPE |</code></pre>
| CeDatabaseHelper::findAuthtokenForAllAccounts | java | Reginer/aosp-android-jar | android-33/src/com/android/server/accounts/AccountsDb.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/accounts/AccountsDb.java | MIT |
Map<String, Integer> findAllVisibilityValuesForAccount(Account account) {
SQLiteDatabase db = mDeDatabase.getReadableDatabase();
Map<String, Integer> result = new HashMap<>();
final Cursor cursor =
db.query(TABLE_VISIBILITY, new String[] {VISIBILITY_PACKAGE, VISIBILITY_VALUE},
SELECTION_ACCOUNTS_ID_BY_ACCOUNT, new String[] {account.name, account.type},
null, null, null);
try {
while (cursor.moveToNext()) {
result.put(cursor.getString(0), cursor.getInt(1));
}
} finally {
cursor.close();
}
return result;
} |
Returns a map from packageNames to visibility.
| DeDatabaseHelper::findAllVisibilityValuesForAccount | java | Reginer/aosp-android-jar | android-33/src/com/android/server/accounts/AccountsDb.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/accounts/AccountsDb.java | MIT |
Map <Account, Map<String, Integer>> findAllVisibilityValues() {
SQLiteDatabase db = mDeDatabase.getReadableDatabase();
Map<Account, Map<String, Integer>> result = new HashMap<>();
Cursor cursor = db.rawQuery(
"SELECT " + TABLE_VISIBILITY + "." + VISIBILITY_PACKAGE
+ ", " + TABLE_VISIBILITY + "." + VISIBILITY_VALUE
+ ", " + TABLE_ACCOUNTS + "." + ACCOUNTS_NAME
+ ", " + TABLE_ACCOUNTS + "." + ACCOUNTS_TYPE
+ " FROM " + TABLE_VISIBILITY
+ " JOIN " + TABLE_ACCOUNTS
+ " ON " + TABLE_ACCOUNTS + "." + ACCOUNTS_ID
+ " = " + TABLE_VISIBILITY + "." + VISIBILITY_ACCOUNTS_ID, null);
try {
while (cursor.moveToNext()) {
String packageName = cursor.getString(0);
Integer visibility = cursor.getInt(1);
String accountName = cursor.getString(2);
String accountType = cursor.getString(3);
Account account = new Account(accountName, accountType);
Map <String, Integer> accountVisibility = result.get(account);
if (accountVisibility == null) {
accountVisibility = new HashMap<>();
result.put(account, accountVisibility);
}
accountVisibility.put(packageName, visibility);
}
} finally {
cursor.close();
}
return result;
} |
Returns a map account -> (package -> visibility)
| DeDatabaseHelper::findAllVisibilityValues | java | Reginer/aosp-android-jar | android-33/src/com/android/server/accounts/AccountsDb.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/accounts/AccountsDb.java | MIT |
List<Pair<String, Integer>> findAllAccountGrants() {
SQLiteDatabase db = mDeDatabase.getReadableDatabase();
try (Cursor cursor = db.rawQuery(ACCOUNT_ACCESS_GRANTS, null)) {
if (cursor == null || !cursor.moveToFirst()) {
return Collections.emptyList();
}
List<Pair<String, Integer>> results = new ArrayList<>();
do {
final String accountName = cursor.getString(0);
final int uid = cursor.getInt(1);
results.add(Pair.create(accountName, uid));
} while (cursor.moveToNext());
return results;
}
} |
Returns list of all grants as {@link Pair pairs} of account name and UID.
| DeDatabaseHelper::findAllAccountGrants | java | Reginer/aosp-android-jar | android-33/src/com/android/server/accounts/AccountsDb.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/accounts/AccountsDb.java | MIT |
long calculateDebugTableInsertionPoint() {
try {
SQLiteDatabase db = mDeDatabase.getReadableDatabase();
String queryCountDebugDbRows = "SELECT COUNT(*) FROM " + TABLE_DEBUG;
int size = (int) DatabaseUtils.longForQuery(db, queryCountDebugDbRows, null);
if (size < MAX_DEBUG_DB_SIZE) {
return size;
}
// This query finds the smallest timestamp value (and if 2 records have
// same timestamp, the choose the lower id).
queryCountDebugDbRows =
"SELECT " + DEBUG_TABLE_KEY
+ " FROM " + TABLE_DEBUG
+ " ORDER BY " + DEBUG_TABLE_TIMESTAMP + ","
+ DEBUG_TABLE_KEY
+ " LIMIT 1";
return DatabaseUtils.longForQuery(db, queryCountDebugDbRows, null);
} catch (SQLiteException e) {
Log.e(TAG, "Failed to open debug table" + e);
return -1;
}
} |
Pre-N database may need an upgrade before splitting
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.e(TAG, "upgrade from version " + oldVersion + " to version " + newVersion);
if (oldVersion == 1) {
// no longer need to do anything since the work is done
// when upgrading from version 2
oldVersion++;
}
if (oldVersion == 2) {
createGrantsTable(db);
db.execSQL("DROP TRIGGER " + TABLE_ACCOUNTS + "Delete");
createAccountsDeletionTrigger(db);
oldVersion++;
}
if (oldVersion == 3) {
db.execSQL("UPDATE " + TABLE_ACCOUNTS + " SET " + ACCOUNTS_TYPE +
" = 'com.google' WHERE " + ACCOUNTS_TYPE + " == 'com.google.GAIA'");
oldVersion++;
}
if (oldVersion == 4) {
createSharedAccountsTable(db);
oldVersion++;
}
if (oldVersion == 5) {
addOldAccountNameColumn(db);
oldVersion++;
}
if (oldVersion == 6) {
addLastSuccessfullAuthenticatedTimeColumn(db);
oldVersion++;
}
if (oldVersion == 7) {
addDebugTable(db);
oldVersion++;
}
if (oldVersion == 8) {
populateMetaTableWithAuthTypeAndUID(
db,
AccountManagerService.getAuthenticatorTypeAndUIDForUser(mContext, mUserId));
oldVersion++;
}
if (oldVersion != newVersion) {
Log.e(TAG, "failed to upgrade version " + oldVersion + " to version " + newVersion);
}
}
@Override
public void onOpen(SQLiteDatabase db) {
if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "opened database " + DATABASE_NAME);
}
}
List<Account> findCeAccountsNotInDe() {
SQLiteDatabase db = mDeDatabase.getReadableDatabaseUserIsUnlocked();
// Select accounts from CE that do not exist in DE
Cursor cursor = db.rawQuery(
"SELECT " + ACCOUNTS_NAME + "," + ACCOUNTS_TYPE
+ " FROM " + CE_TABLE_ACCOUNTS
+ " WHERE NOT EXISTS "
+ " (SELECT " + ACCOUNTS_ID + " FROM " + TABLE_ACCOUNTS
+ " WHERE " + ACCOUNTS_ID + "=" + CE_TABLE_ACCOUNTS + "." + ACCOUNTS_ID
+ " )", null);
try {
List<Account> accounts = new ArrayList<>(cursor.getCount());
while (cursor.moveToNext()) {
String accountName = cursor.getString(0);
String accountType = cursor.getString(1);
accounts.add(new Account(accountName, accountType));
}
return accounts;
} finally {
cursor.close();
}
}
boolean deleteCeAccount(long accountId) {
SQLiteDatabase db = mDeDatabase.getWritableDatabaseUserIsUnlocked();
return db.delete(
CE_TABLE_ACCOUNTS, ACCOUNTS_ID + "=" + accountId, null) > 0;
}
boolean isCeDatabaseAttached() {
return mDeDatabase.mCeAttached;
}
void beginTransaction() {
mDeDatabase.getWritableDatabase().beginTransaction();
}
void setTransactionSuccessful() {
mDeDatabase.getWritableDatabase().setTransactionSuccessful();
}
void endTransaction() {
mDeDatabase.getWritableDatabase().endTransaction();
}
void attachCeDatabase(File ceDbFile) {
CeDatabaseHelper.create(mContext, mPreNDatabaseFile, ceDbFile);
SQLiteDatabase db = mDeDatabase.getWritableDatabase();
db.execSQL("ATTACH DATABASE '" + ceDbFile.getPath()+ "' AS ceDb");
mDeDatabase.mCeAttached = true;
}
/*
Finds the row key where the next insertion should take place. Returns number of rows
if it is less {@link #MAX_DEBUG_DB_SIZE}, otherwise finds the lowest number available.
| PreNDatabaseHelper::calculateDebugTableInsertionPoint | java | Reginer/aosp-android-jar | android-33/src/com/android/server/accounts/AccountsDb.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/accounts/AccountsDb.java | MIT |
@Nullable SQLiteStatement getStatementForLogging() {
if (mDebugStatementForLogging != null) {
return mDebugStatementForLogging;
}
try {
mDebugStatementForLogging = compileSqlStatementForLogging();
return mDebugStatementForLogging;
} catch (SQLiteException e) {
Log.e(TAG, "Failed to open debug table" + e);
return null;
}
} |
Returns statement for logging or {@code null} on database open failure.
Returned value must be guarded by {link #debugStatementLock}
| PreNDatabaseHelper::getStatementForLogging | java | Reginer/aosp-android-jar | android-33/src/com/android/server/accounts/AccountsDb.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/accounts/AccountsDb.java | MIT |
private static void resetDatabase(SQLiteDatabase db) {
try (Cursor c = db.rawQuery("SELECT name FROM sqlite_master WHERE type ='table'", null)) {
while (c.moveToNext()) {
String name = c.getString(0);
// Skip tables managed by SQLiteDatabase
if ("android_metadata".equals(name) || "sqlite_sequence".equals(name)) {
continue;
}
db.execSQL("DROP TABLE IF EXISTS " + name);
}
}
try (Cursor c = db.rawQuery("SELECT name FROM sqlite_master WHERE type ='trigger'", null)) {
while (c.moveToNext()) {
String name = c.getString(0);
db.execSQL("DROP TRIGGER IF EXISTS " + name);
}
}
} |
Removes all tables and triggers created by AccountManager.
| PreNDatabaseHelper::resetDatabase | java | Reginer/aosp-android-jar | android-33/src/com/android/server/accounts/AccountsDb.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/accounts/AccountsDb.java | MIT |
public static NanoAppMessage createMessageToNanoApp(
long targetNanoAppId, int messageType, byte[] messageBody) {
return new NanoAppMessage(
targetNanoAppId, messageType, messageBody, false /* broadcasted */);
} |
Creates a NanoAppMessage object to send to a nanoapp.
This factory method can be used to generate a NanoAppMessage object to be used in
the ContextHubClient.sendMessageToNanoApp API.
@param targetNanoAppId the ID of the nanoapp to send the message to
@param messageType the nanoapp-dependent message type
@param messageBody the byte array message contents
@return the NanoAppMessage object
| NanoAppMessage::createMessageToNanoApp | java | Reginer/aosp-android-jar | android-34/src/android/hardware/location/NanoAppMessage.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/hardware/location/NanoAppMessage.java | MIT |
public static NanoAppMessage createMessageFromNanoApp(
long sourceNanoAppId, int messageType, byte[] messageBody, boolean broadcasted) {
return new NanoAppMessage(sourceNanoAppId, messageType, messageBody, broadcasted);
} |
Creates a NanoAppMessage object sent from a nanoapp.
This factory method is intended only to be used by the Context Hub Service when delivering
messages from a nanoapp to clients.
@param sourceNanoAppId the ID of the nanoapp that the message was sent from
@param messageType the nanoapp-dependent message type
@param messageBody the byte array message contents
@param broadcasted {@code true} if the message was broadcasted, {@code false} otherwise
@return the NanoAppMessage object
| NanoAppMessage::createMessageFromNanoApp | java | Reginer/aosp-android-jar | android-34/src/android/hardware/location/NanoAppMessage.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/hardware/location/NanoAppMessage.java | MIT |
public long getNanoAppId() {
return mNanoAppId;
} |
@return the ID of the source or destination nanoapp
| NanoAppMessage::getNanoAppId | java | Reginer/aosp-android-jar | android-34/src/android/hardware/location/NanoAppMessage.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/hardware/location/NanoAppMessage.java | MIT |
public int getMessageType() {
return mMessageType;
} |
@return the type of the message that is nanoapp-dependent
| NanoAppMessage::getMessageType | java | Reginer/aosp-android-jar | android-34/src/android/hardware/location/NanoAppMessage.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/hardware/location/NanoAppMessage.java | MIT |
public byte[] getMessageBody() {
return mMessageBody;
} |
@return the byte array contents of the message
| NanoAppMessage::getMessageBody | java | Reginer/aosp-android-jar | android-34/src/android/hardware/location/NanoAppMessage.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/hardware/location/NanoAppMessage.java | MIT |
public boolean isBroadcastMessage() {
return mIsBroadcasted;
} |
@return {@code true} if the message is broadcasted, {@code false} otherwise
| NanoAppMessage::isBroadcastMessage | java | Reginer/aosp-android-jar | android-34/src/android/hardware/location/NanoAppMessage.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/hardware/location/NanoAppMessage.java | MIT |
void processNewAssociationRequest(@NonNull AssociationRequest request,
@NonNull String packageName, @UserIdInt int userId,
@NonNull IAssociationRequestCallback callback) {
requireNonNull(request, "Request MUST NOT be null");
if (request.isSelfManaged()) {
requireNonNull(request.getDisplayName(), "AssociationRequest.displayName "
+ "MUST NOT be null.");
}
requireNonNull(packageName, "Package name MUST NOT be null");
requireNonNull(callback, "Callback MUST NOT be null");
final int packageUid = mPackageManager.getPackageUid(packageName, 0, userId);
if (DEBUG) {
Slog.d(TAG, "processNewAssociationRequest() "
+ "request=" + request + ", "
+ "package=u" + userId + "/" + packageName + " (uid=" + packageUid + ")");
}
// 1. Enforce permissions and other requirements.
enforcePermissionsForAssociation(mContext, request, packageUid);
enforceUsesCompanionDeviceFeature(mContext, userId, packageName);
// 2. Check if association can be created without launching UI (i.e. CDM needs NEITHER
// to perform discovery NOR to collect user consent).
if (request.isSelfManaged() && !request.isForceConfirmation()
&& !willAddRoleHolder(request, packageName, userId)) {
// 2a. Create association right away.
createAssociationAndNotifyApplication(request, packageName, userId,
/* macAddress */ null, callback, /* resultReceiver */ null);
return;
}
// 2b. Build a PendingIntent for launching the confirmation UI, and send it back to the app:
// 2b.1. Populate the request with required info.
request.setPackageName(packageName);
request.setUserId(userId);
request.setSkipPrompt(mayAssociateWithoutPrompt(packageName, userId));
// 2b.2. Prepare extras and create an Intent.
final Bundle extras = new Bundle();
extras.putParcelable(EXTRA_ASSOCIATION_REQUEST, request);
extras.putBinder(EXTRA_APPLICATION_CALLBACK, callback.asBinder());
extras.putParcelable(EXTRA_RESULT_RECEIVER, prepareForIpc(mOnRequestConfirmationReceiver));
final Intent intent = new Intent();
intent.setComponent(ASSOCIATION_REQUEST_APPROVAL_ACTIVITY);
intent.putExtras(extras);
// 2b.3. Create a PendingIntent.
final PendingIntent pendingIntent = createPendingIntent(packageUid, intent);
// 2b.4. Send the PendingIntent back to the app.
try {
callback.onAssociationPending(pendingIntent);
} catch (RemoteException ignore) { }
} |
Handle incoming {@link AssociationRequest}s, sent via
{@link android.companion.ICompanionDeviceManager#associate(AssociationRequest, IAssociationRequestCallback, String, int)}
| AssociationRequestsProcessor::processNewAssociationRequest | java | Reginer/aosp-android-jar | android-34/src/com/android/server/companion/AssociationRequestsProcessor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/companion/AssociationRequestsProcessor.java | MIT |
PendingIntent buildAssociationCancellationIntent(@NonNull String packageName,
@UserIdInt int userId) {
requireNonNull(packageName, "Package name MUST NOT be null");
enforceUsesCompanionDeviceFeature(mContext, userId, packageName);
final int packageUid = mPackageManager.getPackageUid(packageName, 0, userId);
final Bundle extras = new Bundle();
extras.putBoolean(EXTRA_FORCE_CANCEL_CONFIRMATION, true);
final Intent intent = new Intent();
intent.setComponent(ASSOCIATION_REQUEST_APPROVAL_ACTIVITY);
intent.putExtras(extras);
return createPendingIntent(packageUid, intent);
} |
Process another AssociationRequest in CompanionDeviceActivity to cancel current dialog.
| AssociationRequestsProcessor::buildAssociationCancellationIntent | java | Reginer/aosp-android-jar | android-34/src/com/android/server/companion/AssociationRequestsProcessor.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/companion/AssociationRequestsProcessor.java | MIT |
BluetoothHealthAppConfiguration() {} |
Hide auto-created default constructor
@hide
| BluetoothHealthAppConfiguration::BluetoothHealthAppConfiguration | java | Reginer/aosp-android-jar | android-31/src/android/bluetooth/BluetoothHealthAppConfiguration.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/bluetooth/BluetoothHealthAppConfiguration.java | MIT |
public GLSurfaceView(Context context) {
super(context);
init();
} |
Standard View constructor. In order to render something, you
must call {@link #setRenderer} to register a renderer.
| GLSurfaceView::GLSurfaceView | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public GLSurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
} |
Standard View constructor. In order to render something, you
must call {@link #setRenderer} to register a renderer.
| GLSurfaceView::GLSurfaceView | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void setGLWrapper(GLWrapper glWrapper) {
mGLWrapper = glWrapper;
} |
Set the glWrapper. If the glWrapper is not null, its
{@link GLWrapper#wrap(GL)} method is called
whenever a surface is created. A GLWrapper can be used to wrap
the GL object that's passed to the renderer. Wrapping a GL
object enables examining and modifying the behavior of the
GL calls made by the renderer.
<p>
Wrapping is typically used for debugging purposes.
<p>
The default value is null.
@param glWrapper the new GLWrapper
| GLSurfaceView::setGLWrapper | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void setDebugFlags(int debugFlags) {
mDebugFlags = debugFlags;
} |
Set the debug flags to a new value. The value is
constructed by OR-together zero or more
of the DEBUG_CHECK_* constants. The debug flags take effect
whenever a surface is created. The default value is zero.
@param debugFlags the new debug flags
@see #DEBUG_CHECK_GL_ERROR
@see #DEBUG_LOG_GL_CALLS
| GLSurfaceView::setDebugFlags | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public int getDebugFlags() {
return mDebugFlags;
} |
Get the current value of the debug flags.
@return the current value of the debug flags.
| GLSurfaceView::getDebugFlags | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void setPreserveEGLContextOnPause(boolean preserveOnPause) {
mPreserveEGLContextOnPause = preserveOnPause;
} |
Control whether the EGL context is preserved when the GLSurfaceView is paused and
resumed.
<p>
If set to true, then the EGL context may be preserved when the GLSurfaceView is paused.
<p>
Prior to API level 11, whether the EGL context is actually preserved or not
depends upon whether the Android device can support an arbitrary number of
EGL contexts or not. Devices that can only support a limited number of EGL
contexts must release the EGL context in order to allow multiple applications
to share the GPU.
<p>
If set to false, the EGL context will be released when the GLSurfaceView is paused,
and recreated when the GLSurfaceView is resumed.
<p>
The default is false.
@param preserveOnPause preserve the EGL context when paused
| GLSurfaceView::setPreserveEGLContextOnPause | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public boolean getPreserveEGLContextOnPause() {
return mPreserveEGLContextOnPause;
} |
@return true if the EGL context will be preserved when paused
| GLSurfaceView::getPreserveEGLContextOnPause | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void setRenderer(Renderer renderer) {
checkRenderThreadState();
if (mEGLConfigChooser == null) {
mEGLConfigChooser = new SimpleEGLConfigChooser(true);
}
if (mEGLContextFactory == null) {
mEGLContextFactory = new DefaultContextFactory();
}
if (mEGLWindowSurfaceFactory == null) {
mEGLWindowSurfaceFactory = new DefaultWindowSurfaceFactory();
}
mRenderer = renderer;
mGLThread = new GLThread(mThisWeakRef);
mGLThread.start();
} |
Set the renderer associated with this view. Also starts the thread that
will call the renderer, which in turn causes the rendering to start.
<p>This method should be called once and only once in the life-cycle of
a GLSurfaceView.
<p>The following GLSurfaceView methods can only be called <em>before</em>
setRenderer is called:
<ul>
<li>{@link #setEGLConfigChooser(boolean)}
<li>{@link #setEGLConfigChooser(EGLConfigChooser)}
<li>{@link #setEGLConfigChooser(int, int, int, int, int, int)}
</ul>
<p>
The following GLSurfaceView methods can only be called <em>after</em>
setRenderer is called:
<ul>
<li>{@link #getRenderMode()}
<li>{@link #onPause()}
<li>{@link #onResume()}
<li>{@link #queueEvent(Runnable)}
<li>{@link #requestRender()}
<li>{@link #setRenderMode(int)}
</ul>
@param renderer the renderer to use to perform OpenGL drawing.
| GLSurfaceView::setRenderer | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void setEGLContextFactory(EGLContextFactory factory) {
checkRenderThreadState();
mEGLContextFactory = factory;
} |
Install a custom EGLContextFactory.
<p>If this method is
called, it must be called before {@link #setRenderer(Renderer)}
is called.
<p>
If this method is not called, then by default
a context will be created with no shared context and
with a null attribute list.
| GLSurfaceView::setEGLContextFactory | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void setEGLWindowSurfaceFactory(EGLWindowSurfaceFactory factory) {
checkRenderThreadState();
mEGLWindowSurfaceFactory = factory;
} |
Install a custom EGLWindowSurfaceFactory.
<p>If this method is
called, it must be called before {@link #setRenderer(Renderer)}
is called.
<p>
If this method is not called, then by default
a window surface will be created with a null attribute list.
| GLSurfaceView::setEGLWindowSurfaceFactory | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void setEGLConfigChooser(EGLConfigChooser configChooser) {
checkRenderThreadState();
mEGLConfigChooser = configChooser;
} |
Install a custom EGLConfigChooser.
<p>If this method is
called, it must be called before {@link #setRenderer(Renderer)}
is called.
<p>
If no setEGLConfigChooser method is called, then by default the
view will choose an EGLConfig that is compatible with the current
android.view.Surface, with a depth buffer depth of
at least 16 bits.
@param configChooser
| GLSurfaceView::setEGLConfigChooser | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void setEGLConfigChooser(boolean needDepth) {
setEGLConfigChooser(new SimpleEGLConfigChooser(needDepth));
} |
Install a config chooser which will choose a config
as close to 16-bit RGB as possible, with or without an optional depth
buffer as close to 16-bits as possible.
<p>If this method is
called, it must be called before {@link #setRenderer(Renderer)}
is called.
<p>
If no setEGLConfigChooser method is called, then by default the
view will choose an RGB_888 surface with a depth buffer depth of
at least 16 bits.
@param needDepth
| GLSurfaceView::setEGLConfigChooser | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void setEGLConfigChooser(int redSize, int greenSize, int blueSize,
int alphaSize, int depthSize, int stencilSize) {
setEGLConfigChooser(new ComponentSizeChooser(redSize, greenSize,
blueSize, alphaSize, depthSize, stencilSize));
} |
Install a config chooser which will choose a config
with at least the specified depthSize and stencilSize,
and exactly the specified redSize, greenSize, blueSize and alphaSize.
<p>If this method is
called, it must be called before {@link #setRenderer(Renderer)}
is called.
<p>
If no setEGLConfigChooser method is called, then by default the
view will choose an RGB_888 surface with a depth buffer depth of
at least 16 bits.
| GLSurfaceView::setEGLConfigChooser | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void setEGLContextClientVersion(int version) {
checkRenderThreadState();
mEGLContextClientVersion = version;
} |
Inform the default EGLContextFactory and default EGLConfigChooser
which EGLContext client version to pick.
<p>Use this method to create an OpenGL ES 2.0-compatible context.
Example:
<pre class="prettyprint">
public MyView(Context context) {
super(context);
setEGLContextClientVersion(2); // Pick an OpenGL ES 2.0 context.
setRenderer(new MyRenderer());
}
</pre>
<p>Note: Activities which require OpenGL ES 2.0 should indicate this by
setting @lt;uses-feature android:glEsVersion="0x00020000" /> in the activity's
AndroidManifest.xml file.
<p>If this method is called, it must be called before {@link #setRenderer(Renderer)}
is called.
<p>This method only affects the behavior of the default EGLContexFactory and the
default EGLConfigChooser. If
{@link #setEGLContextFactory(EGLContextFactory)} has been called, then the supplied
EGLContextFactory is responsible for creating an OpenGL ES 2.0-compatible context.
If
{@link #setEGLConfigChooser(EGLConfigChooser)} has been called, then the supplied
EGLConfigChooser is responsible for choosing an OpenGL ES 2.0-compatible config.
@param version The EGLContext client version to choose. Use 2 for OpenGL ES 2.0
| GLSurfaceView::setEGLContextClientVersion | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void setRenderMode(int renderMode) {
mGLThread.setRenderMode(renderMode);
} |
Set the rendering mode. When renderMode is
RENDERMODE_CONTINUOUSLY, the renderer is called
repeatedly to re-render the scene. When renderMode
is RENDERMODE_WHEN_DIRTY, the renderer only rendered when the surface
is created, or when {@link #requestRender} is called. Defaults to RENDERMODE_CONTINUOUSLY.
<p>
Using RENDERMODE_WHEN_DIRTY can improve battery life and overall system performance
by allowing the GPU and CPU to idle when the view does not need to be updated.
<p>
This method can only be called after {@link #setRenderer(Renderer)}
@param renderMode one of the RENDERMODE_X constants
@see #RENDERMODE_CONTINUOUSLY
@see #RENDERMODE_WHEN_DIRTY
| GLSurfaceView::setRenderMode | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public int getRenderMode() {
return mGLThread.getRenderMode();
} |
Get the current rendering mode. May be called
from any thread. Must not be called before a renderer has been set.
@return the current rendering mode.
@see #RENDERMODE_CONTINUOUSLY
@see #RENDERMODE_WHEN_DIRTY
| GLSurfaceView::getRenderMode | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void requestRender() {
mGLThread.requestRender();
} |
Request that the renderer render a frame.
This method is typically used when the render mode has been set to
{@link #RENDERMODE_WHEN_DIRTY}, so that frames are only rendered on demand.
May be called
from any thread. Must not be called before a renderer has been set.
| GLSurfaceView::requestRender | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void surfaceCreated(SurfaceHolder holder) {
mGLThread.surfaceCreated();
} |
This method is part of the SurfaceHolder.Callback interface, and is
not normally called or subclassed by clients of GLSurfaceView.
| GLSurfaceView::surfaceCreated | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void surfaceDestroyed(SurfaceHolder holder) {
// Surface will be destroyed when we return
mGLThread.surfaceDestroyed();
} |
This method is part of the SurfaceHolder.Callback interface, and is
not normally called or subclassed by clients of GLSurfaceView.
| GLSurfaceView::surfaceDestroyed | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
mGLThread.onWindowResize(w, h);
} |
This method is part of the SurfaceHolder.Callback interface, and is
not normally called or subclassed by clients of GLSurfaceView.
| GLSurfaceView::surfaceChanged | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void onPause() {
mGLThread.onPause();
} |
Pause the rendering thread, optionally tearing down the EGL context
depending upon the value of {@link #setPreserveEGLContextOnPause(boolean)}.
This method should be called when it is no longer desirable for the
GLSurfaceView to continue rendering, such as in response to
{@link android.app.Activity#onStop Activity.onStop}.
Must not be called before a renderer has been set.
| GLSurfaceView::onPause | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void onResume() {
mGLThread.onResume();
} |
Resumes the rendering thread, re-creating the OpenGL context if necessary. It
is the counterpart to {@link #onPause()}.
This method should typically be called in
{@link android.app.Activity#onStart Activity.onStart}.
Must not be called before a renderer has been set.
| GLSurfaceView::onResume | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void queueEvent(Runnable r) {
mGLThread.queueEvent(r);
} |
Queue a runnable to be run on the GL rendering thread. This can be used
to communicate with the Renderer on the rendering thread.
Must not be called before a renderer has been set.
@param r the runnable to be run on the GL rendering thread.
| GLSurfaceView::queueEvent | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void start() {
if (LOG_EGL) {
Log.w("EglHelper", "start() tid=" + Thread.currentThread().getId());
}
/*
* Get an EGL instance
*/
mEgl = (EGL10) EGLContext.getEGL();
/*
* Get to the default display.
*/
mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
if (mEglDisplay == EGL10.EGL_NO_DISPLAY) {
throw new RuntimeException("eglGetDisplay failed");
}
/*
* We can now initialize EGL for that display
*/
int[] version = new int[2];
if(!mEgl.eglInitialize(mEglDisplay, version)) {
throw new RuntimeException("eglInitialize failed");
}
GLSurfaceView view = mGLSurfaceViewWeakRef.get();
if (view == null) {
mEglConfig = null;
mEglContext = null;
} else {
mEglConfig = view.mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);
/*
* Create an EGL context. We want to do this as rarely as we can, because an
* EGL context is a somewhat heavy object.
*/
mEglContext = view.mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig);
}
if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) {
mEglContext = null;
throwEglException("createContext");
}
if (LOG_EGL) {
Log.w("EglHelper", "createContext " + mEglContext + " tid=" + Thread.currentThread().getId());
}
mEglSurface = null;
} |
Initialize EGL for a given configuration spec.
@param configSpec
| EglHelper::start | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public boolean createSurface() {
if (LOG_EGL) {
Log.w("EglHelper", "createSurface() tid=" + Thread.currentThread().getId());
}
/*
* Check preconditions.
*/
if (mEgl == null) {
throw new RuntimeException("egl not initialized");
}
if (mEglDisplay == null) {
throw new RuntimeException("eglDisplay not initialized");
}
if (mEglConfig == null) {
throw new RuntimeException("mEglConfig not initialized");
}
/*
* The window size has changed, so we need to create a new
* surface.
*/
destroySurfaceImp();
/*
* Create an EGL surface we can render into.
*/
GLSurfaceView view = mGLSurfaceViewWeakRef.get();
if (view != null) {
mEglSurface = view.mEGLWindowSurfaceFactory.createWindowSurface(mEgl,
mEglDisplay, mEglConfig, view.getHolder());
} else {
mEglSurface = null;
}
if (mEglSurface == null || mEglSurface == EGL10.EGL_NO_SURFACE) {
int error = mEgl.eglGetError();
if (error == EGL10.EGL_BAD_NATIVE_WINDOW) {
Log.e("EglHelper", "createWindowSurface returned EGL_BAD_NATIVE_WINDOW.");
}
return false;
}
/*
* Before we can issue GL commands, we need to make sure
* the context is current and bound to a surface.
*/
if (!mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)) {
/*
* Could not make the context current, probably because the underlying
* SurfaceView surface has been destroyed.
*/
logEglErrorAsWarning("EGLHelper", "eglMakeCurrent", mEgl.eglGetError());
return false;
}
return true;
} |
Create an egl surface for the current SurfaceHolder surface. If a surface
already exists, destroy it before creating the new surface.
@return true if the surface was created successfully.
| EglHelper::createSurface | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
GL createGL() {
GL gl = mEglContext.getGL();
GLSurfaceView view = mGLSurfaceViewWeakRef.get();
if (view != null) {
if (view.mGLWrapper != null) {
gl = view.mGLWrapper.wrap(gl);
}
if ((view.mDebugFlags & (DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS)) != 0) {
int configFlags = 0;
Writer log = null;
if ((view.mDebugFlags & DEBUG_CHECK_GL_ERROR) != 0) {
configFlags |= GLDebugHelper.CONFIG_CHECK_GL_ERROR;
}
if ((view.mDebugFlags & DEBUG_LOG_GL_CALLS) != 0) {
log = new LogWriter();
}
gl = GLDebugHelper.wrap(gl, configFlags, log);
}
}
return gl;
} |
Create a GL object for the current EGL context.
@return
| EglHelper::createGL | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public int swap() {
if (! mEgl.eglSwapBuffers(mEglDisplay, mEglSurface)) {
return mEgl.eglGetError();
}
return EGL10.EGL_SUCCESS;
} |
Display the current render surface.
@return the EGL error code from eglSwapBuffers.
| EglHelper::swap | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
private void stopEglSurfaceLocked() {
if (mHaveEglSurface) {
mHaveEglSurface = false;
mEglHelper.destroySurface();
}
} |
A generic GL Thread. Takes care of initializing EGL and GL. Delegates
to a Renderer instance to do the actual drawing. Can be configured to
render continuously or on request.
All potentially blocking synchronization is done through the
sGLThreadManager object. This avoids multiple-lock ordering issues.
static class GLThread extends Thread {
GLThread(WeakReference<GLSurfaceView> glSurfaceViewWeakRef) {
super();
mWidth = 0;
mHeight = 0;
mRequestRender = true;
mRenderMode = RENDERMODE_CONTINUOUSLY;
mWantRenderNotification = false;
mGLSurfaceViewWeakRef = glSurfaceViewWeakRef;
}
@Override
public void run() {
setName("GLThread " + getId());
if (LOG_THREADS) {
Log.i("GLThread", "starting tid=" + getId());
}
try {
guardedRun();
} catch (InterruptedException e) {
// fall thru and exit normally
} finally {
sGLThreadManager.threadExiting(this);
}
}
/*
This private method should only be called inside a
synchronized(sGLThreadManager) block.
| GLThread::stopEglSurfaceLocked | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
private void stopEglContextLocked() {
if (mHaveEglContext) {
mEglHelper.finish();
mHaveEglContext = false;
sGLThreadManager.releaseEglContextLocked(this);
}
} |
A generic GL Thread. Takes care of initializing EGL and GL. Delegates
to a Renderer instance to do the actual drawing. Can be configured to
render continuously or on request.
All potentially blocking synchronization is done through the
sGLThreadManager object. This avoids multiple-lock ordering issues.
static class GLThread extends Thread {
GLThread(WeakReference<GLSurfaceView> glSurfaceViewWeakRef) {
super();
mWidth = 0;
mHeight = 0;
mRequestRender = true;
mRenderMode = RENDERMODE_CONTINUOUSLY;
mWantRenderNotification = false;
mGLSurfaceViewWeakRef = glSurfaceViewWeakRef;
}
@Override
public void run() {
setName("GLThread " + getId());
if (LOG_THREADS) {
Log.i("GLThread", "starting tid=" + getId());
}
try {
guardedRun();
} catch (InterruptedException e) {
// fall thru and exit normally
} finally {
sGLThreadManager.threadExiting(this);
}
}
/*
This private method should only be called inside a
synchronized(sGLThreadManager) block.
private void stopEglSurfaceLocked() {
if (mHaveEglSurface) {
mHaveEglSurface = false;
mEglHelper.destroySurface();
}
}
/*
This private method should only be called inside a
synchronized(sGLThreadManager) block.
| GLThread::stopEglContextLocked | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void queueEvent(Runnable r) {
if (r == null) {
throw new IllegalArgumentException("r must not be null");
}
synchronized(sGLThreadManager) {
mEventQueue.add(r);
sGLThreadManager.notifyAll();
}
} |
Queue an "event" to be run on the GL rendering thread.
@param r the runnable to be run on the GL rendering thread.
| GLThread::queueEvent | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
public void releaseEglContextLocked(GLThread thread) {
notifyAll();
} |
Set once at thread construction time, nulled out when the parent view is garbage
called. This weak reference allows the GLSurfaceView to be garbage collected while
the GLThread is still alive.
private WeakReference<GLSurfaceView> mGLSurfaceViewWeakRef;
}
static class LogWriter extends Writer {
@Override public void close() {
flushBuilder();
}
@Override public void flush() {
flushBuilder();
}
@Override public void write(char[] buf, int offset, int count) {
for(int i = 0; i < count; i++) {
char c = buf[offset + i];
if ( c == '\n') {
flushBuilder();
}
else {
mBuilder.append(c);
}
}
}
private void flushBuilder() {
if (mBuilder.length() > 0) {
Log.v("GLSurfaceView", mBuilder.toString());
mBuilder.delete(0, mBuilder.length());
}
}
private StringBuilder mBuilder = new StringBuilder();
}
private void checkRenderThreadState() {
if (mGLThread != null) {
throw new IllegalStateException(
"setRenderer has already been called for this instance.");
}
}
private static class GLThreadManager {
private static String TAG = "GLThreadManager";
public synchronized void threadExiting(GLThread thread) {
if (LOG_THREADS) {
Log.i("GLThread", "exiting tid=" + thread.getId());
}
thread.mExited = true;
notifyAll();
}
/*
Releases the EGL context. Requires that we are already in the
sGLThreadManager monitor when this is called.
| GLThreadManager::releaseEglContextLocked | java | Reginer/aosp-android-jar | android-35/src/android/opengl/GLSurfaceView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/opengl/GLSurfaceView.java | MIT |
long deadline(long millis) {
// beware of rounding
return System.currentTimeMillis() + millis + 1;
} |
Returns the blocker object used by tests in this file.
Any old object will do; we'll return a convenient one.
static Object theBlocker() {
return LockSupportTest.class;
}
enum ParkMethod {
park() {
void park() {
LockSupport.park();
}
void park(long millis) {
throw new UnsupportedOperationException();
}
},
parkUntil() {
void park(long millis) {
LockSupport.parkUntil(deadline(millis));
}
},
parkNanos() {
void park(long millis) {
LockSupport.parkNanos(MILLISECONDS.toNanos(millis));
}
},
parkBlocker() {
void park() {
LockSupport.park(theBlocker());
}
void park(long millis) {
throw new UnsupportedOperationException();
}
},
parkUntilBlocker() {
void park(long millis) {
LockSupport.parkUntil(theBlocker(), deadline(millis));
}
},
parkNanosBlocker() {
void park(long millis) {
LockSupport.parkNanos(theBlocker(),
MILLISECONDS.toNanos(millis));
}
};
void park() { park(2 * LONG_DELAY_MS); }
abstract void park(long millis);
/** Returns a deadline to use with parkUntil. | enum::deadline | java | Reginer/aosp-android-jar | android-32/src/jsr166/LockSupportTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/jsr166/LockSupportTest.java | MIT |
public void testParkBeforeUnpark_park() {
testParkBeforeUnpark(ParkMethod.park);
} |
park is released by subsequent unpark
| enum::testParkBeforeUnpark_park | java | Reginer/aosp-android-jar | android-32/src/jsr166/LockSupportTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/jsr166/LockSupportTest.java | MIT |
public void testParkAfterUnpark_park() {
testParkAfterUnpark(ParkMethod.park);
} |
park is released by preceding unpark
| enum::testParkAfterUnpark_park | java | Reginer/aosp-android-jar | android-32/src/jsr166/LockSupportTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/jsr166/LockSupportTest.java | MIT |
public void testParkBeforeInterrupt_park() {
testParkBeforeInterrupt(ParkMethod.park);
} |
park is released by subsequent interrupt
| enum::testParkBeforeInterrupt_park | java | Reginer/aosp-android-jar | android-32/src/jsr166/LockSupportTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/jsr166/LockSupportTest.java | MIT |
public void testParkAfterInterrupt_park() {
testParkAfterInterrupt(ParkMethod.park);
} |
park is released by preceding interrupt
| enum::testParkAfterInterrupt_park | java | Reginer/aosp-android-jar | android-32/src/jsr166/LockSupportTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/jsr166/LockSupportTest.java | MIT |
public void testParkTimesOut_parkNanos() {
testParkTimesOut(ParkMethod.parkNanos);
} |
timed park times out if not unparked
| enum::testParkTimesOut_parkNanos | java | Reginer/aosp-android-jar | android-32/src/jsr166/LockSupportTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/jsr166/LockSupportTest.java | MIT |
public void testGetBlockerNull() {
try {
LockSupport.getBlocker(null);
shouldThrow();
} catch (NullPointerException success) {}
} |
getBlocker(null) throws NullPointerException
| enum::testGetBlockerNull | java | Reginer/aosp-android-jar | android-32/src/jsr166/LockSupportTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/jsr166/LockSupportTest.java | MIT |
public void testGetBlocker_parkBlocker() {
testGetBlocker(ParkMethod.parkBlocker);
} |
getBlocker returns the blocker object passed to park
| enum::testGetBlocker_parkBlocker | java | Reginer/aosp-android-jar | android-32/src/jsr166/LockSupportTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/jsr166/LockSupportTest.java | MIT |
public void testPark0_parkNanos() {
testPark0(ParkMethod.parkNanos);
} |
timed park(0) returns immediately.
Requires hotspot fix for:
6763959 java.util.concurrent.locks.LockSupport.parkUntil(0) blocks forever
which is in jdk7-b118 and 6u25.
| enum::testPark0_parkNanos | java | Reginer/aosp-android-jar | android-32/src/jsr166/LockSupportTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/jsr166/LockSupportTest.java | MIT |
public void testParkNeg_parkNanos() {
testParkNeg(ParkMethod.parkNanos);
} |
timed park(Long.MIN_VALUE) returns immediately.
| enum::testParkNeg_parkNanos | java | Reginer/aosp-android-jar | android-32/src/jsr166/LockSupportTest.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/jsr166/LockSupportTest.java | MIT |
public WindowContextController(@NonNull WindowTokenClient token) {
mToken = token;
} |
Window Context Controller constructor
@param token The token used to attach to a window manager node. It is usually from
{@link Context#getWindowContextToken()}.
| WindowContextController::WindowContextController | java | Reginer/aosp-android-jar | android-33/src/android/window/WindowContextController.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/window/WindowContextController.java | MIT |
public void attachToDisplayArea(@WindowType int type, int displayId, @Nullable Bundle options) {
if (mAttachedToDisplayArea == AttachStatus.STATUS_ATTACHED) {
throw new IllegalStateException("A Window Context can be only attached to "
+ "a DisplayArea once.");
}
mAttachedToDisplayArea = mToken.attachToDisplayArea(type, displayId, options)
? AttachStatus.STATUS_ATTACHED : AttachStatus.STATUS_FAILED;
if (mAttachedToDisplayArea == AttachStatus.STATUS_FAILED) {
Log.w(TAG, "attachToDisplayArea fail, type:" + type + ", displayId:"
+ displayId);
} else if (DEBUG_ATTACH) {
Log.d(TAG, "attachToDisplayArea success, type:" + type + ", displayId:"
+ displayId);
}
} |
Attaches the {@code mToken} to a {@link com.android.server.wm.DisplayArea}.
@param type The window type of the {@link WindowContext}
@param displayId The {@link Context#getDisplayId() ID of display} to associate with
@param options The window context launched option
@throws IllegalStateException if the {@code mToken} has already been attached to a
DisplayArea.
| WindowContextController::attachToDisplayArea | java | Reginer/aosp-android-jar | android-33/src/android/window/WindowContextController.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/window/WindowContextController.java | MIT |
public void attachToWindowToken(IBinder windowToken) {
if (mAttachedToDisplayArea != AttachStatus.STATUS_ATTACHED) {
throw new IllegalStateException("The Window Context should have been attached"
+ " to a DisplayArea. AttachToDisplayArea:" + mAttachedToDisplayArea);
}
mToken.attachToWindowToken(windowToken);
} |
Switches to attach the window context to a window token.
<p>
Note that the context should have been attached to a
{@link com.android.server.wm.DisplayArea} by {@link #attachToDisplayArea(int, int, Bundle)}
before attaching to a window token, and the window token's type must match the window
context's type.
</p><p>
A {@link WindowContext} can only attach to a specific window manager node, which is either a
{@link com.android.server.wm.DisplayArea} by calling
{@link #attachToDisplayArea(int, int, Bundle)} or the latest attached {@code windowToken}
although this API is allowed to be called multiple times.
</p>
@throws IllegalStateException if the {@code mClientToken} has not yet attached to
a {@link com.android.server.wm.DisplayArea} by
{@link #attachToDisplayArea(int, int, Bundle)}.
@see WindowProviderService#attachToWindowToken(IBinder))
@see IWindowManager#attachWindowContextToWindowToken(IBinder, IBinder)
| WindowContextController::attachToWindowToken | java | Reginer/aosp-android-jar | android-33/src/android/window/WindowContextController.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/window/WindowContextController.java | MIT |
public void detachIfNeeded() {
if (mAttachedToDisplayArea == AttachStatus.STATUS_ATTACHED) {
mToken.detachFromWindowContainerIfNeeded();
mAttachedToDisplayArea = AttachStatus.STATUS_DETACHED;
if (DEBUG_ATTACH) {
Log.d(TAG, "Detach Window Context.");
}
}
} |
Switches to attach the window context to a window token.
<p>
Note that the context should have been attached to a
{@link com.android.server.wm.DisplayArea} by {@link #attachToDisplayArea(int, int, Bundle)}
before attaching to a window token, and the window token's type must match the window
context's type.
</p><p>
A {@link WindowContext} can only attach to a specific window manager node, which is either a
{@link com.android.server.wm.DisplayArea} by calling
{@link #attachToDisplayArea(int, int, Bundle)} or the latest attached {@code windowToken}
although this API is allowed to be called multiple times.
</p>
@throws IllegalStateException if the {@code mClientToken} has not yet attached to
a {@link com.android.server.wm.DisplayArea} by
{@link #attachToDisplayArea(int, int, Bundle)}.
@see WindowProviderService#attachToWindowToken(IBinder))
@see IWindowManager#attachWindowContextToWindowToken(IBinder, IBinder)
public void attachToWindowToken(IBinder windowToken) {
if (mAttachedToDisplayArea != AttachStatus.STATUS_ATTACHED) {
throw new IllegalStateException("The Window Context should have been attached"
+ " to a DisplayArea. AttachToDisplayArea:" + mAttachedToDisplayArea);
}
mToken.attachToWindowToken(windowToken);
}
/** Detaches the window context from the node it's currently associated with. | WindowContextController::detachIfNeeded | java | Reginer/aosp-android-jar | android-33/src/android/window/WindowContextController.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/window/WindowContextController.java | MIT |
private void doSleepWhileTop(int sleepTime) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
SystemClock.sleep(sleepTime);
return null;
}
@Override
protected void onPostExecute(Void nothing) {
finish();
}
}.execute();
} | /*
Copyright (C) 2019 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 perftests.multiuser.apps.dummyapp;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.SystemClock;
/** An activity.
public class DummyForegroundActivity extends Activity {
private static final String TAG = DummyForegroundActivity.class.getSimpleName();
public static final int TOP_SLEEP_TIME_MS = 2_000;
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
doSleepWhileTop(TOP_SLEEP_TIME_MS);
}
/** Does nothing, but asynchronously. | getSimpleName::doSleepWhileTop | java | Reginer/aosp-android-jar | android-34/src/perftests/multiuser/apps/dummyapp/DummyForegroundActivity.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/perftests/multiuser/apps/dummyapp/DummyForegroundActivity.java | MIT |
public static <T> TerminalOp<T, Optional<T>> makeRef(boolean mustFindFirst) {
return new FindOp<>(mustFindFirst, StreamShape.REFERENCE, Optional.empty(),
Optional::isPresent, FindSink.OfRef::new);
} |
Constructs a {@code TerminalOp} for streams of objects.
@param <T> the type of elements of the stream
@param mustFindFirst whether the {@code TerminalOp} must produce the
first element in the encounter order
@return a {@code TerminalOp} implementing the find operation
| FindOps::makeRef | java | Reginer/aosp-android-jar | android-32/src/java/util/stream/FindOps.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/stream/FindOps.java | MIT |
FindOp(boolean mustFindFirst,
StreamShape shape,
O emptyValue,
Predicate<O> presentPredicate,
Supplier<TerminalSink<T, O>> sinkSupplier) {
this.mustFindFirst = mustFindFirst;
this.shape = shape;
this.emptyValue = emptyValue;
this.presentPredicate = presentPredicate;
this.sinkSupplier = sinkSupplier;
} |
Constructs a {@code FindOp}.
@param mustFindFirst if true, must find the first element in
encounter order, otherwise can find any element
@param shape stream shape of elements to search
@param emptyValue result value corresponding to "found nothing"
@param presentPredicate {@code Predicate} on result value
corresponding to "found something"
@param sinkSupplier supplier for a {@code TerminalSink} implementing
the matching functionality
| FindOp::FindOp | java | Reginer/aosp-android-jar | android-32/src/java/util/stream/FindOps.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/stream/FindOps.java | MIT |
public int getFlags() {
return 0;
} |
@hide
| KeyStoreParameter::getFlags | java | Reginer/aosp-android-jar | android-31/src/android/security/KeyStoreParameter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/security/KeyStoreParameter.java | MIT |
public Builder(@NonNull Context context) {
if (context == null) {
throw new NullPointerException("context == null");
}
} |
Creates a new instance of the {@code Builder} with the given
{@code context}. The {@code context} passed in may be used to pop up
some UI to ask the user to unlock or initialize the Android KeyStore
facility.
| Builder::Builder | java | Reginer/aosp-android-jar | android-31/src/android/security/KeyStoreParameter.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/security/KeyStoreParameter.java | MIT |
default void exposeContent(@NonNull InputContentInfo inputContentInfo,
@NonNull InputConnection inputConnection) {
} |
Allow the receiver of {@link InputContentInfo} to obtain a temporary read-only access
permission to the content.
@param inputContentInfo Content to be temporarily exposed from the input method to the
application. This cannot be {@code null}.
@param inputConnection {@link InputConnection} with which
{@link InputConnection#commitContent(InputContentInfo, int, Bundle)}
will be called.
| exposeContent | java | Reginer/aosp-android-jar | android-35/src/android/inputmethodservice/InputMethodServiceInternal.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/inputmethodservice/InputMethodServiceInternal.java | MIT |
default void notifyUserActionIfNecessary() {
} |
Called when the user took some actions that should be taken into consideration to update the
MRU list for input method rotation.
| notifyUserActionIfNecessary | java | Reginer/aosp-android-jar | android-35/src/android/inputmethodservice/InputMethodServiceInternal.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/inputmethodservice/InputMethodServiceInternal.java | MIT |
default void dump(@SuppressLint("UseParcelFileDescriptor") @NonNull FileDescriptor fd,
@NonNull PrintWriter fout, @NonNull String[] args) {
} |
Called when the system is asking the IME to dump its information for debugging.
<p>The caller is responsible for checking {@link android.Manifest.permission.DUMP}.</p>
@param fd The raw file descriptor that the dump is being sent to.
@param fout The file to which you should dump your state. This will be
closed for you after you return.
@param args additional arguments to the dump request.
| dump | java | Reginer/aosp-android-jar | android-35/src/android/inputmethodservice/InputMethodServiceInternal.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/inputmethodservice/InputMethodServiceInternal.java | MIT |
default void triggerServiceDump(@NonNull String where, @Nullable byte[] icProto) {
} |
Called with {@link com.android.internal.inputmethod.ImeTracing#triggerServiceDump(String,
com.android.internal.inputmethod.ImeTracing.ServiceDumper, byte[])} needs to be triggered
with the given parameters.
@param where {@code where} parameter to be passed.
@param icProto {@code icProto} parameter to be passed.
| triggerServiceDump | java | Reginer/aosp-android-jar | android-35/src/android/inputmethodservice/InputMethodServiceInternal.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/inputmethodservice/InputMethodServiceInternal.java | MIT |
default boolean isServiceDestroyed() {
return false;
}; |
@return {@code true} if {@link InputMethodService} is destroyed.
| isServiceDestroyed | java | Reginer/aosp-android-jar | android-35/src/android/inputmethodservice/InputMethodServiceInternal.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/inputmethodservice/InputMethodServiceInternal.java | MIT |
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
{
int context = getArg0AsNode(xctxt);
XObject val;
if (DTM.NULL != context)
{
DTM dtm = xctxt.getDTM(context);
String qname = dtm.getNodeNameX(context);
val = (null == qname) ? XString.EMPTYSTRING : new XString(qname);
}
else
{
val = XString.EMPTYSTRING;
}
return val;
} |
Execute the function. The function must return
a valid object.
@param xctxt The current execution context.
@return A valid XObject.
@throws javax.xml.transform.TransformerException
| FuncQname::execute | java | Reginer/aosp-android-jar | android-35/src/org/apache/xpath/functions/FuncQname.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/org/apache/xpath/functions/FuncQname.java | MIT |
private ImmutableCollections() { } |
A "salt" value used for randomizing iteration order. This is initialized once
and stays constant for the lifetime of the JVM. It need not be truly random, but
it needs to vary sufficiently from one run to the next so that iteration order
will vary between JVM runs.
static final int SALT;
static {
long nt = System.nanoTime();
SALT = (int)((nt >>> 32) ^ nt);
}
/** No instances. | ImmutableCollections::ImmutableCollections | java | Reginer/aosp-android-jar | android-33/src/java/util/ImmutableCollections.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/java/util/ImmutableCollections.java | MIT |
static <E> SubList<E> fromSubList(SubList<E> parent, int fromIndex, int toIndex) {
return new SubList<>(parent.root, parent.offset + fromIndex, toIndex - fromIndex);
} |
Constructs a sublist of another SubList.
| SubList::fromSubList | java | Reginer/aosp-android-jar | android-33/src/java/util/ImmutableCollections.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/java/util/ImmutableCollections.java | MIT |
static <E> SubList<E> fromList(List<E> list, int fromIndex, int toIndex) {
return new SubList<>(list, fromIndex, toIndex - fromIndex);
} |
Constructs a sublist of an arbitrary AbstractImmutableList, which is
not a SubList itself.
| SubList::fromList | java | Reginer/aosp-android-jar | android-33/src/java/util/ImmutableCollections.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/java/util/ImmutableCollections.java | MIT |
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
ois.defaultReadObject();
int len = ois.readInt();
if (len < 0) {
throw new InvalidObjectException("negative length " + len);
}
Object[] a = new Object[len];
for (int i = 0; i < len; i++) {
a[i] = ois.readObject();
}
array = a;
} |
Reads objects from the stream and stores them
in the transient {@code Object[] array} field.
@serialData
A nonnegative int, indicating the count of objects,
followed by that many objects.
@param ois the ObjectInputStream from which data is read
@throws IOException if an I/O error occurs
@throws ClassNotFoundException if a serialized class cannot be loaded
@throws InvalidObjectException if the count is negative
@since 9
| CollSer::readObject | java | Reginer/aosp-android-jar | android-33/src/java/util/ImmutableCollections.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/java/util/ImmutableCollections.java | MIT |
private void writeObject(ObjectOutputStream oos) throws IOException {
oos.defaultWriteObject();
oos.writeInt(array.length);
for (int i = 0; i < array.length; i++) {
oos.writeObject(array[i]);
}
} |
Writes objects to the stream from
the transient {@code Object[] array} field.
@serialData
A nonnegative int, indicating the count of objects,
followed by that many objects.
@param oos the ObjectOutputStream to which data is written
@throws IOException if an I/O error occurs
@since 9
| CollSer::writeObject | java | Reginer/aosp-android-jar | android-33/src/java/util/ImmutableCollections.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/java/util/ImmutableCollections.java | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.