Skip to content

Commit

Permalink
Update AGP to 7.0.2 (#53)
Browse files Browse the repository at this point in the history
* Update AGP to 7.0.2

* Update semaphore configuration

* Fix warnings detected by lint
  • Loading branch information
koral-- authored Oct 3, 2021
1 parent 3b0004b commit a4f56d0
Show file tree
Hide file tree
Showing 16 changed files with 207 additions and 162 deletions.
15 changes: 8 additions & 7 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ blocks:
jobs:
- name: Build
commands:
- 'wget https://dl.google.com/android/repository/commandlinetools-linux-6514223_latest.zip -O ~/android-commandline-tools.zip '
- mkdir -p ~/android-sdk/cmdline-tools/
- unzip ~/android-commandline-tools.zip -d ~/android-sdk/cmdline-tools
- 'export PATH=$PATH:~/android-sdk/cmdline-tools/tools/bin'
- yes | sdkmanager "ndk;21.4.7075529"
- 'export PATH=$PATH:~/android-sdk/ndk/21.4.7075529/'
- wget https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip -O ~/android-commandline-tools.zip
- mkdir -p ~/android-sdk/
- unzip ~/android-commandline-tools.zip -d ~/android-sdk/cmdline-tools/
- mv ~/android-sdk/cmdline-tools/cmdline-tools/ ~/android-sdk/cmdline-tools/latest
- export PATH=$PATH:~/android-sdk/cmdline-tools/latest/bin
- yes | sdkmanager "ndk;23.0.7599858"
- export PATH=$PATH:~/android-sdk/ndk/23.0.7599858/
- export ANDROID_SDK_ROOT=~/android-sdk
- checkout
- sem-version java 1.8
- sem-version java 11
- ./gradlew build
- artifact push job app/build/outputs/apk/release/app-release.apk
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
}

