ADD week 5
This commit is contained in:
@ -0,0 +1,59 @@
|
||||
package androidx.core.net;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ConnectivityManagerCompat {
|
||||
public static final int RESTRICT_BACKGROUND_STATUS_DISABLED = 1;
|
||||
public static final int RESTRICT_BACKGROUND_STATUS_ENABLED = 3;
|
||||
public static final int RESTRICT_BACKGROUND_STATUS_WHITELISTED = 2;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface RestrictBackgroundStatus {
|
||||
}
|
||||
|
||||
public static boolean isActiveNetworkMetered(ConnectivityManager connectivityManager) {
|
||||
return Api16Impl.isActiveNetworkMetered(connectivityManager);
|
||||
}
|
||||
|
||||
public static NetworkInfo getNetworkInfoFromBroadcast(ConnectivityManager connectivityManager, Intent intent) {
|
||||
NetworkInfo networkInfo = (NetworkInfo) intent.getParcelableExtra("networkInfo");
|
||||
if (networkInfo != null) {
|
||||
return connectivityManager.getNetworkInfo(networkInfo.getType());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getRestrictBackgroundStatus(ConnectivityManager connectivityManager) {
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
return Api24Impl.getRestrictBackgroundStatus(connectivityManager);
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
|
||||
private ConnectivityManagerCompat() {
|
||||
}
|
||||
|
||||
static class Api16Impl {
|
||||
private Api16Impl() {
|
||||
}
|
||||
|
||||
static boolean isActiveNetworkMetered(ConnectivityManager connectivityManager) {
|
||||
return connectivityManager.isActiveNetworkMetered();
|
||||
}
|
||||
}
|
||||
|
||||
static class Api24Impl {
|
||||
private Api24Impl() {
|
||||
}
|
||||
|
||||
static int getRestrictBackgroundStatus(ConnectivityManager connectivityManager) {
|
||||
return connectivityManager.getRestrictBackgroundStatus();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package androidx.core.net;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.SocketException;
|
||||
import java.net.SocketImpl;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class DatagramSocketWrapper extends Socket {
|
||||
DatagramSocketWrapper(DatagramSocket datagramSocket, FileDescriptor fileDescriptor) throws SocketException {
|
||||
super(new DatagramSocketImplWrapper(datagramSocket, fileDescriptor));
|
||||
}
|
||||
|
||||
private static class DatagramSocketImplWrapper extends SocketImpl {
|
||||
DatagramSocketImplWrapper(DatagramSocket datagramSocket, FileDescriptor fileDescriptor) {
|
||||
this.localport = datagramSocket.getLocalPort();
|
||||
this.fd = fileDescriptor;
|
||||
}
|
||||
|
||||
@Override // java.net.SocketImpl
|
||||
protected void accept(SocketImpl socketImpl) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.net.SocketImpl
|
||||
protected int available() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.net.SocketImpl
|
||||
protected void bind(InetAddress inetAddress, int i) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.net.SocketImpl
|
||||
protected void close() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.net.SocketImpl
|
||||
protected void connect(String str, int i) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.net.SocketImpl
|
||||
protected void connect(InetAddress inetAddress, int i) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.net.SocketImpl
|
||||
protected void create(boolean z) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.net.SocketImpl
|
||||
protected InputStream getInputStream() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.net.SocketImpl
|
||||
protected OutputStream getOutputStream() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.net.SocketImpl
|
||||
protected void listen(int i) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.net.SocketImpl
|
||||
protected void connect(SocketAddress socketAddress, int i) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.net.SocketImpl
|
||||
protected void sendUrgentData(int i) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.net.SocketOptions
|
||||
public Object getOption(int i) throws SocketException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override // java.net.SocketOptions
|
||||
public void setOption(int i, Object obj) throws SocketException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
}
|
106
02-Easy5/E5/sources/androidx/core/net/MailTo.java
Normal file
106
02-Easy5/E5/sources/androidx/core/net/MailTo.java
Normal file
@ -0,0 +1,106 @@
|
||||
package androidx.core.net;
|
||||
|
||||
import android.net.Uri;
|
||||
import androidx.core.util.Preconditions;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import kotlin.text.Typography;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class MailTo {
|
||||
private static final String BCC = "bcc";
|
||||
private static final String BODY = "body";
|
||||
private static final String CC = "cc";
|
||||
private static final String MAILTO = "mailto";
|
||||
public static final String MAILTO_SCHEME = "mailto:";
|
||||
private static final String SUBJECT = "subject";
|
||||
private static final String TO = "to";
|
||||
private HashMap<String, String> mHeaders = new HashMap<>();
|
||||
|
||||
public Map<String, String> getHeaders() {
|
||||
return this.mHeaders;
|
||||
}
|
||||
|
||||
private MailTo() {
|
||||
}
|
||||
|
||||
public static boolean isMailTo(String str) {
|
||||
return str != null && str.startsWith(MAILTO_SCHEME);
|
||||
}
|
||||
|
||||
public static boolean isMailTo(Uri uri) {
|
||||
return uri != null && MAILTO.equals(uri.getScheme());
|
||||
}
|
||||
|
||||
public static MailTo parse(String str) throws ParseException {
|
||||
String decode;
|
||||
String substring;
|
||||
Preconditions.checkNotNull(str);
|
||||
if (!isMailTo(str)) {
|
||||
throw new ParseException("Not a mailto scheme");
|
||||
}
|
||||
int indexOf = str.indexOf(35);
|
||||
if (indexOf != -1) {
|
||||
str = str.substring(0, indexOf);
|
||||
}
|
||||
int indexOf2 = str.indexOf(63);
|
||||
if (indexOf2 == -1) {
|
||||
decode = Uri.decode(str.substring(7));
|
||||
substring = null;
|
||||
} else {
|
||||
decode = Uri.decode(str.substring(7, indexOf2));
|
||||
substring = str.substring(indexOf2 + 1);
|
||||
}
|
||||
MailTo mailTo = new MailTo();
|
||||
if (substring != null) {
|
||||
for (String str2 : substring.split("&")) {
|
||||
String[] split = str2.split("=", 2);
|
||||
if (split.length != 0) {
|
||||
mailTo.mHeaders.put(Uri.decode(split[0]).toLowerCase(Locale.ROOT), split.length > 1 ? Uri.decode(split[1]) : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
String to = mailTo.getTo();
|
||||
if (to != null) {
|
||||
decode = decode + ", " + to;
|
||||
}
|
||||
mailTo.mHeaders.put("to", decode);
|
||||
return mailTo;
|
||||
}
|
||||
|
||||
public static MailTo parse(Uri uri) throws ParseException {
|
||||
return parse(uri.toString());
|
||||
}
|
||||
|
||||
public String getTo() {
|
||||
return this.mHeaders.get("to");
|
||||
}
|
||||
|
||||
public String getCc() {
|
||||
return this.mHeaders.get(CC);
|
||||
}
|
||||
|
||||
public String getBcc() {
|
||||
return this.mHeaders.get(BCC);
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
return this.mHeaders.get(SUBJECT);
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return this.mHeaders.get(BODY);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("mailto:?");
|
||||
for (Map.Entry<String, String> entry : this.mHeaders.entrySet()) {
|
||||
sb.append(Uri.encode(entry.getKey()));
|
||||
sb.append('=');
|
||||
sb.append(Uri.encode(entry.getValue()));
|
||||
sb.append(Typography.amp);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
11
02-Easy5/E5/sources/androidx/core/net/ParseException.java
Normal file
11
02-Easy5/E5/sources/androidx/core/net/ParseException.java
Normal file
@ -0,0 +1,11 @@
|
||||
package androidx.core.net;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ParseException extends RuntimeException {
|
||||
public final String response;
|
||||
|
||||
ParseException(String str) {
|
||||
super(str);
|
||||
this.response = str;
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package androidx.core.net;
|
||||
|
||||
import android.net.TrafficStats;
|
||||
import android.os.Build;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class TrafficStatsCompat {
|
||||
@Deprecated
|
||||
public static void clearThreadStatsTag() {
|
||||
TrafficStats.clearThreadStatsTag();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static int getThreadStatsTag() {
|
||||
return TrafficStats.getThreadStatsTag();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void incrementOperationCount(int i) {
|
||||
TrafficStats.incrementOperationCount(i);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void incrementOperationCount(int i, int i2) {
|
||||
TrafficStats.incrementOperationCount(i, i2);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void setThreadStatsTag(int i) {
|
||||
TrafficStats.setThreadStatsTag(i);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void tagSocket(Socket socket) throws SocketException {
|
||||
TrafficStats.tagSocket(socket);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void untagSocket(Socket socket) throws SocketException {
|
||||
TrafficStats.untagSocket(socket);
|
||||
}
|
||||
|
||||
public static void tagDatagramSocket(DatagramSocket datagramSocket) throws SocketException {
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
Api24Impl.tagDatagramSocket(datagramSocket);
|
||||
return;
|
||||
}
|
||||
ParcelFileDescriptor fromDatagramSocket = ParcelFileDescriptor.fromDatagramSocket(datagramSocket);
|
||||
TrafficStats.tagSocket(new DatagramSocketWrapper(datagramSocket, fromDatagramSocket.getFileDescriptor()));
|
||||
fromDatagramSocket.detachFd();
|
||||
}
|
||||
|
||||
public static void untagDatagramSocket(DatagramSocket datagramSocket) throws SocketException {
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
Api24Impl.untagDatagramSocket(datagramSocket);
|
||||
return;
|
||||
}
|
||||
ParcelFileDescriptor fromDatagramSocket = ParcelFileDescriptor.fromDatagramSocket(datagramSocket);
|
||||
TrafficStats.untagSocket(new DatagramSocketWrapper(datagramSocket, fromDatagramSocket.getFileDescriptor()));
|
||||
fromDatagramSocket.detachFd();
|
||||
}
|
||||
|
||||
private TrafficStatsCompat() {
|
||||
}
|
||||
|
||||
static class Api24Impl {
|
||||
private Api24Impl() {
|
||||
}
|
||||
|
||||
static void tagDatagramSocket(DatagramSocket datagramSocket) throws SocketException {
|
||||
TrafficStats.tagDatagramSocket(datagramSocket);
|
||||
}
|
||||
|
||||
static void untagDatagramSocket(DatagramSocket datagramSocket) throws SocketException {
|
||||
TrafficStats.untagDatagramSocket(datagramSocket);
|
||||
}
|
||||
}
|
||||
}
|
48
02-Easy5/E5/sources/androidx/core/net/UriCompat.java
Normal file
48
02-Easy5/E5/sources/androidx/core/net/UriCompat.java
Normal file
@ -0,0 +1,48 @@
|
||||
package androidx.core.net;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class UriCompat {
|
||||
private UriCompat() {
|
||||
}
|
||||
|
||||
public static String toSafeString(Uri uri) {
|
||||
String scheme = uri.getScheme();
|
||||
String schemeSpecificPart = uri.getSchemeSpecificPart();
|
||||
if (scheme != null) {
|
||||
if (scheme.equalsIgnoreCase("tel") || scheme.equalsIgnoreCase("sip") || scheme.equalsIgnoreCase("sms") || scheme.equalsIgnoreCase("smsto") || scheme.equalsIgnoreCase("mailto") || scheme.equalsIgnoreCase("nfc")) {
|
||||
StringBuilder sb = new StringBuilder(64);
|
||||
sb.append(scheme);
|
||||
sb.append(':');
|
||||
if (schemeSpecificPart != null) {
|
||||
for (int i = 0; i < schemeSpecificPart.length(); i++) {
|
||||
char charAt = schemeSpecificPart.charAt(i);
|
||||
if (charAt == '-' || charAt == '@' || charAt == '.') {
|
||||
sb.append(charAt);
|
||||
} else {
|
||||
sb.append('x');
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
if (scheme.equalsIgnoreCase("http") || scheme.equalsIgnoreCase("https") || scheme.equalsIgnoreCase("ftp") || scheme.equalsIgnoreCase("rtsp")) {
|
||||
StringBuilder sb2 = new StringBuilder("//");
|
||||
sb2.append(uri.getHost() != null ? uri.getHost() : "");
|
||||
sb2.append(uri.getPort() != -1 ? ":" + uri.getPort() : "");
|
||||
sb2.append("/...");
|
||||
schemeSpecificPart = sb2.toString();
|
||||
}
|
||||
}
|
||||
StringBuilder sb3 = new StringBuilder(64);
|
||||
if (scheme != null) {
|
||||
sb3.append(scheme);
|
||||
sb3.append(':');
|
||||
}
|
||||
if (schemeSpecificPart != null) {
|
||||
sb3.append(schemeSpecificPart);
|
||||
}
|
||||
return sb3.toString();
|
||||
}
|
||||
}
|
37
02-Easy5/E5/sources/androidx/core/net/UriKt.java
Normal file
37
02-Easy5/E5/sources/androidx/core/net/UriKt.java
Normal file
@ -0,0 +1,37 @@
|
||||
package androidx.core.net;
|
||||
|
||||
import android.net.Uri;
|
||||
import java.io.File;
|
||||
import kotlin.Metadata;
|
||||
import kotlin.jvm.internal.Intrinsics;
|
||||
|
||||
/* compiled from: Uri.kt */
|
||||
@Metadata(d1 = {"\u0000\u0012\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\u001a\n\u0010\u0000\u001a\u00020\u0001*\u00020\u0002\u001a\r\u0010\u0003\u001a\u00020\u0002*\u00020\u0001H\u0086\b\u001a\r\u0010\u0003\u001a\u00020\u0002*\u00020\u0004H\u0086\b¨\u0006\u0005"}, d2 = {"toFile", "Ljava/io/File;", "Landroid/net/Uri;", "toUri", "", "core-ktx_release"}, k = 2, mv = {1, 7, 1}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public final class UriKt {
|
||||
public static final Uri toUri(String str) {
|
||||
Intrinsics.checkNotNullParameter(str, "<this>");
|
||||
Uri parse = Uri.parse(str);
|
||||
Intrinsics.checkNotNullExpressionValue(parse, "parse(this)");
|
||||
return parse;
|
||||
}
|
||||
|
||||
public static final Uri toUri(File file) {
|
||||
Intrinsics.checkNotNullParameter(file, "<this>");
|
||||
Uri fromFile = Uri.fromFile(file);
|
||||
Intrinsics.checkNotNullExpressionValue(fromFile, "fromFile(this)");
|
||||
return fromFile;
|
||||
}
|
||||
|
||||
public static final File toFile(Uri uri) {
|
||||
Intrinsics.checkNotNullParameter(uri, "<this>");
|
||||
if (!Intrinsics.areEqual(uri.getScheme(), "file")) {
|
||||
throw new IllegalArgumentException(("Uri lacks 'file' scheme: " + uri).toString());
|
||||
}
|
||||
String path = uri.getPath();
|
||||
if (path != null) {
|
||||
return new File(path);
|
||||
}
|
||||
throw new IllegalArgumentException(("Uri path is null: " + uri).toString());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user