Merge "Add a native aidl API." am: 577e3114da am: 4cfb3545d6
am: b17294db1c
Change-Id: I1628aaba2bb1b029fe8b7279bce6faff7503e982
This commit is contained in:
@@ -194,6 +194,9 @@ filegroup {
|
|||||||
":PacProcessor-aidl-sources",
|
":PacProcessor-aidl-sources",
|
||||||
":ProxyHandler-aidl-sources",
|
":ProxyHandler-aidl-sources",
|
||||||
|
|
||||||
|
// AIDL from frameworks/base/native/
|
||||||
|
":platform-compat-native-aidl",
|
||||||
|
|
||||||
// AIDL sources from external directories
|
// AIDL sources from external directories
|
||||||
":dumpstate_aidl",
|
":dumpstate_aidl",
|
||||||
":framework_native_aidl",
|
":framework_native_aidl",
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ import android.view.contentcapture.ContentCaptureManager.ContentCaptureClient;
|
|||||||
import android.view.textclassifier.TextClassificationManager;
|
import android.view.textclassifier.TextClassificationManager;
|
||||||
|
|
||||||
import com.android.internal.compat.IPlatformCompat;
|
import com.android.internal.compat.IPlatformCompat;
|
||||||
|
import com.android.internal.compat.IPlatformCompatNative;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@@ -3236,6 +3237,7 @@ public abstract class Context {
|
|||||||
//@hide ROLE_CONTROLLER_SERVICE,
|
//@hide ROLE_CONTROLLER_SERVICE,
|
||||||
CAMERA_SERVICE,
|
CAMERA_SERVICE,
|
||||||
//@hide: PLATFORM_COMPAT_SERVICE,
|
//@hide: PLATFORM_COMPAT_SERVICE,
|
||||||
|
//@hide: PLATFORM_COMPAT_NATIVE_SERVICE,
|
||||||
PRINT_SERVICE,
|
PRINT_SERVICE,
|
||||||
CONSUMER_IR_SERVICE,
|
CONSUMER_IR_SERVICE,
|
||||||
//@hide: TRUST_SERVICE,
|
//@hide: TRUST_SERVICE,
|
||||||
@@ -4603,6 +4605,14 @@ public abstract class Context {
|
|||||||
*/
|
*/
|
||||||
public static final String PLATFORM_COMPAT_SERVICE = "platform_compat";
|
public static final String PLATFORM_COMPAT_SERVICE = "platform_compat";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use with {@link android.os.ServiceManager.getService()} to retrieve a
|
||||||
|
* {@link IPlatformCompatNative} IBinder for native code communicating with the platform compat
|
||||||
|
* service.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final String PLATFORM_COMPAT_NATIVE_SERVICE = "platform_compat_native";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service to capture a bugreport.
|
* Service to capture a bugreport.
|
||||||
* @see #getSystemService(String)
|
* @see #getSystemService(String)
|
||||||
|
|||||||
@@ -110,3 +110,31 @@ llndk_library {
|
|||||||
symbol_file: "libandroid_net.map.txt",
|
symbol_file: "libandroid_net.map.txt",
|
||||||
unversioned: true,
|
unversioned: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Aidl library for platform compat.
|
||||||
|
cc_library_shared {
|
||||||
|
name: "lib-platform-compat-native-api",
|
||||||
|
defaults: ["libandroid_defaults"],
|
||||||
|
|
||||||
|
shared_libs: [
|
||||||
|
"libbinder",
|
||||||
|
"libutils",
|
||||||
|
],
|
||||||
|
aidl: {
|
||||||
|
local_include_dirs: ["aidl"],
|
||||||
|
export_aidl_headers: true,
|
||||||
|
},
|
||||||
|
srcs: [
|
||||||
|
":platform-compat-native-aidl",
|
||||||
|
],
|
||||||
|
export_include_dirs: ["aidl"],
|
||||||
|
}
|
||||||
|
|
||||||
|
filegroup {
|
||||||
|
name: "platform-compat-native-aidl",
|
||||||
|
srcs: [
|
||||||
|
"aidl/com/android/internal/compat/IPlatformCompatNative.aidl",
|
||||||
|
],
|
||||||
|
path: "aidl",
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.internal.compat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Platform native private API for talking with the PlatformCompat service.
|
||||||
|
*
|
||||||
|
* <p> Should be used for gating and logging from non-app processes running cpp code.
|
||||||
|
* For app processes please use android.compat.Compatibility API.
|
||||||
|
*
|
||||||
|
* {@hide}
|
||||||
|
*/
|
||||||
|
interface IPlatformCompatNative
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Reports that a compatibility change is affecting an app process now.
|
||||||
|
*
|
||||||
|
* <p>Note: for changes that are gated using {@link #isChangeEnabled(long, String)},
|
||||||
|
* you do not need to call this API directly. The change will be reported for you.
|
||||||
|
*
|
||||||
|
* @param changeId The ID of the compatibility change taking effect.
|
||||||
|
* @param packageName The package name of the app in question.
|
||||||
|
*/
|
||||||
|
void reportChangeByPackageName(long changeId, @utf8InCpp String packageName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reports that a compatibility change is affecting an app process now.
|
||||||
|
*
|
||||||
|
* <p>Note: for changes that are gated using {@link #isChangeEnabled(long, int)},
|
||||||
|
* you do not need to call this API directly. The change will be reported for you.
|
||||||
|
*
|
||||||
|
* @param changeId The ID of the compatibility change taking effect.
|
||||||
|
* @param uid The UID of the app in question.
|
||||||
|
*/
|
||||||
|
void reportChangeByUid(long changeId, int uid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query if a given compatibility change is enabled for an app process. This method should
|
||||||
|
* be called when implementing functionality on behalf of the affected app.
|
||||||
|
*
|
||||||
|
* <p>Returns {@code true} if there is no installed package by the provided package name.
|
||||||
|
*
|
||||||
|
* <p>If this method returns {@code true}, the calling code should implement the compatibility
|
||||||
|
* change, resulting in differing behaviour compared to earlier releases. If this method
|
||||||
|
* returns
|
||||||
|
* {@code false}, the calling code should behave as it did in earlier releases.
|
||||||
|
*
|
||||||
|
* <p>It will also report the change as {@link #reportChange(long, String)} would, so there is
|
||||||
|
* no need to call that method directly.
|
||||||
|
*
|
||||||
|
* @param changeId The ID of the compatibility change in question.
|
||||||
|
* @param packageName The package name of the app in question.
|
||||||
|
* @return {@code true} if the change is enabled for the current app.
|
||||||
|
*/
|
||||||
|
boolean isChangeEnabledByPackageName(long changeId, @utf8InCpp String packageName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query if a given compatibility change is enabled for an app process. This method should
|
||||||
|
* be called when implementing functionality on behalf of the affected app.
|
||||||
|
*
|
||||||
|
* <p> Returns {@code true} if there are no installed packages for the required UID, or if the
|
||||||
|
* change is enabled for ALL of the installed packages associated with the provided UID. Please
|
||||||
|
* use a more specific API if you want a different behaviour for multi-package UIDs.
|
||||||
|
*
|
||||||
|
* <p>If this method returns {@code true}, the calling code should implement the compatibility
|
||||||
|
* change, resulting in differing behaviour compared to earlier releases. If this method
|
||||||
|
* returns {@code false}, the calling code should behave as it did in earlier releases.
|
||||||
|
*
|
||||||
|
* <p>It will also report the change as {@link #reportChange(long, int)} would, so there is
|
||||||
|
* no need to call that method directly.
|
||||||
|
*
|
||||||
|
* @param changeId The ID of the compatibility change in question.
|
||||||
|
* @param uid The UID of the app in question.
|
||||||
|
* @return {@code true} if the change is enabled for the current app.
|
||||||
|
*/
|
||||||
|
boolean isChangeEnabledByUid(long changeId, int uid);
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.server.compat;
|
||||||
|
|
||||||
|
import com.android.internal.compat.IPlatformCompatNative;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public class PlatformCompatNative extends IPlatformCompatNative.Stub {
|
||||||
|
private final PlatformCompat mPlatformCompat;
|
||||||
|
|
||||||
|
public PlatformCompatNative(PlatformCompat platformCompat) {
|
||||||
|
mPlatformCompat = platformCompat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reportChangeByPackageName(long changeId, String packageName) {
|
||||||
|
mPlatformCompat.reportChangeByPackageName(changeId, packageName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reportChangeByUid(long changeId, int uid) {
|
||||||
|
mPlatformCompat.reportChangeByUid(changeId, uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isChangeEnabledByPackageName(long changeId, String packageName) {
|
||||||
|
return mPlatformCompat.isChangeEnabledByPackageName(changeId, packageName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isChangeEnabledByUid(long changeId, int uid) {
|
||||||
|
return mPlatformCompat.isChangeEnabledByUid(changeId, uid);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -91,6 +91,7 @@ import com.android.server.broadcastradio.BroadcastRadioService;
|
|||||||
import com.android.server.camera.CameraServiceProxy;
|
import com.android.server.camera.CameraServiceProxy;
|
||||||
import com.android.server.clipboard.ClipboardService;
|
import com.android.server.clipboard.ClipboardService;
|
||||||
import com.android.server.compat.PlatformCompat;
|
import com.android.server.compat.PlatformCompat;
|
||||||
|
import com.android.server.compat.PlatformCompatNative;
|
||||||
import com.android.server.connectivity.IpConnectivityMetrics;
|
import com.android.server.connectivity.IpConnectivityMetrics;
|
||||||
import com.android.server.contentcapture.ContentCaptureManagerInternal;
|
import com.android.server.contentcapture.ContentCaptureManagerInternal;
|
||||||
import com.android.server.coverage.CoverageService;
|
import com.android.server.coverage.CoverageService;
|
||||||
@@ -641,8 +642,10 @@ public final class SystemServer {
|
|||||||
// Platform compat service is used by ActivityManagerService, PackageManagerService, and
|
// Platform compat service is used by ActivityManagerService, PackageManagerService, and
|
||||||
// possibly others in the future. b/135010838.
|
// possibly others in the future. b/135010838.
|
||||||
traceBeginAndSlog("PlatformCompat");
|
traceBeginAndSlog("PlatformCompat");
|
||||||
ServiceManager.addService(Context.PLATFORM_COMPAT_SERVICE,
|
PlatformCompat platformCompat = new PlatformCompat(mSystemContext);
|
||||||
new PlatformCompat(mSystemContext));
|
ServiceManager.addService(Context.PLATFORM_COMPAT_SERVICE, platformCompat);
|
||||||
|
ServiceManager.addService(Context.PLATFORM_COMPAT_NATIVE_SERVICE,
|
||||||
|
new PlatformCompatNative(platformCompat));
|
||||||
traceEnd();
|
traceEnd();
|
||||||
|
|
||||||
// Wait for installd to finish starting up so that it has a chance to
|
// Wait for installd to finish starting up so that it has a chance to
|
||||||
|
|||||||
Reference in New Issue
Block a user