android {
compileSdkVersion 30
compileSdkVersion 31

signingConfigs {
debug {
Expand All @@ -26,7 +26,7 @@ android {
minSdkVersion 16
targetSdkVersion 30
versionCode 10
versionName "2.4.7"
versionName "2.4.8"
applicationId "jp.co.cyberagent.stf"
}

Expand Down
8 changes: 8 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
xmlns:tools="http://schemas.android.com/tools"
package="jp.co.cyberagent.stf">

<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
Expand All @@ -18,6 +19,13 @@
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>

<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" />
</intent>
</queries>

<application android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/java/jp/co/cyberagent/stf/IdentityActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package jp.co.cyberagent.stf;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.KeyguardManager;
import android.content.Context;
Expand Down Expand Up @@ -40,6 +41,7 @@ private String getSecuredId( SecuredGetter<String> supplier ) {
}
}

@SuppressLint("MissingPermission")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -76,11 +78,10 @@ protected void onCreate(Bundle savedInstanceState) {
layout.addView(createData(tm.getSimOperatorName()));
layout.addView(createLabel("PHONE"));
layout.addView(createData(getSecuredId(tm::getLine1Number)));
layout.addView(createLabel("IMEI"));
layout.addView(createData(getSecuredId(tm::getLine1Number)));
layout.addView(createLabel("ICCID"));
layout.addView(createData(getSecuredId(tm::getLine1Number)));

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
layout.addView(createLabel("IMEI"));
layout.addView(createData(getSecuredId(tm::getImei)));
}

requestWindowFeature(Window.FEATURE_NO_TITLE);
ensureVisibility();
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/jp/co/cyberagent/stf/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import jp.co.cyberagent.stf.query.DoIdentifyResponder;
import jp.co.cyberagent.stf.query.DoRemoveAccountResponder;
import jp.co.cyberagent.stf.query.GetAccountsResponder;
import jp.co.cyberagent.stf.query.GetBluetoothStatusResponder;
import jp.co.cyberagent.stf.query.GetBrowsersResponder;
import jp.co.cyberagent.stf.query.GetClipboardResponder;
import jp.co.cyberagent.stf.query.GetDisplayResponder;
Expand All @@ -55,14 +56,13 @@
import jp.co.cyberagent.stf.query.GetSdStatusResponder;
import jp.co.cyberagent.stf.query.GetVersionResponder;
import jp.co.cyberagent.stf.query.GetWifiStatusResponder;
import jp.co.cyberagent.stf.query.GetBluetoothStatusResponder;
import jp.co.cyberagent.stf.query.SetBluetoothEnabledResponder;
import jp.co.cyberagent.stf.query.SetClipboardResponder;
import jp.co.cyberagent.stf.query.SetKeyguardStateResponder;
import jp.co.cyberagent.stf.query.SetMasterMuteResponder;
import jp.co.cyberagent.stf.query.SetRingerModeResponder;
import jp.co.cyberagent.stf.query.SetWakeLockResponder;
import jp.co.cyberagent.stf.query.SetWifiEnabledResponder;
import jp.co.cyberagent.stf.query.SetBluetoothEnabledResponder;

public class Service extends android.app.Service {
public static final String ACTION_START = "jp.co.cyberagent.stf.ACTION_START";
Expand All @@ -72,6 +72,7 @@ public class Service extends android.app.Service {

private static final String TAG = "STFService";
private static final int NOTIFICATION_ID = 0x1;
private static final int PENDING_INTENT_FLAG = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_IMMUTABLE : 0;

private List<AbstractMonitor> monitors = new ArrayList<AbstractMonitor>();
private ExecutorService executor = Executors.newCachedThreadPool();
Expand Down Expand Up @@ -122,7 +123,7 @@ public void onCreate() {
.setTicker(getString(R.string.service_ticker))
.setContentTitle(getString(R.string.service_title))
.setContentText(getString(R.string.service_text))
.setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, 0))
.setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, PENDING_INTENT_FLAG))
.setWhen(System.currentTimeMillis())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,20 @@ public void cleanup() {
}

private CharSequence getClipboardText() {
if (Build.VERSION.SDK_INT >= 11) {
android.content.ClipboardManager clipboardManager =
(android.content.ClipboardManager) Service.getClipboardManager();
if (clipboardManager.hasPrimaryClip()) {
ClipData clipData = clipboardManager.getPrimaryClip();
if (clipData.getItemCount() > 0) {
ClipData.Item clip = clipData.getItemAt(0);
return clip.coerceToText(context.getApplicationContext());
}
else {
return null;
}
android.content.ClipboardManager clipboardManager =
(android.content.ClipboardManager) Service.getClipboardManager();
if (clipboardManager.hasPrimaryClip()) {
ClipData clipData = clipboardManager.getPrimaryClip();
if (clipData.getItemCount() > 0) {
ClipData.Item clip = clipData.getItemAt(0);
return clip.coerceToText(context.getApplicationContext());
}
else {
return null;
}
}
else {
return ((android.text.ClipboardManager) Service.getClipboardManager())
.getText();
return null;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package jp.co.cyberagent.stf.query;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.telephony.TelephonyManager;
Expand All @@ -21,6 +22,7 @@ public GetPropertiesResponder(Context context) {
super(context);
}

@SuppressLint("MissingPermission") //fall back to nulls on newer Android versions
@Override
public GeneratedMessageLite respond(Wire.Envelope envelope) throws InvalidProtocolBufferException {
Wire.GetPropertiesRequest request =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ public GeneratedMessageLite respond(Wire.Envelope envelope) throws InvalidProtoc
}
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
if (!Environment.isExternalStorageRemovable()) {
mountList.remove(Environment.getExternalStorageDirectory().getPath());
}
if (!Environment.isExternalStorageRemovable()) {
mountList.remove(Environment.getExternalStorageDirectory().getPath());
}

for (int i = 0; i < mountList.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ public GeneratedMessageLite respond(Wire.Envelope envelope) throws InvalidProtoc
if (bm != null) {
BluetoothAdapter ba = bm.getAdapter();
if (ba != null) {
if (request.getEnabled()) {
ba.enable();
try {
if (request.getEnabled()) {
ba.enable();
} else {
ba.disable();
}
successful = true;
} catch (SecurityException exception) {
successful = false;
}
else {
ba.disable();
}
successful = true;
}
// No Bluetooth available
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,7 @@ public void cleanup() {
}

private void setClipboardText(String content) {
if (Build.VERSION.SDK_INT >= 11) {
((android.content.ClipboardManager) Service.getClipboardManager())
.setPrimaryClip(ClipData.newPlainText(null, content));
}
else {
((android.text.ClipboardManager) Service.getClipboardManager())
.setText(content);
}
((android.content.ClipboardManager) Service.getClipboardManager())
.setPrimaryClip(ClipData.newPlainText(null, content));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public void cleanup() {
releaseWakeLock();
}

@SuppressWarnings("deprecation")
private void acquireWakeLock() {
releaseWakeLock();
Log.i(TAG, "Acquiring wake lock");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public GeneratedMessageLite respond(Wire.Envelope envelope) throws InvalidProtoc
Wire.SetWifiEnabledRequest request =
Wire.SetWifiEnabledRequest.parseFrom(envelope.getMessage());

WifiManager wm = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
WifiManager wm = (WifiManager)context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);

wm.setWifiEnabled(request.getEnabled());

Expand Down
6 changes: 1 addition & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.android.tools.build:gradle:7.0.2'
}
}

allprojects {
repositories {
mavenCentral()
google()
jcenter()
}

tasks.withType(JavaCompile) {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Thu May 20 19:00:41 CEST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
Loading

0 comments on commit a4f56d0

Please sign in to comment.