fix: 首次提交
This commit is contained in:
139
setupcompat/Android.bp
Normal file
139
setupcompat/Android.bp
Normal file
@@ -0,0 +1,139 @@
|
||||
//
|
||||
// Build the setup compat library.
|
||||
//
|
||||
|
||||
package {
|
||||
default_applicable_licenses: ["external_setupcompat_license"],
|
||||
}
|
||||
|
||||
// Added automatically by a large-scale-change
|
||||
// See: http://go/android-license-faq
|
||||
license {
|
||||
name: "external_setupcompat_license",
|
||||
visibility: [":__subpackages__"],
|
||||
license_kinds: [
|
||||
"SPDX-license-identifier-Apache-2.0",
|
||||
],
|
||||
license_text: [
|
||||
"LICENSE",
|
||||
],
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "Aidls",
|
||||
srcs: [
|
||||
"main/aidl/com/google/android/setupcompat/ISetupCompatService.aidl",
|
||||
],
|
||||
path: "main/aidl",
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "AidlsPortal",
|
||||
srcs: [
|
||||
"main/aidl/com/google/android/setupcompat/portal/*.aidl",
|
||||
],
|
||||
path: "main/aidl",
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "AidlsBts",
|
||||
srcs: [
|
||||
"bts/aidl/com/google/android/setupcompat/bts/*.aidl",
|
||||
],
|
||||
path: "bts/aidl",
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "Srcs",
|
||||
srcs: [
|
||||
"main/java/com/google/android/setupcompat/*.java",
|
||||
"main/java/com/google/android/setupcompat/internal/*.java",
|
||||
"main/java/com/google/android/setupcompat/logging/*.java",
|
||||
"main/java/com/google/android/setupcompat/logging/*.kt",
|
||||
"main/java/com/google/android/setupcompat/logging/internal/*.java",
|
||||
"main/java/com/google/android/setupcompat/template/*.java",
|
||||
"main/java/com/google/android/setupcompat/util/*.java",
|
||||
"main/java/com/google/android/setupcompat/view/*.java",
|
||||
],
|
||||
path: "main/java",
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "SrcsPartnerConfig",
|
||||
srcs: [
|
||||
"partnerconfig/java/**/*.java",
|
||||
],
|
||||
path: "partnerconfig/java",
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "SrcsPortal",
|
||||
srcs: [
|
||||
"main/java/com/google/android/setupcompat/portal/*.java",
|
||||
],
|
||||
path: "main/java",
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "SrcsBts",
|
||||
srcs: [
|
||||
"bts/java/com/google/android/setupcompat/bts/*.java",
|
||||
],
|
||||
path: "bts/java",
|
||||
}
|
||||
|
||||
android_library {
|
||||
name: "setupcompat",
|
||||
manifest: "AndroidManifest.xml",
|
||||
resource_dirs: [
|
||||
"main/res",
|
||||
],
|
||||
srcs: [
|
||||
":Aidls",
|
||||
":AidlsPortal",
|
||||
":Srcs",
|
||||
":SrcsPartnerConfig",
|
||||
":SrcsPortal",
|
||||
],
|
||||
static_libs: [
|
||||
"androidx.annotation_annotation",
|
||||
"androidx.window_window",
|
||||
"error_prone_annotations",
|
||||
],
|
||||
min_sdk_version: "21",
|
||||
sdk_version: "current",
|
||||
optimize: {
|
||||
proguard_flags_files: ["proguard.flags"],
|
||||
},
|
||||
lint: {
|
||||
baseline_filename: "lint-baseline.xml",
|
||||
},
|
||||
}
|
||||
|
||||
android_library {
|
||||
name: "setupcompat_bts",
|
||||
manifest: "AndroidManifest.xml",
|
||||
resource_dirs: [
|
||||
"main/res",
|
||||
],
|
||||
srcs: [
|
||||
":Srcs",
|
||||
":SrcsBts",
|
||||
":SrcsPartnerConfig",
|
||||
":Aidls",
|
||||
":AidlsBts",
|
||||
],
|
||||
static_libs: [
|
||||
"androidx.annotation_annotation",
|
||||
"androidx.window_window",
|
||||
"error_prone_annotations",
|
||||
],
|
||||
min_sdk_version: "21",
|
||||
sdk_version: "current",
|
||||
optimize: {
|
||||
proguard_flags_files: ["proguard.flags"],
|
||||
},
|
||||
lint: {
|
||||
baseline_filename: "lint-baseline.xml",
|
||||
},
|
||||
}
|
||||
21
setupcompat/AndroidManifest.xml
Normal file
21
setupcompat/AndroidManifest.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2018 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.
|
||||
-->
|
||||
|
||||
<manifest package="com.google.android.setupcompat">
|
||||
<!-- Set in the BUILD or gradle file -->
|
||||
<uses-sdk />
|
||||
</manifest>
|
||||
202
setupcompat/LICENSE
Normal file
202
setupcompat/LICENSE
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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.
|
||||
3
setupcompat/METADATA
Normal file
3
setupcompat/METADATA
Normal file
@@ -0,0 +1,3 @@
|
||||
third_party {
|
||||
license_type: NOTICE
|
||||
}
|
||||
0
setupcompat/MODULE_LICENSE_APACHE2
Normal file
0
setupcompat/MODULE_LICENSE_APACHE2
Normal file
1
setupcompat/OWNERS
Normal file
1
setupcompat/OWNERS
Normal file
@@ -0,0 +1 @@
|
||||
include platform/external/setupdesign:/OWNERS
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.google.android.setupcompat.bts;
|
||||
|
||||
import com.google.android.setupcompat.bts.IBtsTaskServiceCallback;
|
||||
|
||||
/**
|
||||
* Declare the interface for BTS task service.
|
||||
*
|
||||
* The SetupWizard will bind BtsTaskService when specific event triggerred. The service callback
|
||||
* using {@link IBtsTaskServiceCallback#onTaskFinished} to notify SetupWizard the task is already
|
||||
* completed and SetupWizard will unbind the service.
|
||||
*
|
||||
* If the service can't be complete before end of SetupWizard, the SetupWizard still unbind the
|
||||
* service since the background task is no longer helpful for SetupWizard.
|
||||
*/
|
||||
interface IBtsTaskService {
|
||||
|
||||
/**
|
||||
* Set the callback for the client to notify the job already completed and can
|
||||
* be disconnected.
|
||||
*/
|
||||
oneway void setCallback(IBtsTaskServiceCallback callback) = 1;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.google.android.setupcompat.bts;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
* Declare the callback interface for BTS task service to notice the SUW the
|
||||
* status of task service.
|
||||
*/
|
||||
interface IBtsTaskServiceCallback {
|
||||
|
||||
/**
|
||||
* Called when the task is finished.
|
||||
*
|
||||
* @param bundle The metrics bundle.
|
||||
*/
|
||||
void onTaskFinished(in Bundle bundle) = 1;
|
||||
}
|
||||
@@ -0,0 +1,299 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.google.android.setupcompat.bts;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.Signature;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.Build.VERSION_CODES;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import com.google.android.setupcompat.internal.Preconditions;
|
||||
import com.google.android.setupcompat.util.Logger;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/** Class to handle service binding from SUW, and execute the client's task in the executor. */
|
||||
public abstract class AbstractSetupBtsService extends Service {
|
||||
private static final Logger LOG = new Logger(AbstractSetupBtsService.class);
|
||||
|
||||
private static final String SETUP_WIZARD_PACKAGE_NAME = "com.google.android.setupwizard";
|
||||
|
||||
private static final String BTS_STARTER_FOR_TEST =
|
||||
"com.google.android.apps.setupwizard.sample.bts.starter";
|
||||
|
||||
private static final String SETUP_BTS_PERMISSION = "com.google.android.setupwizard.SETUP_BTS";
|
||||
|
||||
@VisibleForTesting
|
||||
static final String SETUP_WIZARD_RELEASE_CERTIFICATE_STRING =
|
||||
"308204433082032ba003020102020900c2e08746644a308d300d06092a864886f70d01010405003074310b300"
|
||||
+ "9060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d"
|
||||
+ "4d6f756e7461696e205669657731143012060355040a130b476f6f676c6520496e632e3110300e06035"
|
||||
+ "5040b1307416e64726f69643110300e06035504031307416e64726f6964301e170d3038303832313233"
|
||||
+ "313333345a170d3336303130373233313333345a3074310b30090603550406130255533113301106035"
|
||||
+ "50408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e2056696577311430"
|
||||
+ "12060355040a130b476f6f676c6520496e632e3110300e060355040b1307416e64726f69643110300e0"
|
||||
+ "6035504031307416e64726f696430820120300d06092a864886f70d01010105000382010d0030820108"
|
||||
+ "0282010100ab562e00d83ba208ae0a966f124e29da11f2ab56d08f58e2cca91303e9b754d372f640a71"
|
||||
+ "b1dcb130967624e4656a7776a92193db2e5bfb724a91e77188b0e6a47a43b33d9609b77183145ccdf7b"
|
||||
+ "2e586674c9e1565b1f4c6a5955bff251a63dabf9c55c27222252e875e4f8154a645f897168c0b1bfc61"
|
||||
+ "2eabf785769bb34aa7984dc7e2ea2764cae8307d8c17154d7ee5f64a51a44a602c249054157dc02cd5f"
|
||||
+ "5c0e55fbef8519fbe327f0b1511692c5a06f19d18385f5c4dbc2d6b93f68cc2979c70e18ab93866b3bd"
|
||||
+ "5db8999552a0e3b4c99df58fb918bedc182ba35e003c1b4b10dd244a8ee24fffd333872ab5221985eda"
|
||||
+ "b0fc0d0b145b6aa192858e79020103a381d93081d6301d0603551d0e04160414c77d8cc2211756259a7"
|
||||
+ "fd382df6be398e4d786a53081a60603551d2304819e30819b8014c77d8cc2211756259a7fd382df6be3"
|
||||
+ "98e4d786a5a178a4763074310b3009060355040613025553311330110603550408130a43616c69666f7"
|
||||
+ "26e6961311630140603550407130d4d6f756e7461696e205669657731143012060355040a130b476f6f"
|
||||
+ "676c6520496e632e3110300e060355040b1307416e64726f69643110300e06035504031307416e64726"
|
||||
+ "f6964820900c2e08746644a308d300c0603551d13040530030101ff300d06092a864886f70d01010405"
|
||||
+ "0003820101006dd252ceef85302c360aaace939bcff2cca904bb5d7a1661f8ae46b2994204d0ff4a68c"
|
||||
+ "7ed1a531ec4595a623ce60763b167297a7ae35712c407f208f0cb109429124d7b106219c084ca3eb3f9"
|
||||
+ "ad5fb871ef92269a8be28bf16d44c8d9a08e6cb2f005bb3fe2cb96447e868e731076ad45b33f6009ea1"
|
||||
+ "9c161e62641aa99271dfd5228c5c587875ddb7f452758d661f6cc0cccb7352e424cc4365c523532f732"
|
||||
+ "5137593c4ae341f4db41edda0d0b1071a7c440f0fe9ea01cb627ca674369d084bd2fd911ff06cdbf2cf"
|
||||
+ "a10dc0f893ae35762919048c7efc64c7144178342f70581c9de573af55b390dd7fdb9418631895d5f75"
|
||||
+ "9f30112687ff621410c069308a";
|
||||
|
||||
@VisibleForTesting
|
||||
static final String SETUP_WIZARD_DEBUG_CERTIFICATE_STRING =
|
||||
"308204a830820390a003020102020900d585b86c7dd34ef5300d06092a864886f70d0101040500308194310b3"
|
||||
+ "009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130"
|
||||
+ "d4d6f756e7461696e20566965773110300e060355040a1307416e64726f69643110300e060355040b13"
|
||||
+ "07416e64726f69643110300e06035504031307416e64726f69643122302006092a864886f70d0109011"
|
||||
+ "613616e64726f696440616e64726f69642e636f6d301e170d3038303431353233333635365a170d3335"
|
||||
+ "303930313233333635365a308194310b3009060355040613025553311330110603550408130a43616c6"
|
||||
+ "9666f726e6961311630140603550407130d4d6f756e7461696e20566965773110300e060355040a1307"
|
||||
+ "416e64726f69643110300e060355040b1307416e64726f69643110300e06035504031307416e64726f6"
|
||||
+ "9643122302006092a864886f70d0109011613616e64726f696440616e64726f69642e636f6d30820120"
|
||||
+ "300d06092a864886f70d01010105000382010d00308201080282010100d6ce2e080abfe2314dd18db3c"
|
||||
+ "fd3185cb43d33fa0c74e1bdb6d1db8913f62c5c39df56f846813d65bec0f3ca426b07c5a8ed5a3990c1"
|
||||
+ "67e76bc999b927894b8f0b22001994a92915e572c56d2a301ba36fc5fc113ad6cb9e7435a16d23ab7df"
|
||||
+ "aeee165e4df1f0a8dbda70a869d516c4e9d051196ca7c0c557f175bc375f948c56aae86089ba44f8aa6"
|
||||
+ "a4dd9a7dbf2c0a352282ad06b8cc185eb15579eef86d080b1d6189c0f9af98b1c2ebd107ea45abdb68a"
|
||||
+ "3c7838a5e5488c76c53d40b121de7bbd30e620c188ae1aa61dbbc87dd3c645f2f55f3d4c375ec4070a9"
|
||||
+ "3f7151d83670c16a971abe5ef2d11890e1b8aef3298cf066bf9e6ce144ac9ae86d1c1b0f020103a381f"
|
||||
+ "c3081f9301d0603551d0e041604148d1cc5be954c433c61863a15b04cbc03f24fe0b23081c90603551d"
|
||||
+ "230481c13081be80148d1cc5be954c433c61863a15b04cbc03f24fe0b2a1819aa48197308194310b300"
|
||||
+ "9060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d"
|
||||
+ "4d6f756e7461696e20566965773110300e060355040a1307416e64726f69643110300e060355040b130"
|
||||
+ "7416e64726f69643110300e06035504031307416e64726f69643122302006092a864886f70d01090116"
|
||||
+ "13616e64726f696440616e64726f69642e636f6d820900d585b86c7dd34ef5300c0603551d130405300"
|
||||
+ "30101ff300d06092a864886f70d0101040500038201010019d30cf105fb78923f4c0d7dd223233d4096"
|
||||
+ "7acfce00081d5bd7c6e9d6ed206b0e11209506416ca244939913d26b4aa0e0f524cad2bb5c6e4ca1016"
|
||||
+ "a15916ea1ec5dc95a5e3a010036f49248d5109bbf2e1e618186673a3be56daf0b77b1c229e3c255e3e8"
|
||||
+ "4c905d2387efba09cbf13b202b4e5a22c93263484a23d2fc29fa9f1939759733afd8aa160f4296c2d01"
|
||||
+ "63e8182859c6643e9c1962fa0c18333335bc090ff9a6b22ded1ad444229a539a94eefadabd065ced24b"
|
||||
+ "3e51e5dd7b66787bef12fe97fba484c423fb4ff8cc494c02f0f5051612ff6529393e8e46eac5bb21f27"
|
||||
+ "7c151aa5f2aa627d1e89da70ab6033569de3b9897bfff7ca9da3e1243f60b";
|
||||
|
||||
@VisibleForTesting boolean allowDebugKeys = false;
|
||||
|
||||
@VisibleForTesting IBtsTaskServiceCallback callback;
|
||||
|
||||
/** Allow debug signature calling app when developing stage. */
|
||||
protected void setAllowDebugKeys(boolean allowed) {
|
||||
allowDebugKeys = allowed;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
if (verifyIntentAction(intent)) {
|
||||
return binder;
|
||||
} else {
|
||||
LOG.w(
|
||||
"["
|
||||
+ this.getClass().getSimpleName()
|
||||
+ "] Unauthorized binder uid="
|
||||
+ Binder.getCallingUid()
|
||||
+ ", intentAction="
|
||||
+ (intent == null ? "(null)" : intent.getAction()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onUnbind(Intent intent) {
|
||||
if (verifyIntentAction(intent)) {
|
||||
callback = null;
|
||||
}
|
||||
return super.onUnbind(intent);
|
||||
}
|
||||
|
||||
private boolean verifyIntentAction(Intent intent) {
|
||||
if (intent != null
|
||||
&& intent.getAction() != null
|
||||
&& intent.getAction().equals(getIntentAction())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the task is finished.
|
||||
*
|
||||
* @param succeed whether the task success or not.
|
||||
* @param failedReason A simple phrase to explain the failed reason. Like "No network". Null if
|
||||
* task is success.
|
||||
*/
|
||||
protected void onTaskFinished(boolean succeed, @Nullable String failedReason) {
|
||||
LOG.atDebug("onTaskFinished callback " + ((callback == null) ? "is null." : "is not null."));
|
||||
if (callback != null) {
|
||||
try {
|
||||
Bundle metricBundle = new Bundle();
|
||||
metricBundle.putBoolean(Constants.EXTRA_KEY_TASK_SUCCEED, succeed);
|
||||
metricBundle.putString(Constants.EXTRA_KEY_TASK_FAILED_REASON, failedReason);
|
||||
callback.onTaskFinished(metricBundle);
|
||||
} catch (RemoteException e) {
|
||||
LOG.e(
|
||||
"[" + this.getClass().getSimpleName() + "] Fail to invoke remove method onJobFinished");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the intent action that expected to execute the task. Use to avoid the receiver launch
|
||||
* unexpectedly.
|
||||
*/
|
||||
@NonNull
|
||||
protected abstract String getIntentAction();
|
||||
|
||||
/** Returns the executor used to execute the task. */
|
||||
@NonNull
|
||||
protected abstract Executor getExecutor();
|
||||
|
||||
/** Tasks can be done before activity launched, in order to remove the loading before activity. */
|
||||
protected abstract void onStartTask();
|
||||
|
||||
@VisibleForTesting
|
||||
final IBtsTaskService.Stub binder =
|
||||
new IBtsTaskService.Stub() {
|
||||
@Override
|
||||
public void setCallback(IBtsTaskServiceCallback callback) {
|
||||
LOG.atDebug("setCallback called.");
|
||||
if (verifyCallingApp()) {
|
||||
AbstractSetupBtsService.this.callback = callback;
|
||||
Executor executor = getExecutor();
|
||||
|
||||
if (executor != null) {
|
||||
executor.execute(
|
||||
() -> {
|
||||
Preconditions.ensureNotOnMainThread(
|
||||
AbstractSetupBtsService.this.getClass().getSimpleName() + "::onStartTask");
|
||||
onStartTask();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (callback != null) {
|
||||
try {
|
||||
callback.onTaskFinished(Bundle.EMPTY);
|
||||
} catch (RemoteException e) {
|
||||
LOG.e("Error occurred while invoke remote method onTaskFinished");
|
||||
}
|
||||
}
|
||||
LOG.e(
|
||||
"BTS service bound with untrusted application, callingUid="
|
||||
+ Binder.getCallingUid());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@VisibleForTesting
|
||||
boolean verifyCallingApp() {
|
||||
if (verifyCallingPackageName() && verifyCallingSignature() && verifyCallingAppPermission()) {
|
||||
LOG.atInfo("Trusted caller=" + getPackageManager().getNameForUid(Binder.getCallingUid()));
|
||||
return true;
|
||||
} else {
|
||||
LOG.e("Untrusted caller=" + getPackageManager().getNameForUid(Binder.getCallingUid()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean verifyCallingPackageName() {
|
||||
String packageName = getPackageManager().getNameForUid(Binder.getCallingUid());
|
||||
if (SETUP_WIZARD_PACKAGE_NAME.equals(packageName)
|
||||
|| (allowDebugKeys && BTS_STARTER_FOR_TEST.equals(packageName))) {
|
||||
LOG.atDebug("Package name match to SetupWizard");
|
||||
return true;
|
||||
} else {
|
||||
LOG.w("Untrusted package:" + packageName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean verifyCallingSignature() {
|
||||
String packageName = getPackageManager().getNameForUid(Binder.getCallingUid());
|
||||
if (Build.VERSION.SDK_INT >= VERSION_CODES.P) {
|
||||
try {
|
||||
PackageInfo info =
|
||||
getPackageManager()
|
||||
.getPackageInfo(packageName, PackageManager.GET_SIGNING_CERTIFICATES);
|
||||
|
||||
for (Signature signature : info.signingInfo.getApkContentsSigners()) {
|
||||
if (SETUP_WIZARD_RELEASE_CERTIFICATE_STRING.equals(signature.toCharsString())
|
||||
|| (isAllowDebugKeysOrBuild()
|
||||
&& SETUP_WIZARD_DEBUG_CERTIFICATE_STRING.equals(signature.toCharsString()))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (NameNotFoundException | NullPointerException e) {
|
||||
LOG.e("Exception occurred while verify signature", e);
|
||||
}
|
||||
} else {
|
||||
LOG.w("Signature verify is not support before Android P.");
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG.w("Signature not match to SetupWizard");
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isAllowDebugKeysOrBuild() {
|
||||
return Build.TYPE.equals("userdebug") || Build.TYPE.equals("eng") || allowDebugKeys;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean verifyCallingAppPermission() {
|
||||
int checkPermission =
|
||||
checkPermission(SETUP_BTS_PERMISSION, Binder.getCallingPid(), Binder.getCallingUid());
|
||||
if (PackageManager.PERMISSION_GRANTED == checkPermission) {
|
||||
LOG.atDebug(
|
||||
"permission:"
|
||||
+ SETUP_BTS_PERMISSION
|
||||
+ ", grant pid="
|
||||
+ Binder.getCallingPid()
|
||||
+ ", uid="
|
||||
+ Binder.getCallingUid()
|
||||
+ ", checkPermission="
|
||||
+ checkPermission);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.google.android.setupcompat.bts;
|
||||
|
||||
/** Constant values used by {@link com.google.android.setupcompat.bts.AbstractSetupBtsService}. */
|
||||
public class Constants {
|
||||
|
||||
/**
|
||||
* The extra key for {@link AbstractSetupBtsService} to send the task result to SUW for metric
|
||||
* collection.
|
||||
*/
|
||||
public static final String EXTRA_KEY_TASK_SUCCEED = "succeed";
|
||||
|
||||
/**
|
||||
* The extra key for {@link com.google.android.setupcompat.bts.AbstractSetupBtsService} to send
|
||||
* the failed reason to SUW for metric collection.
|
||||
*/
|
||||
public static final String EXTRA_KEY_TASK_FAILED_REASON = "failed_reason";
|
||||
|
||||
private Constants() {}
|
||||
}
|
||||
59
setupcompat/build.gradle
Normal file
59
setupcompat/build.gradle
Normal file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Include this gradle file if you are building against this as a standalone gradle library project,
|
||||
* as opposed to building it as part of the git-tree. This is typically the file you want to include
|
||||
* if you create a new project in Android Studio.
|
||||
*
|
||||
* For example, you can include the following in your settings.gradle file:
|
||||
* include ':setupcompat'
|
||||
* project(':setupcompat').projectDir = new File(PATH_TO_THIS_DIRECTORY)
|
||||
*
|
||||
* And then you can include the :setupcompat project as one of your dependencies
|
||||
* dependencies {
|
||||
* implementation project(path: ':setupcompat')
|
||||
* }
|
||||
*/
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.library)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
}
|
||||
|
||||
android {
|
||||
// Not specifying compileSdkVersion here so clients can specify it; must be at least Q
|
||||
namespace = "com.google.android.setupcompat"
|
||||
compileSdk 34
|
||||
defaultConfig {
|
||||
minSdkVersion 31
|
||||
targetSdkVersion 34
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.flags'
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.main {
|
||||
manifest.srcFile 'AndroidManifest.xml'
|
||||
java.srcDirs = ['main/java', 'partnerconfig/java']
|
||||
aidl.srcDirs = ['main/aidl']
|
||||
res.srcDirs = ['main/res']
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
aidl = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// implementation "androidx.annotation:annotation:1.0.0"
|
||||
implementation libs.window.window
|
||||
implementation files('../libs/error_prone_annotations.jar')
|
||||
implementation libs.androidx.annotation.annotation
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
o/classes
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
i/release_dex
|
||||
@@ -0,0 +1 @@
|
||||
i/classes_global-synthetics
|
||||
@@ -0,0 +1 @@
|
||||
i/
|
||||
@@ -0,0 +1 @@
|
||||
o/release
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user