code
stringlengths
11
173k
docstring
stringlengths
2
593k
func_name
stringlengths
2
189
language
stringclasses
1 value
repo
stringclasses
833 values
path
stringlengths
11
294
url
stringlengths
60
339
license
stringclasses
4 values
int execute() { try { // Refuse possible leaked file descriptors if (mRequest.intent != null && mRequest.intent.hasFileDescriptors()) { throw new IllegalArgumentException("File descriptors passed in Intent"); } final LaunchingState launchingState; synchronized (mService.mGlobalLock) { final ActivityRecord caller = ActivityRecord.forTokenLocked(mRequest.resultTo); final int callingUid = mRequest.realCallingUid == Request.DEFAULT_REAL_CALLING_UID ? Binder.getCallingUid() : mRequest.realCallingUid; launchingState = mSupervisor.getActivityMetricsLogger().notifyActivityLaunching( mRequest.intent, caller, callingUid); } // If the caller hasn't already resolved the activity, we're willing // to do so here. If the caller is already holding the WM lock here, // and we need to check dynamic Uri permissions, then we're forced // to assume those permissions are denied to avoid deadlocking. if (mRequest.activityInfo == null) { mRequest.resolveActivity(mSupervisor); } // Add checkpoint for this shutdown or reboot attempt, so we can record the original // intent action and package name. if (mRequest.intent != null) { String intentAction = mRequest.intent.getAction(); String callingPackage = mRequest.callingPackage; if (intentAction != null && callingPackage != null && (Intent.ACTION_REQUEST_SHUTDOWN.equals(intentAction) || Intent.ACTION_SHUTDOWN.equals(intentAction) || Intent.ACTION_REBOOT.equals(intentAction))) { ShutdownCheckPoints.recordCheckPoint(intentAction, callingPackage, null); } } int res; synchronized (mService.mGlobalLock) { final boolean globalConfigWillChange = mRequest.globalConfig != null && mService.getGlobalConfiguration().diff(mRequest.globalConfig) != 0; final Task rootTask = mRootWindowContainer.getTopDisplayFocusedRootTask(); if (rootTask != null) { rootTask.mConfigWillChange = globalConfigWillChange; } ProtoLog.v(WM_DEBUG_CONFIGURATION, "Starting activity when config " + "will change = %b", globalConfigWillChange); final long origId = Binder.clearCallingIdentity(); res = resolveToHeavyWeightSwitcherIfNeeded(); if (res != START_SUCCESS) { return res; } res = executeRequest(mRequest); Binder.restoreCallingIdentity(origId); if (globalConfigWillChange) { // If the caller also wants to switch to a new configuration, do so now. // This allows a clean switch, as we are waiting for the current activity // to pause (so we will not destroy it), and have not yet started the // next activity. mService.mAmInternal.enforceCallingPermission( android.Manifest.permission.CHANGE_CONFIGURATION, "updateConfiguration()"); if (rootTask != null) { rootTask.mConfigWillChange = false; } ProtoLog.v(WM_DEBUG_CONFIGURATION, "Updating to new configuration after starting activity."); mService.updateConfigurationLocked(mRequest.globalConfig, null, false); } // The original options may have additional info about metrics. The mOptions is not // used here because it may be cleared in setTargetRootTaskIfNeeded. final ActivityOptions originalOptions = mRequest.activityOptions != null ? mRequest.activityOptions.getOriginalOptions() : null; // If the new record is the one that started, a new activity has created. final boolean newActivityCreated = mStartActivity == mLastStartActivityRecord; // Notify ActivityMetricsLogger that the activity has launched. // ActivityMetricsLogger will then wait for the windows to be drawn and populate // WaitResult. mSupervisor.getActivityMetricsLogger().notifyActivityLaunched(launchingState, res, newActivityCreated, mLastStartActivityRecord, originalOptions); if (mRequest.waitResult != null) { mRequest.waitResult.result = res; res = waitResultIfNeeded(mRequest.waitResult, mLastStartActivityRecord, launchingState); } return getExternalResult(res); } } finally { onExecutionComplete(); } }
Resolve necessary information according the request parameters provided earlier, and execute the request which begin the journey of starting an activity. @return The starter result.
Request::execute
java
Reginer/aosp-android-jar
android-33/src/com/android/server/wm/ActivityStarter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/wm/ActivityStarter.java
MIT
ActivityStarter setCallingPid(int pid) { mRequest.callingPid = pid; return this; }
Sets the pid of the caller who originally started the activity. Normally, the pid/uid would be the calling pid from the binder call. However, in case of a {@link PendingIntent}, the pid/uid pair of the caller is considered the original entity that created the pending intent, in contrast to setRealCallingPid/Uid, which represents the entity who invoked pending intent via {@link PendingIntent#send}.
Request::setCallingPid
java
Reginer/aosp-android-jar
android-33/src/com/android/server/wm/ActivityStarter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/wm/ActivityStarter.java
MIT
ActivityStarter setCallingUid(int uid) { mRequest.callingUid = uid; return this; }
Sets the uid of the caller who originally started the activity. @see #setCallingPid
Request::setCallingUid
java
Reginer/aosp-android-jar
android-33/src/com/android/server/wm/ActivityStarter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/wm/ActivityStarter.java
MIT
ActivityStarter setRealCallingPid(int pid) { mRequest.realCallingPid = pid; return this; }
Sets the pid of the caller who requested to launch the activity. The pid/uid represents the caller who launches the activity in this request. It will almost same as setCallingPid/Uid except when processing {@link PendingIntent}: the pid/uid will be the caller who called {@link PendingIntent#send()}. @see #setCallingPid
Request::setRealCallingPid
java
Reginer/aosp-android-jar
android-33/src/com/android/server/wm/ActivityStarter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/wm/ActivityStarter.java
MIT
ActivityStarter setRealCallingUid(int uid) { mRequest.realCallingUid = uid; return this; }
Sets the uid of the caller who requested to launch the activity. @see #setRealCallingPid
Request::setRealCallingUid
java
Reginer/aosp-android-jar
android-33/src/com/android/server/wm/ActivityStarter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/wm/ActivityStarter.java
MIT
private int getColor(float fx, float fy) { int x = getCoordinate(Math.round(fx), mImage.getWidth(), mTileModeX); int y = getCoordinate(Math.round(fy), mImage.getHeight(), mTileModeY); return mImage.getRGB(x, y); }
Returns a color for an arbitrary point.
BitmapShaderContext::getColor
java
Reginer/aosp-android-jar
android-32/src/android/graphics/BitmapShader_Delegate.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/android/graphics/BitmapShader_Delegate.java
MIT
public void notifyShortcutTriggered() { if (DEBUG_ALL) { Slog.i(mLogTag, "notifyShortcutTriggered():"); } if (mDetectShortcutTrigger) { handleShortcutTriggered(); mCallback.onShortcutTriggered(mDisplayId, getMode()); } }
Called when the shortcut target is magnification.
MagnificationGestureHandler::notifyShortcutTriggered
java
Reginer/aosp-android-jar
android-31/src/com/android/server/accessibility/magnification/MagnificationGestureHandler.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/accessibility/magnification/MagnificationGestureHandler.java
MIT
public FileInputStream(String name) throws FileNotFoundException { this(name != null ? new File(name) : null); }
Creates a <code>FileInputStream</code> by opening a connection to an actual file, the file named by the path name <code>name</code> in the file system. A new <code>FileDescriptor</code> object is created to represent this file connection. <p> First, if there is a security manager, its <code>checkRead</code> method is called with the <code>name</code> argument as its argument. <p> If the named file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading then a <code>FileNotFoundException</code> is thrown. @param name the system-dependent file name. @exception FileNotFoundException if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading. @exception SecurityException if a security manager exists and its <code>checkRead</code> method denies read access to the file. @see java.lang.SecurityManager#checkRead(java.lang.String)
FileInputStream::FileInputStream
java
Reginer/aosp-android-jar
android-34/src/java/io/FileInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java
MIT
public FileInputStream(File file) throws FileNotFoundException { String name = (file != null ? file.getPath() : null); SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkRead(name); } if (name == null) { throw new NullPointerException(); } if (file.isInvalid()) { throw new FileNotFoundException("Invalid file path"); } // BEGIN Android-changed: Open files using IoBridge to share BlockGuard & StrictMode logic. // http://b/112107427 // fd = new FileDescriptor(); fd = IoBridge.open(name, O_RDONLY); // END Android-changed: Open files using IoBridge to share BlockGuard & StrictMode logic. // Android-changed: Tracking mechanism for FileDescriptor sharing. // fd.attach(this); isFdOwner = true; path = name; // Android-removed: Open files using IoBridge to share BlockGuard & StrictMode logic. // open(name); // Android-added: File descriptor ownership tracking. IoUtils.setFdOwner(this.fd, this); // Android-added: CloseGuard support. guard.open("close"); }
Creates a <code>FileInputStream</code> by opening a connection to an actual file, the file named by the <code>File</code> object <code>file</code> in the file system. A new <code>FileDescriptor</code> object is created to represent this file connection. <p> First, if there is a security manager, its <code>checkRead</code> method is called with the path represented by the <code>file</code> argument as its argument. <p> If the named file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading then a <code>FileNotFoundException</code> is thrown. @param file the file to be opened for reading. @exception FileNotFoundException if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be opened for reading. @exception SecurityException if a security manager exists and its <code>checkRead</code> method denies read access to the file. @see java.io.File#getPath() @see java.lang.SecurityManager#checkRead(java.lang.String)
FileInputStream::FileInputStream
java
Reginer/aosp-android-jar
android-34/src/java/io/FileInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java
MIT
public FileInputStream(FileDescriptor fdObj) { // Android-changed: Delegate to added hidden constructor. this(fdObj, false /* isFdOwner */); }
Creates a <code>FileInputStream</code> by using the file descriptor <code>fdObj</code>, which represents an existing connection to an actual file in the file system. <p> If there is a security manager, its <code>checkRead</code> method is called with the file descriptor <code>fdObj</code> as its argument to see if it's ok to read the file descriptor. If read access is denied to the file descriptor a <code>SecurityException</code> is thrown. <p> If <code>fdObj</code> is null then a <code>NullPointerException</code> is thrown. <p> This constructor does not throw an exception if <code>fdObj</code> is {@link java.io.FileDescriptor#valid() invalid}. However, if the methods are invoked on the resulting stream to attempt I/O on the stream, an <code>IOException</code> is thrown. <p> Android-specific warning: {@link #close()} method doesn't close the {@code fdObj} provided, because this object doesn't own the file descriptor, but the caller does. The caller can call {@link android.system.Os#close(FileDescriptor)} to close the fd. @param fdObj the file descriptor to be opened for reading.
FileInputStream::FileInputStream
java
Reginer/aosp-android-jar
android-34/src/java/io/FileInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java
MIT
public FileInputStream(FileDescriptor fdObj, boolean isFdOwner) { if (fdObj == null) { // Android-changed: Improved NullPointerException message. throw new NullPointerException("fdObj == null"); } fd = fdObj; path = null; // Android-changed: FileDescriptor ownership tracking mechanism. /* /* * FileDescriptor is being shared by streams. * Register this stream with FileDescriptor tracker. * fd.attach(this); */ this.isFdOwner = isFdOwner; if (isFdOwner) { IoUtils.setFdOwner(this.fd, this); } }
Creates a <code>FileInputStream</code> by using the file descriptor <code>fdObj</code>, which represents an existing connection to an actual file in the file system. <p> If there is a security manager, its <code>checkRead</code> method is called with the file descriptor <code>fdObj</code> as its argument to see if it's ok to read the file descriptor. If read access is denied to the file descriptor a <code>SecurityException</code> is thrown. <p> If <code>fdObj</code> is null then a <code>NullPointerException</code> is thrown. <p> This constructor does not throw an exception if <code>fdObj</code> is {@link java.io.FileDescriptor#valid() invalid}. However, if the methods are invoked on the resulting stream to attempt I/O on the stream, an <code>IOException</code> is thrown. <p> Android-specific warning: {@link #close()} method doesn't close the {@code fdObj} provided, because this object doesn't own the file descriptor, but the caller does. The caller can call {@link android.system.Os#close(FileDescriptor)} to close the fd. @param fdObj the file descriptor to be opened for reading. public FileInputStream(FileDescriptor fdObj) { // Android-changed: Delegate to added hidden constructor. this(fdObj, false /* isFdOwner */); } // Android-added: Internal/hidden constructor for specifying FileDescriptor ownership. // Android-removed: SecurityManager calls. /** @hide
FileInputStream::FileInputStream
java
Reginer/aosp-android-jar
android-34/src/java/io/FileInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java
MIT
public int read() throws IOException { // Android-changed: Read methods delegate to read(byte[], int, int) to share Android logic. byte[] b = new byte[1]; return (read(b, 0, 1) != -1) ? b[0] & 0xff : -1; }
Reads a byte of data from this input stream. This method blocks if no input is yet available. @return the next byte of data, or <code>-1</code> if the end of the file is reached. @exception IOException if an I/O error occurs.
FileInputStream::read
java
Reginer/aosp-android-jar
android-34/src/java/io/FileInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java
MIT
public int read(byte b[]) throws IOException { // Android-changed: Read methods delegate to read(byte[], int, int) to share Android logic. return read(b, 0, b.length); }
Reads up to <code>b.length</code> bytes of data from this input stream into an array of bytes. This method blocks until some input is available. @param b the buffer into which the data is read. @return the total number of bytes read into the buffer, or <code>-1</code> if there is no more data because the end of the file has been reached. @exception IOException if an I/O error occurs.
FileInputStream::read
java
Reginer/aosp-android-jar
android-34/src/java/io/FileInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java
MIT
public int read(byte b[], int off, int len) throws IOException { // Android-added: close() check before I/O. if (closed && len > 0) { throw new IOException("Stream Closed"); } // Android-added: Tracking of unbuffered I/O. tracker.trackIo(len, IoTracker.Mode.READ); // Android-changed: Use IoBridge instead of calling native method. return IoBridge.read(fd, b, off, len); }
Reads up to <code>len</code> bytes of data from this input stream into an array of bytes. If <code>len</code> is not zero, the method blocks until some input is available; otherwise, no bytes are read and <code>0</code> is returned. @param b the buffer into which the data is read. @param off the start offset in the destination array <code>b</code> @param len the maximum number of bytes read. @return the total number of bytes read into the buffer, or <code>-1</code> if there is no more data because the end of the file has been reached. @exception NullPointerException If <code>b</code> is <code>null</code>. @exception IndexOutOfBoundsException If <code>off</code> is negative, <code>len</code> is negative, or <code>len</code> is greater than <code>b.length - off</code> @exception IOException if an I/O error occurs.
FileInputStream::read
java
Reginer/aosp-android-jar
android-34/src/java/io/FileInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java
MIT
public void close() throws IOException { synchronized (closeLock) { if (closed) { return; } closed = true; } // Android-added: CloseGuard support. guard.close(); if (channel != null) { channel.close(); } // BEGIN Android-changed: Close handling / notification of blocked threads. if (isFdOwner) { IoBridge.closeAndSignalBlockedThreads(fd); } // END Android-changed: Close handling / notification of blocked threads. }
Closes this file input stream and releases any system resources associated with the stream. <p> If this stream has an associated channel then the channel is closed as well. @exception IOException if an I/O error occurs. @revised 1.4 @spec JSR-51
UseManualSkipException::close
java
Reginer/aosp-android-jar
android-34/src/java/io/FileInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java
MIT
public final FileDescriptor getFD() throws IOException { if (fd != null) { return fd; } throw new IOException(); }
Returns the <code>FileDescriptor</code> object that represents the connection to the actual file in the file system being used by this <code>FileInputStream</code>. @return the file descriptor object associated with this stream. @exception IOException if an I/O error occurs. @see java.io.FileDescriptor
UseManualSkipException::getFD
java
Reginer/aosp-android-jar
android-34/src/java/io/FileInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java
MIT
public FileChannel getChannel() { synchronized (this) { if (channel == null) { channel = FileChannelImpl.open(fd, path, true, false, this); } return channel; } }
Returns the unique {@link java.nio.channels.FileChannel FileChannel} object associated with this file input stream. <p> The initial {@link java.nio.channels.FileChannel#position() position} of the returned channel will be equal to the number of bytes read from the file so far. Reading bytes from this stream will increment the channel's position. Changing the channel's position, either explicitly or by reading, will change this stream's file position. @return the file channel associated with this file input stream @since 1.4 @spec JSR-51
UseManualSkipException::getChannel
java
Reginer/aosp-android-jar
android-34/src/java/io/FileInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java
MIT
protected void finalize() throws IOException { // Android-added: CloseGuard support. if (guard != null) { guard.warnIfOpen(); } if ((fd != null) && (fd != FileDescriptor.in)) { // Android-removed: Obsoleted comment about shared FileDescriptor handling. close(); } }
Ensures that the <code>close</code> method of this file input stream is called when there are no more references to it. @exception IOException if an I/O error occurs. @see java.io.FileInputStream#close()
UseManualSkipException::finalize
java
Reginer/aosp-android-jar
android-34/src/java/io/FileInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/io/FileInputStream.java
MIT
public synchronized static void setDefault(Authenticator a) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { NetPermission setDefaultPermission = new NetPermission("setDefaultAuthenticator"); sm.checkPermission(setDefaultPermission); } theAuthenticator = a; }
Sets the authenticator that will be used by the networking code when a proxy or an HTTP server asks for authentication. <p> First, if there is a security manager, its {@code checkPermission} method is called with a {@code NetPermission("setDefaultAuthenticator")} permission. This may result in a java.lang.SecurityException. @param a The authenticator to be set. If a is {@code null} then any previously set authenticator is removed. @throws SecurityException if a security manager exists and its {@code checkPermission} method doesn't allow setting the default authenticator. @see SecurityManager#checkPermission @see java.net.NetPermission
RequestorType::setDefault
java
Reginer/aosp-android-jar
android-35/src/java/net/Authenticator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java
MIT
public static PasswordAuthentication requestPasswordAuthentication( InetAddress addr, int port, String protocol, String prompt, String scheme) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { NetPermission requestPermission = new NetPermission("requestPasswordAuthentication"); sm.checkPermission(requestPermission); } Authenticator a = theAuthenticator; if (a == null) { return null; } else { synchronized(a) { a.reset(); a.requestingSite = addr; a.requestingPort = port; a.requestingProtocol = protocol; a.requestingPrompt = prompt; a.requestingScheme = scheme; return a.getPasswordAuthentication(); } } }
Ask the authenticator that has been registered with the system for a password. <p> First, if there is a security manager, its {@code checkPermission} method is called with a {@code NetPermission("requestPasswordAuthentication")} permission. This may result in a java.lang.SecurityException. @param addr The InetAddress of the site requesting authorization, or null if not known. @param port the port for the requested connection @param protocol The protocol that's requesting the connection ({@link java.net.Authenticator#getRequestingProtocol()}) @param prompt A prompt string for the user @param scheme The authentication scheme @return The username/password, or null if one can't be gotten. @throws SecurityException if a security manager exists and its {@code checkPermission} method doesn't allow the password authentication request. @see SecurityManager#checkPermission @see java.net.NetPermission
RequestorType::requestPasswordAuthentication
java
Reginer/aosp-android-jar
android-35/src/java/net/Authenticator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java
MIT
public static PasswordAuthentication requestPasswordAuthentication( String host, InetAddress addr, int port, String protocol, String prompt, String scheme) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { NetPermission requestPermission = new NetPermission("requestPasswordAuthentication"); sm.checkPermission(requestPermission); } Authenticator a = theAuthenticator; if (a == null) { return null; } else { synchronized(a) { a.reset(); a.requestingHost = host; a.requestingSite = addr; a.requestingPort = port; a.requestingProtocol = protocol; a.requestingPrompt = prompt; a.requestingScheme = scheme; return a.getPasswordAuthentication(); } } }
Ask the authenticator that has been registered with the system for a password. This is the preferred method for requesting a password because the hostname can be provided in cases where the InetAddress is not available. <p> First, if there is a security manager, its {@code checkPermission} method is called with a {@code NetPermission("requestPasswordAuthentication")} permission. This may result in a java.lang.SecurityException. @param host The hostname of the site requesting authentication. @param addr The InetAddress of the site requesting authentication, or null if not known. @param port the port for the requested connection. @param protocol The protocol that's requesting the connection ({@link java.net.Authenticator#getRequestingProtocol()}) @param prompt A prompt string for the user which identifies the authentication realm. @param scheme The authentication scheme @return The username/password, or null if one can't be gotten. @throws SecurityException if a security manager exists and its {@code checkPermission} method doesn't allow the password authentication request. @see SecurityManager#checkPermission @see java.net.NetPermission @since 1.4
RequestorType::requestPasswordAuthentication
java
Reginer/aosp-android-jar
android-35/src/java/net/Authenticator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java
MIT
public static PasswordAuthentication requestPasswordAuthentication( String host, InetAddress addr, int port, String protocol, String prompt, String scheme, URL url, RequestorType reqType) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { NetPermission requestPermission = new NetPermission("requestPasswordAuthentication"); sm.checkPermission(requestPermission); } Authenticator a = theAuthenticator; if (a == null) { return null; } else { synchronized(a) { a.reset(); a.requestingHost = host; a.requestingSite = addr; a.requestingPort = port; a.requestingProtocol = protocol; a.requestingPrompt = prompt; a.requestingScheme = scheme; a.requestingURL = url; a.requestingAuthType = reqType; return a.getPasswordAuthentication(); } } }
Ask the authenticator that has been registered with the system for a password. <p> First, if there is a security manager, its {@code checkPermission} method is called with a {@code NetPermission("requestPasswordAuthentication")} permission. This may result in a java.lang.SecurityException. @param host The hostname of the site requesting authentication. @param addr The InetAddress of the site requesting authorization, or null if not known. @param port the port for the requested connection @param protocol The protocol that's requesting the connection ({@link java.net.Authenticator#getRequestingProtocol()}) @param prompt A prompt string for the user @param scheme The authentication scheme @param url The requesting URL that caused the authentication @param reqType The type (server or proxy) of the entity requesting authentication. @return The username/password, or null if one can't be gotten. @throws SecurityException if a security manager exists and its {@code checkPermission} method doesn't allow the password authentication request. @see SecurityManager#checkPermission @see java.net.NetPermission @since 1.5
RequestorType::requestPasswordAuthentication
java
Reginer/aosp-android-jar
android-35/src/java/net/Authenticator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java
MIT
protected final String getRequestingHost() { return requestingHost; }
Gets the {@code hostname} of the site or proxy requesting authentication, or {@code null} if not available. @return the hostname of the connection requiring authentication, or null if it's not available. @since 1.4
RequestorType::getRequestingHost
java
Reginer/aosp-android-jar
android-35/src/java/net/Authenticator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java
MIT
protected final InetAddress getRequestingSite() { return requestingSite; }
Gets the {@code InetAddress} of the site requesting authorization, or {@code null} if not available. @return the InetAddress of the site requesting authorization, or null if it's not available.
RequestorType::getRequestingSite
java
Reginer/aosp-android-jar
android-35/src/java/net/Authenticator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java
MIT
protected final int getRequestingPort() { return requestingPort; }
Gets the port number for the requested connection. @return an {@code int} indicating the port for the requested connection.
RequestorType::getRequestingPort
java
Reginer/aosp-android-jar
android-35/src/java/net/Authenticator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java
MIT
protected final String getRequestingProtocol() { return requestingProtocol; }
Give the protocol that's requesting the connection. Often this will be based on a URL, but in a future JDK it could be, for example, "SOCKS" for a password-protected SOCKS5 firewall. @return the protocol, optionally followed by "/version", where version is a version number. @see java.net.URL#getProtocol()
RequestorType::getRequestingProtocol
java
Reginer/aosp-android-jar
android-35/src/java/net/Authenticator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java
MIT
protected final String getRequestingPrompt() { return requestingPrompt; }
Gets the prompt string given by the requestor. @return the prompt string given by the requestor (realm for http requests)
RequestorType::getRequestingPrompt
java
Reginer/aosp-android-jar
android-35/src/java/net/Authenticator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java
MIT
protected final String getRequestingScheme() { return requestingScheme; }
Gets the scheme of the requestor (the HTTP scheme for an HTTP firewall, for example). @return the scheme of the requestor
RequestorType::getRequestingScheme
java
Reginer/aosp-android-jar
android-35/src/java/net/Authenticator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java
MIT
protected PasswordAuthentication getPasswordAuthentication() { return null; }
Called when password authorization is needed. Subclasses should override the default implementation, which returns null. @return The PasswordAuthentication collected from the user, or null if none is provided.
RequestorType::getPasswordAuthentication
java
Reginer/aosp-android-jar
android-35/src/java/net/Authenticator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java
MIT
protected URL getRequestingURL () { return requestingURL; }
Returns the URL that resulted in this request for authentication. @since 1.5 @return the requesting URL
RequestorType::getRequestingURL
java
Reginer/aosp-android-jar
android-35/src/java/net/Authenticator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java
MIT
protected RequestorType getRequestorType () { return requestingAuthType; }
Returns whether the requestor is a Proxy or a Server. @since 1.5 @return the authentication type of the requestor
RequestorType::getRequestorType
java
Reginer/aosp-android-jar
android-35/src/java/net/Authenticator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/java/net/Authenticator.java
MIT
public GsmCdmaConnection (GsmCdmaPhone phone, DriverCall dc, GsmCdmaCallTracker ct, int index) { super(phone.getPhoneType()); createWakeLock(phone.getContext()); acquireWakeLock(); mOwner = ct; mHandler = new MyHandler(mOwner.getLooper()); mAddress = dc.number; setEmergencyCallInfo(mOwner); String forwardedNumber = TextUtils.isEmpty(dc.forwardedNumber) ? null : dc.forwardedNumber; Rlog.i(LOG_TAG, "create, forwardedNumber=" + Rlog.pii(LOG_TAG, forwardedNumber)); mForwardedNumber = forwardedNumber == null ? null : new ArrayList<>(Collections.singletonList(dc.forwardedNumber)); mIsIncoming = dc.isMT; mCreateTime = System.currentTimeMillis(); mCnapName = dc.name; mCnapNamePresentation = dc.namePresentation; mNumberPresentation = dc.numberPresentation; mUusInfo = dc.uusInfo; mIndex = index; mParent = parentFromDCState(dc.state); mParent.attach(this, dc); fetchDtmfToneDelay(phone); setAudioQuality(getAudioQualityFromDC(dc.audioQuality)); setCallRadioTech(mOwner.getPhone().getCsCallRadioTech()); }
{@hide} public class GsmCdmaConnection extends Connection { private static final String LOG_TAG = "GsmCdmaConnection"; private static final boolean DBG = true; private static final boolean VDBG = false; public static final String OTASP_NUMBER = "*22899"; //***** Instance Variables @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) GsmCdmaCallTracker mOwner; GsmCdmaCall mParent; boolean mDisconnected; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) int mIndex; // index in GsmCdmaCallTracker.connections[], -1 if unassigned // The GsmCdma index is 1 + this /* These time/timespan values are based on System.currentTimeMillis(), i.e., "wall clock" time. long mDisconnectTime; UUSInfo mUusInfo; int mPreciseCause = 0; String mVendorCause; Connection mOrigConnection; Handler mHandler; private PowerManager.WakeLock mPartialWakeLock; // The cached delay to be used between DTMF tones fetched from carrier config. private int mDtmfToneDelay = 0; private TelephonyMetrics mMetrics = TelephonyMetrics.getInstance(); //***** Event Constants static final int EVENT_DTMF_DONE = 1; static final int EVENT_PAUSE_DONE = 2; static final int EVENT_NEXT_POST_DIAL = 3; static final int EVENT_WAKE_LOCK_TIMEOUT = 4; static final int EVENT_DTMF_DELAY_DONE = 5; //***** Constants static final int PAUSE_DELAY_MILLIS_GSM = 3 * 1000; static final int PAUSE_DELAY_MILLIS_CDMA = 2 * 1000; static final int WAKE_LOCK_TIMEOUT_MILLIS = 60 * 1000; //***** Inner Classes class MyHandler extends Handler { MyHandler(Looper l) {super(l);} @Override public void handleMessage(Message msg) { switch (msg.what) { case EVENT_NEXT_POST_DIAL: case EVENT_DTMF_DELAY_DONE: case EVENT_PAUSE_DONE: processNextPostDialChar(); break; case EVENT_WAKE_LOCK_TIMEOUT: releaseWakeLock(); break; case EVENT_DTMF_DONE: // We may need to add a delay specified by carrier between DTMF tones that are // sent out. mHandler.sendMessageDelayed(mHandler.obtainMessage(EVENT_DTMF_DELAY_DONE), mDtmfToneDelay); break; } } } //***** Constructors /** This is probably an MT call that we first saw in a CLCC response or a hand over.
MyHandler::GsmCdmaConnection
java
Reginer/aosp-android-jar
android-32/src/com/android/internal/telephony/GsmCdmaConnection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/GsmCdmaConnection.java
MIT
public GsmCdmaConnection (GsmCdmaPhone phone, String dialString, GsmCdmaCallTracker ct, GsmCdmaCall parent, DialArgs dialArgs) { super(phone.getPhoneType()); createWakeLock(phone.getContext()); acquireWakeLock(); mOwner = ct; mHandler = new MyHandler(mOwner.getLooper()); mDialString = dialString; if (!isPhoneTypeGsm()) { Rlog.d(LOG_TAG, "[GsmCdmaConn] GsmCdmaConnection: dialString=" + maskDialString(dialString)); dialString = formatDialString(dialString); Rlog.d(LOG_TAG, "[GsmCdmaConn] GsmCdmaConnection:formated dialString=" + maskDialString(dialString)); } mAddress = PhoneNumberUtils.extractNetworkPortionAlt(dialString); if (dialArgs.isEmergency) { setEmergencyCallInfo(mOwner); // There was no emergency number info found for this call, however it is // still marked as an emergency number. This may happen if it was a redialed // non-detectable emergency call from IMS. if (getEmergencyNumberInfo() == null) { setNonDetectableEmergencyCallInfo(dialArgs.eccCategory); } } mPostDialString = PhoneNumberUtils.extractPostDialPortion(dialString); mIndex = -1; mIsIncoming = false; mCnapName = null; mCnapNamePresentation = PhoneConstants.PRESENTATION_ALLOWED; mNumberPresentation = PhoneConstants.PRESENTATION_ALLOWED; mCreateTime = System.currentTimeMillis(); if (parent != null) { mParent = parent; if (isPhoneTypeGsm()) { parent.attachFake(this, GsmCdmaCall.State.DIALING); } else { //for the three way call case, not change parent state if (parent.mState == GsmCdmaCall.State.ACTIVE) { parent.attachFake(this, GsmCdmaCall.State.ACTIVE); } else { parent.attachFake(this, GsmCdmaCall.State.DIALING); } } } fetchDtmfToneDelay(phone); setCallRadioTech(mOwner.getPhone().getCsCallRadioTech()); }
{@hide} public class GsmCdmaConnection extends Connection { private static final String LOG_TAG = "GsmCdmaConnection"; private static final boolean DBG = true; private static final boolean VDBG = false; public static final String OTASP_NUMBER = "*22899"; //***** Instance Variables @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) GsmCdmaCallTracker mOwner; GsmCdmaCall mParent; boolean mDisconnected; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) int mIndex; // index in GsmCdmaCallTracker.connections[], -1 if unassigned // The GsmCdma index is 1 + this /* These time/timespan values are based on System.currentTimeMillis(), i.e., "wall clock" time. long mDisconnectTime; UUSInfo mUusInfo; int mPreciseCause = 0; String mVendorCause; Connection mOrigConnection; Handler mHandler; private PowerManager.WakeLock mPartialWakeLock; // The cached delay to be used between DTMF tones fetched from carrier config. private int mDtmfToneDelay = 0; private TelephonyMetrics mMetrics = TelephonyMetrics.getInstance(); //***** Event Constants static final int EVENT_DTMF_DONE = 1; static final int EVENT_PAUSE_DONE = 2; static final int EVENT_NEXT_POST_DIAL = 3; static final int EVENT_WAKE_LOCK_TIMEOUT = 4; static final int EVENT_DTMF_DELAY_DONE = 5; //***** Constants static final int PAUSE_DELAY_MILLIS_GSM = 3 * 1000; static final int PAUSE_DELAY_MILLIS_CDMA = 2 * 1000; static final int WAKE_LOCK_TIMEOUT_MILLIS = 60 * 1000; //***** Inner Classes class MyHandler extends Handler { MyHandler(Looper l) {super(l);} @Override public void handleMessage(Message msg) { switch (msg.what) { case EVENT_NEXT_POST_DIAL: case EVENT_DTMF_DELAY_DONE: case EVENT_PAUSE_DONE: processNextPostDialChar(); break; case EVENT_WAKE_LOCK_TIMEOUT: releaseWakeLock(); break; case EVENT_DTMF_DONE: // We may need to add a delay specified by carrier between DTMF tones that are // sent out. mHandler.sendMessageDelayed(mHandler.obtainMessage(EVENT_DTMF_DELAY_DONE), mDtmfToneDelay); break; } } } //***** Constructors /** This is probably an MT call that we first saw in a CLCC response or a hand over. public GsmCdmaConnection (GsmCdmaPhone phone, DriverCall dc, GsmCdmaCallTracker ct, int index) { super(phone.getPhoneType()); createWakeLock(phone.getContext()); acquireWakeLock(); mOwner = ct; mHandler = new MyHandler(mOwner.getLooper()); mAddress = dc.number; setEmergencyCallInfo(mOwner); String forwardedNumber = TextUtils.isEmpty(dc.forwardedNumber) ? null : dc.forwardedNumber; Rlog.i(LOG_TAG, "create, forwardedNumber=" + Rlog.pii(LOG_TAG, forwardedNumber)); mForwardedNumber = forwardedNumber == null ? null : new ArrayList<>(Collections.singletonList(dc.forwardedNumber)); mIsIncoming = dc.isMT; mCreateTime = System.currentTimeMillis(); mCnapName = dc.name; mCnapNamePresentation = dc.namePresentation; mNumberPresentation = dc.numberPresentation; mUusInfo = dc.uusInfo; mIndex = index; mParent = parentFromDCState(dc.state); mParent.attach(this, dc); fetchDtmfToneDelay(phone); setAudioQuality(getAudioQualityFromDC(dc.audioQuality)); setCallRadioTech(mOwner.getPhone().getCsCallRadioTech()); } /** This is an MO call, created when dialing
MyHandler::GsmCdmaConnection
java
Reginer/aosp-android-jar
android-32/src/com/android/internal/telephony/GsmCdmaConnection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/GsmCdmaConnection.java
MIT
public GsmCdmaConnection(Context context, CdmaCallWaitingNotification cw, GsmCdmaCallTracker ct, GsmCdmaCall parent) { super(parent.getPhone().getPhoneType()); createWakeLock(context); acquireWakeLock(); mOwner = ct; mHandler = new MyHandler(mOwner.getLooper()); mAddress = cw.number; mNumberPresentation = cw.numberPresentation; mCnapName = cw.name; mCnapNamePresentation = cw.namePresentation; mIndex = -1; mIsIncoming = true; mCreateTime = System.currentTimeMillis(); mConnectTime = 0; mParent = parent; parent.attachFake(this, GsmCdmaCall.State.WAITING); setCallRadioTech(mOwner.getPhone().getCsCallRadioTech()); }
{@hide} public class GsmCdmaConnection extends Connection { private static final String LOG_TAG = "GsmCdmaConnection"; private static final boolean DBG = true; private static final boolean VDBG = false; public static final String OTASP_NUMBER = "*22899"; //***** Instance Variables @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) GsmCdmaCallTracker mOwner; GsmCdmaCall mParent; boolean mDisconnected; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) int mIndex; // index in GsmCdmaCallTracker.connections[], -1 if unassigned // The GsmCdma index is 1 + this /* These time/timespan values are based on System.currentTimeMillis(), i.e., "wall clock" time. long mDisconnectTime; UUSInfo mUusInfo; int mPreciseCause = 0; String mVendorCause; Connection mOrigConnection; Handler mHandler; private PowerManager.WakeLock mPartialWakeLock; // The cached delay to be used between DTMF tones fetched from carrier config. private int mDtmfToneDelay = 0; private TelephonyMetrics mMetrics = TelephonyMetrics.getInstance(); //***** Event Constants static final int EVENT_DTMF_DONE = 1; static final int EVENT_PAUSE_DONE = 2; static final int EVENT_NEXT_POST_DIAL = 3; static final int EVENT_WAKE_LOCK_TIMEOUT = 4; static final int EVENT_DTMF_DELAY_DONE = 5; //***** Constants static final int PAUSE_DELAY_MILLIS_GSM = 3 * 1000; static final int PAUSE_DELAY_MILLIS_CDMA = 2 * 1000; static final int WAKE_LOCK_TIMEOUT_MILLIS = 60 * 1000; //***** Inner Classes class MyHandler extends Handler { MyHandler(Looper l) {super(l);} @Override public void handleMessage(Message msg) { switch (msg.what) { case EVENT_NEXT_POST_DIAL: case EVENT_DTMF_DELAY_DONE: case EVENT_PAUSE_DONE: processNextPostDialChar(); break; case EVENT_WAKE_LOCK_TIMEOUT: releaseWakeLock(); break; case EVENT_DTMF_DONE: // We may need to add a delay specified by carrier between DTMF tones that are // sent out. mHandler.sendMessageDelayed(mHandler.obtainMessage(EVENT_DTMF_DELAY_DONE), mDtmfToneDelay); break; } } } //***** Constructors /** This is probably an MT call that we first saw in a CLCC response or a hand over. public GsmCdmaConnection (GsmCdmaPhone phone, DriverCall dc, GsmCdmaCallTracker ct, int index) { super(phone.getPhoneType()); createWakeLock(phone.getContext()); acquireWakeLock(); mOwner = ct; mHandler = new MyHandler(mOwner.getLooper()); mAddress = dc.number; setEmergencyCallInfo(mOwner); String forwardedNumber = TextUtils.isEmpty(dc.forwardedNumber) ? null : dc.forwardedNumber; Rlog.i(LOG_TAG, "create, forwardedNumber=" + Rlog.pii(LOG_TAG, forwardedNumber)); mForwardedNumber = forwardedNumber == null ? null : new ArrayList<>(Collections.singletonList(dc.forwardedNumber)); mIsIncoming = dc.isMT; mCreateTime = System.currentTimeMillis(); mCnapName = dc.name; mCnapNamePresentation = dc.namePresentation; mNumberPresentation = dc.numberPresentation; mUusInfo = dc.uusInfo; mIndex = index; mParent = parentFromDCState(dc.state); mParent.attach(this, dc); fetchDtmfToneDelay(phone); setAudioQuality(getAudioQualityFromDC(dc.audioQuality)); setCallRadioTech(mOwner.getPhone().getCsCallRadioTech()); } /** This is an MO call, created when dialing public GsmCdmaConnection (GsmCdmaPhone phone, String dialString, GsmCdmaCallTracker ct, GsmCdmaCall parent, DialArgs dialArgs) { super(phone.getPhoneType()); createWakeLock(phone.getContext()); acquireWakeLock(); mOwner = ct; mHandler = new MyHandler(mOwner.getLooper()); mDialString = dialString; if (!isPhoneTypeGsm()) { Rlog.d(LOG_TAG, "[GsmCdmaConn] GsmCdmaConnection: dialString=" + maskDialString(dialString)); dialString = formatDialString(dialString); Rlog.d(LOG_TAG, "[GsmCdmaConn] GsmCdmaConnection:formated dialString=" + maskDialString(dialString)); } mAddress = PhoneNumberUtils.extractNetworkPortionAlt(dialString); if (dialArgs.isEmergency) { setEmergencyCallInfo(mOwner); // There was no emergency number info found for this call, however it is // still marked as an emergency number. This may happen if it was a redialed // non-detectable emergency call from IMS. if (getEmergencyNumberInfo() == null) { setNonDetectableEmergencyCallInfo(dialArgs.eccCategory); } } mPostDialString = PhoneNumberUtils.extractPostDialPortion(dialString); mIndex = -1; mIsIncoming = false; mCnapName = null; mCnapNamePresentation = PhoneConstants.PRESENTATION_ALLOWED; mNumberPresentation = PhoneConstants.PRESENTATION_ALLOWED; mCreateTime = System.currentTimeMillis(); if (parent != null) { mParent = parent; if (isPhoneTypeGsm()) { parent.attachFake(this, GsmCdmaCall.State.DIALING); } else { //for the three way call case, not change parent state if (parent.mState == GsmCdmaCall.State.ACTIVE) { parent.attachFake(this, GsmCdmaCall.State.ACTIVE); } else { parent.attachFake(this, GsmCdmaCall.State.DIALING); } } } fetchDtmfToneDelay(phone); setCallRadioTech(mOwner.getPhone().getCsCallRadioTech()); } //CDMA /** This is a Call waiting call
MyHandler::GsmCdmaConnection
java
Reginer/aosp-android-jar
android-32/src/com/android/internal/telephony/GsmCdmaConnection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/GsmCdmaConnection.java
MIT
void onConnectedConnectionMigrated() { // We can release the wakelock in this case, the migrated call is not still // DIALING/ALERTING/INCOMING/WAITING. releaseWakeLock(); }
We have completed the migration of another connection to this GsmCdmaConnection (for example, in the case of SRVCC) and not still DIALING/ALERTING/INCOMING/WAITING.
MyHandler::onConnectedConnectionMigrated
java
Reginer/aosp-android-jar
android-32/src/com/android/internal/telephony/GsmCdmaConnection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/GsmCdmaConnection.java
MIT
private void setPostDialState(PostDialState s) { if (s == PostDialState.STARTED || s == PostDialState.PAUSE) { synchronized (mPartialWakeLock) { if (mPartialWakeLock.isHeld()) { mHandler.removeMessages(EVENT_WAKE_LOCK_TIMEOUT); } else { acquireWakeLock(); } Message msg = mHandler.obtainMessage(EVENT_WAKE_LOCK_TIMEOUT); mHandler.sendMessageDelayed(msg, WAKE_LOCK_TIMEOUT_MILLIS); } } else { mHandler.removeMessages(EVENT_WAKE_LOCK_TIMEOUT); releaseWakeLock(); } mPostDialState = s; notifyPostDialListeners(); }
Set post dial state and acquire wake lock while switching to "started" or "pause" state, the wake lock will be released if state switches out of "started" or "pause" state or after WAKE_LOCK_TIMEOUT_MILLIS. @param s new PostDialState
MyHandler::setPostDialState
java
Reginer/aosp-android-jar
android-32/src/com/android/internal/telephony/GsmCdmaConnection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/GsmCdmaConnection.java
MIT
public EmergencyNumberTracker getEmergencyNumberTracker() { if (mOwner != null) { Phone phone = mOwner.getPhone(); if (phone != null) { return phone.getEmergencyNumberTracker(); } } return null; }
Get the corresponding EmergencyNumberTracker associated with the connection. @return the EmergencyNumberTracker
MyHandler::getEmergencyNumberTracker
java
Reginer/aosp-android-jar
android-32/src/com/android/internal/telephony/GsmCdmaConnection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/GsmCdmaConnection.java
MIT
public boolean isOtaspCall() { return mAddress != null && OTASP_NUMBER.equals(mAddress); }
@return {@code true} if this call is an OTASP activation call, {@code false} otherwise.
MyHandler::isOtaspCall
java
Reginer/aosp-android-jar
android-32/src/com/android/internal/telephony/GsmCdmaConnection.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/internal/telephony/GsmCdmaConnection.java
MIT
public int getTag() { return mTag; }
Exception for invalid ASN.1 data in DER encoding which cannot be parsed as a node or a specific data type. public class InvalidAsn1DataException extends Exception { private final int mTag; public InvalidAsn1DataException(int tag, String message) { super(message); mTag = tag; } public InvalidAsn1DataException(int tag, String message, Throwable throwable) { super(message, throwable); mTag = tag; } /** @return The tag which has the invalid data.
InvalidAsn1DataException::getTag
java
Reginer/aosp-android-jar
android-35/src/com/android/internal/telephony/uicc/asn1/InvalidAsn1DataException.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/uicc/asn1/InvalidAsn1DataException.java
MIT
public VCardBuilder(final int vcardType, String charset) { mVCardType = vcardType; if (VCardConfig.isVersion40(vcardType)) { Log.w(LOG_TAG, "Should not use vCard 4.0 when building vCard. " + "It is not officially published yet."); } mIsV30OrV40 = VCardConfig.isVersion30(vcardType) || VCardConfig.isVersion40(vcardType); mShouldUseQuotedPrintable = VCardConfig.shouldUseQuotedPrintable(vcardType); mIsDoCoMo = VCardConfig.isDoCoMo(vcardType); mIsJapaneseMobilePhone = VCardConfig.needsToConvertPhoneticString(vcardType); mOnlyOneNoteFieldIsAvailable = VCardConfig.onlyOneNoteFieldIsAvailable(vcardType); mUsesAndroidProperty = VCardConfig.usesAndroidSpecificProperty(vcardType); mUsesDefactProperty = VCardConfig.usesDefactProperty(vcardType); mRefrainsQPToNameProperties = VCardConfig.shouldRefrainQPToNameProperties(vcardType); mAppendTypeParamName = VCardConfig.appendTypeParamName(vcardType); mNeedsToConvertPhoneticString = VCardConfig.needsToConvertPhoneticString(vcardType); // vCard 2.1 requires charset. // vCard 3.0 does not allow it but we found some devices use it to determine // the exact charset. // We currently append it only when charset other than UTF_8 is used. mShouldAppendCharsetParam = !(VCardConfig.isVersion30(vcardType) && "UTF-8".equalsIgnoreCase(charset)); if (VCardConfig.isDoCoMo(vcardType)) { if (!SHIFT_JIS.equalsIgnoreCase(charset)) { /* Log.w(LOG_TAG, "The charset \"" + charset + "\" is used while " + SHIFT_JIS + " is needed to be used."); */ if (TextUtils.isEmpty(charset)) { mCharset = SHIFT_JIS; } else { mCharset = charset; } } else { mCharset = charset; } mVCardCharsetParameter = "CHARSET=" + SHIFT_JIS; } else { if (TextUtils.isEmpty(charset)) { Log.i(LOG_TAG, "Use the charset \"" + VCardConfig.DEFAULT_EXPORT_CHARSET + "\" for export."); mCharset = VCardConfig.DEFAULT_EXPORT_CHARSET; mVCardCharsetParameter = "CHARSET=" + VCardConfig.DEFAULT_EXPORT_CHARSET; } else { mCharset = charset; mVCardCharsetParameter = "CHARSET=" + charset; } } clear(); }
@param vcardType @param charset If null, we use default charset for export. @hide
VCardBuilder::VCardBuilder
java
Reginer/aosp-android-jar
android-31/src/com/android/vcard/VCardBuilder.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java
MIT
private VCardBuilder appendNamePropertiesV40(final List<ContentValues> contentValuesList) { if (mIsDoCoMo || mNeedsToConvertPhoneticString) { // Ignore all flags that look stale from the view of vCard 4.0 to // simplify construction algorithm. Actually we don't have any vCard file // available from real world yet, so we may need to re-enable some of these // in the future. Log.w(LOG_TAG, "Invalid flag is used in vCard 4.0 construction. Ignored."); } if (contentValuesList == null || contentValuesList.isEmpty()) { appendLine(VCardConstants.PROPERTY_FN, ""); return this; } // We have difficulty here. How can we appropriately handle StructuredName with // missing parts necessary for displaying while it has suppremental information. // // e.g. How to handle non-empty phonetic names with empty structured names? final ContentValues contentValues = getPrimaryContentValueWithStructuredName(contentValuesList); String familyName = contentValues.getAsString(StructuredName.FAMILY_NAME); final String middleName = contentValues.getAsString(StructuredName.MIDDLE_NAME); final String givenName = contentValues.getAsString(StructuredName.GIVEN_NAME); final String prefix = contentValues.getAsString(StructuredName.PREFIX); final String suffix = contentValues.getAsString(StructuredName.SUFFIX); final String formattedName = contentValues.getAsString(StructuredName.DISPLAY_NAME); if (TextUtils.isEmpty(familyName) && TextUtils.isEmpty(givenName) && TextUtils.isEmpty(middleName) && TextUtils.isEmpty(prefix) && TextUtils.isEmpty(suffix)) { if (TextUtils.isEmpty(formattedName)) { appendLine(VCardConstants.PROPERTY_FN, ""); return this; } familyName = formattedName; } final String phoneticFamilyName = contentValues.getAsString(StructuredName.PHONETIC_FAMILY_NAME); final String phoneticMiddleName = contentValues.getAsString(StructuredName.PHONETIC_MIDDLE_NAME); final String phoneticGivenName = contentValues.getAsString(StructuredName.PHONETIC_GIVEN_NAME); final String escapedFamily = escapeCharacters(familyName); final String escapedGiven = escapeCharacters(givenName); final String escapedMiddle = escapeCharacters(middleName); final String escapedPrefix = escapeCharacters(prefix); final String escapedSuffix = escapeCharacters(suffix); mBuilder.append(VCardConstants.PROPERTY_N); if (!(TextUtils.isEmpty(phoneticFamilyName) && TextUtils.isEmpty(phoneticMiddleName) && TextUtils.isEmpty(phoneticGivenName))) { mBuilder.append(VCARD_PARAM_SEPARATOR); final String sortAs = escapeCharacters(phoneticFamilyName) + ';' + escapeCharacters(phoneticGivenName) + ';' + escapeCharacters(phoneticMiddleName); mBuilder.append("SORT-AS=").append( VCardUtils.toStringAsV40ParamValue(sortAs)); } mBuilder.append(VCARD_DATA_SEPARATOR); mBuilder.append(escapedFamily); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(escapedGiven); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(escapedMiddle); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(escapedPrefix); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(escapedSuffix); mBuilder.append(VCARD_END_OF_LINE); if (TextUtils.isEmpty(formattedName)) { // Note: // DISPLAY_NAME doesn't exist while some other elements do, which is usually // weird in Android, as DISPLAY_NAME should (usually) be constructed // from the others using locale information and its code points. Log.w(LOG_TAG, "DISPLAY_NAME is empty."); final String escaped = escapeCharacters(VCardUtils.constructNameFromElements( VCardConfig.getNameOrderType(mVCardType), familyName, middleName, givenName, prefix, suffix)); appendLine(VCardConstants.PROPERTY_FN, escaped); } else { final String escapedFormatted = escapeCharacters(formattedName); mBuilder.append(VCardConstants.PROPERTY_FN); mBuilder.append(VCARD_DATA_SEPARATOR); mBuilder.append(escapedFormatted); mBuilder.append(VCARD_END_OF_LINE); } // We may need X- properties for phonetic names. appendPhoneticNameFields(contentValues); return this; }
To avoid unnecessary complication in logic, we use this method to construct N, FN properties for vCard 4.0.
VCardBuilder::appendNamePropertiesV40
java
Reginer/aosp-android-jar
android-31/src/com/android/vcard/VCardBuilder.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java
MIT
public VCardBuilder appendNameProperties(final List<ContentValues> contentValuesList) { if (VCardConfig.isVersion40(mVCardType)) { return appendNamePropertiesV40(contentValuesList); } if (contentValuesList == null || contentValuesList.isEmpty()) { if (VCardConfig.isVersion30(mVCardType)) { // vCard 3.0 requires "N" and "FN" properties. // vCard 4.0 does NOT require N, but we take care of possible backward // compatibility issues. appendLine(VCardConstants.PROPERTY_N, ""); appendLine(VCardConstants.PROPERTY_FN, ""); } else if (mIsDoCoMo) { appendLine(VCardConstants.PROPERTY_N, ""); } return this; } final ContentValues contentValues = getPrimaryContentValueWithStructuredName(contentValuesList); final String familyName = contentValues.getAsString(StructuredName.FAMILY_NAME); final String middleName = contentValues.getAsString(StructuredName.MIDDLE_NAME); final String givenName = contentValues.getAsString(StructuredName.GIVEN_NAME); final String prefix = contentValues.getAsString(StructuredName.PREFIX); final String suffix = contentValues.getAsString(StructuredName.SUFFIX); final String displayName = contentValues.getAsString(StructuredName.DISPLAY_NAME); if (!TextUtils.isEmpty(familyName) || !TextUtils.isEmpty(givenName)) { final boolean reallyAppendCharsetParameterToName = shouldAppendCharsetParam(familyName, givenName, middleName, prefix, suffix); final boolean reallyUseQuotedPrintableToName = (!mRefrainsQPToNameProperties && !(VCardUtils.containsOnlyNonCrLfPrintableAscii(familyName) && VCardUtils.containsOnlyNonCrLfPrintableAscii(givenName) && VCardUtils.containsOnlyNonCrLfPrintableAscii(middleName) && VCardUtils.containsOnlyNonCrLfPrintableAscii(prefix) && VCardUtils.containsOnlyNonCrLfPrintableAscii(suffix))); final String formattedName; if (!TextUtils.isEmpty(displayName)) { formattedName = displayName; } else { formattedName = VCardUtils.constructNameFromElements( VCardConfig.getNameOrderType(mVCardType), familyName, middleName, givenName, prefix, suffix); } final boolean reallyAppendCharsetParameterToFN = shouldAppendCharsetParam(formattedName); final boolean reallyUseQuotedPrintableToFN = !mRefrainsQPToNameProperties && !VCardUtils.containsOnlyNonCrLfPrintableAscii(formattedName); final String encodedFamily; final String encodedGiven; final String encodedMiddle; final String encodedPrefix; final String encodedSuffix; if (reallyUseQuotedPrintableToName) { encodedFamily = encodeQuotedPrintable(familyName); encodedGiven = encodeQuotedPrintable(givenName); encodedMiddle = encodeQuotedPrintable(middleName); encodedPrefix = encodeQuotedPrintable(prefix); encodedSuffix = encodeQuotedPrintable(suffix); } else { encodedFamily = escapeCharacters(familyName); encodedGiven = escapeCharacters(givenName); encodedMiddle = escapeCharacters(middleName); encodedPrefix = escapeCharacters(prefix); encodedSuffix = escapeCharacters(suffix); } final String encodedFormattedname = (reallyUseQuotedPrintableToFN ? encodeQuotedPrintable(formattedName) : escapeCharacters(formattedName)); mBuilder.append(VCardConstants.PROPERTY_N); if (mIsDoCoMo) { if (reallyAppendCharsetParameterToName) { mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(mVCardCharsetParameter); } if (reallyUseQuotedPrintableToName) { mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(VCARD_PARAM_ENCODING_QP); } mBuilder.append(VCARD_DATA_SEPARATOR); // DoCoMo phones require that all the elements in the "family name" field. mBuilder.append(formattedName); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(VCARD_ITEM_SEPARATOR); } else { if (reallyAppendCharsetParameterToName) { mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(mVCardCharsetParameter); } if (reallyUseQuotedPrintableToName) { mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(VCARD_PARAM_ENCODING_QP); } mBuilder.append(VCARD_DATA_SEPARATOR); mBuilder.append(encodedFamily); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(encodedGiven); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(encodedMiddle); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(encodedPrefix); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(encodedSuffix); } mBuilder.append(VCARD_END_OF_LINE); // FN property mBuilder.append(VCardConstants.PROPERTY_FN); if (reallyAppendCharsetParameterToFN) { mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(mVCardCharsetParameter); } if (reallyUseQuotedPrintableToFN) { mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(VCARD_PARAM_ENCODING_QP); } mBuilder.append(VCARD_DATA_SEPARATOR); mBuilder.append(encodedFormattedname); mBuilder.append(VCARD_END_OF_LINE); } else if (!TextUtils.isEmpty(displayName)) { // N buildSinglePartNameField(VCardConstants.PROPERTY_N, displayName); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(VCARD_END_OF_LINE); // FN buildSinglePartNameField(VCardConstants.PROPERTY_FN, displayName); mBuilder.append(VCARD_END_OF_LINE); } else if (VCardConfig.isVersion30(mVCardType)) { appendLine(VCardConstants.PROPERTY_N, ""); appendLine(VCardConstants.PROPERTY_FN, ""); } else if (mIsDoCoMo) { appendLine(VCardConstants.PROPERTY_N, ""); } appendPhoneticNameFields(contentValues); return this; }
For safety, we'll emit just one value around StructuredName, as external importers may get confused with multiple "N", "FN", etc. properties, though it is valid in vCard spec.
VCardBuilder::appendNameProperties
java
Reginer/aosp-android-jar
android-31/src/com/android/vcard/VCardBuilder.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java
MIT
private void appendPhoneticNameFields(final ContentValues contentValues) { final String phoneticFamilyName; final String phoneticMiddleName; final String phoneticGivenName; { final String tmpPhoneticFamilyName = contentValues.getAsString(StructuredName.PHONETIC_FAMILY_NAME); final String tmpPhoneticMiddleName = contentValues.getAsString(StructuredName.PHONETIC_MIDDLE_NAME); final String tmpPhoneticGivenName = contentValues.getAsString(StructuredName.PHONETIC_GIVEN_NAME); if (mNeedsToConvertPhoneticString) { phoneticFamilyName = VCardUtils.toHalfWidthString(tmpPhoneticFamilyName); phoneticMiddleName = VCardUtils.toHalfWidthString(tmpPhoneticMiddleName); phoneticGivenName = VCardUtils.toHalfWidthString(tmpPhoneticGivenName); } else { phoneticFamilyName = tmpPhoneticFamilyName; phoneticMiddleName = tmpPhoneticMiddleName; phoneticGivenName = tmpPhoneticGivenName; } } if (TextUtils.isEmpty(phoneticFamilyName) && TextUtils.isEmpty(phoneticMiddleName) && TextUtils.isEmpty(phoneticGivenName)) { if (mIsDoCoMo) { mBuilder.append(VCardConstants.PROPERTY_SOUND); mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(VCardConstants.PARAM_TYPE_X_IRMC_N); mBuilder.append(VCARD_DATA_SEPARATOR); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(VCARD_ITEM_SEPARATOR); mBuilder.append(VCARD_END_OF_LINE); } return; } if (VCardConfig.isVersion40(mVCardType)) { // We don't want SORT-STRING anyway. } else if (VCardConfig.isVersion30(mVCardType)) { final String sortString = VCardUtils.constructNameFromElements(mVCardType, phoneticFamilyName, phoneticMiddleName, phoneticGivenName); mBuilder.append(VCardConstants.PROPERTY_SORT_STRING); if (VCardConfig.isVersion30(mVCardType) && shouldAppendCharsetParam(sortString)) { // vCard 3.0 does not force us to use UTF-8 and actually we see some // programs which emit this value. It is incorrect from the view of // specification, but actually necessary for parsing vCard with non-UTF-8 // charsets, expecting other parsers not get confused with this value. mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(mVCardCharsetParameter); } mBuilder.append(VCARD_DATA_SEPARATOR); mBuilder.append(escapeCharacters(sortString)); mBuilder.append(VCARD_END_OF_LINE); } else if (mIsJapaneseMobilePhone) { // Note: There is no appropriate property for expressing // phonetic name (Yomigana in Japanese) in vCard 2.1, while there is in // vCard 3.0 (SORT-STRING). // We use DoCoMo's way when the device is Japanese one since it is already // supported by a lot of Japanese mobile phones. // This is "X-" property, so any parser hopefully would not get // confused with this. // // Also, DoCoMo's specification requires vCard composer to use just the first // column. // i.e. // good: SOUND;X-IRMC-N:Miyakawa Daisuke;;;; // bad : SOUND;X-IRMC-N:Miyakawa;Daisuke;;; mBuilder.append(VCardConstants.PROPERTY_SOUND); mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(VCardConstants.PARAM_TYPE_X_IRMC_N); boolean reallyUseQuotedPrintable = (!mRefrainsQPToNameProperties && !(VCardUtils.containsOnlyNonCrLfPrintableAscii( phoneticFamilyName) && VCardUtils.containsOnlyNonCrLfPrintableAscii( phoneticMiddleName) && VCardUtils.containsOnlyNonCrLfPrintableAscii( phoneticGivenName))); final String encodedPhoneticFamilyName; final String encodedPhoneticMiddleName; final String encodedPhoneticGivenName; if (reallyUseQuotedPrintable) { encodedPhoneticFamilyName = encodeQuotedPrintable(phoneticFamilyName); encodedPhoneticMiddleName = encodeQuotedPrintable(phoneticMiddleName); encodedPhoneticGivenName = encodeQuotedPrintable(phoneticGivenName); } else { encodedPhoneticFamilyName = escapeCharacters(phoneticFamilyName); encodedPhoneticMiddleName = escapeCharacters(phoneticMiddleName); encodedPhoneticGivenName = escapeCharacters(phoneticGivenName); } if (shouldAppendCharsetParam(encodedPhoneticFamilyName, encodedPhoneticMiddleName, encodedPhoneticGivenName)) { mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(mVCardCharsetParameter); } mBuilder.append(VCARD_DATA_SEPARATOR); { boolean first = true; if (!TextUtils.isEmpty(encodedPhoneticFamilyName)) { mBuilder.append(encodedPhoneticFamilyName); first = false; } if (!TextUtils.isEmpty(encodedPhoneticMiddleName)) { if (first) { first = false; } else { mBuilder.append(' '); } mBuilder.append(encodedPhoneticMiddleName); } if (!TextUtils.isEmpty(encodedPhoneticGivenName)) { if (!first) { mBuilder.append(' '); } mBuilder.append(encodedPhoneticGivenName); } } mBuilder.append(VCARD_ITEM_SEPARATOR); // family;given mBuilder.append(VCARD_ITEM_SEPARATOR); // given;middle mBuilder.append(VCARD_ITEM_SEPARATOR); // middle;prefix mBuilder.append(VCARD_ITEM_SEPARATOR); // prefix;suffix mBuilder.append(VCARD_END_OF_LINE); } if (mUsesDefactProperty) { if (!TextUtils.isEmpty(phoneticGivenName)) { final boolean reallyUseQuotedPrintable = (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticGivenName)); final String encodedPhoneticGivenName; if (reallyUseQuotedPrintable) { encodedPhoneticGivenName = encodeQuotedPrintable(phoneticGivenName); } else { encodedPhoneticGivenName = escapeCharacters(phoneticGivenName); } mBuilder.append(VCardConstants.PROPERTY_X_PHONETIC_FIRST_NAME); if (shouldAppendCharsetParam(phoneticGivenName)) { mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(mVCardCharsetParameter); } if (reallyUseQuotedPrintable) { mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(VCARD_PARAM_ENCODING_QP); } mBuilder.append(VCARD_DATA_SEPARATOR); mBuilder.append(encodedPhoneticGivenName); mBuilder.append(VCARD_END_OF_LINE); } // if (!TextUtils.isEmpty(phoneticGivenName)) if (!TextUtils.isEmpty(phoneticMiddleName)) { final boolean reallyUseQuotedPrintable = (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticMiddleName)); final String encodedPhoneticMiddleName; if (reallyUseQuotedPrintable) { encodedPhoneticMiddleName = encodeQuotedPrintable(phoneticMiddleName); } else { encodedPhoneticMiddleName = escapeCharacters(phoneticMiddleName); } mBuilder.append(VCardConstants.PROPERTY_X_PHONETIC_MIDDLE_NAME); if (shouldAppendCharsetParam(phoneticMiddleName)) { mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(mVCardCharsetParameter); } if (reallyUseQuotedPrintable) { mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(VCARD_PARAM_ENCODING_QP); } mBuilder.append(VCARD_DATA_SEPARATOR); mBuilder.append(encodedPhoneticMiddleName); mBuilder.append(VCARD_END_OF_LINE); } // if (!TextUtils.isEmpty(phoneticGivenName)) if (!TextUtils.isEmpty(phoneticFamilyName)) { final boolean reallyUseQuotedPrintable = (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticFamilyName)); final String encodedPhoneticFamilyName; if (reallyUseQuotedPrintable) { encodedPhoneticFamilyName = encodeQuotedPrintable(phoneticFamilyName); } else { encodedPhoneticFamilyName = escapeCharacters(phoneticFamilyName); } mBuilder.append(VCardConstants.PROPERTY_X_PHONETIC_LAST_NAME); if (shouldAppendCharsetParam(phoneticFamilyName)) { mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(mVCardCharsetParameter); } if (reallyUseQuotedPrintable) { mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(VCARD_PARAM_ENCODING_QP); } mBuilder.append(VCARD_DATA_SEPARATOR); mBuilder.append(encodedPhoneticFamilyName); mBuilder.append(VCARD_END_OF_LINE); } // if (!TextUtils.isEmpty(phoneticFamilyName)) } }
Emits SOUND;IRMC, SORT-STRING, and de-fact values for phonetic names like X-PHONETIC-FAMILY.
VCardBuilder::appendPhoneticNameFields
java
Reginer/aosp-android-jar
android-31/src/com/android/vcard/VCardBuilder.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java
MIT
private List<String> splitPhoneNumbers(final String phoneNumber) { final List<String> phoneList = new ArrayList<String>(); StringBuilder builder = new StringBuilder(); final int length = phoneNumber.length(); for (int i = 0; i < length; i++) { final char ch = phoneNumber.charAt(i); if (ch == '\n' && builder.length() > 0) { phoneList.add(builder.toString()); builder = new StringBuilder(); } else { builder.append(ch); } } if (builder.length() > 0) { phoneList.add(builder.toString()); } return phoneList; }
<p> Splits a given string expressing phone numbers into several strings, and remove unnecessary characters inside them. The size of a returned list becomes 1 when no split is needed. </p> <p> The given number "may" have several phone numbers when the contact entry is corrupted because of its original source. e.g. "111-222-3333 (Miami)\n444-555-6666 (Broward; 305-653-6796 (Miami)" </p> <p> This kind of "phone numbers" will not be created with Android vCard implementation, but we may encounter them if the source of the input data has already corrupted implementation. </p> <p> To handle this case, this method first splits its input into multiple parts (e.g. "111-222-3333 (Miami)", "444-555-6666 (Broward", and 305653-6796 (Miami)") and removes unnecessary strings like "(Miami)". </p> <p> Do not call this method when trimming is inappropriate for its receivers. </p>
VCardBuilder::splitPhoneNumbers
java
Reginer/aosp-android-jar
android-31/src/com/android/vcard/VCardBuilder.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java
MIT
private void appendPostalsForDoCoMo(final List<ContentValues> contentValuesList) { int currentPriority = Integer.MAX_VALUE; int currentType = Integer.MAX_VALUE; ContentValues currentContentValues = null; for (final ContentValues contentValues : contentValuesList) { if (contentValues == null) { continue; } final Integer typeAsInteger = contentValues.getAsInteger(StructuredPostal.TYPE); final Integer priorityAsInteger = sPostalTypePriorityMap.get(typeAsInteger); final int priority = (priorityAsInteger != null ? priorityAsInteger : Integer.MAX_VALUE); if (priority < currentPriority) { currentPriority = priority; currentType = typeAsInteger; currentContentValues = contentValues; if (priority == 0) { break; } } } if (currentContentValues == null) { Log.w(LOG_TAG, "Should not come here. Must have at least one postal data."); return; } final String label = currentContentValues.getAsString(StructuredPostal.LABEL); appendPostalLine(currentType, label, currentContentValues, false, true); }
Tries to append just one line. If there's no appropriate address information, append an empty line.
VCardBuilder::appendPostalsForDoCoMo
java
Reginer/aosp-android-jar
android-31/src/com/android/vcard/VCardBuilder.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java
MIT
private PostalStruct tryConstructPostalStruct(ContentValues contentValues) { // adr-value = 0*6(text-value ";") text-value // ; PO Box, Extended Address, Street, Locality, Region, Postal // ; Code, Country Name final String rawPoBox = contentValues.getAsString(StructuredPostal.POBOX); final String rawNeighborhood = contentValues.getAsString(StructuredPostal.NEIGHBORHOOD); final String rawStreet = contentValues.getAsString(StructuredPostal.STREET); final String rawLocality = contentValues.getAsString(StructuredPostal.CITY); final String rawRegion = contentValues.getAsString(StructuredPostal.REGION); final String rawPostalCode = contentValues.getAsString(StructuredPostal.POSTCODE); final String rawCountry = contentValues.getAsString(StructuredPostal.COUNTRY); final String[] rawAddressArray = new String[]{ rawPoBox, rawNeighborhood, rawStreet, rawLocality, rawRegion, rawPostalCode, rawCountry}; if (!VCardUtils.areAllEmpty(rawAddressArray)) { final boolean reallyUseQuotedPrintable = (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(rawAddressArray)); final boolean appendCharset = !VCardUtils.containsOnlyPrintableAscii(rawAddressArray); final String encodedPoBox; final String encodedStreet; final String encodedLocality; final String encodedRegion; final String encodedPostalCode; final String encodedCountry; final String encodedNeighborhood; final String rawLocality2; // This looks inefficient since we encode rawLocality and rawNeighborhood twice, // but this is intentional. // // QP encoding may add line feeds when needed and the result of // - encodeQuotedPrintable(rawLocality + " " + rawNeighborhood) // may be different from // - encodedLocality + " " + encodedNeighborhood. // // We use safer way. if (TextUtils.isEmpty(rawLocality)) { if (TextUtils.isEmpty(rawNeighborhood)) { rawLocality2 = ""; } else { rawLocality2 = rawNeighborhood; } } else { if (TextUtils.isEmpty(rawNeighborhood)) { rawLocality2 = rawLocality; } else { rawLocality2 = rawLocality + " " + rawNeighborhood; } } if (reallyUseQuotedPrintable) { encodedPoBox = encodeQuotedPrintable(rawPoBox); encodedStreet = encodeQuotedPrintable(rawStreet); encodedLocality = encodeQuotedPrintable(rawLocality2); encodedRegion = encodeQuotedPrintable(rawRegion); encodedPostalCode = encodeQuotedPrintable(rawPostalCode); encodedCountry = encodeQuotedPrintable(rawCountry); } else { encodedPoBox = escapeCharacters(rawPoBox); encodedStreet = escapeCharacters(rawStreet); encodedLocality = escapeCharacters(rawLocality2); encodedRegion = escapeCharacters(rawRegion); encodedPostalCode = escapeCharacters(rawPostalCode); encodedCountry = escapeCharacters(rawCountry); encodedNeighborhood = escapeCharacters(rawNeighborhood); } final StringBuilder addressBuilder = new StringBuilder(); addressBuilder.append(encodedPoBox); addressBuilder.append(VCARD_ITEM_SEPARATOR); // PO BOX ; Extended Address addressBuilder.append(VCARD_ITEM_SEPARATOR); // Extended Address : Street addressBuilder.append(encodedStreet); addressBuilder.append(VCARD_ITEM_SEPARATOR); // Street : Locality addressBuilder.append(encodedLocality); addressBuilder.append(VCARD_ITEM_SEPARATOR); // Locality : Region addressBuilder.append(encodedRegion); addressBuilder.append(VCARD_ITEM_SEPARATOR); // Region : Postal Code addressBuilder.append(encodedPostalCode); addressBuilder.append(VCARD_ITEM_SEPARATOR); // Postal Code : Country addressBuilder.append(encodedCountry); return new PostalStruct( reallyUseQuotedPrintable, appendCharset, addressBuilder.toString()); } else { // VCardUtils.areAllEmpty(rawAddressArray) == true // Try to use FORMATTED_ADDRESS instead. final String rawFormattedAddress = contentValues.getAsString(StructuredPostal.FORMATTED_ADDRESS); if (TextUtils.isEmpty(rawFormattedAddress)) { return null; } final boolean reallyUseQuotedPrintable = (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(rawFormattedAddress)); final boolean appendCharset = !VCardUtils.containsOnlyPrintableAscii(rawFormattedAddress); final String encodedFormattedAddress; if (reallyUseQuotedPrintable) { encodedFormattedAddress = encodeQuotedPrintable(rawFormattedAddress); } else { encodedFormattedAddress = escapeCharacters(rawFormattedAddress); } // We use the second value ("Extended Address") just because Japanese mobile phones // do so. If the other importer expects the value be in the other field, some flag may // be needed. final StringBuilder addressBuilder = new StringBuilder(); addressBuilder.append(VCARD_ITEM_SEPARATOR); // PO BOX ; Extended Address addressBuilder.append(encodedFormattedAddress); addressBuilder.append(VCARD_ITEM_SEPARATOR); // Extended Address : Street addressBuilder.append(VCARD_ITEM_SEPARATOR); // Street : Locality addressBuilder.append(VCARD_ITEM_SEPARATOR); // Locality : Region addressBuilder.append(VCARD_ITEM_SEPARATOR); // Region : Postal Code addressBuilder.append(VCARD_ITEM_SEPARATOR); // Postal Code : Country return new PostalStruct( reallyUseQuotedPrintable, appendCharset, addressBuilder.toString()); } }
@return null when there's no information available to construct the data.
PostalStruct::tryConstructPostalStruct
java
Reginer/aosp-android-jar
android-31/src/com/android/vcard/VCardBuilder.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java
MIT
public void appendPostalLine(final int type, final String label, final ContentValues contentValues, final boolean isPrimary, final boolean emitEveryTime) { final boolean reallyUseQuotedPrintable; final boolean appendCharset; final String addressValue; { PostalStruct postalStruct = tryConstructPostalStruct(contentValues); if (postalStruct == null) { if (emitEveryTime) { reallyUseQuotedPrintable = false; appendCharset = false; addressValue = ""; } else { return; } } else { reallyUseQuotedPrintable = postalStruct.reallyUseQuotedPrintable; appendCharset = postalStruct.appendCharset; addressValue = postalStruct.addressData; } } List<String> parameterList = new ArrayList<String>(); if (isPrimary) { parameterList.add(VCardConstants.PARAM_TYPE_PREF); } switch (type) { case StructuredPostal.TYPE_HOME: { parameterList.add(VCardConstants.PARAM_TYPE_HOME); break; } case StructuredPostal.TYPE_WORK: { parameterList.add(VCardConstants.PARAM_TYPE_WORK); break; } case StructuredPostal.TYPE_CUSTOM: { if (!TextUtils.isEmpty(label) && VCardUtils.containsOnlyAlphaDigitHyphen(label)) { // We're not sure whether the label is valid in the spec // ("IANA-token" in the vCard 3.0 is unclear...) // Just for safety, we add "X-" at the beggining of each label. // Also checks the label obeys with vCard 3.0 spec. parameterList.add("X-" + label); } break; } case StructuredPostal.TYPE_OTHER: { break; } default: { Log.e(LOG_TAG, "Unknown StructuredPostal type: " + type); break; } } mBuilder.append(VCardConstants.PROPERTY_ADR); if (!parameterList.isEmpty()) { mBuilder.append(VCARD_PARAM_SEPARATOR); appendTypeParameters(parameterList); } if (appendCharset) { // Strictly, vCard 3.0 does not allow exporters to emit charset information, // but we will add it since the information should be useful for importers, // // Assume no parser does not emit error with this parameter in vCard 3.0. mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(mVCardCharsetParameter); } if (reallyUseQuotedPrintable) { mBuilder.append(VCARD_PARAM_SEPARATOR); mBuilder.append(VCARD_PARAM_ENCODING_QP); } mBuilder.append(VCARD_DATA_SEPARATOR); mBuilder.append(addressValue); mBuilder.append(VCARD_END_OF_LINE); }
@param emitEveryTime If true, builder builds the line even when there's no entry.
PostalStruct::appendPostalLine
java
Reginer/aosp-android-jar
android-31/src/com/android/vcard/VCardBuilder.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java
MIT
private void appendUncommonPhoneType(final StringBuilder builder, final Integer type) { if (mIsDoCoMo) { // The previous implementation for DoCoMo had been conservative // about miscellaneous types. builder.append(VCardConstants.PARAM_TYPE_VOICE); } else { String phoneType = VCardUtils.getPhoneTypeString(type); if (phoneType != null) { appendTypeParameter(phoneType); } else { Log.e(LOG_TAG, "Unknown or unsupported (by vCard) Phone type: " + type); } } }
Appends phone type string which may not be available in some devices.
PostalStruct::appendUncommonPhoneType
java
Reginer/aosp-android-jar
android-31/src/com/android/vcard/VCardBuilder.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java
MIT
public void appendPhotoLine(final String encodedValue, final String photoType) { StringBuilder tmpBuilder = new StringBuilder(); tmpBuilder.append(VCardConstants.PROPERTY_PHOTO); tmpBuilder.append(VCARD_PARAM_SEPARATOR); if (mIsV30OrV40) { tmpBuilder.append(VCARD_PARAM_ENCODING_BASE64_AS_B); } else { tmpBuilder.append(VCARD_PARAM_ENCODING_BASE64_V21); } tmpBuilder.append(VCARD_PARAM_SEPARATOR); appendTypeParameter(tmpBuilder, photoType); tmpBuilder.append(VCARD_DATA_SEPARATOR); tmpBuilder.append(encodedValue); final String tmpStr = tmpBuilder.toString(); tmpBuilder = new StringBuilder(); int lineCount = 0; final int length = tmpStr.length(); final int maxNumForFirstLine = VCardConstants.MAX_CHARACTER_NUMS_BASE64_V30 - VCARD_END_OF_LINE.length(); final int maxNumInGeneral = maxNumForFirstLine - VCARD_WS.length(); int maxNum = maxNumForFirstLine; for (int i = 0; i < length; i++) { tmpBuilder.append(tmpStr.charAt(i)); lineCount++; if (lineCount > maxNum) { tmpBuilder.append(VCARD_END_OF_LINE); tmpBuilder.append(VCARD_WS); maxNum = maxNumInGeneral; lineCount = 0; } } mBuilder.append(tmpBuilder.toString()); mBuilder.append(VCARD_END_OF_LINE); mBuilder.append(VCARD_END_OF_LINE); }
@param encodedValue Must be encoded by BASE64 @param photoType
PostalStruct::appendPhotoLine
java
Reginer/aosp-android-jar
android-31/src/com/android/vcard/VCardBuilder.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java
MIT
public VCardBuilder appendSipAddresses(final List<ContentValues> contentValuesList) { final boolean useXProperty; if (mIsV30OrV40) { useXProperty = false; } else if (mUsesDefactProperty){ useXProperty = true; } else { return this; } if (contentValuesList != null) { for (ContentValues contentValues : contentValuesList) { String sipAddress = contentValues.getAsString(SipAddress.SIP_ADDRESS); if (TextUtils.isEmpty(sipAddress)) { continue; } if (useXProperty) { // X-SIP does not contain "sip:" prefix. if (sipAddress.startsWith("sip:")) { if (sipAddress.length() == 4) { continue; } sipAddress = sipAddress.substring(4); } // No type is available yet. appendLineWithCharsetAndQPDetection(VCardConstants.PROPERTY_X_SIP, sipAddress); } else { if (!sipAddress.startsWith("sip:")) { sipAddress = "sip:" + sipAddress; } final String propertyName; if (VCardConfig.isVersion40(mVCardType)) { // We have two ways to emit sip address: TEL and IMPP. Currently (rev.13) // TEL seems appropriate but may change in the future. propertyName = VCardConstants.PROPERTY_TEL; } else { // RFC 4770 (for vCard 3.0) propertyName = VCardConstants.PROPERTY_IMPP; } appendLineWithCharsetAndQPDetection(propertyName, sipAddress); } } } return this; }
SIP (Session Initiation Protocol) is first supported in RFC 4770 as part of IMPP support. vCard 2.1 and old vCard 3.0 may not able to parse it, or expect X-SIP instead of "IMPP;sip:...". We honor RFC 4770 and don't allow vCard 3.0 to emit X-SIP at all.
PostalStruct::appendSipAddresses
java
Reginer/aosp-android-jar
android-31/src/com/android/vcard/VCardBuilder.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java
MIT
public void appendLine(final String propertyName, final String rawValue) { appendLine(propertyName, rawValue, false, false); }
Appends one line with a given property name and value.
PostalStruct::appendLine
java
Reginer/aosp-android-jar
android-31/src/com/android/vcard/VCardBuilder.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java
MIT
private void appendTypeParameters(final List<String> types) { // We may have to make this comma separated form like "TYPE=DOM,WORK" in the future, // which would be recommended way in vcard 3.0 though not valid in vCard 2.1. boolean first = true; for (final String typeValue : types) { if (VCardConfig.isVersion30(mVCardType) || VCardConfig.isVersion40(mVCardType)) { final String encoded = (VCardConfig.isVersion40(mVCardType) ? VCardUtils.toStringAsV40ParamValue(typeValue) : VCardUtils.toStringAsV30ParamValue(typeValue)); if (TextUtils.isEmpty(encoded)) { continue; } if (first) { first = false; } else { mBuilder.append(VCARD_PARAM_SEPARATOR); } appendTypeParameter(encoded); } else { // vCard 2.1 if (!VCardUtils.isV21Word(typeValue)) { continue; } if (first) { first = false; } else { mBuilder.append(VCARD_PARAM_SEPARATOR); } appendTypeParameter(typeValue); } } }
VCARD_PARAM_SEPARATOR must be appended before this method being called.
PostalStruct::appendTypeParameters
java
Reginer/aosp-android-jar
android-31/src/com/android/vcard/VCardBuilder.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java
MIT
private boolean shouldAppendCharsetParam(String...propertyValueList) { if (!mShouldAppendCharsetParam) { return false; } for (String propertyValue : propertyValueList) { if (!VCardUtils.containsOnlyPrintableAscii(propertyValue)) { return true; } } return false; }
Returns true when the property line should contain charset parameter information. This method may return true even when vCard version is 3.0. Strictly, adding charset information is invalid in VCard 3.0. However we'll add the info only when charset we use is not UTF-8 in vCard 3.0 format, since parser side may be able to use the charset via this field, though we may encounter another problem by adding it. e.g. Japanese mobile phones use Shift_Jis while RFC 2426 recommends UTF-8. By adding this field, parsers may be able to know this text is NOT UTF-8 but Shift_Jis.
PostalStruct::shouldAppendCharsetParam
java
Reginer/aosp-android-jar
android-31/src/com/android/vcard/VCardBuilder.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/vcard/VCardBuilder.java
MIT
public @NonNull List<MediaSize> getMediaSizes() { return Collections.unmodifiableList(mMediaSizes); }
Gets the supported media sizes. @return The media sizes.
PrinterCapabilitiesInfo::getMediaSizes
java
Reginer/aosp-android-jar
android-35/src/android/print/PrinterCapabilitiesInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java
MIT
public @NonNull List<Resolution> getResolutions() { return Collections.unmodifiableList(mResolutions); }
Gets the supported resolutions. @return The resolutions.
PrinterCapabilitiesInfo::getResolutions
java
Reginer/aosp-android-jar
android-35/src/android/print/PrinterCapabilitiesInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java
MIT
public @NonNull Margins getMinMargins() { return mMinMargins; }
Gets the minimal margins. These are the minimal margins the printer physically supports. @return The minimal margins.
PrinterCapabilitiesInfo::getMinMargins
java
Reginer/aosp-android-jar
android-35/src/android/print/PrinterCapabilitiesInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java
MIT
public @ColorMode int getColorModes() { return mColorModes; }
Gets the bit mask of supported color modes. @return The bit mask of supported color modes. @see PrintAttributes#COLOR_MODE_COLOR @see PrintAttributes#COLOR_MODE_MONOCHROME
PrinterCapabilitiesInfo::getColorModes
java
Reginer/aosp-android-jar
android-35/src/android/print/PrinterCapabilitiesInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java
MIT
public @DuplexMode int getDuplexModes() { return mDuplexModes; }
Gets the bit mask of supported duplex modes. @return The bit mask of supported duplex modes. @see PrintAttributes#DUPLEX_MODE_NONE @see PrintAttributes#DUPLEX_MODE_LONG_EDGE @see PrintAttributes#DUPLEX_MODE_SHORT_EDGE
PrinterCapabilitiesInfo::getDuplexModes
java
Reginer/aosp-android-jar
android-35/src/android/print/PrinterCapabilitiesInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java
MIT
public @NonNull PrintAttributes getDefaults() { PrintAttributes.Builder builder = new PrintAttributes.Builder(); builder.setMinMargins(mMinMargins); final int mediaSizeIndex = mDefaults[PROPERTY_MEDIA_SIZE]; if (mediaSizeIndex >= 0) { builder.setMediaSize(mMediaSizes.get(mediaSizeIndex)); } final int resolutionIndex = mDefaults[PROPERTY_RESOLUTION]; if (resolutionIndex >= 0) { builder.setResolution(mResolutions.get(resolutionIndex)); } final int colorMode = mDefaults[PROPERTY_COLOR_MODE]; if (colorMode > 0) { builder.setColorMode(colorMode); } final int duplexMode = mDefaults[PROPERTY_DUPLEX_MODE]; if (duplexMode > 0) { builder.setDuplexMode(duplexMode); } return builder.build(); }
Gets the default print attributes. @return The default attributes.
PrinterCapabilitiesInfo::getDefaults
java
Reginer/aosp-android-jar
android-35/src/android/print/PrinterCapabilitiesInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java
MIT
private static void enforceValidMask(int mask, IntConsumer enforceSingle) { int current = mask; while (current > 0) { final int currentMode = (1 << Integer.numberOfTrailingZeros(current)); current &= ~currentMode; enforceSingle.accept(currentMode); } }
Call enforceSingle for each bit in the mask. @param mask The mask @param enforceSingle The function to call
PrinterCapabilitiesInfo::enforceValidMask
java
Reginer/aosp-android-jar
android-35/src/android/print/PrinterCapabilitiesInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java
MIT
public Builder(@NonNull PrinterId printerId) { if (printerId == null) { throw new IllegalArgumentException("printerId cannot be null."); } mPrototype = new PrinterCapabilitiesInfo(); }
Creates a new instance. @param printerId The printer id. Cannot be <code>null</code>. @throws IllegalArgumentException If the printer id is <code>null</code>.
Builder::Builder
java
Reginer/aosp-android-jar
android-35/src/android/print/PrinterCapabilitiesInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java
MIT
public @NonNull Builder addMediaSize(@NonNull MediaSize mediaSize, boolean isDefault) { if (mPrototype.mMediaSizes == null) { mPrototype.mMediaSizes = new ArrayList<MediaSize>(); } final int insertionIndex = mPrototype.mMediaSizes.size(); mPrototype.mMediaSizes.add(mediaSize); if (isDefault) { throwIfDefaultAlreadySpecified(PROPERTY_MEDIA_SIZE); mPrototype.mDefaults[PROPERTY_MEDIA_SIZE] = insertionIndex; } return this; }
Adds a supported media size. <p> <strong>Required:</strong> Yes </p> @param mediaSize A media size. @param isDefault Whether this is the default. @return This builder. @throws IllegalArgumentException If set as default and there is already a default. @see PrintAttributes.MediaSize
Builder::addMediaSize
java
Reginer/aosp-android-jar
android-35/src/android/print/PrinterCapabilitiesInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java
MIT
public @NonNull Builder addResolution(@NonNull Resolution resolution, boolean isDefault) { if (mPrototype.mResolutions == null) { mPrototype.mResolutions = new ArrayList<Resolution>(); } final int insertionIndex = mPrototype.mResolutions.size(); mPrototype.mResolutions.add(resolution); if (isDefault) { throwIfDefaultAlreadySpecified(PROPERTY_RESOLUTION); mPrototype.mDefaults[PROPERTY_RESOLUTION] = insertionIndex; } return this; }
Adds a supported resolution. <p> <strong>Required:</strong> Yes </p> @param resolution A resolution. @param isDefault Whether this is the default. @return This builder. @throws IllegalArgumentException If set as default and there is already a default. @see PrintAttributes.Resolution
Builder::addResolution
java
Reginer/aosp-android-jar
android-35/src/android/print/PrinterCapabilitiesInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java
MIT
public @NonNull Builder setMinMargins(@NonNull Margins margins) { if (margins == null) { throw new IllegalArgumentException("margins cannot be null"); } mPrototype.mMinMargins = margins; return this; }
Sets the minimal margins. These are the minimal margins the printer physically supports. <p> <strong>Required:</strong> Yes </p> @param margins The margins. @return This builder. @throws IllegalArgumentException If margins are <code>null</code>. @see PrintAttributes.Margins
Builder::setMinMargins
java
Reginer/aosp-android-jar
android-35/src/android/print/PrinterCapabilitiesInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java
MIT
public @NonNull Builder setColorModes(@ColorMode int colorModes, @ColorMode int defaultColorMode) { enforceValidMask(colorModes, (currentMode) -> PrintAttributes.enforceValidColorMode(currentMode)); PrintAttributes.enforceValidColorMode(defaultColorMode); mPrototype.mColorModes = colorModes; mPrototype.mDefaults[PROPERTY_COLOR_MODE] = defaultColorMode; return this; }
Sets the color modes. <p> <strong>Required:</strong> Yes </p> @param colorModes The color mode bit mask. @param defaultColorMode The default color mode. @return This builder. <p> <strong>Note:</strong> On platform version 19 (Kitkat) specifying only PrintAttributes#COLOR_MODE_MONOCHROME leads to a print spooler crash. Hence, you should declare either both color modes or PrintAttributes#COLOR_MODE_COLOR. </p> @throws IllegalArgumentException If color modes contains an invalid mode bit or if the default color mode is invalid. @see PrintAttributes#COLOR_MODE_COLOR @see PrintAttributes#COLOR_MODE_MONOCHROME
Builder::setColorModes
java
Reginer/aosp-android-jar
android-35/src/android/print/PrinterCapabilitiesInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java
MIT
public @NonNull Builder setDuplexModes(@DuplexMode int duplexModes, @DuplexMode int defaultDuplexMode) { enforceValidMask(duplexModes, (currentMode) -> PrintAttributes.enforceValidDuplexMode(currentMode)); PrintAttributes.enforceValidDuplexMode(defaultDuplexMode); mPrototype.mDuplexModes = duplexModes; mPrototype.mDefaults[PROPERTY_DUPLEX_MODE] = defaultDuplexMode; return this; }
Sets the duplex modes. <p> <strong>Required:</strong> No </p> @param duplexModes The duplex mode bit mask. @param defaultDuplexMode The default duplex mode. @return This builder. @throws IllegalArgumentException If duplex modes contains an invalid mode bit or if the default duplex mode is invalid. @see PrintAttributes#DUPLEX_MODE_NONE @see PrintAttributes#DUPLEX_MODE_LONG_EDGE @see PrintAttributes#DUPLEX_MODE_SHORT_EDGE
Builder::setDuplexModes
java
Reginer/aosp-android-jar
android-35/src/android/print/PrinterCapabilitiesInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java
MIT
public @NonNull PrinterCapabilitiesInfo build() { if (mPrototype.mMediaSizes == null || mPrototype.mMediaSizes.isEmpty()) { throw new IllegalStateException("No media size specified."); } if (mPrototype.mDefaults[PROPERTY_MEDIA_SIZE] == DEFAULT_UNDEFINED) { throw new IllegalStateException("No default media size specified."); } if (mPrototype.mResolutions == null || mPrototype.mResolutions.isEmpty()) { throw new IllegalStateException("No resolution specified."); } if (mPrototype.mDefaults[PROPERTY_RESOLUTION] == DEFAULT_UNDEFINED) { throw new IllegalStateException("No default resolution specified."); } if (mPrototype.mColorModes == 0) { throw new IllegalStateException("No color mode specified."); } if (mPrototype.mDefaults[PROPERTY_COLOR_MODE] == DEFAULT_UNDEFINED) { throw new IllegalStateException("No default color mode specified."); } if (mPrototype.mDuplexModes == 0) { setDuplexModes(PrintAttributes.DUPLEX_MODE_NONE, PrintAttributes.DUPLEX_MODE_NONE); } if (mPrototype.mMinMargins == null) { throw new IllegalArgumentException("margins cannot be null"); } return mPrototype; }
Crates a new {@link PrinterCapabilitiesInfo} enforcing that all required properties have been specified. See individual methods in this class for reference about required attributes. <p> <strong>Note:</strong> If you do not add supported duplex modes, {@link android.print.PrintAttributes#DUPLEX_MODE_NONE} will set as the only supported mode and also as the default duplex mode. </p> @return A new {@link PrinterCapabilitiesInfo}. @throws IllegalStateException If a required attribute was not specified.
Builder::build
java
Reginer/aosp-android-jar
android-35/src/android/print/PrinterCapabilitiesInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/print/PrinterCapabilitiesInfo.java
MIT
public @UserAssignmentResult int assignUserToDisplayOnStart(@UserIdInt int userId, @UserIdInt int unResolvedProfileGroupId, @UserStartMode int userStartMode, int displayId, boolean isAlwaysVisible) { Preconditions.checkArgument(!isSpecialUserId(userId), "user id cannot be generic: %d", userId); validateUserStartMode(userStartMode); // This method needs to perform 4 actions: // // 1. Check if the user can be started given the provided arguments // 2. If it can, decide whether it's visible or not (which is the return value) // 3. Update the current user / profiles state // 4. Update the users on secondary display state (if applicable) // // Notice that steps 3 and 4 should be done atomically (i.e., while holding mLock), so the // previous steps are delegated to other methods (canAssignUserToDisplayLocked() and // getUserVisibilityOnStartLocked() respectively). int profileGroupId = resolveProfileGroupId(userId, unResolvedProfileGroupId, isAlwaysVisible); if (DBG) { Slogf.d(TAG, "assignUserToDisplayOnStart(%d, %d, %s, %d): actualProfileGroupId=%d", userId, unResolvedProfileGroupId, userStartModeToString(userStartMode), displayId, profileGroupId); } int result; IntArray visibleUsersBefore, visibleUsersAfter; synchronized (mLock) { result = getUserVisibilityOnStartLocked(userId, profileGroupId, userStartMode, displayId); if (DBG) { Slogf.d(TAG, "result of getUserVisibilityOnStartLocked(%s)", userAssignmentResultToString(result)); } if (result == USER_ASSIGNMENT_RESULT_FAILURE || result == USER_ASSIGNMENT_RESULT_SUCCESS_ALREADY_VISIBLE) { return result; } int mappingResult = canAssignUserToDisplayLocked(userId, profileGroupId, userStartMode, displayId); if (DBG) { Slogf.d(TAG, "mapping result: %s", secondaryDisplayMappingStatusToString(mappingResult)); } if (mappingResult == SECONDARY_DISPLAY_MAPPING_FAILED) { return USER_ASSIGNMENT_RESULT_FAILURE; } visibleUsersBefore = getVisibleUsers(); // Set current user / started users state switch (userStartMode) { case USER_START_MODE_FOREGROUND: mCurrentUserId = userId; // Fallthrough case USER_START_MODE_BACKGROUND_VISIBLE: if (DBG) { Slogf.d(TAG, "adding visible user / profile group id mapping (%d -> %d)", userId, profileGroupId); } mStartedVisibleProfileGroupIds.put(userId, profileGroupId); break; case USER_START_MODE_BACKGROUND: if (mStartedInvisibleProfileUserIds != null && isProfile(userId, profileGroupId)) { Slogf.d(TAG, "adding user %d to list of invisible profiles", userId); mStartedInvisibleProfileUserIds.add(userId); } break; default: Slogf.wtf(TAG, "invalid userStartMode passed to assignUserToDisplayOnStart: " + "%d", userStartMode); } // Set user / display state switch (mappingResult) { case SECONDARY_DISPLAY_MAPPING_NEEDED: if (DBG) { Slogf.d(TAG, "adding user / display mapping (%d -> %d)", userId, displayId); } mUsersAssignedToDisplayOnStart.put(userId, displayId); break; case SECONDARY_DISPLAY_MAPPING_NOT_NEEDED: if (DBG) { // Don't need to do set state because methods (such as isUserVisible()) // already know that the current user (and their profiles) is assigned to // the default display. Slogf.d(TAG, "don't need to update mUsersOnSecondaryDisplays"); } break; default: Slogf.wtf(TAG, "invalid resut from canAssignUserToDisplayLocked: %d", mappingResult); } visibleUsersAfter = getVisibleUsers(); } dispatchVisibilityChanged(visibleUsersBefore, visibleUsersAfter); if (DBG) { Slogf.d(TAG, "returning %s", userAssignmentResultToString(result)); } return result; }
See {@link UserManagerInternal#assignUserToDisplayOnStart(int, int, int, int)}.
getSimpleName::assignUserToDisplayOnStart
java
Reginer/aosp-android-jar
android-35/src/com/android/server/pm/UserVisibilityMediator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/pm/UserVisibilityMediator.java
MIT
public boolean assignUserToExtraDisplay(@UserIdInt int userId, int displayId) { if (DBG) { Slogf.d(TAG, "assignUserToExtraDisplay(%d, %d)", userId, displayId); } if (!mVisibleBackgroundUsersEnabled) { Slogf.w(TAG, "assignUserToExtraDisplay(%d, %d): called when not supported", userId, displayId); return false; } if (displayId == INVALID_DISPLAY) { Slogf.w(TAG, "assignUserToExtraDisplay(%d, %d): called with INVALID_DISPLAY", userId, displayId); return false; } if (displayId == DEFAULT_DISPLAY) { Slogf.w(TAG, "assignUserToExtraDisplay(%d, %d): DEFAULT_DISPLAY is automatically " + "assigned to current user", userId, displayId); return false; } synchronized (mLock) { if (!isUserVisible(userId)) { Slogf.w(TAG, "assignUserToExtraDisplay(%d, %d): failed because user is not visible", userId, displayId); return false; } if (isStartedVisibleProfileLocked(userId)) { Slogf.w(TAG, "assignUserToExtraDisplay(%d, %d): failed because user is a profile", userId, displayId); return false; } if (mExtraDisplaysAssignedToUsers.get(displayId, USER_NULL) == userId) { Slogf.w(TAG, "assignUserToExtraDisplay(%d, %d): failed because user is already " + "assigned to that display", userId, displayId); return false; } // First check if the user started on display int userAssignedToDisplay = getUserStartedOnDisplay(displayId); if (userAssignedToDisplay != USER_NULL) { Slogf.w(TAG, "assignUserToExtraDisplay(%d, %d): failed because display was assigned" + " to user %d on start", userId, displayId, userAssignedToDisplay); return false; } // Then if was assigned extra userAssignedToDisplay = mExtraDisplaysAssignedToUsers.get(userId, USER_NULL); if (userAssignedToDisplay != USER_NULL) { Slogf.w(TAG, "assignUserToExtraDisplay(%d, %d): failed because user %d was already " + "assigned that extra display", userId, displayId, userAssignedToDisplay); return false; } if (DBG) { Slogf.d(TAG, "addding %d -> %d to mExtraDisplaysAssignedToUsers", displayId, userId); } mExtraDisplaysAssignedToUsers.put(displayId, userId); } return true; }
See {@link UserManagerInternal#assignUserToExtraDisplay(int, int)}.
getSimpleName::assignUserToExtraDisplay
java
Reginer/aosp-android-jar
android-35/src/com/android/server/pm/UserVisibilityMediator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/pm/UserVisibilityMediator.java
MIT
public boolean unassignUserFromExtraDisplay(@UserIdInt int userId, int displayId) { if (DBG) { Slogf.d(TAG, "unassignUserFromExtraDisplay(%d, %d)", userId, displayId); } if (!mVisibleBackgroundUsersEnabled) { Slogf.w(TAG, "unassignUserFromExtraDisplay(%d, %d): called when not supported", userId, displayId); return false; } synchronized (mLock) { int assignedUserId = mExtraDisplaysAssignedToUsers.get(displayId, USER_NULL); if (assignedUserId == USER_NULL) { Slogf.w(TAG, "unassignUserFromExtraDisplay(%d, %d): not assigned to any user", userId, displayId); return false; } if (assignedUserId != userId) { Slogf.w(TAG, "unassignUserFromExtraDisplay(%d, %d): was assigned to user %d", userId, displayId, assignedUserId); return false; } if (DBG) { Slogf.d(TAG, "removing %d from map", displayId); } mExtraDisplaysAssignedToUsers.delete(displayId); } return true; }
See {@link UserManagerInternal#unassignUserFromExtraDisplay(int, int)}.
getSimpleName::unassignUserFromExtraDisplay
java
Reginer/aosp-android-jar
android-35/src/com/android/server/pm/UserVisibilityMediator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/pm/UserVisibilityMediator.java
MIT
public void unassignUserFromDisplayOnStop(@UserIdInt int userId) { if (DBG) { Slogf.d(TAG, "unassignUserFromDisplayOnStop(%d)", userId); } IntArray visibleUsersBefore, visibleUsersAfter; synchronized (mLock) { visibleUsersBefore = getVisibleUsers(); unassignUserFromAllDisplaysOnStopLocked(userId); visibleUsersAfter = getVisibleUsers(); } dispatchVisibilityChanged(visibleUsersBefore, visibleUsersAfter); }
See {@link UserManagerInternal#unassignUserFromDisplayOnStop(int)}.
getSimpleName::unassignUserFromDisplayOnStop
java
Reginer/aosp-android-jar
android-35/src/com/android/server/pm/UserVisibilityMediator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/pm/UserVisibilityMediator.java
MIT
public boolean isUserVisible(@UserIdInt int userId) { // For optimization (as most devices don't support visible background users), check for // current foreground user and their profiles first if (isCurrentUserOrRunningProfileOfCurrentUser(userId)) { if (VERBOSE) { Slogf.v(TAG, "isUserVisible(%d): true to current user or profile", userId); } return true; } if (!mVisibleBackgroundUsersEnabled) { if (VERBOSE) { Slogf.v(TAG, "isUserVisible(%d): false for non-current user (or its profiles) when" + " device doesn't support visible background users", userId); } return false; } synchronized (mLock) { int profileGroupId; synchronized (mLock) { profileGroupId = mStartedVisibleProfileGroupIds.get(userId, NO_PROFILE_GROUP_ID); } if (isProfile(userId, profileGroupId)) { return isUserAssignedToDisplayOnStartLocked(profileGroupId); } return isUserAssignedToDisplayOnStartLocked(userId); } }
See {@link UserManagerInternal#isUserVisible(int)}.
getSimpleName::isUserVisible
java
Reginer/aosp-android-jar
android-35/src/com/android/server/pm/UserVisibilityMediator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/pm/UserVisibilityMediator.java
MIT
private boolean isParentVisibleOnDisplay(@UserIdInt int profileGroupId, int displayId) { if (profileGroupId == ALWAYS_VISIBLE_PROFILE_GROUP_ID) { return true; } // The profileGroupId is the user (for a non-profile) or its parent (for a profile), // so query whether it is visible. return isUserVisible(profileGroupId, displayId); }
Returns whether the given profileGroupId - i.e. the user (for a non-profile), or its parent (for a profile) - is visible on the given display.
getSimpleName::isParentVisibleOnDisplay
java
Reginer/aosp-android-jar
android-35/src/com/android/server/pm/UserVisibilityMediator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/pm/UserVisibilityMediator.java
MIT
public boolean isUserVisible(@UserIdInt int userId, int displayId) { if (displayId == INVALID_DISPLAY) { return false; } // For optimization (as most devices don't support visible background users), check for // current user and profile first. Current user is always visible on: // - Default display // - Secondary displays when device doesn't support visible bg users // - Or when explicitly added (which is checked below) if (isCurrentUserOrRunningProfileOfCurrentUser(userId) && (displayId == DEFAULT_DISPLAY || !mVisibleBackgroundUsersEnabled)) { if (VERBOSE) { Slogf.v(TAG, "isUserVisible(%d, %d): returning true for current user/profile", userId, displayId); } return true; } if (!mVisibleBackgroundUsersEnabled) { if (DBG) { Slogf.d(TAG, "isUserVisible(%d, %d): returning false as device does not support" + " visible background users", userId, displayId); } return false; } synchronized (mLock) { int profileGroupId; synchronized (mLock) { profileGroupId = mStartedVisibleProfileGroupIds.get(userId, NO_PROFILE_GROUP_ID); } if (isProfile(userId, profileGroupId)) { return isFullUserVisibleOnBackgroundLocked(profileGroupId, displayId); } return isFullUserVisibleOnBackgroundLocked(userId, displayId); } }
See {@link UserManagerInternal#isUserVisible(int, int)}.
getSimpleName::isUserVisible
java
Reginer/aosp-android-jar
android-35/src/com/android/server/pm/UserVisibilityMediator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/pm/UserVisibilityMediator.java
MIT
public int getMainDisplayAssignedToUser(@UserIdInt int userId) { if (isCurrentUserOrRunningProfileOfCurrentUser(userId)) { if (mVisibleBackgroundUserOnDefaultDisplayEnabled) { // When device supports visible bg users on default display, the default display is // assigned to the current user, unless a user is started visible on it int userStartedOnDefaultDisplay; synchronized (mLock) { userStartedOnDefaultDisplay = getUserStartedOnDisplay(DEFAULT_DISPLAY); } if (userStartedOnDefaultDisplay != USER_NULL) { if (DBG) { Slogf.d(TAG, "getMainDisplayAssignedToUser(%d): returning INVALID_DISPLAY " + "for current user user %d was started on DEFAULT_DISPLAY", userId, userStartedOnDefaultDisplay); } return INVALID_DISPLAY; } } return DEFAULT_DISPLAY; } if (!mVisibleBackgroundUsersEnabled) { return INVALID_DISPLAY; } synchronized (mLock) { return mUsersAssignedToDisplayOnStart.get(userId, INVALID_DISPLAY); } }
See {@link UserManagerInternal#getMainDisplayAssignedToUser(int)}.
getSimpleName::getMainDisplayAssignedToUser
java
Reginer/aosp-android-jar
android-35/src/com/android/server/pm/UserVisibilityMediator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/pm/UserVisibilityMediator.java
MIT
public @UserIdInt int getUserAssignedToDisplay(@UserIdInt int displayId) { return getUserAssignedToDisplay(displayId, /* returnCurrentUserByDefault= */ true); }
See {@link UserManagerInternal#getUserAssignedToDisplay(int)}.
getSimpleName::getUserAssignedToDisplay
java
Reginer/aosp-android-jar
android-35/src/com/android/server/pm/UserVisibilityMediator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/pm/UserVisibilityMediator.java
MIT
private @UserIdInt int getUserStartedOnDisplay(@UserIdInt int displayId) { return getUserAssignedToDisplay(displayId, /* returnCurrentUserByDefault= */ false); }
Gets the user explicitly assigned to a display.
getSimpleName::getUserStartedOnDisplay
java
Reginer/aosp-android-jar
android-35/src/com/android/server/pm/UserVisibilityMediator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/pm/UserVisibilityMediator.java
MIT
private @UserIdInt int getUserAssignedToDisplay(@UserIdInt int displayId, boolean returnCurrentUserByDefault) { if (returnCurrentUserByDefault && ((displayId == DEFAULT_DISPLAY && !mVisibleBackgroundUserOnDefaultDisplayEnabled || !mVisibleBackgroundUsersEnabled))) { return getCurrentUserId(); } synchronized (mLock) { for (int i = 0; i < mUsersAssignedToDisplayOnStart.size(); i++) { if (mUsersAssignedToDisplayOnStart.valueAt(i) != displayId) { continue; } int userId = mUsersAssignedToDisplayOnStart.keyAt(i); if (!isStartedVisibleProfileLocked(userId)) { return userId; } else if (DBG) { Slogf.d(TAG, "getUserAssignedToDisplay(%d): skipping user %d because it's " + "a profile", displayId, userId); } } } if (!returnCurrentUserByDefault) { if (DBG) { Slogf.d(TAG, "getUserAssignedToDisplay(%d): no user assigned to display, returning " + "USER_NULL instead", displayId); } return USER_NULL; } int currentUserId = getCurrentUserId(); if (DBG) { Slogf.d(TAG, "getUserAssignedToDisplay(%d): no user assigned to display, returning " + "current user (%d) instead", displayId, currentUserId); } return currentUserId; }
Gets the user explicitly assigned to a display, or the current user when no user is assigned to it (and {@code returnCurrentUserByDefault} is {@code true}).
getSimpleName::getUserAssignedToDisplay
java
Reginer/aosp-android-jar
android-35/src/com/android/server/pm/UserVisibilityMediator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/pm/UserVisibilityMediator.java
MIT
public IntArray getVisibleUsers() { // TODO(b/258054362): this method's performance is O(n2), as it interacts through all users // here, then again on isUserVisible(). We could "fix" it to be O(n), but given that the // number of users is too small, the gain is probably not worth the increase on complexity. IntArray visibleUsers = new IntArray(); synchronized (mLock) { for (int i = 0; i < mStartedVisibleProfileGroupIds.size(); i++) { int userId = mStartedVisibleProfileGroupIds.keyAt(i); if (isUserVisible(userId)) { visibleUsers.add(userId); } } } return visibleUsers; }
Gets the ids of the visible users.
getSimpleName::getVisibleUsers
java
Reginer/aosp-android-jar
android-35/src/com/android/server/pm/UserVisibilityMediator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/pm/UserVisibilityMediator.java
MIT
public void addListener(UserVisibilityListener listener) { if (DBG) { Slogf.d(TAG, "adding listener %s", listener); } synchronized (mLock) { mListeners.add(listener); } }
Adds a {@link UserVisibilityListener listener}.
getSimpleName::addListener
java
Reginer/aosp-android-jar
android-35/src/com/android/server/pm/UserVisibilityMediator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/pm/UserVisibilityMediator.java
MIT
public void removeListener(UserVisibilityListener listener) { if (DBG) { Slogf.d(TAG, "removing listener %s", listener); } synchronized (mLock) { mListeners.remove(listener); } }
Removes a {@link UserVisibilityListener listener}.
getSimpleName::removeListener
java
Reginer/aosp-android-jar
android-35/src/com/android/server/pm/UserVisibilityMediator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/pm/UserVisibilityMediator.java
MIT
void onSystemUserVisibilityChanged(boolean visible) { dispatchVisibilityChanged(mListeners, USER_SYSTEM, visible); }
Nofify all listeners that the system user visibility changed.
getSimpleName::onSystemUserVisibilityChanged
java
Reginer/aosp-android-jar
android-35/src/com/android/server/pm/UserVisibilityMediator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/pm/UserVisibilityMediator.java
MIT
private void dispatchVisibilityChanged(IntArray visibleUsersBefore, IntArray visibleUsersAfter) { if (visibleUsersBefore == null) { // Optimization - it's only null when listeners is empty if (DBG) { Slogf.d(TAG, "dispatchVisibilityChanged(): ignoring, no listeners"); } return; } CopyOnWriteArrayList<UserVisibilityListener> listeners = mListeners; if (DBG) { Slogf.d(TAG, "dispatchVisibilityChanged(): visibleUsersBefore=%s, visibleUsersAfter=%s, " + "%d listeners (%s)", visibleUsersBefore, visibleUsersAfter, listeners.size(), listeners); } for (int i = 0; i < visibleUsersBefore.size(); i++) { int userId = visibleUsersBefore.get(i); if (visibleUsersAfter.indexOf(userId) == -1) { dispatchVisibilityChanged(listeners, userId, /* visible= */ false); } } for (int i = 0; i < visibleUsersAfter.size(); i++) { int userId = visibleUsersAfter.get(i); if (visibleUsersBefore.indexOf(userId) == -1) { dispatchVisibilityChanged(listeners, userId, /* visible= */ true); } } }
Nofify all listeners about the visibility changes from before / after a change of state.
getSimpleName::dispatchVisibilityChanged
java
Reginer/aosp-android-jar
android-35/src/com/android/server/pm/UserVisibilityMediator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/pm/UserVisibilityMediator.java
MIT
private MapEntryLite( WireFormat.FieldType keyType, K defaultKey, WireFormat.FieldType valueType, V defaultValue) { this.metadata = new Metadata<K, V>(keyType, defaultKey, valueType, defaultValue); this.key = defaultKey; this.value = defaultValue; }
Implements the lite version of map entry messages. <p>This class serves as an utility class to help do serialization/parsing of map entries. It's used in generated code and also in the full version MapEntry message. <p>Protobuf internal. Users shouldn't use. public class MapEntryLite<K, V> { static class Metadata<K, V> { public final WireFormat.FieldType keyType; public final K defaultKey; public final WireFormat.FieldType valueType; public final V defaultValue; public Metadata( WireFormat.FieldType keyType, K defaultKey, WireFormat.FieldType valueType, V defaultValue) { this.keyType = keyType; this.defaultKey = defaultKey; this.valueType = valueType; this.defaultValue = defaultValue; } } private static final int KEY_FIELD_NUMBER = 1; private static final int VALUE_FIELD_NUMBER = 2; private final Metadata<K, V> metadata; private final K key; private final V value; /** Creates a default MapEntryLite message instance.
Metadata::MapEntryLite
java
Reginer/aosp-android-jar
android-35/src/com/google/protobuf/MapEntryLite.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/google/protobuf/MapEntryLite.java
MIT
private MapEntryLite(Metadata<K, V> metadata, K key, V value) { this.metadata = metadata; this.key = key; this.value = value; }
Implements the lite version of map entry messages. <p>This class serves as an utility class to help do serialization/parsing of map entries. It's used in generated code and also in the full version MapEntry message. <p>Protobuf internal. Users shouldn't use. public class MapEntryLite<K, V> { static class Metadata<K, V> { public final WireFormat.FieldType keyType; public final K defaultKey; public final WireFormat.FieldType valueType; public final V defaultValue; public Metadata( WireFormat.FieldType keyType, K defaultKey, WireFormat.FieldType valueType, V defaultValue) { this.keyType = keyType; this.defaultKey = defaultKey; this.valueType = valueType; this.defaultValue = defaultValue; } } private static final int KEY_FIELD_NUMBER = 1; private static final int VALUE_FIELD_NUMBER = 2; private final Metadata<K, V> metadata; private final K key; private final V value; /** Creates a default MapEntryLite message instance. private MapEntryLite( WireFormat.FieldType keyType, K defaultKey, WireFormat.FieldType valueType, V defaultValue) { this.metadata = new Metadata<K, V>(keyType, defaultKey, valueType, defaultValue); this.key = defaultKey; this.value = defaultValue; } /** Creates a new MapEntryLite message.
Metadata::MapEntryLite
java
Reginer/aosp-android-jar
android-35/src/com/google/protobuf/MapEntryLite.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/google/protobuf/MapEntryLite.java
MIT
public static <K, V> MapEntryLite<K, V> newDefaultInstance( WireFormat.FieldType keyType, K defaultKey, WireFormat.FieldType valueType, V defaultValue) { return new MapEntryLite<K, V>(keyType, defaultKey, valueType, defaultValue); }
Creates a default MapEntryLite message instance. <p>This method is used by generated code to create the default instance for a map entry message. The created default instance should be used to create new map entry messages of the same type. For each map entry message, only one default instance should be created.
Metadata::newDefaultInstance
java
Reginer/aosp-android-jar
android-35/src/com/google/protobuf/MapEntryLite.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/google/protobuf/MapEntryLite.java
MIT
public void serializeTo(CodedOutputStream output, int fieldNumber, K key, V value) throws IOException { output.writeTag(fieldNumber, WireFormat.WIRETYPE_LENGTH_DELIMITED); output.writeUInt32NoTag(computeSerializedSize(metadata, key, value)); writeTo(output, metadata, key, value); }
Serializes the provided key and value as though they were wrapped by a {@link MapEntryLite} to the output stream. This helper method avoids allocation of a {@link MapEntryLite} built with a key and value and is called from generated code directly.
Metadata::serializeTo
java
Reginer/aosp-android-jar
android-35/src/com/google/protobuf/MapEntryLite.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/google/protobuf/MapEntryLite.java
MIT
public int computeMessageSize(int fieldNumber, K key, V value) { return CodedOutputStream.computeTagSize(fieldNumber) + CodedOutputStream.computeLengthDelimitedFieldSize( computeSerializedSize(metadata, key, value)); }
Computes the message size for the provided key and value as though they were wrapped by a {@link MapEntryLite}. This helper method avoids allocation of a {@link MapEntryLite} built with a key and value and is called from generated code directly.
Metadata::computeMessageSize
java
Reginer/aosp-android-jar
android-35/src/com/google/protobuf/MapEntryLite.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/google/protobuf/MapEntryLite.java
MIT
public Map.Entry<K, V> parseEntry(ByteString bytes, ExtensionRegistryLite extensionRegistry) throws IOException { return parseEntry(bytes.newCodedInput(), metadata, extensionRegistry); }
Parses an entry off of the input as a {@link Map.Entry}. This helper requires an allocation so using {@link #parseInto} is preferred if possible.
Metadata::parseEntry
java
Reginer/aosp-android-jar
android-35/src/com/google/protobuf/MapEntryLite.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/google/protobuf/MapEntryLite.java
MIT
public void parseInto( MapFieldLite<K, V> map, CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws IOException { int length = input.readRawVarint32(); final int oldLimit = input.pushLimit(length); K key = metadata.defaultKey; V value = metadata.defaultValue; while (true) { int tag = input.readTag(); if (tag == 0) { break; } if (tag == WireFormat.makeTag(KEY_FIELD_NUMBER, metadata.keyType.getWireType())) { key = parseField(input, extensionRegistry, metadata.keyType, key); } else if (tag == WireFormat.makeTag(VALUE_FIELD_NUMBER, metadata.valueType.getWireType())) { value = parseField(input, extensionRegistry, metadata.valueType, value); } else { if (!input.skipField(tag)) { break; } } } input.checkLastTagWas(0); input.popLimit(oldLimit); map.put(key, value); }
Parses an entry off of the input into the map. This helper avoids allocation of a {@link MapEntryLite} by parsing directly into the provided {@link MapFieldLite}.
Metadata::parseInto
java
Reginer/aosp-android-jar
android-35/src/com/google/protobuf/MapEntryLite.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/google/protobuf/MapEntryLite.java
MIT
Metadata<K, V> getMetadata() { return metadata; }
Parses an entry off of the input into the map. This helper avoids allocation of a {@link MapEntryLite} by parsing directly into the provided {@link MapFieldLite}. public void parseInto( MapFieldLite<K, V> map, CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws IOException { int length = input.readRawVarint32(); final int oldLimit = input.pushLimit(length); K key = metadata.defaultKey; V value = metadata.defaultValue; while (true) { int tag = input.readTag(); if (tag == 0) { break; } if (tag == WireFormat.makeTag(KEY_FIELD_NUMBER, metadata.keyType.getWireType())) { key = parseField(input, extensionRegistry, metadata.keyType, key); } else if (tag == WireFormat.makeTag(VALUE_FIELD_NUMBER, metadata.valueType.getWireType())) { value = parseField(input, extensionRegistry, metadata.valueType, value); } else { if (!input.skipField(tag)) { break; } } } input.checkLastTagWas(0); input.popLimit(oldLimit); map.put(key, value); } /** For experimental runtime internal use only.
Metadata::getMetadata
java
Reginer/aosp-android-jar
android-35/src/com/google/protobuf/MapEntryLite.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/google/protobuf/MapEntryLite.java
MIT
public static @NonNull X509Certificate getTestOnlyInsecureCertificate() { return parseBase64Certificate(TEST_ONLY_INSECURE_CERTIFICATE_BASE64); }
TODO: Add insecure certificate to TestApi. @hide
TrustedRootCertificates::getTestOnlyInsecureCertificate
java
Reginer/aosp-android-jar
android-34/src/android/security/keystore/recovery/TrustedRootCertificates.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/security/keystore/recovery/TrustedRootCertificates.java
MIT
public static @NonNull Map<String, X509Certificate> getRootCertificates() { return new ArrayMap(ALL_ROOT_CERTIFICATES); }
Returns all available root certificates, keyed by alias.
TrustedRootCertificates::getRootCertificates
java
Reginer/aosp-android-jar
android-34/src/android/security/keystore/recovery/TrustedRootCertificates.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/security/keystore/recovery/TrustedRootCertificates.java
MIT
public static @NonNull X509Certificate getRootCertificate(String alias) { return ALL_ROOT_CERTIFICATES.get(alias); }
Gets a root certificate referenced by the given {@code alias}. @param alias the alias of the certificate @return the certificate referenced by the alias, or null if such a certificate doesn't exist.
TrustedRootCertificates::getRootCertificate
java
Reginer/aosp-android-jar
android-34/src/android/security/keystore/recovery/TrustedRootCertificates.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/security/keystore/recovery/TrustedRootCertificates.java
MIT
public @AppSetIdScope int getAppSetIdScope() { return mAppSetIdScope; }
Returns the error message associated with this result. <p>If {@link #isSuccess} is {@code true}, the error message is always {@code null}. The error message may be {@code null} even if {@link #isSuccess} is {@code false}. @Nullable public String getErrorMessage() { return mErrorMessage; } /** Returns the AppSetId associated with this result. @NonNull public String getAppSetId() { return mAppSetId; } /** Returns the AppSetId scope associated with this result.
GetAppSetIdResult::getAppSetIdScope
java
Reginer/aosp-android-jar
android-35/src/android/adservices/appsetid/GetAppSetIdResult.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/adservices/appsetid/GetAppSetIdResult.java
MIT
public @NonNull Builder setStatusCode(@AdServicesStatusUtils.StatusCode int statusCode) { mStatusCode = statusCode; return this; }
Builder for {@link GetAppSetIdResult} objects. @hide public static final class Builder { private @AdServicesStatusUtils.StatusCode int mStatusCode; @Nullable private String mErrorMessage; @NonNull private String mAppSetId; private @AppSetIdScope int mAppSetIdScope; public Builder() {} /** Set the Result Code.
Builder::setStatusCode
java
Reginer/aosp-android-jar
android-35/src/android/adservices/appsetid/GetAppSetIdResult.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/adservices/appsetid/GetAppSetIdResult.java
MIT
public @NonNull Builder setErrorMessage(@Nullable String errorMessage) { mErrorMessage = errorMessage; return this; }
Builder for {@link GetAppSetIdResult} objects. @hide public static final class Builder { private @AdServicesStatusUtils.StatusCode int mStatusCode; @Nullable private String mErrorMessage; @NonNull private String mAppSetId; private @AppSetIdScope int mAppSetIdScope; public Builder() {} /** Set the Result Code. public @NonNull Builder setStatusCode(@AdServicesStatusUtils.StatusCode int statusCode) { mStatusCode = statusCode; return this; } /** Set the Error Message.
Builder::setErrorMessage
java
Reginer/aosp-android-jar
android-35/src/android/adservices/appsetid/GetAppSetIdResult.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/adservices/appsetid/GetAppSetIdResult.java
MIT
public @NonNull Builder setAppSetId(@NonNull String appSetId) { mAppSetId = appSetId; return this; }
Builder for {@link GetAppSetIdResult} objects. @hide public static final class Builder { private @AdServicesStatusUtils.StatusCode int mStatusCode; @Nullable private String mErrorMessage; @NonNull private String mAppSetId; private @AppSetIdScope int mAppSetIdScope; public Builder() {} /** Set the Result Code. public @NonNull Builder setStatusCode(@AdServicesStatusUtils.StatusCode int statusCode) { mStatusCode = statusCode; return this; } /** Set the Error Message. public @NonNull Builder setErrorMessage(@Nullable String errorMessage) { mErrorMessage = errorMessage; return this; } /** Set the appSetId.
Builder::setAppSetId
java
Reginer/aosp-android-jar
android-35/src/android/adservices/appsetid/GetAppSetIdResult.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/adservices/appsetid/GetAppSetIdResult.java
MIT
public @NonNull Builder setAppSetIdScope(@AppSetIdScope int scope) { mAppSetIdScope = scope; return this; }
Builder for {@link GetAppSetIdResult} objects. @hide public static final class Builder { private @AdServicesStatusUtils.StatusCode int mStatusCode; @Nullable private String mErrorMessage; @NonNull private String mAppSetId; private @AppSetIdScope int mAppSetIdScope; public Builder() {} /** Set the Result Code. public @NonNull Builder setStatusCode(@AdServicesStatusUtils.StatusCode int statusCode) { mStatusCode = statusCode; return this; } /** Set the Error Message. public @NonNull Builder setErrorMessage(@Nullable String errorMessage) { mErrorMessage = errorMessage; return this; } /** Set the appSetId. public @NonNull Builder setAppSetId(@NonNull String appSetId) { mAppSetId = appSetId; return this; } /** Set the appSetId scope field.
Builder::setAppSetIdScope
java
Reginer/aosp-android-jar
android-35/src/android/adservices/appsetid/GetAppSetIdResult.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/adservices/appsetid/GetAppSetIdResult.java
MIT
public @NonNull GetAppSetIdResult build() { if (mAppSetId == null) { throw new IllegalArgumentException("appSetId is null"); } return new GetAppSetIdResult(mStatusCode, mErrorMessage, mAppSetId, mAppSetIdScope); }
Builder for {@link GetAppSetIdResult} objects. @hide public static final class Builder { private @AdServicesStatusUtils.StatusCode int mStatusCode; @Nullable private String mErrorMessage; @NonNull private String mAppSetId; private @AppSetIdScope int mAppSetIdScope; public Builder() {} /** Set the Result Code. public @NonNull Builder setStatusCode(@AdServicesStatusUtils.StatusCode int statusCode) { mStatusCode = statusCode; return this; } /** Set the Error Message. public @NonNull Builder setErrorMessage(@Nullable String errorMessage) { mErrorMessage = errorMessage; return this; } /** Set the appSetId. public @NonNull Builder setAppSetId(@NonNull String appSetId) { mAppSetId = appSetId; return this; } /** Set the appSetId scope field. public @NonNull Builder setAppSetIdScope(@AppSetIdScope int scope) { mAppSetIdScope = scope; return this; } /** Builds a {@link GetAppSetIdResult} instance.
Builder::build
java
Reginer/aosp-android-jar
android-35/src/android/adservices/appsetid/GetAppSetIdResult.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/adservices/appsetid/GetAppSetIdResult.java
MIT