Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
Bump Gradle to 6.1.1
Bump build tools to 29.0.3
  • Loading branch information
koral-- committed Feb 3, 2020
1 parent 5abcc6f commit 72f5544
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 23 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
buildToolsVersion "29.0.3"

signingConfigs {
debug {
Expand Down Expand Up @@ -49,6 +49,7 @@ android {

dependencies {
//TODO consider migrating to androidx
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.protobuf:protobuf-lite:3.0.1'
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import jp.co.cyberagent.stf.util.BrowserUtil;

public class BrowserPackageMonitor extends AbstractMonitor {
private static final String TAG = "STFBrowserPackageMonitor";
private static final String TAG = "STFBrowserPkgMonitor";

private Set<Browser> browsers = new HashSet<Browser>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package jp.co.cyberagent.stf.query;

import android.content.Context;
import android.os.Build;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
Expand All @@ -23,31 +24,31 @@ public GetPropertiesResponder(Context context) {
@Override
public GeneratedMessageLite respond(Wire.Envelope envelope) throws InvalidProtocolBufferException {
Wire.GetPropertiesRequest request =
Wire.GetPropertiesRequest.parseFrom(envelope.getMessage());
Wire.GetPropertiesRequest.parseFrom(envelope.getMessage());

ArrayList<Wire.Property> properties = new ArrayList<Wire.Property>();
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

for (String name : request.getPropertiesList()) {
String value=null;
String value = null;
try {
switch(name) {
switch (name) {
case "imei":
value = tm.getDeviceId();
value = getValueOrNull(tm::getDeviceId);
break;
case "imsi":
value = tm.getSubscriberId();
value = getValueOrNull(tm::getSubscriberId);
break;
case "phonenumber":
value = tm.getLine1Number();
break;
case "iccid":
value = tm.getSimSerialNumber();
value = getValueOrNull(tm::getSimSerialNumber);
break;
case "operator":
if(tm.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) {
if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) {
value = tm.getSimOperatorName();
}else {
} else {
value = tm.getNetworkOperatorName();
if (TextUtils.isEmpty(value)) {
value = tm.getSimOperatorName();
Expand All @@ -63,26 +64,33 @@ public GeneratedMessageLite respond(Wire.Envelope envelope) throws InvalidProtoc
}
if (!TextUtils.isEmpty(value)) {
properties.add(Wire.Property.newBuilder()
.setName(name)
.setValue(value)
.build());
.setName(name)
.setValue(value)
.build());
}
} catch(SecurityException e ) {
Log.d(TAG,"Security exception trying to retrieve "+name);
} catch (SecurityException e) {
Log.d(TAG, "Security exception trying to retrieve " + name);
}
}

return Wire.Envelope.newBuilder()
.setId(envelope.getId())
.setType(Wire.MessageType.GET_PROPERTIES)
.setMessage(Wire.GetPropertiesResponse.newBuilder()
.setSuccess(true)
.addAllProperties(properties)
.build()
.toByteString())
.setSuccess(true)
.addAllProperties(properties)
.build()
.toByteString())
.build();
}

private static String getValueOrNull(StringCallable callable) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
return null;
}
return callable.call();
}

@Override
public void cleanup() {
// No-op
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.GetWifiStatusRequest request =
Wire.GetWifiStatusRequest.parseFrom(envelope.getMessage());

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

return Wire.Envelope.newBuilder()
.setId(envelope.getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import jp.co.cyberagent.stf.proto.Wire;

public class SetKeyguardStateResponder extends AbstractResponder {
private static final String TAG = "STFKeyguardStateResponder";
private static final String TAG = "STFKeyguardStateResp";

private KeyguardManager.KeyguardLock lock;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void acquireWakeLock() {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(
PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,
"STFService"
"STF:STFService"
);
wakeLock.acquire();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package jp.co.cyberagent.stf.query;

@FunctionalInterface
interface StringCallable {
String call();
}
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ allprojects {
repositories {
mavenCentral()
google()
jcenter()
}

tasks.withType(JavaCompile) {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

0 comments on commit 72f5544

Please sign in to comment.