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 int describeContents() {
return 0;
} |
Constructor for the PresTupleInfo class.
@hide
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public PresTupleInfo(){};
/** @hide | PresTupleInfo::describeContents | java | Reginer/aosp-android-jar | android-35/src/com/android/ims/internal/uce/presence/PresTupleInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/ims/internal/uce/presence/PresTupleInfo.java | MIT |
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mFeatureTag);
dest.writeString(mContactUri);
dest.writeString(mTimestamp);
dest.writeString(mVersion);
} |
Constructor for the PresTupleInfo class.
@hide
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public PresTupleInfo(){};
/** @hide
public int describeContents() {
return 0;
}
/** @hide | PresTupleInfo::writeToParcel | java | Reginer/aosp-android-jar | android-35/src/com/android/ims/internal/uce/presence/PresTupleInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/ims/internal/uce/presence/PresTupleInfo.java | MIT |
private PresTupleInfo(Parcel source) {
readFromParcel(source);
} |
Constructor for the PresTupleInfo class.
@hide
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public PresTupleInfo(){};
/** @hide
public int describeContents() {
return 0;
}
/** @hide
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mFeatureTag);
dest.writeString(mContactUri);
dest.writeString(mTimestamp);
dest.writeString(mVersion);
}
/** @hide
public static final Parcelable.Creator<PresTupleInfo> CREATOR =
new Parcelable.Creator<PresTupleInfo>() {
public PresTupleInfo createFromParcel(Parcel source) {
return new PresTupleInfo(source);
}
public PresTupleInfo[] newArray(int size) {
return new PresTupleInfo[size];
}
};
/** @hide | PresTupleInfo::PresTupleInfo | java | Reginer/aosp-android-jar | android-35/src/com/android/ims/internal/uce/presence/PresTupleInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/ims/internal/uce/presence/PresTupleInfo.java | MIT |
public void readFromParcel(Parcel source) {
mFeatureTag = source.readString();
mContactUri = source.readString();
mTimestamp = source.readString();
mVersion = source.readString();
} |
Constructor for the PresTupleInfo class.
@hide
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public PresTupleInfo(){};
/** @hide
public int describeContents() {
return 0;
}
/** @hide
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mFeatureTag);
dest.writeString(mContactUri);
dest.writeString(mTimestamp);
dest.writeString(mVersion);
}
/** @hide
public static final Parcelable.Creator<PresTupleInfo> CREATOR =
new Parcelable.Creator<PresTupleInfo>() {
public PresTupleInfo createFromParcel(Parcel source) {
return new PresTupleInfo(source);
}
public PresTupleInfo[] newArray(int size) {
return new PresTupleInfo[size];
}
};
/** @hide
private PresTupleInfo(Parcel source) {
readFromParcel(source);
}
/** @hide | PresTupleInfo::readFromParcel | java | Reginer/aosp-android-jar | android-35/src/com/android/ims/internal/uce/presence/PresTupleInfo.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/ims/internal/uce/presence/PresTupleInfo.java | MIT |
default void init() {
getShell().onInit();
} |
Initializes all the WMShell components before starting any of the SystemUI components.
| public::init | java | Reginer/aosp-android-jar | android-34/src/com/android/systemui/dagger/WMComponent.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/dagger/WMComponent.java | MIT |
/* package private */ DrmInitData() {
} |
Prevent public constuctor access
| DrmInitData::DrmInitData | java | Reginer/aosp-android-jar | android-31/src/android/media/DrmInitData.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/media/DrmInitData.java | MIT |
public int getSchemeInitDataCount() {
return 0;
} |
Returns the number of {@link SchemeInitData} elements available through {@link
#getSchemeInitDataAt}.
| DrmInitData::getSchemeInitDataCount | java | Reginer/aosp-android-jar | android-31/src/android/media/DrmInitData.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/media/DrmInitData.java | MIT |
@NonNull public SchemeInitData getSchemeInitDataAt(int index) {
throw new IndexOutOfBoundsException();
} |
Returns the {@link SchemeInitData} with the given {@code index}.
@param index The index of the {@link SchemeInitData} to return.
@return The {@link SchemeInitData} associated with the given {@code index}.
@throws IndexOutOfBoundsException If the given {@code index} is negative or greater than
{@link #getSchemeInitDataCount}{@code - 1}.
| DrmInitData::getSchemeInitDataAt | java | Reginer/aosp-android-jar | android-31/src/android/media/DrmInitData.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/media/DrmInitData.java | MIT |
public SchemeInitData(@NonNull UUID uuid, @NonNull String mimeType, @NonNull byte[] data) {
this.uuid = Objects.requireNonNull(uuid);
this.mimeType = Objects.requireNonNull(mimeType);
this.data = Objects.requireNonNull(data);
} |
Creates a new instance with the given values.
@param uuid The UUID associated with this scheme initialization data.
@param mimeType The mimeType of the initialization data.
@param data The initialization data.
| SchemeInitData::SchemeInitData | java | Reginer/aosp-android-jar | android-31/src/android/media/DrmInitData.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/media/DrmInitData.java | MIT |
private void startUnlockHintAnimationPhase2(boolean right, final Runnable onFinishedListener) {
ValueAnimator animator = getAnimatorToRadius(right, 0);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mSwipeAnimator = null;
mTargetedView = null;
onFinishedListener.run();
}
});
animator.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN);
animator.setDuration(HINT_PHASE2_DURATION);
animator.setStartDelay(HINT_CIRCLE_OPEN_DURATION);
animator.start();
mSwipeAnimator = animator;
} |
Phase 2: Move back.
| KeyguardAffordanceHelper::startUnlockHintAnimationPhase2 | java | Reginer/aosp-android-jar | android-32/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java | MIT |
public void setTouching(boolean touching, boolean animate) {
if (touching == mTouching) {
return;
}
if (mAnimator != null) {
mAnimator.cancel();
mAnimator = null;
}
if (!animate) {
if (touching) {
mCurrentWidth = mCircleDiameter;
mCurrentHeight = mCircleDiameter;
} else {
mCurrentWidth = mWidth;
mCurrentHeight = mHeight;
}
invalidate();
} else {
animateToTarget(touching ? mCircleDiameter : mWidth,
touching ? mCircleDiameter : mHeight, touching);
}
mTouching = touching;
} |
View for the handle in the docked stack divider.
public class DividerHandleView extends View {
private static final Property<DividerHandleView, Integer> WIDTH_PROPERTY =
new Property<DividerHandleView, Integer>(Integer.class, "width") {
@Override
public Integer get(DividerHandleView object) {
return object.mCurrentWidth;
}
@Override
public void set(DividerHandleView object, Integer value) {
object.mCurrentWidth = value;
object.invalidate();
}
};
private static final Property<DividerHandleView, Integer> HEIGHT_PROPERTY =
new Property<DividerHandleView, Integer>(Integer.class, "height") {
@Override
public Integer get(DividerHandleView object) {
return object.mCurrentHeight;
}
@Override
public void set(DividerHandleView object, Integer value) {
object.mCurrentHeight = value;
object.invalidate();
}
};
private final Paint mPaint = new Paint();
private final int mWidth;
private final int mHeight;
private final int mCircleDiameter;
private int mCurrentWidth;
private int mCurrentHeight;
private AnimatorSet mAnimator;
private boolean mTouching;
public DividerHandleView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
mPaint.setColor(getResources().getColor(R.color.docked_divider_handle, null));
mPaint.setAntiAlias(true);
mWidth = getResources().getDimensionPixelSize(R.dimen.docked_divider_handle_width);
mHeight = getResources().getDimensionPixelSize(R.dimen.docked_divider_handle_height);
mCurrentWidth = mWidth;
mCurrentHeight = mHeight;
mCircleDiameter = (mWidth + mHeight) / 3;
}
/** Sets touching state for this handle view. | DividerHandleView::setTouching | java | Reginer/aosp-android-jar | android-31/src/com/android/wm/shell/common/split/DividerHandleView.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/common/split/DividerHandleView.java | MIT |
public void notifyUserActivity(
long eventTime, int powerGroupId, @PowerManager.UserActivityEvent int event) {
if (!mPowerGroups.contains(powerGroupId)) {
mPowerGroups.append(powerGroupId, new WakefulnessSessionPowerGroup(powerGroupId));
}
mPowerGroups.get(powerGroupId).notifyUserActivity(eventTime, event);
} |
Track the user activity event.
@param eventTime Activity time, in uptime millis.
@param powerGroupId Power Group Id for this user activity
@param event Activity type as defined in {@link PowerManager}. {@link
android.hardware.display.DisplayManagerInternal.DisplayPowerRequest}
| WakefulnessSessionObserver::notifyUserActivity | java | Reginer/aosp-android-jar | android-35/src/com/android/server/power/WakefulnessSessionObserver.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/power/WakefulnessSessionObserver.java | MIT |
public void onWakefulnessChangeStarted(int powerGroupId, int wakefulness, int changeReason,
long eventTime) {
if (!mPowerGroups.contains(powerGroupId)) {
mPowerGroups.append(powerGroupId, new WakefulnessSessionPowerGroup(powerGroupId));
}
mPowerGroups.get(powerGroupId).onWakefulnessChangeStarted(wakefulness, changeReason,
eventTime);
} |
Track the system wakefulness
@param powerGroupId Power Group Id for this wakefulness changes
@param wakefulness Wakefulness as defined in {@link PowerManagerInternal}
@param changeReason Reason of the go to sleep in
{@link PowerManager.GoToSleepReason} or {@link PowerManager.WakeReason}
@param eventTime timestamp of the wakefulness changes
| WakefulnessSessionObserver::onWakefulnessChangeStarted | java | Reginer/aosp-android-jar | android-35/src/com/android/server/power/WakefulnessSessionObserver.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/power/WakefulnessSessionObserver.java | MIT |
public void onWakeLockAcquired(int flags) {
int maskedFlag = flags & PowerManager.WAKE_LOCK_LEVEL_MASK;
if (maskedFlag == PowerManager.SCREEN_TIMEOUT_OVERRIDE_WAKE_LOCK) {
for (int idx = 0; idx < mPowerGroups.size(); idx++) {
mPowerGroups.valueAt(idx).acquireTimeoutOverrideWakeLock();
}
}
} |
Track the acquired wakelocks
@param flags wakelocks to be acquired {@link PowerManager}
| WakefulnessSessionObserver::onWakeLockAcquired | java | Reginer/aosp-android-jar | android-35/src/com/android/server/power/WakefulnessSessionObserver.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/power/WakefulnessSessionObserver.java | MIT |
public void onWakeLockReleased(int flags, int releaseReason) {
int maskedFlag = flags & PowerManager.WAKE_LOCK_LEVEL_MASK;
if (maskedFlag == PowerManager.SCREEN_TIMEOUT_OVERRIDE_WAKE_LOCK) {
for (int idx = 0; idx < mPowerGroups.size(); idx++) {
mPowerGroups.valueAt(idx).releaseTimeoutOverrideWakeLock(releaseReason);
}
}
} |
Track the released wakelocks
@param flags wakelocks to be released {@link PowerManager}
@param releaseReason the reason to release wakelock
{@link ScreenTimeoutOverridePolicy.ReleaseReason}
| WakefulnessSessionObserver::onWakeLockReleased | java | Reginer/aosp-android-jar | android-35/src/com/android/server/power/WakefulnessSessionObserver.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/power/WakefulnessSessionObserver.java | MIT |
public void removePowerGroup(int powerGroupId) {
if (mPowerGroups.contains((powerGroupId))) {
mPowerGroups.delete(powerGroupId);
}
} |
Remove the inactive power group
@param powerGroupId Power Group Id that should be removed
| WakefulnessSessionObserver::removePowerGroup | java | Reginer/aosp-android-jar | android-35/src/com/android/server/power/WakefulnessSessionObserver.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/power/WakefulnessSessionObserver.java | MIT |
public ProgressBarMixin(TemplateLayout layout) {
templateLayout = layout;
} | /*
Copyright (C) 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
package com.android.setupwizardlib.template;
import android.content.res.ColorStateList;
import android.os.Build;
import android.os.Build.VERSION_CODES;
import androidx.annotation.Nullable;
import android.view.View;
import android.view.ViewStub;
import android.widget.ProgressBar;
import com.android.setupwizardlib.R;
import com.android.setupwizardlib.TemplateLayout;
/** A {@link Mixin} for showing a progress bar.
public class ProgressBarMixin implements Mixin {
private final TemplateLayout templateLayout;
@Nullable private ColorStateList color;
/** @param layout The layout this mixin belongs to. | ProgressBarMixin::ProgressBarMixin | java | Reginer/aosp-android-jar | android-32/src/com/android/setupwizardlib/template/ProgressBarMixin.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/setupwizardlib/template/ProgressBarMixin.java | MIT |
public boolean isShown() {
final View progressBar = templateLayout.findManagedViewById(R.id.suw_layout_progress);
return progressBar != null && progressBar.getVisibility() == View.VISIBLE;
} | /*
Copyright (C) 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
package com.android.setupwizardlib.template;
import android.content.res.ColorStateList;
import android.os.Build;
import android.os.Build.VERSION_CODES;
import androidx.annotation.Nullable;
import android.view.View;
import android.view.ViewStub;
import android.widget.ProgressBar;
import com.android.setupwizardlib.R;
import com.android.setupwizardlib.TemplateLayout;
/** A {@link Mixin} for showing a progress bar.
public class ProgressBarMixin implements Mixin {
private final TemplateLayout templateLayout;
@Nullable private ColorStateList color;
/** @param layout The layout this mixin belongs to.
public ProgressBarMixin(TemplateLayout layout) {
templateLayout = layout;
}
/** @return True if the progress bar is currently shown. | ProgressBarMixin::isShown | java | Reginer/aosp-android-jar | android-32/src/com/android/setupwizardlib/template/ProgressBarMixin.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/setupwizardlib/template/ProgressBarMixin.java | MIT |
public void setShown(boolean shown) {
if (shown) {
View progressBar = getProgressBar();
if (progressBar != null) {
progressBar.setVisibility(View.VISIBLE);
}
} else {
View progressBar = peekProgressBar();
if (progressBar != null) {
progressBar.setVisibility(View.GONE);
}
}
} |
Sets whether the progress bar is shown. If the progress bar has not been inflated from the
stub, this method will inflate the progress bar.
@param shown True to show the progress bar, false to hide it.
| ProgressBarMixin::setShown | java | Reginer/aosp-android-jar | android-32/src/com/android/setupwizardlib/template/ProgressBarMixin.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/setupwizardlib/template/ProgressBarMixin.java | MIT |
private ProgressBar getProgressBar() {
final View progressBar = peekProgressBar();
if (progressBar == null) {
final ViewStub progressBarStub =
(ViewStub) templateLayout.findManagedViewById(R.id.suw_layout_progress_stub);
if (progressBarStub != null) {
progressBarStub.inflate();
}
setColor(color);
}
return peekProgressBar();
} |
Gets the progress bar in the layout. If the progress bar has not been used before, it will be
installed (i.e. inflated from its view stub).
@return The progress bar of this layout. May be null only if the template used doesn't have a
progress bar built-in.
| ProgressBarMixin::getProgressBar | java | Reginer/aosp-android-jar | android-32/src/com/android/setupwizardlib/template/ProgressBarMixin.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/setupwizardlib/template/ProgressBarMixin.java | MIT |
public ProgressBar peekProgressBar() {
return (ProgressBar) templateLayout.findManagedViewById(R.id.suw_layout_progress);
} |
Gets the progress bar in the layout only if it has been installed. {@link #setShown(boolean)}
should be called before this to ensure the progress bar is set up correctly.
@return The progress bar of this layout, or null if the progress bar is not installed. The null
case can happen either if {@link #setShown(boolean)} with true was not called before this,
or if the template does not contain a progress bar.
| ProgressBarMixin::peekProgressBar | java | Reginer/aosp-android-jar | android-32/src/com/android/setupwizardlib/template/ProgressBarMixin.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/setupwizardlib/template/ProgressBarMixin.java | MIT |
public void setColor(@Nullable ColorStateList color) {
this.color = color;
if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
final ProgressBar bar = peekProgressBar();
if (bar != null) {
bar.setIndeterminateTintList(color);
if (Build.VERSION.SDK_INT >= VERSION_CODES.M || color != null) {
// There is a bug in Lollipop where setting the progress tint color to null
// will crash with "java.lang.NullPointerException: Attempt to invoke virtual
// method 'int android.graphics.Paint.getAlpha()' on a null object reference"
// at android.graphics.drawable.NinePatchDrawable.draw(:250)
// The bug doesn't affect ProgressBar on M because it uses ShapeDrawable instead
// of NinePatchDrawable. (commit 6a8253fdc9f4574c28b4beeeed90580ffc93734a)
bar.setProgressBackgroundTintList(color);
}
}
}
} |
Gets the progress bar in the layout only if it has been installed. {@link #setShown(boolean)}
should be called before this to ensure the progress bar is set up correctly.
@return The progress bar of this layout, or null if the progress bar is not installed. The null
case can happen either if {@link #setShown(boolean)} with true was not called before this,
or if the template does not contain a progress bar.
public ProgressBar peekProgressBar() {
return (ProgressBar) templateLayout.findManagedViewById(R.id.suw_layout_progress);
}
/** Sets the color of the indeterminate progress bar. This method is a no-op on SDK < 21. | ProgressBarMixin::setColor | java | Reginer/aosp-android-jar | android-32/src/com/android/setupwizardlib/template/ProgressBarMixin.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/setupwizardlib/template/ProgressBarMixin.java | MIT |
public AlreadyConnectedException() { } |
Constructs an instance of this class.
| AlreadyConnectedException::AlreadyConnectedException | java | Reginer/aosp-android-jar | android-35/src/java/nio/channels/AlreadyConnectedException.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/nio/channels/AlreadyConnectedException.java | MIT |
public int toMetricsEventEnum() {
return mMetricsEventNotificationLocation;
} |
Returns the field from MetricsEvent.NotificationLocation that corresponds to this object.
| NotificationLocation::toMetricsEventEnum | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/statusbar/NotificationVisibility.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/statusbar/NotificationVisibility.java | MIT |
public static NotificationVisibility obtain(String key, int rank, int count, boolean visible) {
return obtain(key, rank, count, visible,
NotificationVisibility.NotificationLocation.LOCATION_UNKNOWN);
} |
Create a new NotificationVisibility object.
| NotificationLocation::obtain | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/statusbar/NotificationVisibility.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/statusbar/NotificationVisibility.java | MIT |
public static NotificationVisibility obtain(String key, int rank, int count, boolean visible,
NotificationLocation location) {
NotificationVisibility vo = obtain();
vo.key = key;
vo.rank = rank;
vo.count = count;
vo.visible = visible;
vo.location = location;
return vo;
} |
Create a new NotificationVisibility object.
| NotificationLocation::obtain | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/statusbar/NotificationVisibility.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/statusbar/NotificationVisibility.java | MIT |
public void recycle() {
// With a modern GC, this is no longer useful for objects this small.
} |
Return a NotificationVisibility instance to the global pool.
<p>
You MUST NOT touch the NotificationVisibility after calling this function because it has
effectively been freed.
</p>
| NotificationLocation::recycle | java | Reginer/aosp-android-jar | android-34/src/com/android/internal/statusbar/NotificationVisibility.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/statusbar/NotificationVisibility.java | MIT |
private Locale(BaseLocale baseLocale, LocaleExtensions extensions) {
this.baseLocale = baseLocale;
this.localeExtensions = extensions;
} |
Private constructor used by getInstance method
| Locale::Locale | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public Locale(String language, String country, String variant) {
if (language== null || country == null || variant == null) {
throw new NullPointerException();
}
baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), "", country, variant);
localeExtensions = getCompatibilityExtensions(language, "", country, variant);
} |
Construct a locale from language, country and variant.
This constructor normalizes the language value to lowercase and
the country value to uppercase.
<p>
<b>Note:</b>
<ul>
<li>ISO 639 is not a stable standard; some of the language codes it defines
(specifically "iw", "ji", and "in") have changed. This constructor accepts both the
old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other
API on Locale will return only the OLD codes.
<li>For backward compatibility reasons, this constructor does not make
any syntactic checks on the input.
<li>The two cases ("ja", "JP", "JP") and ("th", "TH", "TH") are handled specially,
see <a href="#special_cases_constructor">Special Cases</a> for more information.
</ul>
@param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
up to 8 characters in length. See the <code>Locale</code> class description about
valid language values.
@param country An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.
See the <code>Locale</code> class description about valid country values.
@param variant Any arbitrary value used to indicate a variation of a <code>Locale</code>.
See the <code>Locale</code> class description for the details.
@exception NullPointerException thrown if any argument is null.
| Locale::Locale | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public Locale(String language, String country) {
this(language, country, "");
} |
Construct a locale from language and country.
This constructor normalizes the language value to lowercase and
the country value to uppercase.
<p>
<b>Note:</b>
<ul>
<li>ISO 639 is not a stable standard; some of the language codes it defines
(specifically "iw", "ji", and "in") have changed. This constructor accepts both the
old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other
API on Locale will return only the OLD codes.
<li>For backward compatibility reasons, this constructor does not make
any syntactic checks on the input.
</ul>
@param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
up to 8 characters in length. See the <code>Locale</code> class description about
valid language values.
@param country An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code.
See the <code>Locale</code> class description about valid country values.
@exception NullPointerException thrown if either argument is null.
| Locale::Locale | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public Locale(String language) {
this(language, "", "");
} |
Construct a locale from a language code.
This constructor normalizes the language value to lowercase.
<p>
<b>Note:</b>
<ul>
<li>ISO 639 is not a stable standard; some of the language codes it defines
(specifically "iw", "ji", and "in") have changed. This constructor accepts both the
old codes ("iw", "ji", and "in") and the new codes ("he", "yi", and "id"), but all other
API on Locale will return only the OLD codes.
<li>For backward compatibility reasons, this constructor does not make
any syntactic checks on the input.
</ul>
@param language An ISO 639 alpha-2 or alpha-3 language code, or a language subtag
up to 8 characters in length. See the <code>Locale</code> class description about
valid language values.
@exception NullPointerException thrown if argument is null.
@since 1.4
| Locale::Locale | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
private static Locale createConstant(String lang, String country) {
BaseLocale base = BaseLocale.createInstance(lang, country);
return getInstance(base, null);
} |
This method must be called only for creating the Locale.*
constants due to making shortcuts.
| Locale::createConstant | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
static Locale getInstance(String language, String country, String variant) {
return getInstance(language, "", country, variant, null);
} |
Returns a <code>Locale</code> constructed from the given
<code>language</code>, <code>country</code> and
<code>variant</code>. If the same <code>Locale</code> instance
is available in the cache, then that instance is
returned. Otherwise, a new <code>Locale</code> instance is
created and cached.
@param language lowercase 2 to 8 language code.
@param country uppercase two-letter ISO-3166 code and numric-3 UN M.49 area code.
@param variant vendor and browser specific code. See class description.
@return the <code>Locale</code> instance requested
@exception NullPointerException if any argument is null.
| Locale::getInstance | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public static Locale getDefault() {
// do not synchronize this method - see 4071298
// Android-changed: Add NoImagePreloadHolder to allow compile-time initialization.
// return defaultLocale;
return NoImagePreloadHolder.defaultLocale;
} |
Gets the current value of the default locale for this instance
of the Java Virtual Machine.
<p>
The Java Virtual Machine sets the default locale during startup
based on the host environment. It is used by many locale-sensitive
methods if no locale is explicitly specified.
It can be changed using the
{@link #setDefault(java.util.Locale) setDefault} method.
@return the default locale for this instance of the Java Virtual Machine
| LocaleKey::getDefault | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public static Locale getDefault(Locale.Category category) {
// do not synchronize this method - see 4071298
switch (category) {
case DISPLAY:
if (defaultDisplayLocale == null) {
synchronized(Locale.class) {
if (defaultDisplayLocale == null) {
defaultDisplayLocale = initDefault(category);
}
}
}
return defaultDisplayLocale;
case FORMAT:
if (defaultFormatLocale == null) {
synchronized(Locale.class) {
if (defaultFormatLocale == null) {
defaultFormatLocale = initDefault(category);
}
}
}
return defaultFormatLocale;
default:
assert false: "Unknown Category";
}
return getDefault();
} |
Gets the current value of the default locale for the specified Category
for this instance of the Java Virtual Machine.
<p>
The Java Virtual Machine sets the default locale during startup based
on the host environment. It is used by many locale-sensitive methods
if no locale is explicitly specified. It can be changed using the
setDefault(Locale.Category, Locale) method.
@param category - the specified category to get the default locale
@throws NullPointerException - if category is null
@return the default locale for the specified Category for this instance
of the Java Virtual Machine
@see #setDefault(Locale.Category, Locale)
@since 1.7
| LocaleKey::getDefault | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public Builder() {
localeBuilder = new InternalLocaleBuilder();
} |
Constructs an empty Builder. The default value of all
fields, extensions, and private use information is the
empty string.
| Builder::Builder | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public Builder setLocale(Locale locale) {
try {
localeBuilder.setLocale(locale.baseLocale, locale.localeExtensions);
} catch (LocaleSyntaxException e) {
throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex());
}
return this;
} |
Resets the <code>Builder</code> to match the provided
<code>locale</code>. Existing state is discarded.
<p>All fields of the locale must be well-formed, see {@link Locale}.
<p>Locales with any ill-formed fields cause
<code>IllformedLocaleException</code> to be thrown, except for the
following three cases which are accepted for compatibility
reasons:<ul>
<li>Locale("ja", "JP", "JP") is treated as "ja-JP-u-ca-japanese"
<li>Locale("th", "TH", "TH") is treated as "th-TH-u-nu-thai"
<li>Locale("no", "NO", "NY") is treated as "nn-NO"</ul>
@param locale the locale
@return This builder.
@throws IllformedLocaleException if <code>locale</code> has
any ill-formed fields.
@throws NullPointerException if <code>locale</code> is null.
| Builder::setLocale | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public Builder setLanguageTag(String languageTag) {
ParseStatus sts = new ParseStatus();
LanguageTag tag = LanguageTag.parse(languageTag, sts);
if (sts.isError()) {
throw new IllformedLocaleException(sts.getErrorMessage(), sts.getErrorIndex());
}
localeBuilder.setLanguageTag(tag);
return this;
} |
Resets the Builder to match the provided IETF BCP 47
language tag. Discards the existing state. Null and the
empty string cause the builder to be reset, like {@link
#clear}. Grandfathered tags (see {@link
Locale#forLanguageTag}) are converted to their canonical
form before being processed. Otherwise, the language tag
must be well-formed (see {@link Locale}) or an exception is
thrown (unlike <code>Locale.forLanguageTag</code>, which
just discards ill-formed and following portions of the
tag).
@param languageTag the language tag
@return This builder.
@throws IllformedLocaleException if <code>languageTag</code> is ill-formed
@see Locale#forLanguageTag(String)
| Builder::setLanguageTag | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public Builder setLanguage(String language) {
try {
localeBuilder.setLanguage(language);
} catch (LocaleSyntaxException e) {
throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex());
}
return this;
} |
Sets the language. If <code>language</code> is the empty string or
null, the language in this <code>Builder</code> is removed. Otherwise,
the language must be <a href="./Locale.html#def_language">well-formed</a>
or an exception is thrown.
<p>The typical language value is a two or three-letter language
code as defined in ISO639.
@param language the language
@return This builder.
@throws IllformedLocaleException if <code>language</code> is ill-formed
| Builder::setLanguage | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public Builder setScript(String script) {
try {
localeBuilder.setScript(script);
} catch (LocaleSyntaxException e) {
throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex());
}
return this;
} |
Sets the script. If <code>script</code> is null or the empty string,
the script in this <code>Builder</code> is removed.
Otherwise, the script must be <a href="./Locale.html#def_script">well-formed</a> or an
exception is thrown.
<p>The typical script value is a four-letter script code as defined by ISO 15924.
@param script the script
@return This builder.
@throws IllformedLocaleException if <code>script</code> is ill-formed
| Builder::setScript | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public Builder setRegion(String region) {
try {
localeBuilder.setRegion(region);
} catch (LocaleSyntaxException e) {
throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex());
}
return this;
} |
Sets the region. If region is null or the empty string, the region
in this <code>Builder</code> is removed. Otherwise,
the region must be <a href="./Locale.html#def_region">well-formed</a> or an
exception is thrown.
<p>The typical region value is a two-letter ISO 3166 code or a
three-digit UN M.49 area code.
<p>The country value in the <code>Locale</code> created by the
<code>Builder</code> is always normalized to upper case.
@param region the region
@return This builder.
@throws IllformedLocaleException if <code>region</code> is ill-formed
| Builder::setRegion | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public Builder setVariant(String variant) {
try {
localeBuilder.setVariant(variant);
} catch (LocaleSyntaxException e) {
throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex());
}
return this;
} |
Sets the variant. If variant is null or the empty string, the
variant in this <code>Builder</code> is removed. Otherwise, it
must consist of one or more <a href="./Locale.html#def_variant">well-formed</a>
subtags, or an exception is thrown.
<p><b>Note:</b> This method checks if <code>variant</code>
satisfies the IETF BCP 47 variant subtag's syntax requirements,
and normalizes the value to lowercase letters. However,
the <code>Locale</code> class does not impose any syntactic
restriction on variant, and the variant value in
<code>Locale</code> is case sensitive. To set such a variant,
use a Locale constructor.
@param variant the variant
@return This builder.
@throws IllformedLocaleException if <code>variant</code> is ill-formed
| Builder::setVariant | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public Builder setExtension(char key, String value) {
try {
localeBuilder.setExtension(key, value);
} catch (LocaleSyntaxException e) {
throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex());
}
return this;
} |
Sets the extension for the given key. If the value is null or the
empty string, the extension is removed. Otherwise, the extension
must be <a href="./Locale.html#def_extensions">well-formed</a> or an exception
is thrown.
<p><b>Note:</b> The key {@link Locale#UNICODE_LOCALE_EXTENSION
UNICODE_LOCALE_EXTENSION} ('u') is used for the Unicode locale extension.
Setting a value for this key replaces any existing Unicode locale key/type
pairs with those defined in the extension.
<p><b>Note:</b> The key {@link Locale#PRIVATE_USE_EXTENSION
PRIVATE_USE_EXTENSION} ('x') is used for the private use code. To be
well-formed, the value for this key needs only to have subtags of one to
eight alphanumeric characters, not two to eight as in the general case.
@param key the extension key
@param value the extension value
@return This builder.
@throws IllformedLocaleException if <code>key</code> is illegal
or <code>value</code> is ill-formed
@see #setUnicodeLocaleKeyword(String, String)
| Builder::setExtension | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public Builder setUnicodeLocaleKeyword(String key, String type) {
try {
localeBuilder.setUnicodeLocaleKeyword(key, type);
} catch (LocaleSyntaxException e) {
throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex());
}
return this;
} |
Sets the Unicode locale keyword type for the given key. If the type
is null, the Unicode keyword is removed. Otherwise, the key must be
non-null and both key and type must be <a
href="./Locale.html#def_locale_extension">well-formed</a> or an exception
is thrown.
<p>Keys and types are converted to lower case.
<p><b>Note</b>:Setting the 'u' extension via {@link #setExtension}
replaces all Unicode locale keywords with those defined in the
extension.
@param key the Unicode locale key
@param type the Unicode locale type
@return This builder.
@throws IllformedLocaleException if <code>key</code> or <code>type</code>
is ill-formed
@throws NullPointerException if <code>key</code> is null
@see #setExtension(char, String)
| Builder::setUnicodeLocaleKeyword | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public Builder addUnicodeLocaleAttribute(String attribute) {
try {
localeBuilder.addUnicodeLocaleAttribute(attribute);
} catch (LocaleSyntaxException e) {
throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex());
}
return this;
} |
Adds a unicode locale attribute, if not already present, otherwise
has no effect. The attribute must not be null and must be <a
href="./Locale.html#def_locale_extension">well-formed</a> or an exception
is thrown.
@param attribute the attribute
@return This builder.
@throws NullPointerException if <code>attribute</code> is null
@throws IllformedLocaleException if <code>attribute</code> is ill-formed
@see #setExtension(char, String)
| Builder::addUnicodeLocaleAttribute | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public Builder removeUnicodeLocaleAttribute(String attribute) {
// BEGIN Android-added: removeUnicodeLocaleAttribute(null) is documented to throw NPE.
// This could probably be contributed back to upstream. http://b/110752069
if (attribute == null) {
throw new NullPointerException("attribute == null");
}
// END Android-added: removeUnicodeLocaleAttribute(null) is documented to throw NPE.
try {
localeBuilder.removeUnicodeLocaleAttribute(attribute);
} catch (LocaleSyntaxException e) {
throw new IllformedLocaleException(e.getMessage(), e.getErrorIndex());
}
return this;
} |
Removes a unicode locale attribute, if present, otherwise has no
effect. The attribute must not be null and must be <a
href="./Locale.html#def_locale_extension">well-formed</a> or an exception
is thrown.
<p>Attribute comparision for removal is case-insensitive.
@param attribute the attribute
@return This builder.
@throws NullPointerException if <code>attribute</code> is null
@throws IllformedLocaleException if <code>attribute</code> is ill-formed
@see #setExtension(char, String)
| Builder::removeUnicodeLocaleAttribute | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public Builder clear() {
localeBuilder.clear();
return this;
} |
Resets the builder to its initial, empty state.
@return This builder.
| Builder::clear | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public Builder clearExtensions() {
localeBuilder.clearExtensions();
return this;
} |
Resets the extensions to their initial, empty state.
Language, script, region and variant are unchanged.
@return This builder.
@see #setExtension(char, String)
| Builder::clearExtensions | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public Locale build() {
BaseLocale baseloc = localeBuilder.getBaseLocale();
LocaleExtensions extensions = localeBuilder.getLocaleExtensions();
if (extensions == null && baseloc.getVariant().length() > 0) {
extensions = getCompatibilityExtensions(baseloc.getLanguage(), baseloc.getScript(),
baseloc.getRegion(), baseloc.getVariant());
}
return Locale.getInstance(baseloc, extensions);
} |
Returns an instance of <code>Locale</code> created from the fields set
on this builder.
<p>This applies the conversions listed in {@link Locale#forLanguageTag}
when constructing a Locale. (Grandfathered tags are handled in
{@link #setLanguageTag}.)
@return A Locale.
| Builder::build | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public LanguageRange(String range) {
this(range, MAX_WEIGHT);
} |
Constructs a {@code LanguageRange} using the given {@code range}.
Note that no validation is done against the IANA Language Subtag
Registry at time of construction.
<p>This is equivalent to {@code LanguageRange(range, MAX_WEIGHT)}.
@param range a language range
@throws NullPointerException if the given {@code range} is
{@code null}
| LanguageRange::LanguageRange | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public LanguageRange(String range, double weight) {
if (range == null) {
throw new NullPointerException();
}
if (weight < MIN_WEIGHT || weight > MAX_WEIGHT) {
throw new IllegalArgumentException("weight=" + weight);
}
range = range.toLowerCase();
// Do syntax check.
boolean isIllFormed = false;
String[] subtags = range.split("-");
if (isSubtagIllFormed(subtags[0], true)
|| range.endsWith("-")) {
isIllFormed = true;
} else {
for (int i = 1; i < subtags.length; i++) {
if (isSubtagIllFormed(subtags[i], false)) {
isIllFormed = true;
break;
}
}
}
if (isIllFormed) {
throw new IllegalArgumentException("range=" + range);
}
this.range = range;
this.weight = weight;
} |
Constructs a {@code LanguageRange} using the given {@code range} and
{@code weight}. Note that no validation is done against the IANA
Language Subtag Registry at time of construction.
@param range a language range
@param weight a weight value between {@code MIN_WEIGHT} and
{@code MAX_WEIGHT}
@throws NullPointerException if the given {@code range} is
{@code null}
@throws IllegalArgumentException if the given {@code weight} is less
than {@code MIN_WEIGHT} or greater than {@code MAX_WEIGHT}
| LanguageRange::LanguageRange | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public String getRange() {
return range;
} |
Returns the language range of this {@code LanguageRange}.
@return the language range.
| LanguageRange::getRange | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public double getWeight() {
return weight;
} |
Returns the weight of this {@code LanguageRange}.
@return the weight value.
| LanguageRange::getWeight | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public static List<LanguageRange> parse(String ranges) {
return LocaleMatcher.parse(ranges);
} |
Parses the given {@code ranges} to generate a Language Priority List.
<p>This method performs a syntactic check for each language range in
the given {@code ranges} but doesn't do validation using the IANA
Language Subtag Registry.
<p>The {@code ranges} to be given can take one of the following
forms:
<pre>
"Accept-Language: ja,en;q=0.4" (weighted list with Accept-Language prefix)
"ja,en;q=0.4" (weighted list)
"ja,en" (prioritized list)
</pre>
In a weighted list, each language range is given a weight value.
The weight value is identical to the "quality value" in
<a href="http://tools.ietf.org/html/rfc2616">RFC 2616</a>, and it
expresses how much the user prefers the language. A weight value is
specified after a corresponding language range followed by
{@code ";q="}, and the default weight value is {@code MAX_WEIGHT}
when it is omitted.
<p>Unlike a weighted list, language ranges in a prioritized list
are sorted in the descending order based on its priority. The first
language range has the highest priority and meets the user's
preference most.
<p>In either case, language ranges are sorted in descending order in
the Language Priority List based on priority or weight. If a
language range appears in the given {@code ranges} more than once,
only the first one is included on the Language Priority List.
<p>The returned list consists of language ranges from the given
{@code ranges} and their equivalents found in the IANA Language
Subtag Registry. For example, if the given {@code ranges} is
{@code "Accept-Language: iw,en-us;q=0.7,en;q=0.3"}, the elements in
the list to be returned are:
<pre>
<b>Range</b> <b>Weight</b>
"iw" (older tag for Hebrew) 1.0
"he" (new preferred code for Hebrew) 1.0
"en-us" (English, United States) 0.7
"en" (English) 0.3
</pre>
Two language ranges, {@code "iw"} and {@code "he"}, have the same
highest priority in the list. By adding {@code "he"} to the user's
Language Priority List, locale-matching method can find Hebrew as a
matching locale (or language tag) even if the application or system
offers only {@code "he"} as a supported locale (or language tag).
@param ranges a list of comma-separated language ranges or a list of
language ranges in the form of the "Accept-Language" header
defined in <a href="http://tools.ietf.org/html/rfc2616">RFC
2616</a>
@return a Language Priority List consisting of language ranges
included in the given {@code ranges} and their equivalent
language ranges if available. The list is modifiable.
@throws NullPointerException if {@code ranges} is null
@throws IllegalArgumentException if a language range or a weight
found in the given {@code ranges} is ill-formed
| LanguageRange::parse | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public static List<LanguageRange> parse(String ranges,
Map<String, List<String>> map) {
return mapEquivalents(parse(ranges), map);
} |
Parses the given {@code ranges} to generate a Language Priority
List, and then customizes the list using the given {@code map}.
This method is equivalent to
{@code mapEquivalents(parse(ranges), map)}.
@param ranges a list of comma-separated language ranges or a list
of language ranges in the form of the "Accept-Language" header
defined in <a href="http://tools.ietf.org/html/rfc2616">RFC
2616</a>
@param map a map containing information to customize language ranges
@return a Language Priority List with customization. The list is
modifiable.
@throws NullPointerException if {@code ranges} is null
@throws IllegalArgumentException if a language range or a weight
found in the given {@code ranges} is ill-formed
@see #parse(String)
@see #mapEquivalents
| LanguageRange::parse | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
public static List<LanguageRange> mapEquivalents(
List<LanguageRange>priorityList,
Map<String, List<String>> map) {
return LocaleMatcher.mapEquivalents(priorityList, map);
} |
Generates a new customized Language Priority List using the given
{@code priorityList} and {@code map}. If the given {@code map} is
empty, this method returns a copy of the given {@code priorityList}.
<p>In the map, a key represents a language range whereas a value is
a list of equivalents of it. {@code '*'} cannot be used in the map.
Each equivalent language range has the same weight value as its
original language range.
<pre>
An example of map:
<b>Key</b> <b>Value</b>
"zh" (Chinese) "zh",
"zh-Hans"(Simplified Chinese)
"zh-HK" (Chinese, Hong Kong) "zh-HK"
"zh-TW" (Chinese, Taiwan) "zh-TW"
</pre>
The customization is performed after modification using the IANA
Language Subtag Registry.
<p>For example, if a user's Language Priority List consists of five
language ranges ({@code "zh"}, {@code "zh-CN"}, {@code "en"},
{@code "zh-TW"}, and {@code "zh-HK"}), the newly generated Language
Priority List which is customized using the above map example will
consists of {@code "zh"}, {@code "zh-Hans"}, {@code "zh-CN"},
{@code "zh-Hans-CN"}, {@code "en"}, {@code "zh-TW"}, and
{@code "zh-HK"}.
<p>{@code "zh-HK"} and {@code "zh-TW"} aren't converted to
{@code "zh-Hans-HK"} nor {@code "zh-Hans-TW"} even if they are
included in the Language Priority List. In this example, mapping
is used to clearly distinguish Simplified Chinese and Traditional
Chinese.
<p>If the {@code "zh"}-to-{@code "zh"} mapping isn't included in the
map, a simple replacement will be performed and the customized list
won't include {@code "zh"} and {@code "zh-CN"}.
@param priorityList user's Language Priority List
@param map a map containing information to customize language ranges
@return a new Language Priority List with customization. The list is
modifiable.
@throws NullPointerException if {@code priorityList} is {@code null}
@see #parse(String, Map)
| LanguageRange::mapEquivalents | java | Reginer/aosp-android-jar | android-32/src/java/util/Locale.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/util/Locale.java | MIT |
void addEntry(@NonNull StartInputInfo info) {
final int index = mNextIndex;
if (mEntries[index] == null) {
mEntries[index] = new Entry(info);
} else {
mEntries[index].set(info);
}
mNextIndex = (mNextIndex + 1) % mEntries.length;
} |
Add a new entry and discard the oldest entry as needed.
@param info {@link StartInputInfo} to be added.
| Entry::addEntry | java | Reginer/aosp-android-jar | android-34/src/com/android/server/inputmethod/InputMethodManagerService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/inputmethod/InputMethodManagerService.java | MIT |
SettingsObserver(Handler handler) {
super(handler);
} |
<em>This constructor must be called within the lock.</em>
| SettingsObserver::SettingsObserver | java | Reginer/aosp-android-jar | android-34/src/com/android/server/inputmethod/InputMethodManagerService.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/inputmethod/InputMethodManagerService.java | MIT |
public ContentQueryMap(Cursor cursor, String columnNameOfKey, boolean keepUpdated,
Handler handlerForUpdateNotifications) {
mCursor = cursor;
mColumnNames = mCursor.getColumnNames();
mKeyColumn = mCursor.getColumnIndexOrThrow(columnNameOfKey);
mHandlerForUpdateNotifications = handlerForUpdateNotifications;
setKeepUpdated(keepUpdated);
// If we aren't keeping the cache updated with the current state of the cursor's
// ContentProvider then read it once into the cache. Otherwise the cache will be filled
// automatically.
if (!keepUpdated) {
readCursorIntoCache(cursor);
}
} |
Creates a ContentQueryMap that caches the content backing the cursor
@param cursor the cursor whose contents should be cached
@param columnNameOfKey the column that is to be used as the key of the values map
@param keepUpdated true if the cursor's ContentProvider should be monitored for changes and
the map updated when changes do occur
@param handlerForUpdateNotifications the Handler that should be used to receive
notifications of changes (if requested). Normally you pass null here, but if
you know that the thread that is creating this isn't a thread that can receive
messages then you can create your own handler and use that here.
| ContentQueryMap::ContentQueryMap | java | Reginer/aosp-android-jar | android-34/src/android/content/ContentQueryMap.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/ContentQueryMap.java | MIT |
public void setKeepUpdated(boolean keepUpdated) {
if (keepUpdated == mKeepUpdated) return;
mKeepUpdated = keepUpdated;
if (!mKeepUpdated) {
mCursor.unregisterContentObserver(mContentObserver);
mContentObserver = null;
} else {
if (mHandlerForUpdateNotifications == null) {
mHandlerForUpdateNotifications = new Handler();
}
if (mContentObserver == null) {
mContentObserver = new ContentObserver(mHandlerForUpdateNotifications) {
@Override
public void onChange(boolean selfChange) {
// If anyone is listening, we need to do this now to broadcast
// to the observers. Otherwise, we'll just set mDirty and
// let it query lazily when they ask for the values.
if (countObservers() != 0) {
requery();
} else {
mDirty = true;
}
}
};
}
mCursor.registerContentObserver(mContentObserver);
// mark dirty, since it is possible the cursor's backing data had changed before we
// registered for changes
mDirty = true;
}
} |
Change whether or not the ContentQueryMap will register with the cursor's ContentProvider
for change notifications. If you use a ContentQueryMap in an activity you should call this
with false in onPause(), which means you need to call it with true in onResume()
if want it to be kept updated.
@param keepUpdated if true the ContentQueryMap should be registered with the cursor's
ContentProvider, false otherwise
| ContentQueryMap::setKeepUpdated | java | Reginer/aosp-android-jar | android-34/src/android/content/ContentQueryMap.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/ContentQueryMap.java | MIT |
public synchronized ContentValues getValues(String rowName) {
if (mDirty) requery();
return mValues.get(rowName);
} |
Access the ContentValues for the row specified by rowName
@param rowName which row to read
@return the ContentValues for the row, or null if the row wasn't present in the cursor
| ContentQueryMap::getValues | java | Reginer/aosp-android-jar | android-34/src/android/content/ContentQueryMap.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/ContentQueryMap.java | MIT |
public void requery() {
final Cursor cursor = mCursor;
if (cursor == null) {
// If mCursor is null then it means there was a requery() in flight
// while another thread called close(), which nulls out mCursor.
// If this happens ignore the requery() since we are closed anyways.
return;
}
mDirty = false;
if (!cursor.requery()) {
// again, don't do anything if the cursor is already closed
return;
}
readCursorIntoCache(cursor);
setChanged();
notifyObservers();
} |
Access the ContentValues for the row specified by rowName
@param rowName which row to read
@return the ContentValues for the row, or null if the row wasn't present in the cursor
public synchronized ContentValues getValues(String rowName) {
if (mDirty) requery();
return mValues.get(rowName);
}
/** Requeries the cursor and reads the contents into the cache | ContentQueryMap::requery | java | Reginer/aosp-android-jar | android-34/src/android/content/ContentQueryMap.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/content/ContentQueryMap.java | MIT |
private void onChanged() {
dispatchChange(this);
} |
A private convenience function that notifies registered listeners that an element
has been added to or removed from the array. The what parameter is the array itself.
| WatchedLongSparseArray::onChanged | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
private void registerChild(Object o) {
if (mWatching && o instanceof Watchable) {
((Watchable) o).registerObserver(mObserver);
}
} |
A convenience function. Register the object if it is {@link Watchable} and if the
array is currently watching. Note that the watching flag must be true if this
function is to succeed.
| WatchedLongSparseArray::registerChild | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
private void unregisterChild(Object o) {
if (mWatching && o instanceof Watchable) {
((Watchable) o).unregisterObserver(mObserver);
}
} |
A convenience function. Unregister the object if it is {@link Watchable} and if
the array is currently watching. Note that the watching flag must be true if this
function is to succeed.
| WatchedLongSparseArray::unregisterChild | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
private void unregisterChildIf(Object o) {
if (mWatching && o instanceof Watchable) {
if (mStorage.indexOfValue((E) o) == -1) {
((Watchable) o).unregisterObserver(mObserver);
}
}
} |
A convenience function. Unregister the object if it is {@link Watchable}, if the array is
currently watching, and if the storage does not contain the object. Note that the watching
flag must be true if this function is to succeed. This must be called after an object has
been removed from the storage.
| WatchedLongSparseArray::unregisterChildIf | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public WatchedLongSparseArray() {
mStorage = new LongSparseArray();
} |
Creates a new WatchedSparseArray containing no mappings.
| WatchedLongSparseArray::WatchedLongSparseArray | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public WatchedLongSparseArray(int initialCapacity) {
mStorage = new LongSparseArray(initialCapacity);
} |
Creates a new WatchedSparseArray containing no mappings that
will not require any additional memory allocation to store the
specified number of mappings. If you supply an initial capacity of
0, the sparse array will be initialized with a light-weight
representation not requiring any additional array allocations.
| WatchedLongSparseArray::WatchedLongSparseArray | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public WatchedLongSparseArray(@NonNull LongSparseArray<E> c) {
mStorage = c.clone();
} |
Create a {@link WatchedLongSparseArray} from a {@link LongSparseArray}.
| WatchedLongSparseArray::WatchedLongSparseArray | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public WatchedLongSparseArray(@NonNull WatchedLongSparseArray<E> r) {
mStorage = r.mStorage.clone();
} |
The copy constructor does not copy the watcher data.
| WatchedLongSparseArray::WatchedLongSparseArray | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public void copyFrom(@NonNull LongSparseArray<E> src) {
clear();
final int end = src.size();
for (int i = 0; i < end; i++) {
put(src.keyAt(i), src.valueAt(i));
}
} |
Make <this> a copy of src. Any data in <this> is discarded.
| WatchedLongSparseArray::copyFrom | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public void copyTo(@NonNull LongSparseArray<E> dst) {
dst.clear();
final int end = size();
for (int i = 0; i < end; i++) {
dst.put(keyAt(i), valueAt(i));
}
} |
Make dst a copy of <this>. Any previous data in dst is discarded.
| WatchedLongSparseArray::copyTo | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public LongSparseArray<E> untrackedStorage() {
return mStorage;
} |
Return the underlying storage. This breaks the wrapper but is necessary when
passing the array to distant methods.
| WatchedLongSparseArray::untrackedStorage | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public E get(long key) {
return mStorage.get(key);
} |
Gets the Object mapped from the specified key, or <code>null</code>
if no such mapping has been made.
| WatchedLongSparseArray::get | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public E get(long key, E valueIfKeyNotFound) {
return mStorage.get(key, valueIfKeyNotFound);
} |
Gets the Object mapped from the specified key, or the specified Object
if no such mapping has been made.
| WatchedLongSparseArray::get | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public void delete(long key) {
E old = mStorage.get(key, null);
mStorage.delete(key);
unregisterChildIf(old);
onChanged();
} |
Removes the mapping from the specified key, if there was any.
| WatchedLongSparseArray::delete | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public void remove(long key) {
delete(key);
} |
Alias for {@link #delete(long)}.
| WatchedLongSparseArray::remove | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public void removeAt(int index) {
E old = mStorage.valueAt(index);
mStorage.removeAt(index);
unregisterChildIf(old);
onChanged();
} |
Removes the mapping at the specified index.
<p>For indices outside of the range <code>0...size()-1</code>, an
{@link ArrayIndexOutOfBoundsException} is thrown.</p>
| WatchedLongSparseArray::removeAt | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public void put(long key, E value) {
E old = mStorage.get(key);
mStorage.put(key, value);
unregisterChildIf(old);
registerChild(value);
onChanged();
} |
Adds a mapping from the specified key to the specified value,
replacing the previous mapping from the specified key if there
was one.
| WatchedLongSparseArray::put | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public int size() {
return mStorage.size();
} |
Returns the number of key-value mappings that this LongSparseArray
currently stores.
| WatchedLongSparseArray::size | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public long keyAt(int index) {
return mStorage.keyAt(index);
} |
Given an index in the range <code>0...size()-1</code>, returns
the key from the <code>index</code>th key-value mapping that this
LongSparseArray stores.
<p>The keys corresponding to indices in ascending order are guaranteed to
be in ascending order, e.g., <code>keyAt(0)</code> will return the
smallest key and <code>keyAt(size()-1)</code> will return the largest
key.</p>
<p>For indices outside of the range <code>0...size()-1</code>, an
{@link ArrayIndexOutOfBoundsException} is thrown.</p>
| WatchedLongSparseArray::keyAt | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public E valueAt(int index) {
return mStorage.valueAt(index);
} |
Given an index in the range <code>0...size()-1</code>, returns
the value from the <code>index</code>th key-value mapping that this
LongSparseArray stores.
<p>The values corresponding to indices in ascending order are guaranteed
to be associated with keys in ascending order, e.g.,
<code>valueAt(0)</code> will return the value associated with the
smallest key and <code>valueAt(size()-1)</code> will return the value
associated with the largest key.</p>
<p>For indices outside of the range <code>0...size()-1</code>, an
{@link ArrayIndexOutOfBoundsException} is thrown.</p>
| WatchedLongSparseArray::valueAt | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public void setValueAt(int index, E value) {
E old = mStorage.valueAt(index);
mStorage.setValueAt(index, value);
unregisterChildIf(old);
registerChild(value);
onChanged();
} |
Given an index in the range <code>0...size()-1</code>, sets a new
value for the <code>index</code>th key-value mapping that this
LongSparseArray stores.
<p>For indices outside of the range <code>0...size()-1</code>, an
{@link ArrayIndexOutOfBoundsException} is thrown.</p>
| WatchedLongSparseArray::setValueAt | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public int indexOfKey(long key) {
return mStorage.indexOfKey(key);
} |
Returns the index for which {@link #keyAt} would return the
specified key, or a negative number if the specified
key is not mapped.
| WatchedLongSparseArray::indexOfKey | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public int indexOfValue(E value) {
return mStorage.indexOfValue(value);
} |
Returns an index for which {@link #valueAt} would return the
specified key, or a negative number if no keys map to the
specified value.
Beware that this is a linear search, unlike lookups by key,
and that multiple keys can map to the same value and this will
find only one of them.
| WatchedLongSparseArray::indexOfValue | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public int indexOfValueByValue(E value) {
return mStorage.indexOfValueByValue(value);
} |
Returns an index for which {@link #valueAt} would return the
specified key, or a negative number if no keys map to the
specified value.
<p>Beware that this is a linear search, unlike lookups by key,
and that multiple keys can map to the same value and this will
find only one of them.
<p>Note also that this method uses {@code equals} unlike {@code indexOfValue}.
@hide
| WatchedLongSparseArray::indexOfValueByValue | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public void clear() {
final int end = mStorage.size();
for (int i = 0; i < end; i++) {
unregisterChild(mStorage.valueAt(i));
}
mStorage.clear();
onChanged();
} |
Removes all key-value mappings from this LongSparseArray.
| WatchedLongSparseArray::clear | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public void append(long key, E value) {
mStorage.append(key, value);
registerChild(value);
onChanged();
} |
Puts a key/value pair into the array, optimizing for the case where
the key is greater than all existing keys in the array.
| WatchedLongSparseArray::append | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public WatchedLongSparseArray<E> snapshot() {
WatchedLongSparseArray<E> l = new WatchedLongSparseArray<>(size());
snapshot(l, this);
return l;
} |
Create a copy of the array. If the element is a subclass of Snapper then the copy
contains snapshots of the elements. Otherwise the copy contains references to the
elements. The returned snapshot is immutable.
@return A new array whose elements are the elements of <this>.
| WatchedLongSparseArray::snapshot | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public void snapshot(@NonNull WatchedLongSparseArray<E> r) {
snapshot(this, r);
} |
Make <this> a snapshot of the argument. Note that <this> is immutable when the
method returns. <this> must be empty when the function is called.
@param r The source array, which is copied into <this>
| WatchedLongSparseArray::snapshot | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public static <E> void snapshot(@NonNull WatchedLongSparseArray<E> dst,
@NonNull WatchedLongSparseArray<E> src) {
if (dst.size() != 0) {
throw new IllegalArgumentException("snapshot destination is not empty");
}
final int end = src.size();
for (int i = 0; i < end; i++) {
final E val = Snapshots.maybeSnapshot(src.valueAt(i));
final long key = src.keyAt(i);
dst.put(key, val);
}
dst.seal();
} |
Make the destination a copy of the source. If the element is a subclass of Snapper then the
copy contains snapshots of the elements. Otherwise the copy contains references to the
elements. The destination must be initially empty. Upon return, the destination is
immutable.
@param dst The destination array. It must be empty.
@param src The source array. It is not modified.
| WatchedLongSparseArray::snapshot | java | Reginer/aosp-android-jar | android-31/src/com/android/server/utils/WatchedLongSparseArray.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/utils/WatchedLongSparseArray.java | MIT |
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token,
@Nullable AttributionSource next) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null, next);
} |
This class represents a source to which access to permission protected data should be
attributed. Attribution sources can be chained to represent cases where the protected
data would flow through several applications. For example, app A may ask app B for
contacts and in turn app B may ask app C for contacts. In this case, the attribution
chain would be A -> B -> C and the data flow would be C -> B -> A. There are two
main benefits of using the attribution source mechanism: avoid doing explicit permission
checks on behalf of the calling app if you are accessing private data on their behalf
to send back; avoid double data access blaming which happens as you check the calling
app's permissions and when you access the data behind these permissions (for runtime
permissions). Also if not explicitly blaming the caller the data access would be
counted towards your app vs to the previous app where yours was just a proxy.
<p>
Every {@link Context} has an attribution source and you can get it via {@link
Context#getAttributionSource()} representing itself, which is a chain of one. You
can attribute work to another app, or more precisely to a chain of apps, through
which the data you would be accessing would flow, via {@link Context#createContext(
ContextParams)} plus specifying an attribution source for the next app to receive
the protected data you are accessing via {@link AttributionSource.Builder#setNext(
AttributionSource)}. Creating this attribution chain ensures that the datasource would
check whether every app in the attribution chain has permission to access the data
before releasing it. The datasource will also record appropriately that this data was
accessed by the apps in the sequence if the data is behind a sensitive permission
(e.g. dangerous). Again, this is useful if you are accessing the data on behalf of another
app, for example a speech recognizer using the mic so it can provide recognition to
a calling app.
<p>
You can create an attribution chain of you and any other app without any verification
as this is something already available via the {@link android.app.AppOpsManager} APIs.
This is supported to handle cases where you don't have access to the caller's attribution
source and you can directly use the {@link AttributionSource.Builder} APIs. However,
if the data flows through more than two apps (more than you access the data for the
caller) you need to have a handle to the {@link AttributionSource} for the calling app's
context in order to create an attribution context. This means you either need to have an
API for the other app to send you its attribution source or use a platform API that pipes
the callers attribution source.
<p>
You cannot forge an attribution chain without the participation of every app in the
attribution chain (aside of the special case mentioned above). To create an attribution
source that is trusted you need to create an attribution context that points to an
attribution source that was explicitly created by the app that it refers to, recursively.
<p>
Since creating an attribution context leads to all permissions for apps in the attribution
chain being checked, you need to expect getting a security exception when accessing
permission protected APIs since some app in the chain may not have the permission.
@Immutable
public final class AttributionSource implements Parcelable {
private static final String DESCRIPTOR = "android.content.AttributionSource";
private static final Binder sDefaultToken = new Binder(DESCRIPTOR);
private final @NonNull AttributionSourceState mAttributionSourceState;
private @Nullable AttributionSource mNextCached;
private @Nullable Set<String> mRenouncedPermissionsCached;
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag) {
this(uid, packageName, attributionTag, sDefaultToken);
}
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null,
/*next*/ null);
}
/** @hide | AttributionSource::AttributionSource | java | Reginer/aosp-android-jar | android-32/src/android/content/AttributionSource.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/content/AttributionSource.java | MIT |
public AttributionSource(@NonNull AttributionSource current, @Nullable AttributionSource next) {
this(current.getUid(), current.getPackageName(), current.getAttributionTag(),
current.getToken(), current.mAttributionSourceState.renouncedPermissions, next);
} |
This class represents a source to which access to permission protected data should be
attributed. Attribution sources can be chained to represent cases where the protected
data would flow through several applications. For example, app A may ask app B for
contacts and in turn app B may ask app C for contacts. In this case, the attribution
chain would be A -> B -> C and the data flow would be C -> B -> A. There are two
main benefits of using the attribution source mechanism: avoid doing explicit permission
checks on behalf of the calling app if you are accessing private data on their behalf
to send back; avoid double data access blaming which happens as you check the calling
app's permissions and when you access the data behind these permissions (for runtime
permissions). Also if not explicitly blaming the caller the data access would be
counted towards your app vs to the previous app where yours was just a proxy.
<p>
Every {@link Context} has an attribution source and you can get it via {@link
Context#getAttributionSource()} representing itself, which is a chain of one. You
can attribute work to another app, or more precisely to a chain of apps, through
which the data you would be accessing would flow, via {@link Context#createContext(
ContextParams)} plus specifying an attribution source for the next app to receive
the protected data you are accessing via {@link AttributionSource.Builder#setNext(
AttributionSource)}. Creating this attribution chain ensures that the datasource would
check whether every app in the attribution chain has permission to access the data
before releasing it. The datasource will also record appropriately that this data was
accessed by the apps in the sequence if the data is behind a sensitive permission
(e.g. dangerous). Again, this is useful if you are accessing the data on behalf of another
app, for example a speech recognizer using the mic so it can provide recognition to
a calling app.
<p>
You can create an attribution chain of you and any other app without any verification
as this is something already available via the {@link android.app.AppOpsManager} APIs.
This is supported to handle cases where you don't have access to the caller's attribution
source and you can directly use the {@link AttributionSource.Builder} APIs. However,
if the data flows through more than two apps (more than you access the data for the
caller) you need to have a handle to the {@link AttributionSource} for the calling app's
context in order to create an attribution context. This means you either need to have an
API for the other app to send you its attribution source or use a platform API that pipes
the callers attribution source.
<p>
You cannot forge an attribution chain without the participation of every app in the
attribution chain (aside of the special case mentioned above). To create an attribution
source that is trusted you need to create an attribution context that points to an
attribution source that was explicitly created by the app that it refers to, recursively.
<p>
Since creating an attribution context leads to all permissions for apps in the attribution
chain being checked, you need to expect getting a security exception when accessing
permission protected APIs since some app in the chain may not have the permission.
@Immutable
public final class AttributionSource implements Parcelable {
private static final String DESCRIPTOR = "android.content.AttributionSource";
private static final Binder sDefaultToken = new Binder(DESCRIPTOR);
private final @NonNull AttributionSourceState mAttributionSourceState;
private @Nullable AttributionSource mNextCached;
private @Nullable Set<String> mRenouncedPermissionsCached;
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag) {
this(uid, packageName, attributionTag, sDefaultToken);
}
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null,
/*next*/ null);
}
/** @hide
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token,
@Nullable AttributionSource next) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null, next);
}
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @Nullable Set<String> renouncedPermissions,
@Nullable AttributionSource next) {
this(uid, packageName, attributionTag, (renouncedPermissions != null)
? renouncedPermissions.toArray(new String[0]) : null, next);
}
/** @hide | AttributionSource::AttributionSource | java | Reginer/aosp-android-jar | android-32/src/android/content/AttributionSource.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/content/AttributionSource.java | MIT |
public AttributionSource(@NonNull AttributionSourceState attributionSourceState) {
mAttributionSourceState = attributionSourceState;
} |
This class represents a source to which access to permission protected data should be
attributed. Attribution sources can be chained to represent cases where the protected
data would flow through several applications. For example, app A may ask app B for
contacts and in turn app B may ask app C for contacts. In this case, the attribution
chain would be A -> B -> C and the data flow would be C -> B -> A. There are two
main benefits of using the attribution source mechanism: avoid doing explicit permission
checks on behalf of the calling app if you are accessing private data on their behalf
to send back; avoid double data access blaming which happens as you check the calling
app's permissions and when you access the data behind these permissions (for runtime
permissions). Also if not explicitly blaming the caller the data access would be
counted towards your app vs to the previous app where yours was just a proxy.
<p>
Every {@link Context} has an attribution source and you can get it via {@link
Context#getAttributionSource()} representing itself, which is a chain of one. You
can attribute work to another app, or more precisely to a chain of apps, through
which the data you would be accessing would flow, via {@link Context#createContext(
ContextParams)} plus specifying an attribution source for the next app to receive
the protected data you are accessing via {@link AttributionSource.Builder#setNext(
AttributionSource)}. Creating this attribution chain ensures that the datasource would
check whether every app in the attribution chain has permission to access the data
before releasing it. The datasource will also record appropriately that this data was
accessed by the apps in the sequence if the data is behind a sensitive permission
(e.g. dangerous). Again, this is useful if you are accessing the data on behalf of another
app, for example a speech recognizer using the mic so it can provide recognition to
a calling app.
<p>
You can create an attribution chain of you and any other app without any verification
as this is something already available via the {@link android.app.AppOpsManager} APIs.
This is supported to handle cases where you don't have access to the caller's attribution
source and you can directly use the {@link AttributionSource.Builder} APIs. However,
if the data flows through more than two apps (more than you access the data for the
caller) you need to have a handle to the {@link AttributionSource} for the calling app's
context in order to create an attribution context. This means you either need to have an
API for the other app to send you its attribution source or use a platform API that pipes
the callers attribution source.
<p>
You cannot forge an attribution chain without the participation of every app in the
attribution chain (aside of the special case mentioned above). To create an attribution
source that is trusted you need to create an attribution context that points to an
attribution source that was explicitly created by the app that it refers to, recursively.
<p>
Since creating an attribution context leads to all permissions for apps in the attribution
chain being checked, you need to expect getting a security exception when accessing
permission protected APIs since some app in the chain may not have the permission.
@Immutable
public final class AttributionSource implements Parcelable {
private static final String DESCRIPTOR = "android.content.AttributionSource";
private static final Binder sDefaultToken = new Binder(DESCRIPTOR);
private final @NonNull AttributionSourceState mAttributionSourceState;
private @Nullable AttributionSource mNextCached;
private @Nullable Set<String> mRenouncedPermissionsCached;
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag) {
this(uid, packageName, attributionTag, sDefaultToken);
}
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null,
/*next*/ null);
}
/** @hide
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token,
@Nullable AttributionSource next) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null, next);
}
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @Nullable Set<String> renouncedPermissions,
@Nullable AttributionSource next) {
this(uid, packageName, attributionTag, (renouncedPermissions != null)
? renouncedPermissions.toArray(new String[0]) : null, next);
}
/** @hide
public AttributionSource(@NonNull AttributionSource current, @Nullable AttributionSource next) {
this(current.getUid(), current.getPackageName(), current.getAttributionTag(),
current.getToken(), current.mAttributionSourceState.renouncedPermissions, next);
}
AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag,
@Nullable String[] renouncedPermissions, @Nullable AttributionSource next) {
this(uid, packageName, attributionTag, sDefaultToken, renouncedPermissions, next);
}
AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag,
@NonNull IBinder token, @Nullable String[] renouncedPermissions,
@Nullable AttributionSource next) {
mAttributionSourceState = new AttributionSourceState();
mAttributionSourceState.uid = uid;
mAttributionSourceState.token = token;
mAttributionSourceState.packageName = packageName;
mAttributionSourceState.attributionTag = attributionTag;
mAttributionSourceState.renouncedPermissions = renouncedPermissions;
mAttributionSourceState.next = (next != null) ? new AttributionSourceState[]
{next.mAttributionSourceState} : new AttributionSourceState[0];
}
AttributionSource(@NonNull Parcel in) {
this(AttributionSourceState.CREATOR.createFromParcel(in));
// Since we just unpacked this object as part of it transiting a Binder
// call, this is the perfect time to enforce that its UID can be trusted
enforceCallingUid();
}
/** @hide | AttributionSource::AttributionSource | java | Reginer/aosp-android-jar | android-32/src/android/content/AttributionSource.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/content/AttributionSource.java | MIT |
public AttributionSource withNextAttributionSource(@Nullable AttributionSource next) {
return new AttributionSource(getUid(), getPackageName(), getAttributionTag(),
mAttributionSourceState.renouncedPermissions, next);
} |
This class represents a source to which access to permission protected data should be
attributed. Attribution sources can be chained to represent cases where the protected
data would flow through several applications. For example, app A may ask app B for
contacts and in turn app B may ask app C for contacts. In this case, the attribution
chain would be A -> B -> C and the data flow would be C -> B -> A. There are two
main benefits of using the attribution source mechanism: avoid doing explicit permission
checks on behalf of the calling app if you are accessing private data on their behalf
to send back; avoid double data access blaming which happens as you check the calling
app's permissions and when you access the data behind these permissions (for runtime
permissions). Also if not explicitly blaming the caller the data access would be
counted towards your app vs to the previous app where yours was just a proxy.
<p>
Every {@link Context} has an attribution source and you can get it via {@link
Context#getAttributionSource()} representing itself, which is a chain of one. You
can attribute work to another app, or more precisely to a chain of apps, through
which the data you would be accessing would flow, via {@link Context#createContext(
ContextParams)} plus specifying an attribution source for the next app to receive
the protected data you are accessing via {@link AttributionSource.Builder#setNext(
AttributionSource)}. Creating this attribution chain ensures that the datasource would
check whether every app in the attribution chain has permission to access the data
before releasing it. The datasource will also record appropriately that this data was
accessed by the apps in the sequence if the data is behind a sensitive permission
(e.g. dangerous). Again, this is useful if you are accessing the data on behalf of another
app, for example a speech recognizer using the mic so it can provide recognition to
a calling app.
<p>
You can create an attribution chain of you and any other app without any verification
as this is something already available via the {@link android.app.AppOpsManager} APIs.
This is supported to handle cases where you don't have access to the caller's attribution
source and you can directly use the {@link AttributionSource.Builder} APIs. However,
if the data flows through more than two apps (more than you access the data for the
caller) you need to have a handle to the {@link AttributionSource} for the calling app's
context in order to create an attribution context. This means you either need to have an
API for the other app to send you its attribution source or use a platform API that pipes
the callers attribution source.
<p>
You cannot forge an attribution chain without the participation of every app in the
attribution chain (aside of the special case mentioned above). To create an attribution
source that is trusted you need to create an attribution context that points to an
attribution source that was explicitly created by the app that it refers to, recursively.
<p>
Since creating an attribution context leads to all permissions for apps in the attribution
chain being checked, you need to expect getting a security exception when accessing
permission protected APIs since some app in the chain may not have the permission.
@Immutable
public final class AttributionSource implements Parcelable {
private static final String DESCRIPTOR = "android.content.AttributionSource";
private static final Binder sDefaultToken = new Binder(DESCRIPTOR);
private final @NonNull AttributionSourceState mAttributionSourceState;
private @Nullable AttributionSource mNextCached;
private @Nullable Set<String> mRenouncedPermissionsCached;
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag) {
this(uid, packageName, attributionTag, sDefaultToken);
}
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null,
/*next*/ null);
}
/** @hide
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token,
@Nullable AttributionSource next) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null, next);
}
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @Nullable Set<String> renouncedPermissions,
@Nullable AttributionSource next) {
this(uid, packageName, attributionTag, (renouncedPermissions != null)
? renouncedPermissions.toArray(new String[0]) : null, next);
}
/** @hide
public AttributionSource(@NonNull AttributionSource current, @Nullable AttributionSource next) {
this(current.getUid(), current.getPackageName(), current.getAttributionTag(),
current.getToken(), current.mAttributionSourceState.renouncedPermissions, next);
}
AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag,
@Nullable String[] renouncedPermissions, @Nullable AttributionSource next) {
this(uid, packageName, attributionTag, sDefaultToken, renouncedPermissions, next);
}
AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag,
@NonNull IBinder token, @Nullable String[] renouncedPermissions,
@Nullable AttributionSource next) {
mAttributionSourceState = new AttributionSourceState();
mAttributionSourceState.uid = uid;
mAttributionSourceState.token = token;
mAttributionSourceState.packageName = packageName;
mAttributionSourceState.attributionTag = attributionTag;
mAttributionSourceState.renouncedPermissions = renouncedPermissions;
mAttributionSourceState.next = (next != null) ? new AttributionSourceState[]
{next.mAttributionSourceState} : new AttributionSourceState[0];
}
AttributionSource(@NonNull Parcel in) {
this(AttributionSourceState.CREATOR.createFromParcel(in));
// Since we just unpacked this object as part of it transiting a Binder
// call, this is the perfect time to enforce that its UID can be trusted
enforceCallingUid();
}
/** @hide
public AttributionSource(@NonNull AttributionSourceState attributionSourceState) {
mAttributionSourceState = attributionSourceState;
}
/** @hide | AttributionSource::withNextAttributionSource | java | Reginer/aosp-android-jar | android-32/src/android/content/AttributionSource.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/content/AttributionSource.java | MIT |
public AttributionSource withPackageName(@Nullable String packageName) {
return new AttributionSource(getUid(), packageName, getAttributionTag(),
mAttributionSourceState.renouncedPermissions, getNext());
} |
This class represents a source to which access to permission protected data should be
attributed. Attribution sources can be chained to represent cases where the protected
data would flow through several applications. For example, app A may ask app B for
contacts and in turn app B may ask app C for contacts. In this case, the attribution
chain would be A -> B -> C and the data flow would be C -> B -> A. There are two
main benefits of using the attribution source mechanism: avoid doing explicit permission
checks on behalf of the calling app if you are accessing private data on their behalf
to send back; avoid double data access blaming which happens as you check the calling
app's permissions and when you access the data behind these permissions (for runtime
permissions). Also if not explicitly blaming the caller the data access would be
counted towards your app vs to the previous app where yours was just a proxy.
<p>
Every {@link Context} has an attribution source and you can get it via {@link
Context#getAttributionSource()} representing itself, which is a chain of one. You
can attribute work to another app, or more precisely to a chain of apps, through
which the data you would be accessing would flow, via {@link Context#createContext(
ContextParams)} plus specifying an attribution source for the next app to receive
the protected data you are accessing via {@link AttributionSource.Builder#setNext(
AttributionSource)}. Creating this attribution chain ensures that the datasource would
check whether every app in the attribution chain has permission to access the data
before releasing it. The datasource will also record appropriately that this data was
accessed by the apps in the sequence if the data is behind a sensitive permission
(e.g. dangerous). Again, this is useful if you are accessing the data on behalf of another
app, for example a speech recognizer using the mic so it can provide recognition to
a calling app.
<p>
You can create an attribution chain of you and any other app without any verification
as this is something already available via the {@link android.app.AppOpsManager} APIs.
This is supported to handle cases where you don't have access to the caller's attribution
source and you can directly use the {@link AttributionSource.Builder} APIs. However,
if the data flows through more than two apps (more than you access the data for the
caller) you need to have a handle to the {@link AttributionSource} for the calling app's
context in order to create an attribution context. This means you either need to have an
API for the other app to send you its attribution source or use a platform API that pipes
the callers attribution source.
<p>
You cannot forge an attribution chain without the participation of every app in the
attribution chain (aside of the special case mentioned above). To create an attribution
source that is trusted you need to create an attribution context that points to an
attribution source that was explicitly created by the app that it refers to, recursively.
<p>
Since creating an attribution context leads to all permissions for apps in the attribution
chain being checked, you need to expect getting a security exception when accessing
permission protected APIs since some app in the chain may not have the permission.
@Immutable
public final class AttributionSource implements Parcelable {
private static final String DESCRIPTOR = "android.content.AttributionSource";
private static final Binder sDefaultToken = new Binder(DESCRIPTOR);
private final @NonNull AttributionSourceState mAttributionSourceState;
private @Nullable AttributionSource mNextCached;
private @Nullable Set<String> mRenouncedPermissionsCached;
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag) {
this(uid, packageName, attributionTag, sDefaultToken);
}
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null,
/*next*/ null);
}
/** @hide
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token,
@Nullable AttributionSource next) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null, next);
}
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @Nullable Set<String> renouncedPermissions,
@Nullable AttributionSource next) {
this(uid, packageName, attributionTag, (renouncedPermissions != null)
? renouncedPermissions.toArray(new String[0]) : null, next);
}
/** @hide
public AttributionSource(@NonNull AttributionSource current, @Nullable AttributionSource next) {
this(current.getUid(), current.getPackageName(), current.getAttributionTag(),
current.getToken(), current.mAttributionSourceState.renouncedPermissions, next);
}
AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag,
@Nullable String[] renouncedPermissions, @Nullable AttributionSource next) {
this(uid, packageName, attributionTag, sDefaultToken, renouncedPermissions, next);
}
AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag,
@NonNull IBinder token, @Nullable String[] renouncedPermissions,
@Nullable AttributionSource next) {
mAttributionSourceState = new AttributionSourceState();
mAttributionSourceState.uid = uid;
mAttributionSourceState.token = token;
mAttributionSourceState.packageName = packageName;
mAttributionSourceState.attributionTag = attributionTag;
mAttributionSourceState.renouncedPermissions = renouncedPermissions;
mAttributionSourceState.next = (next != null) ? new AttributionSourceState[]
{next.mAttributionSourceState} : new AttributionSourceState[0];
}
AttributionSource(@NonNull Parcel in) {
this(AttributionSourceState.CREATOR.createFromParcel(in));
// Since we just unpacked this object as part of it transiting a Binder
// call, this is the perfect time to enforce that its UID can be trusted
enforceCallingUid();
}
/** @hide
public AttributionSource(@NonNull AttributionSourceState attributionSourceState) {
mAttributionSourceState = attributionSourceState;
}
/** @hide
public AttributionSource withNextAttributionSource(@Nullable AttributionSource next) {
return new AttributionSource(getUid(), getPackageName(), getAttributionTag(),
mAttributionSourceState.renouncedPermissions, next);
}
/** @hide | AttributionSource::withPackageName | java | Reginer/aosp-android-jar | android-32/src/android/content/AttributionSource.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/content/AttributionSource.java | MIT |
public AttributionSource withToken(@NonNull Binder token) {
return new AttributionSource(getUid(), getPackageName(), getAttributionTag(),
token, mAttributionSourceState.renouncedPermissions, getNext());
} |
This class represents a source to which access to permission protected data should be
attributed. Attribution sources can be chained to represent cases where the protected
data would flow through several applications. For example, app A may ask app B for
contacts and in turn app B may ask app C for contacts. In this case, the attribution
chain would be A -> B -> C and the data flow would be C -> B -> A. There are two
main benefits of using the attribution source mechanism: avoid doing explicit permission
checks on behalf of the calling app if you are accessing private data on their behalf
to send back; avoid double data access blaming which happens as you check the calling
app's permissions and when you access the data behind these permissions (for runtime
permissions). Also if not explicitly blaming the caller the data access would be
counted towards your app vs to the previous app where yours was just a proxy.
<p>
Every {@link Context} has an attribution source and you can get it via {@link
Context#getAttributionSource()} representing itself, which is a chain of one. You
can attribute work to another app, or more precisely to a chain of apps, through
which the data you would be accessing would flow, via {@link Context#createContext(
ContextParams)} plus specifying an attribution source for the next app to receive
the protected data you are accessing via {@link AttributionSource.Builder#setNext(
AttributionSource)}. Creating this attribution chain ensures that the datasource would
check whether every app in the attribution chain has permission to access the data
before releasing it. The datasource will also record appropriately that this data was
accessed by the apps in the sequence if the data is behind a sensitive permission
(e.g. dangerous). Again, this is useful if you are accessing the data on behalf of another
app, for example a speech recognizer using the mic so it can provide recognition to
a calling app.
<p>
You can create an attribution chain of you and any other app without any verification
as this is something already available via the {@link android.app.AppOpsManager} APIs.
This is supported to handle cases where you don't have access to the caller's attribution
source and you can directly use the {@link AttributionSource.Builder} APIs. However,
if the data flows through more than two apps (more than you access the data for the
caller) you need to have a handle to the {@link AttributionSource} for the calling app's
context in order to create an attribution context. This means you either need to have an
API for the other app to send you its attribution source or use a platform API that pipes
the callers attribution source.
<p>
You cannot forge an attribution chain without the participation of every app in the
attribution chain (aside of the special case mentioned above). To create an attribution
source that is trusted you need to create an attribution context that points to an
attribution source that was explicitly created by the app that it refers to, recursively.
<p>
Since creating an attribution context leads to all permissions for apps in the attribution
chain being checked, you need to expect getting a security exception when accessing
permission protected APIs since some app in the chain may not have the permission.
@Immutable
public final class AttributionSource implements Parcelable {
private static final String DESCRIPTOR = "android.content.AttributionSource";
private static final Binder sDefaultToken = new Binder(DESCRIPTOR);
private final @NonNull AttributionSourceState mAttributionSourceState;
private @Nullable AttributionSource mNextCached;
private @Nullable Set<String> mRenouncedPermissionsCached;
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag) {
this(uid, packageName, attributionTag, sDefaultToken);
}
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null,
/*next*/ null);
}
/** @hide
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token,
@Nullable AttributionSource next) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null, next);
}
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @Nullable Set<String> renouncedPermissions,
@Nullable AttributionSource next) {
this(uid, packageName, attributionTag, (renouncedPermissions != null)
? renouncedPermissions.toArray(new String[0]) : null, next);
}
/** @hide
public AttributionSource(@NonNull AttributionSource current, @Nullable AttributionSource next) {
this(current.getUid(), current.getPackageName(), current.getAttributionTag(),
current.getToken(), current.mAttributionSourceState.renouncedPermissions, next);
}
AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag,
@Nullable String[] renouncedPermissions, @Nullable AttributionSource next) {
this(uid, packageName, attributionTag, sDefaultToken, renouncedPermissions, next);
}
AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag,
@NonNull IBinder token, @Nullable String[] renouncedPermissions,
@Nullable AttributionSource next) {
mAttributionSourceState = new AttributionSourceState();
mAttributionSourceState.uid = uid;
mAttributionSourceState.token = token;
mAttributionSourceState.packageName = packageName;
mAttributionSourceState.attributionTag = attributionTag;
mAttributionSourceState.renouncedPermissions = renouncedPermissions;
mAttributionSourceState.next = (next != null) ? new AttributionSourceState[]
{next.mAttributionSourceState} : new AttributionSourceState[0];
}
AttributionSource(@NonNull Parcel in) {
this(AttributionSourceState.CREATOR.createFromParcel(in));
// Since we just unpacked this object as part of it transiting a Binder
// call, this is the perfect time to enforce that its UID can be trusted
enforceCallingUid();
}
/** @hide
public AttributionSource(@NonNull AttributionSourceState attributionSourceState) {
mAttributionSourceState = attributionSourceState;
}
/** @hide
public AttributionSource withNextAttributionSource(@Nullable AttributionSource next) {
return new AttributionSource(getUid(), getPackageName(), getAttributionTag(),
mAttributionSourceState.renouncedPermissions, next);
}
/** @hide
public AttributionSource withPackageName(@Nullable String packageName) {
return new AttributionSource(getUid(), packageName, getAttributionTag(),
mAttributionSourceState.renouncedPermissions, getNext());
}
/** @hide | AttributionSource::withToken | java | Reginer/aosp-android-jar | android-32/src/android/content/AttributionSource.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/content/AttributionSource.java | MIT |
public @NonNull AttributionSourceState asState() {
return mAttributionSourceState;
} |
This class represents a source to which access to permission protected data should be
attributed. Attribution sources can be chained to represent cases where the protected
data would flow through several applications. For example, app A may ask app B for
contacts and in turn app B may ask app C for contacts. In this case, the attribution
chain would be A -> B -> C and the data flow would be C -> B -> A. There are two
main benefits of using the attribution source mechanism: avoid doing explicit permission
checks on behalf of the calling app if you are accessing private data on their behalf
to send back; avoid double data access blaming which happens as you check the calling
app's permissions and when you access the data behind these permissions (for runtime
permissions). Also if not explicitly blaming the caller the data access would be
counted towards your app vs to the previous app where yours was just a proxy.
<p>
Every {@link Context} has an attribution source and you can get it via {@link
Context#getAttributionSource()} representing itself, which is a chain of one. You
can attribute work to another app, or more precisely to a chain of apps, through
which the data you would be accessing would flow, via {@link Context#createContext(
ContextParams)} plus specifying an attribution source for the next app to receive
the protected data you are accessing via {@link AttributionSource.Builder#setNext(
AttributionSource)}. Creating this attribution chain ensures that the datasource would
check whether every app in the attribution chain has permission to access the data
before releasing it. The datasource will also record appropriately that this data was
accessed by the apps in the sequence if the data is behind a sensitive permission
(e.g. dangerous). Again, this is useful if you are accessing the data on behalf of another
app, for example a speech recognizer using the mic so it can provide recognition to
a calling app.
<p>
You can create an attribution chain of you and any other app without any verification
as this is something already available via the {@link android.app.AppOpsManager} APIs.
This is supported to handle cases where you don't have access to the caller's attribution
source and you can directly use the {@link AttributionSource.Builder} APIs. However,
if the data flows through more than two apps (more than you access the data for the
caller) you need to have a handle to the {@link AttributionSource} for the calling app's
context in order to create an attribution context. This means you either need to have an
API for the other app to send you its attribution source or use a platform API that pipes
the callers attribution source.
<p>
You cannot forge an attribution chain without the participation of every app in the
attribution chain (aside of the special case mentioned above). To create an attribution
source that is trusted you need to create an attribution context that points to an
attribution source that was explicitly created by the app that it refers to, recursively.
<p>
Since creating an attribution context leads to all permissions for apps in the attribution
chain being checked, you need to expect getting a security exception when accessing
permission protected APIs since some app in the chain may not have the permission.
@Immutable
public final class AttributionSource implements Parcelable {
private static final String DESCRIPTOR = "android.content.AttributionSource";
private static final Binder sDefaultToken = new Binder(DESCRIPTOR);
private final @NonNull AttributionSourceState mAttributionSourceState;
private @Nullable AttributionSource mNextCached;
private @Nullable Set<String> mRenouncedPermissionsCached;
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag) {
this(uid, packageName, attributionTag, sDefaultToken);
}
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null,
/*next*/ null);
}
/** @hide
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token,
@Nullable AttributionSource next) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null, next);
}
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @Nullable Set<String> renouncedPermissions,
@Nullable AttributionSource next) {
this(uid, packageName, attributionTag, (renouncedPermissions != null)
? renouncedPermissions.toArray(new String[0]) : null, next);
}
/** @hide
public AttributionSource(@NonNull AttributionSource current, @Nullable AttributionSource next) {
this(current.getUid(), current.getPackageName(), current.getAttributionTag(),
current.getToken(), current.mAttributionSourceState.renouncedPermissions, next);
}
AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag,
@Nullable String[] renouncedPermissions, @Nullable AttributionSource next) {
this(uid, packageName, attributionTag, sDefaultToken, renouncedPermissions, next);
}
AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag,
@NonNull IBinder token, @Nullable String[] renouncedPermissions,
@Nullable AttributionSource next) {
mAttributionSourceState = new AttributionSourceState();
mAttributionSourceState.uid = uid;
mAttributionSourceState.token = token;
mAttributionSourceState.packageName = packageName;
mAttributionSourceState.attributionTag = attributionTag;
mAttributionSourceState.renouncedPermissions = renouncedPermissions;
mAttributionSourceState.next = (next != null) ? new AttributionSourceState[]
{next.mAttributionSourceState} : new AttributionSourceState[0];
}
AttributionSource(@NonNull Parcel in) {
this(AttributionSourceState.CREATOR.createFromParcel(in));
// Since we just unpacked this object as part of it transiting a Binder
// call, this is the perfect time to enforce that its UID can be trusted
enforceCallingUid();
}
/** @hide
public AttributionSource(@NonNull AttributionSourceState attributionSourceState) {
mAttributionSourceState = attributionSourceState;
}
/** @hide
public AttributionSource withNextAttributionSource(@Nullable AttributionSource next) {
return new AttributionSource(getUid(), getPackageName(), getAttributionTag(),
mAttributionSourceState.renouncedPermissions, next);
}
/** @hide
public AttributionSource withPackageName(@Nullable String packageName) {
return new AttributionSource(getUid(), packageName, getAttributionTag(),
mAttributionSourceState.renouncedPermissions, getNext());
}
/** @hide
public AttributionSource withToken(@NonNull Binder token) {
return new AttributionSource(getUid(), getPackageName(), getAttributionTag(),
token, mAttributionSourceState.renouncedPermissions, getNext());
}
/** @hide | AttributionSource::asState | java | Reginer/aosp-android-jar | android-32/src/android/content/AttributionSource.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/content/AttributionSource.java | MIT |
public @NonNull ScopedParcelState asScopedParcelState() {
return new ScopedParcelState(this);
} |
This class represents a source to which access to permission protected data should be
attributed. Attribution sources can be chained to represent cases where the protected
data would flow through several applications. For example, app A may ask app B for
contacts and in turn app B may ask app C for contacts. In this case, the attribution
chain would be A -> B -> C and the data flow would be C -> B -> A. There are two
main benefits of using the attribution source mechanism: avoid doing explicit permission
checks on behalf of the calling app if you are accessing private data on their behalf
to send back; avoid double data access blaming which happens as you check the calling
app's permissions and when you access the data behind these permissions (for runtime
permissions). Also if not explicitly blaming the caller the data access would be
counted towards your app vs to the previous app where yours was just a proxy.
<p>
Every {@link Context} has an attribution source and you can get it via {@link
Context#getAttributionSource()} representing itself, which is a chain of one. You
can attribute work to another app, or more precisely to a chain of apps, through
which the data you would be accessing would flow, via {@link Context#createContext(
ContextParams)} plus specifying an attribution source for the next app to receive
the protected data you are accessing via {@link AttributionSource.Builder#setNext(
AttributionSource)}. Creating this attribution chain ensures that the datasource would
check whether every app in the attribution chain has permission to access the data
before releasing it. The datasource will also record appropriately that this data was
accessed by the apps in the sequence if the data is behind a sensitive permission
(e.g. dangerous). Again, this is useful if you are accessing the data on behalf of another
app, for example a speech recognizer using the mic so it can provide recognition to
a calling app.
<p>
You can create an attribution chain of you and any other app without any verification
as this is something already available via the {@link android.app.AppOpsManager} APIs.
This is supported to handle cases where you don't have access to the caller's attribution
source and you can directly use the {@link AttributionSource.Builder} APIs. However,
if the data flows through more than two apps (more than you access the data for the
caller) you need to have a handle to the {@link AttributionSource} for the calling app's
context in order to create an attribution context. This means you either need to have an
API for the other app to send you its attribution source or use a platform API that pipes
the callers attribution source.
<p>
You cannot forge an attribution chain without the participation of every app in the
attribution chain (aside of the special case mentioned above). To create an attribution
source that is trusted you need to create an attribution context that points to an
attribution source that was explicitly created by the app that it refers to, recursively.
<p>
Since creating an attribution context leads to all permissions for apps in the attribution
chain being checked, you need to expect getting a security exception when accessing
permission protected APIs since some app in the chain may not have the permission.
@Immutable
public final class AttributionSource implements Parcelable {
private static final String DESCRIPTOR = "android.content.AttributionSource";
private static final Binder sDefaultToken = new Binder(DESCRIPTOR);
private final @NonNull AttributionSourceState mAttributionSourceState;
private @Nullable AttributionSource mNextCached;
private @Nullable Set<String> mRenouncedPermissionsCached;
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag) {
this(uid, packageName, attributionTag, sDefaultToken);
}
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null,
/*next*/ null);
}
/** @hide
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token,
@Nullable AttributionSource next) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null, next);
}
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @Nullable Set<String> renouncedPermissions,
@Nullable AttributionSource next) {
this(uid, packageName, attributionTag, (renouncedPermissions != null)
? renouncedPermissions.toArray(new String[0]) : null, next);
}
/** @hide
public AttributionSource(@NonNull AttributionSource current, @Nullable AttributionSource next) {
this(current.getUid(), current.getPackageName(), current.getAttributionTag(),
current.getToken(), current.mAttributionSourceState.renouncedPermissions, next);
}
AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag,
@Nullable String[] renouncedPermissions, @Nullable AttributionSource next) {
this(uid, packageName, attributionTag, sDefaultToken, renouncedPermissions, next);
}
AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag,
@NonNull IBinder token, @Nullable String[] renouncedPermissions,
@Nullable AttributionSource next) {
mAttributionSourceState = new AttributionSourceState();
mAttributionSourceState.uid = uid;
mAttributionSourceState.token = token;
mAttributionSourceState.packageName = packageName;
mAttributionSourceState.attributionTag = attributionTag;
mAttributionSourceState.renouncedPermissions = renouncedPermissions;
mAttributionSourceState.next = (next != null) ? new AttributionSourceState[]
{next.mAttributionSourceState} : new AttributionSourceState[0];
}
AttributionSource(@NonNull Parcel in) {
this(AttributionSourceState.CREATOR.createFromParcel(in));
// Since we just unpacked this object as part of it transiting a Binder
// call, this is the perfect time to enforce that its UID can be trusted
enforceCallingUid();
}
/** @hide
public AttributionSource(@NonNull AttributionSourceState attributionSourceState) {
mAttributionSourceState = attributionSourceState;
}
/** @hide
public AttributionSource withNextAttributionSource(@Nullable AttributionSource next) {
return new AttributionSource(getUid(), getPackageName(), getAttributionTag(),
mAttributionSourceState.renouncedPermissions, next);
}
/** @hide
public AttributionSource withPackageName(@Nullable String packageName) {
return new AttributionSource(getUid(), packageName, getAttributionTag(),
mAttributionSourceState.renouncedPermissions, getNext());
}
/** @hide
public AttributionSource withToken(@NonNull Binder token) {
return new AttributionSource(getUid(), getPackageName(), getAttributionTag(),
token, mAttributionSourceState.renouncedPermissions, getNext());
}
/** @hide
public @NonNull AttributionSourceState asState() {
return mAttributionSourceState;
}
/** @hide | AttributionSource::asScopedParcelState | java | Reginer/aosp-android-jar | android-32/src/android/content/AttributionSource.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/content/AttributionSource.java | MIT |
public static AttributionSource myAttributionSource() {
return new AttributionSource(Process.myUid(), ActivityThread.currentOpPackageName(),
/*attributionTag*/ null, (String[]) /*renouncedPermissions*/ null, /*next*/ null);
} |
This class represents a source to which access to permission protected data should be
attributed. Attribution sources can be chained to represent cases where the protected
data would flow through several applications. For example, app A may ask app B for
contacts and in turn app B may ask app C for contacts. In this case, the attribution
chain would be A -> B -> C and the data flow would be C -> B -> A. There are two
main benefits of using the attribution source mechanism: avoid doing explicit permission
checks on behalf of the calling app if you are accessing private data on their behalf
to send back; avoid double data access blaming which happens as you check the calling
app's permissions and when you access the data behind these permissions (for runtime
permissions). Also if not explicitly blaming the caller the data access would be
counted towards your app vs to the previous app where yours was just a proxy.
<p>
Every {@link Context} has an attribution source and you can get it via {@link
Context#getAttributionSource()} representing itself, which is a chain of one. You
can attribute work to another app, or more precisely to a chain of apps, through
which the data you would be accessing would flow, via {@link Context#createContext(
ContextParams)} plus specifying an attribution source for the next app to receive
the protected data you are accessing via {@link AttributionSource.Builder#setNext(
AttributionSource)}. Creating this attribution chain ensures that the datasource would
check whether every app in the attribution chain has permission to access the data
before releasing it. The datasource will also record appropriately that this data was
accessed by the apps in the sequence if the data is behind a sensitive permission
(e.g. dangerous). Again, this is useful if you are accessing the data on behalf of another
app, for example a speech recognizer using the mic so it can provide recognition to
a calling app.
<p>
You can create an attribution chain of you and any other app without any verification
as this is something already available via the {@link android.app.AppOpsManager} APIs.
This is supported to handle cases where you don't have access to the caller's attribution
source and you can directly use the {@link AttributionSource.Builder} APIs. However,
if the data flows through more than two apps (more than you access the data for the
caller) you need to have a handle to the {@link AttributionSource} for the calling app's
context in order to create an attribution context. This means you either need to have an
API for the other app to send you its attribution source or use a platform API that pipes
the callers attribution source.
<p>
You cannot forge an attribution chain without the participation of every app in the
attribution chain (aside of the special case mentioned above). To create an attribution
source that is trusted you need to create an attribution context that points to an
attribution source that was explicitly created by the app that it refers to, recursively.
<p>
Since creating an attribution context leads to all permissions for apps in the attribution
chain being checked, you need to expect getting a security exception when accessing
permission protected APIs since some app in the chain may not have the permission.
@Immutable
public final class AttributionSource implements Parcelable {
private static final String DESCRIPTOR = "android.content.AttributionSource";
private static final Binder sDefaultToken = new Binder(DESCRIPTOR);
private final @NonNull AttributionSourceState mAttributionSourceState;
private @Nullable AttributionSource mNextCached;
private @Nullable Set<String> mRenouncedPermissionsCached;
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag) {
this(uid, packageName, attributionTag, sDefaultToken);
}
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null,
/*next*/ null);
}
/** @hide
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @NonNull IBinder token,
@Nullable AttributionSource next) {
this(uid, packageName, attributionTag, token, /*renouncedPermissions*/ null, next);
}
/** @hide
@TestApi
public AttributionSource(int uid, @Nullable String packageName,
@Nullable String attributionTag, @Nullable Set<String> renouncedPermissions,
@Nullable AttributionSource next) {
this(uid, packageName, attributionTag, (renouncedPermissions != null)
? renouncedPermissions.toArray(new String[0]) : null, next);
}
/** @hide
public AttributionSource(@NonNull AttributionSource current, @Nullable AttributionSource next) {
this(current.getUid(), current.getPackageName(), current.getAttributionTag(),
current.getToken(), current.mAttributionSourceState.renouncedPermissions, next);
}
AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag,
@Nullable String[] renouncedPermissions, @Nullable AttributionSource next) {
this(uid, packageName, attributionTag, sDefaultToken, renouncedPermissions, next);
}
AttributionSource(int uid, @Nullable String packageName, @Nullable String attributionTag,
@NonNull IBinder token, @Nullable String[] renouncedPermissions,
@Nullable AttributionSource next) {
mAttributionSourceState = new AttributionSourceState();
mAttributionSourceState.uid = uid;
mAttributionSourceState.token = token;
mAttributionSourceState.packageName = packageName;
mAttributionSourceState.attributionTag = attributionTag;
mAttributionSourceState.renouncedPermissions = renouncedPermissions;
mAttributionSourceState.next = (next != null) ? new AttributionSourceState[]
{next.mAttributionSourceState} : new AttributionSourceState[0];
}
AttributionSource(@NonNull Parcel in) {
this(AttributionSourceState.CREATOR.createFromParcel(in));
// Since we just unpacked this object as part of it transiting a Binder
// call, this is the perfect time to enforce that its UID can be trusted
enforceCallingUid();
}
/** @hide
public AttributionSource(@NonNull AttributionSourceState attributionSourceState) {
mAttributionSourceState = attributionSourceState;
}
/** @hide
public AttributionSource withNextAttributionSource(@Nullable AttributionSource next) {
return new AttributionSource(getUid(), getPackageName(), getAttributionTag(),
mAttributionSourceState.renouncedPermissions, next);
}
/** @hide
public AttributionSource withPackageName(@Nullable String packageName) {
return new AttributionSource(getUid(), packageName, getAttributionTag(),
mAttributionSourceState.renouncedPermissions, getNext());
}
/** @hide
public AttributionSource withToken(@NonNull Binder token) {
return new AttributionSource(getUid(), getPackageName(), getAttributionTag(),
token, mAttributionSourceState.renouncedPermissions, getNext());
}
/** @hide
public @NonNull AttributionSourceState asState() {
return mAttributionSourceState;
}
/** @hide
public @NonNull ScopedParcelState asScopedParcelState() {
return new ScopedParcelState(this);
}
/** @hide | AttributionSource::myAttributionSource | java | Reginer/aosp-android-jar | android-32/src/android/content/AttributionSource.java | https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/content/AttributionSource.java | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.