Loading Android.mk +3 −0 Original line number Diff line number Diff line Loading @@ -576,6 +576,9 @@ aidl_files := \ frameworks/base/graphics/java/android/graphics/drawable/Icon.aidl \ frameworks/base/core/java/android/accounts/AuthenticatorDescription.aidl \ frameworks/base/core/java/android/accounts/Account.aidl \ frameworks/base/core/java/android/app/admin/ConnectEvent.aidl \ frameworks/base/core/java/android/app/admin/DnsEvent.aidl \ frameworks/base/core/java/android/app/admin/NetworkEvent.aidl \ frameworks/base/core/java/android/app/admin/SystemUpdatePolicy.aidl \ frameworks/base/core/java/android/print/PrintDocumentInfo.aidl \ frameworks/base/core/java/android/print/PageRange.aidl \ Loading core/java/android/app/admin/ConnectEvent.aidl 0 → 100644 +21 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app.admin; /** {@hide} */ parcelable ConnectEvent; core/java/android/app/admin/ConnectEvent.java 0 → 100644 +87 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app.admin; import android.os.Parcel; import android.os.Parcelable; /** * A class that represents a connect library call event. * @hide */ public final class ConnectEvent extends NetworkEvent implements Parcelable { /** The destination IP address. */ private final String ipAddress; /** The destination port number. */ private final int port; public ConnectEvent(String ipAddress, int port, String packageName, long timestamp) { super(packageName, timestamp); this.ipAddress = ipAddress; this.port = port; } private ConnectEvent(Parcel in) { this.ipAddress = in.readString(); this.port = in.readInt(); this.packageName = in.readString(); this.timestamp = in.readLong(); } public String getIpAddress() { return ipAddress; } public int getPort() { return port; } @Override public String toString() { return String.format("ConnectEvent(%s, %d, %d, %s)", ipAddress, port, timestamp, packageName); } public static final Parcelable.Creator<ConnectEvent> CREATOR = new Parcelable.Creator<ConnectEvent>() { @Override public ConnectEvent createFromParcel(Parcel in) { if (in.readInt() != PARCEL_TOKEN_CONNECT_EVENT) { return null; } return new ConnectEvent(in); } @Override public ConnectEvent[] newArray(int size) { return new ConnectEvent[size]; } }; @Override public void writeToParcel(Parcel out, int flags) { // write parcel token first out.writeInt(PARCEL_TOKEN_CONNECT_EVENT); out.writeString(ipAddress); out.writeInt(port); out.writeString(packageName); out.writeLong(timestamp); } } core/java/android/app/admin/DeviceAdminReceiver.java +27 −0 Original line number Diff line number Diff line Loading @@ -275,6 +275,15 @@ public class DeviceAdminReceiver extends BroadcastReceiver { public static final String ACTION_SECURITY_LOGS_AVAILABLE = "android.app.action.SECURITY_LOGS_AVAILABLE"; /** * Broadcast action: notify that a new batch of network logs is ready to be collected. * @see DeviceAdminReceiver#onNetworkLogsAvailable * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_NETWORK_LOGS_AVAILABLE = "android.app.action.NETWORK_LOGS_AVAILABLE"; /** * A string containing the SHA-256 hash of the bugreport file. * Loading Loading @@ -634,6 +643,22 @@ public class DeviceAdminReceiver extends BroadcastReceiver { public void onSecurityLogsAvailable(Context context, Intent intent) { } /** * Called when a new batch of network logs can be retrieved. This callback method will only ever * be called when network logging is enabled. The logs can only be retrieved while network * logging is enabled. * * <p>This callback is only applicable to device owners. * * @param context The running context as per {@link #onReceive}. * @param intent The received intent as per {@link #onReceive}. * @see DevicePolicyManager#retrieveNetworkLogs(ComponentName) * * @hide */ public void onNetworkLogsAvailable(Context context, Intent intent) { } /** * Intercept standard device administrator broadcasts. Implementations * should not override this method; it is better to implement the Loading Loading @@ -688,6 +713,8 @@ public class DeviceAdminReceiver extends BroadcastReceiver { onBugreportFailed(context, intent, failureCode); } else if (ACTION_SECURITY_LOGS_AVAILABLE.equals(action)) { onSecurityLogsAvailable(context, intent); } else if (ACTION_NETWORK_LOGS_AVAILABLE.equals(action)) { onNetworkLogsAvailable(context, intent); } } } core/java/android/app/admin/DevicePolicyManager.java +29 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SystemApi; import android.annotation.UserIdInt; import android.app.Activity; import android.app.admin.NetworkEvent; import android.app.admin.SecurityLog.SecurityEvent; import android.content.ComponentName; import android.content.Context; Loading Loading @@ -6622,6 +6623,7 @@ public class DevicePolicyManager { * @throws {@link SecurityException} if {@code admin} is not a device owner. * @throws {@link RemoteException} if network logging could not be enabled or disabled due to * the logging service not being available * @see #retrieveNetworkLogs * * @hide */ Loading Loading @@ -6651,4 +6653,31 @@ public class DevicePolicyManager { throw re.rethrowFromSystemServer(); } } /** * Called by device owner to retrieve a new batch of network logging events. * * <p> {@link NetworkEvent} can be one of {@link DnsEvent} or {@link ConnectEvent}. * * <p> The list of network events is sorted chronologically, and contains at most 1200 events. * * <p> Access to the logs is rate limited and this method will only return a new batch of logs * after the device device owner has been notified via * {@link DeviceAdminReceiver#onNetworkLogsAvailable}. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @return A new batch of network logs which is a list of {@link NetworkEvent}. Returns * {@code null} if there's no batch currently awaiting for retrieval or if logging is disabled. * @throws {@link SecurityException} if {@code admin} is not a device owner. * * @hide */ public List<NetworkEvent> retrieveNetworkLogs(@NonNull ComponentName admin) { throwIfParentInstance("retrieveNetworkLogs"); try { return mService.retrieveNetworkLogs(admin); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } } Loading
Android.mk +3 −0 Original line number Diff line number Diff line Loading @@ -576,6 +576,9 @@ aidl_files := \ frameworks/base/graphics/java/android/graphics/drawable/Icon.aidl \ frameworks/base/core/java/android/accounts/AuthenticatorDescription.aidl \ frameworks/base/core/java/android/accounts/Account.aidl \ frameworks/base/core/java/android/app/admin/ConnectEvent.aidl \ frameworks/base/core/java/android/app/admin/DnsEvent.aidl \ frameworks/base/core/java/android/app/admin/NetworkEvent.aidl \ frameworks/base/core/java/android/app/admin/SystemUpdatePolicy.aidl \ frameworks/base/core/java/android/print/PrintDocumentInfo.aidl \ frameworks/base/core/java/android/print/PageRange.aidl \ Loading
core/java/android/app/admin/ConnectEvent.aidl 0 → 100644 +21 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app.admin; /** {@hide} */ parcelable ConnectEvent;
core/java/android/app/admin/ConnectEvent.java 0 → 100644 +87 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app.admin; import android.os.Parcel; import android.os.Parcelable; /** * A class that represents a connect library call event. * @hide */ public final class ConnectEvent extends NetworkEvent implements Parcelable { /** The destination IP address. */ private final String ipAddress; /** The destination port number. */ private final int port; public ConnectEvent(String ipAddress, int port, String packageName, long timestamp) { super(packageName, timestamp); this.ipAddress = ipAddress; this.port = port; } private ConnectEvent(Parcel in) { this.ipAddress = in.readString(); this.port = in.readInt(); this.packageName = in.readString(); this.timestamp = in.readLong(); } public String getIpAddress() { return ipAddress; } public int getPort() { return port; } @Override public String toString() { return String.format("ConnectEvent(%s, %d, %d, %s)", ipAddress, port, timestamp, packageName); } public static final Parcelable.Creator<ConnectEvent> CREATOR = new Parcelable.Creator<ConnectEvent>() { @Override public ConnectEvent createFromParcel(Parcel in) { if (in.readInt() != PARCEL_TOKEN_CONNECT_EVENT) { return null; } return new ConnectEvent(in); } @Override public ConnectEvent[] newArray(int size) { return new ConnectEvent[size]; } }; @Override public void writeToParcel(Parcel out, int flags) { // write parcel token first out.writeInt(PARCEL_TOKEN_CONNECT_EVENT); out.writeString(ipAddress); out.writeInt(port); out.writeString(packageName); out.writeLong(timestamp); } }
core/java/android/app/admin/DeviceAdminReceiver.java +27 −0 Original line number Diff line number Diff line Loading @@ -275,6 +275,15 @@ public class DeviceAdminReceiver extends BroadcastReceiver { public static final String ACTION_SECURITY_LOGS_AVAILABLE = "android.app.action.SECURITY_LOGS_AVAILABLE"; /** * Broadcast action: notify that a new batch of network logs is ready to be collected. * @see DeviceAdminReceiver#onNetworkLogsAvailable * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_NETWORK_LOGS_AVAILABLE = "android.app.action.NETWORK_LOGS_AVAILABLE"; /** * A string containing the SHA-256 hash of the bugreport file. * Loading Loading @@ -634,6 +643,22 @@ public class DeviceAdminReceiver extends BroadcastReceiver { public void onSecurityLogsAvailable(Context context, Intent intent) { } /** * Called when a new batch of network logs can be retrieved. This callback method will only ever * be called when network logging is enabled. The logs can only be retrieved while network * logging is enabled. * * <p>This callback is only applicable to device owners. * * @param context The running context as per {@link #onReceive}. * @param intent The received intent as per {@link #onReceive}. * @see DevicePolicyManager#retrieveNetworkLogs(ComponentName) * * @hide */ public void onNetworkLogsAvailable(Context context, Intent intent) { } /** * Intercept standard device administrator broadcasts. Implementations * should not override this method; it is better to implement the Loading Loading @@ -688,6 +713,8 @@ public class DeviceAdminReceiver extends BroadcastReceiver { onBugreportFailed(context, intent, failureCode); } else if (ACTION_SECURITY_LOGS_AVAILABLE.equals(action)) { onSecurityLogsAvailable(context, intent); } else if (ACTION_NETWORK_LOGS_AVAILABLE.equals(action)) { onNetworkLogsAvailable(context, intent); } } }
core/java/android/app/admin/DevicePolicyManager.java +29 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SystemApi; import android.annotation.UserIdInt; import android.app.Activity; import android.app.admin.NetworkEvent; import android.app.admin.SecurityLog.SecurityEvent; import android.content.ComponentName; import android.content.Context; Loading Loading @@ -6622,6 +6623,7 @@ public class DevicePolicyManager { * @throws {@link SecurityException} if {@code admin} is not a device owner. * @throws {@link RemoteException} if network logging could not be enabled or disabled due to * the logging service not being available * @see #retrieveNetworkLogs * * @hide */ Loading Loading @@ -6651,4 +6653,31 @@ public class DevicePolicyManager { throw re.rethrowFromSystemServer(); } } /** * Called by device owner to retrieve a new batch of network logging events. * * <p> {@link NetworkEvent} can be one of {@link DnsEvent} or {@link ConnectEvent}. * * <p> The list of network events is sorted chronologically, and contains at most 1200 events. * * <p> Access to the logs is rate limited and this method will only return a new batch of logs * after the device device owner has been notified via * {@link DeviceAdminReceiver#onNetworkLogsAvailable}. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @return A new batch of network logs which is a list of {@link NetworkEvent}. Returns * {@code null} if there's no batch currently awaiting for retrieval or if logging is disabled. * @throws {@link SecurityException} if {@code admin} is not a device owner. * * @hide */ public List<NetworkEvent> retrieveNetworkLogs(@NonNull ComponentName admin) { throwIfParentInstance("retrieveNetworkLogs"); try { return mService.retrieveNetworkLogs(admin); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } }