Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b4f1718 authored by Hai Zhang's avatar Hai Zhang
Browse files

Move role into module.

These changes have to be in this CL together because:

- Code in service-permission depends on IRoleManager in
framework-permission, so the APIs in framework-permission and the code
in service-permission need to be moved together.

- The changes to service-permission build rules doesn't make sense
without the code moved in, so they have to be together as well.

Other details:

- framework-annotations: Several annotations are added into
framework-annoatations. Since the discussion with API council seems to
allow user IDs in system server in-process APIs, @UserIdInt and
@AppIdInt is added. @MainThread and @AnyThread is added since
@WorkerThread is already added. @CallSuper is added since @CheckResult
is also already added and they are similar in terms of category of
functionality.

- framework-permission-s-shared-srcs: 3 classes (and 2 AIDL files)
from framework is copied as shared source files and jarjared for
framework-permission, and an additional 3 is added for
service-permission as service-permission-shared-srcs. Similar to
framework-wifi and service-wifi, the 3 classes in framework-permission
is also available to service-permission by the stub library
framework-permission-pre-jarjar, and the other 3 classes used only for
service-permission is included separately to minimize our impact on
classes loaded into boot classpath. framework-permission and
service-permission shares the same jarjar rules to make sure the
classes remain available, and for the same reason framework-permission
cannot be shrank during any optimization.

- framework-permission-s-shared: A java_library target for
framework-permission-shared-srcs is created to make sure that the
public classes won't be counted as APIs, as it would be if directly
included as srcs for framework-permission
java_sdk_library. service-permission-shared is the same thing for
service-permission.

- framework-permission-s: A new java_sdk_library target created to be
loaded into bootclasspath by Android S+.

- Dumpsys Protobuf: The dumpsys protobuf
file (rolemanagerservice.proto) is moved into the module, and both the
platform (incident.proto) and the module uses protoc-gen-javastream to
generate the Java classes from it. This should be fine since it's a
"source level inclusion", and we jarjar the generated classes in our
module to avoid conflict with platform copies.

Bug: 158736025
Test: manual
Test: device boots, default apps can be changed successfully.
Change-Id: I1914774f631e51d0c587a7e527a1c9bc05ee1595
parent ac497e9d
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -761,6 +761,7 @@ gensrcs {
        ":libstats_atom_enum_protos",
        "core/proto/**/*.proto",
        "libs/incident/**/*.proto",
        ":service-permission-protos",
    ],
    output_extension: "srcjar",
}
@@ -788,6 +789,7 @@ gensrcs {
        ":libstats_atom_enum_protos",
        "core/proto/**/*.proto",
        "libs/incident/**/*.proto",
        ":service-permission-protos",
    ],

    output_extension: "proto.h",
@@ -796,6 +798,9 @@ gensrcs {
filegroup {
    name: "framework-annotations",
    srcs: [
        "core/java/android/annotation/AnyThread.java",
        "core/java/android/annotation/AppIdInt.java",
        "core/java/android/annotation/CallSuper.java",
        "core/java/android/annotation/CallbackExecutor.java",
        "core/java/android/annotation/CheckResult.java",
        "core/java/android/annotation/CurrentTimeMillisLong.java",
@@ -803,6 +808,7 @@ filegroup {
        "core/java/android/annotation/IntDef.java",
        "core/java/android/annotation/IntRange.java",
        "core/java/android/annotation/LongDef.java",
        "core/java/android/annotation/MainThread.java",
        "core/java/android/annotation/NonNull.java",
        "core/java/android/annotation/Nullable.java",
        "core/java/android/annotation/RequiresPermission.java",
@@ -812,6 +818,7 @@ filegroup {
        "core/java/android/annotation/SystemApi.java",
        "core/java/android/annotation/SystemService.java",
        "core/java/android/annotation/TestApi.java",
        "core/java/android/annotation/UserIdInt.java",
        "core/java/android/annotation/WorkerThread.java",
        "core/java/com/android/internal/annotations/GuardedBy.java",
        "core/java/com/android/internal/annotations/VisibleForTesting.java",
@@ -906,6 +913,30 @@ filegroup {
    ],
}

// Keep these files in sync with the apex/permission/jarjar-rules.txt for the permission module.
filegroup {
    name: "framework-permission-s-shared-srcs",
    srcs: [
        "core/java/com/android/internal/infra/AndroidFuture.java",
        "core/java/com/android/internal/infra/ServiceConnector.java",
        "core/java/com/android/internal/util/Preconditions.java",
        "core/java/com/android/internal/infra/AndroidFuture.aidl",
        "core/java/com/android/internal/infra/IAndroidFuture.aidl",
        "core/java/android/os/HandlerExecutor.java",
    ],
    path: "core/java",
}

// Keep these files in sync with the apex/permission/jarjar-rules.txt for the permission module.
filegroup {
    name: "service-permission-shared-srcs",
    srcs: [
        "core/java/android/util/IndentingPrintWriter.java",
        "core/java/com/android/internal/util/dump/DualDumpOutputStream.java",
    ],
    path: "core/java",
}

// Build ext.jar
// ============================================================
java_library {
@@ -932,6 +963,7 @@ java_library_host {
        "cmds/statsd/src/**/*.proto",
        "core/proto/**/*.proto",
        "libs/incident/proto/**/*.proto",
        ":service-permission-protos",
    ],
    proto: {
        include_dirs: [
@@ -965,6 +997,7 @@ java_library {
        ":libstats_atom_enum_protos",
        "core/proto/**/*.proto",
        "libs/incident/proto/android/os/**/*.proto",
        ":service-permission-protos",
    ],
}

@@ -981,6 +1014,7 @@ java_library {
        ":libstats_atom_enum_protos",
        "core/proto/**/*.proto",
        "libs/incident/proto/android/os/**/*.proto",
        ":service-permission-protos",
    ],
    exclude_srcs: [
        "core/proto/android/privacy.proto",
@@ -1015,6 +1049,7 @@ cc_defaults {
        ":ipconnectivity-proto-src",
        ":libstats_atom_enum_protos",
        "core/proto/**/*.proto",
        ":service-permission-protos",
    ],
}

+5 −0
Original line number Diff line number Diff line
@@ -42,3 +42,8 @@ android_app_certificate {
    name: "com.android.permission.certificate",
    certificate: "com.android.permission",
}

filegroup {
    name: "permission-jarjar-rules",
    srcs: ["jarjar-rules.txt"],
}
+25 −0
Original line number Diff line number Diff line
@@ -22,12 +22,34 @@ filegroup {
    visibility: ["//frameworks/base"],
}

java_library {
    name: "framework-permission-s-shared",
    srcs: [":framework-permission-s-shared-srcs"],
    libs: [
        "framework-annotations-lib",
        "unsupportedappusage",
    ],
    apex_available: [
        "com.android.permission",
        "test_com.android.permission",
    ],
    installable: false,
    min_sdk_version: "30",
    sdk_version: "module_current",
}

java_sdk_library {
    name: "framework-permission-s",
    defaults: ["framework-module-defaults"],
    srcs: [
        ":framework-permission-s-sources",
    ],
    libs: [
        "framework-annotations-lib"
    ],
    static_libs: [
        "framework-permission-s-shared",
    ],
    apex_available: [
        "com.android.permission",
        "test_com.android.permission",
@@ -36,9 +58,12 @@ java_sdk_library {
    // Restrict access to implementation library.
    impl_library_visibility: ["//frameworks/base/apex/permission:__subpackages__"],
    installable: true,
    jarjar_rules: ":permission-jarjar-rules",
    min_sdk_version: "30",
    permitted_packages: [
        "android.permission",
        "android.app.role",
        // For com.android.permission.jarjar.
        "com.android.permission",
    ],
}
+18 −0
Original line number Diff line number Diff line
// Signature format: 2.0
package android.app.role {

  public final class RoleManager {
    method @NonNull public android.content.Intent createRequestRoleIntent(@NonNull String);
    method public boolean isRoleAvailable(@NonNull String);
    method public boolean isRoleHeld(@NonNull String);
    field public static final String ROLE_ASSISTANT = "android.app.role.ASSISTANT";
    field public static final String ROLE_BROWSER = "android.app.role.BROWSER";
    field public static final String ROLE_CALL_REDIRECTION = "android.app.role.CALL_REDIRECTION";
    field public static final String ROLE_CALL_SCREENING = "android.app.role.CALL_SCREENING";
    field public static final String ROLE_DIALER = "android.app.role.DIALER";
    field public static final String ROLE_EMERGENCY = "android.app.role.EMERGENCY";
    field public static final String ROLE_HOME = "android.app.role.HOME";
    field public static final String ROLE_SMS = "android.app.role.SMS";
  }

}
+10 −0
Original line number Diff line number Diff line
// Signature format: 2.0
package android.app.role {

  public final class RoleManager {
    method @Nullable public String getBrowserRoleHolder(int);
    method @Nullable public String getSmsRoleHolder(int);
    method @Nullable @RequiresPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS) public boolean setBrowserRoleHolder(@Nullable String, int);
  }

}
Loading