Merge "Small changes needed to support CTS testing." into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9fa5b76d00
@@ -1948,12 +1948,21 @@ package android.net {
|
|||||||
package android.net.wifi.sharedconnectivity.app {
|
package android.net.wifi.sharedconnectivity.app {
|
||||||
|
|
||||||
public class SharedConnectivityManager {
|
public class SharedConnectivityManager {
|
||||||
|
method @Nullable public static android.net.wifi.sharedconnectivity.app.SharedConnectivityManager create(@NonNull android.content.Context, @NonNull String, @NonNull String);
|
||||||
method @Nullable public android.content.ServiceConnection getServiceConnection();
|
method @Nullable public android.content.ServiceConnection getServiceConnection();
|
||||||
method public void setService(@Nullable android.os.IInterface);
|
method public void setService(@Nullable android.os.IInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
package android.net.wifi.sharedconnectivity.service {
|
||||||
|
|
||||||
|
public abstract class SharedConnectivityService extends android.app.Service {
|
||||||
|
method public void onBind();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
package android.os {
|
package android.os {
|
||||||
|
|
||||||
public final class BatteryStatsManager {
|
public final class BatteryStatsManager {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package android.net.wifi.sharedconnectivity.app;
|
|||||||
import android.annotation.CallbackExecutor;
|
import android.annotation.CallbackExecutor;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
import android.annotation.TestApi;
|
import android.annotation.TestApi;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
@@ -172,6 +173,17 @@ public class SharedConnectivityManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@SuppressLint("ManagerLookup")
|
||||||
|
@TestApi
|
||||||
|
@Nullable
|
||||||
|
public static SharedConnectivityManager create(@NonNull Context context,
|
||||||
|
@NonNull String servicePackageName, @NonNull String serviceIntentAction) {
|
||||||
|
return new SharedConnectivityManager(context, servicePackageName, serviceIntentAction);
|
||||||
|
}
|
||||||
|
|
||||||
private SharedConnectivityManager(@NonNull Context context, String servicePackageName,
|
private SharedConnectivityManager(@NonNull Context context, String servicePackageName,
|
||||||
String serviceIntentAction) {
|
String serviceIntentAction) {
|
||||||
mServiceConnection = new ServiceConnection() {
|
mServiceConnection = new ServiceConnection() {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import android.annotation.NonNull;
|
|||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.RequiresPermission;
|
import android.annotation.RequiresPermission;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
|
import android.annotation.TestApi;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
@@ -59,7 +60,7 @@ public abstract class SharedConnectivityService extends Service {
|
|||||||
private static final String TAG = SharedConnectivityService.class.getSimpleName();
|
private static final String TAG = SharedConnectivityService.class.getSimpleName();
|
||||||
private static final boolean DEBUG = true;
|
private static final boolean DEBUG = true;
|
||||||
|
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
private final List<ISharedConnectivityCallback> mCallbacks = new ArrayList<>();
|
private final List<ISharedConnectivityCallback> mCallbacks = new ArrayList<>();
|
||||||
// Used to find DeathRecipient when unregistering a callback to call unlinkToDeath.
|
// Used to find DeathRecipient when unregistering a callback to call unlinkToDeath.
|
||||||
private final Map<ISharedConnectivityCallback, DeathRecipient> mDeathRecipientMap =
|
private final Map<ISharedConnectivityCallback, DeathRecipient> mDeathRecipientMap =
|
||||||
@@ -90,7 +91,7 @@ public abstract class SharedConnectivityService extends Service {
|
|||||||
public final IBinder onBind(@NonNull Intent intent) {
|
public final IBinder onBind(@NonNull Intent intent) {
|
||||||
if (DEBUG) Log.i(TAG, "onBind intent=" + intent);
|
if (DEBUG) Log.i(TAG, "onBind intent=" + intent);
|
||||||
mHandler = new Handler(getMainLooper());
|
mHandler = new Handler(getMainLooper());
|
||||||
return new ISharedConnectivityService.Stub() {
|
IBinder serviceStub = new ISharedConnectivityService.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void registerCallback(ISharedConnectivityCallback callback) {
|
public void registerCallback(ISharedConnectivityCallback callback) {
|
||||||
checkPermissions();
|
checkPermissions();
|
||||||
@@ -138,8 +139,14 @@ public abstract class SharedConnectivityService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
onBind(); // For CTS testing
|
||||||
|
return serviceStub;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@TestApi
|
||||||
|
public void onBind() {}
|
||||||
|
|
||||||
private void onRegisterCallback(ISharedConnectivityCallback callback) {
|
private void onRegisterCallback(ISharedConnectivityCallback callback) {
|
||||||
// Listener gets triggered on first register using cashed data
|
// Listener gets triggered on first register using cashed data
|
||||||
if (!notifyTetherNetworkUpdate(callback) || !notifyKnownNetworkUpdate(callback)
|
if (!notifyTetherNetworkUpdate(callback) || !notifyKnownNetworkUpdate(callback)
|
||||||
|
|||||||
Reference in New Issue
Block a user