upload android base code part1

This commit is contained in:
August 2018-08-08 15:50:00 +08:00
parent e02f198e2d
commit 0a1de6c4b3
48159 changed files with 9071466 additions and 0 deletions

View file

@ -0,0 +1,38 @@
/*
* Copyright (C) 2017 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.
*/
import android.os.Build.VERSION;
import android.support.v4.os.BuildCompat;
import com.google.errorprone.refaster.annotation.AfterTemplate;
import com.google.errorprone.refaster.annotation.AlsoNegation;
import com.google.errorprone.refaster.annotation.BeforeTemplate;
/**
* Replace usages of BuildCompat.isAtLeastO() with SDK_INT check.
*/
public class IsAtLeastO {
@BeforeTemplate
boolean usingAtLeastO() {
return BuildCompat.isAtLeastO();
}
@AfterTemplate
@AlsoNegation
boolean optimizedMethod() {
return VERSION.SDK_INT >= 26;
}
}

View file

@ -0,0 +1,25 @@
Author: aurimas@google.com
Updated: 6/6/2017
Instructions on how to compile and apply refaster rules to support library
0. Download error-prone and refaster jars
http://errorprone.info/docs/refaster will have up to date instructions
1. Compile the refaster rule (in this example IsAtLeastO.java)
java -cp /path/to/android.jar:/path/to/support-compat.jar:javac-9-dev-r3297-4.jar:error_prone_refaster-2.0.18.jar com.google.errorprone.refaster.RefasterRuleCompiler IsAtLeastO.java --out `pwd`/myrule.refaster
2. Update build to use the refaster rule
Add compiler args to error-prone in SupportLibraryPlugin.groovy
'-XepPatchChecks:refaster:/path/to/refaster/myrule.refaster',
'-XepPatchLocation:' + project.projectDir
3. Compile support library using the refaster rule
./gradlew assembleErrorProne
4. Apply patches
error-prone will produce patch files like "design/error-prone.patch" and to apply them, cd into the
directory e.g. "design" and then run:
patch -p0 -u -i error-prone.patch
5. Rules have been applied! Celebrate!