huawei: Remove unnecessary RuntimeException throws
* move ui message to translatable string resource
This commit is contained in:
parent
2d41a652ea
commit
dc2afd3bc2
|
@ -76,8 +76,8 @@ public class HuaweiInstallHandler implements InstallHandler {
|
|||
|
||||
if (!this.valid) {
|
||||
LOG.error("Watchface cannot be installed");
|
||||
installActivity.setInfoText("Watchface resolution doesnt match device screen. Watchface is "
|
||||
+ resolution.screenByThemeVersion(description.screen) + " device screen is " + deviceScreen);
|
||||
installActivity.setInfoText(context.getString(R.string.watchface_resolution_doesnt_match,
|
||||
resolution.screenByThemeVersion(description.screen), deviceScreen));
|
||||
installActivity.setInstallEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -33,19 +33,15 @@ public class Watchface {
|
|||
// bit 7 - kaleidoskop
|
||||
public byte expandedtype = 0;
|
||||
|
||||
public InstalledWatchfaceInfo(HuaweiTLV tlv) {
|
||||
try {
|
||||
if(tlv.contains(0x03))
|
||||
this.fileName = tlv.getString(0x03);
|
||||
if(tlv.contains(0x04))
|
||||
this.version = tlv.getString(0x04);
|
||||
if(tlv.contains(0x05))
|
||||
this.type = tlv.getByte(0x05);
|
||||
if(tlv.contains(0x07))
|
||||
this.expandedtype = tlv.getByte(0x07);
|
||||
} catch (HuaweiPacket.MissingTagException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
public InstalledWatchfaceInfo(HuaweiTLV tlv) throws HuaweiPacket.MissingTagException {
|
||||
if(tlv.contains(0x03))
|
||||
this.fileName = tlv.getString(0x03);
|
||||
if(tlv.contains(0x04))
|
||||
this.version = tlv.getString(0x04);
|
||||
if(tlv.contains(0x05))
|
||||
this.type = tlv.getByte(0x05);
|
||||
if(tlv.contains(0x07))
|
||||
this.expandedtype = tlv.getByte(0x07);
|
||||
}
|
||||
|
||||
public boolean isCurrent() {
|
||||
|
@ -113,22 +109,18 @@ public class Watchface {
|
|||
|
||||
@Override
|
||||
public void parseTlv() throws ParseException {
|
||||
try {
|
||||
if(this.tlv.contains(0x01))
|
||||
this.params.maxVersion = this.tlv.getString(0x01);
|
||||
if(this.tlv.contains(0x02))
|
||||
this.params.width = this.tlv.getShort(0x02);
|
||||
if(this.tlv.contains(0x03))
|
||||
this.params.height = this.tlv.getShort(0x03);
|
||||
if(this.tlv.contains(0x04))
|
||||
this.params.supportFileType = this.tlv.getByte(0x04);
|
||||
if(this.tlv.contains(0x05))
|
||||
this.params.sort = this.tlv.getByte(0x05);
|
||||
if(this.tlv.contains(0x06))
|
||||
this.params.otherWatchfaceVersions = this.tlv.getString(0x06);
|
||||
} catch (MissingTagException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if(this.tlv.contains(0x01))
|
||||
this.params.maxVersion = this.tlv.getString(0x01);
|
||||
if(this.tlv.contains(0x02))
|
||||
this.params.width = this.tlv.getShort(0x02);
|
||||
if(this.tlv.contains(0x03))
|
||||
this.params.height = this.tlv.getShort(0x03);
|
||||
if(this.tlv.contains(0x04))
|
||||
this.params.supportFileType = this.tlv.getByte(0x04);
|
||||
if(this.tlv.contains(0x05))
|
||||
this.params.sort = this.tlv.getByte(0x05);
|
||||
if(this.tlv.contains(0x06))
|
||||
this.params.otherWatchfaceVersions = this.tlv.getString(0x06);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,15 +151,10 @@ public class Watchface {
|
|||
@Override
|
||||
public void parseTlv() throws HuaweiPacket.ParseException {
|
||||
watchfaceInfoList = new ArrayList<>();
|
||||
try {
|
||||
if(this.tlv.contains(0x81)) {
|
||||
for (HuaweiTLV subTlv : this.tlv.getObject(0x81).getObjects(0x82)) {
|
||||
watchfaceInfoList.add(new Watchface.InstalledWatchfaceInfo(subTlv));
|
||||
}
|
||||
if(this.tlv.contains(0x81)) {
|
||||
for (HuaweiTLV subTlv : this.tlv.getObject(0x81).getObjects(0x82)) {
|
||||
watchfaceInfoList.add(new Watchface.InstalledWatchfaceInfo(subTlv));
|
||||
}
|
||||
|
||||
} catch (HuaweiPacket.MissingTagException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,16 +256,10 @@ public class Watchface {
|
|||
|
||||
@Override
|
||||
public void parseTlv() throws HuaweiPacket.ParseException {
|
||||
|
||||
try {
|
||||
if(this.tlv.contains(0x82)) {
|
||||
for (HuaweiTLV subTlv : this.tlv.getObject(0x82).getObjects(0x83)) {
|
||||
watchFaceNames.put(subTlv.getString(0x04), subTlv.getString(0x05));
|
||||
}
|
||||
if(this.tlv.contains(0x82)) {
|
||||
for (HuaweiTLV subTlv : this.tlv.getObject(0x82).getObjects(0x83)) {
|
||||
watchFaceNames.put(subTlv.getString(0x04), subTlv.getString(0x05));
|
||||
}
|
||||
|
||||
} catch (HuaweiPacket.MissingTagException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ public class HuaweiWatchfaceManager
|
|||
getWatchfacesNames.setFinalizeReq(finalizeReq);
|
||||
getWatchfacesNames.doPerform();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
LOG.error("Could not get watchface names", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ public class HuaweiWatchfaceManager
|
|||
sendWatchfaceOperation.setFinalizeReq(finalizeReq);
|
||||
sendWatchfaceOperation.doPerform();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
LOG.error("Could not set watchface ", getFullFileName(uuid), e );
|
||||
}
|
||||
|
||||
|
||||
|
@ -275,7 +275,7 @@ public class HuaweiWatchfaceManager
|
|||
sendWatchfaceOperation.setFinalizeReq(finalizeReq);
|
||||
sendWatchfaceOperation.doPerform();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
LOG.error("Could not delete watchface", getFullFileName(uuid), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2812,4 +2812,5 @@
|
|||
<string name="pref_sleepasandroid_feat_heartrate">Heart rate</string>
|
||||
<string name="pref_sleepasandroid_feat_oximetry">Oximetry</string>
|
||||
<string name="pref_sleepasandroid_feat_spo2">SPO2</string>
|
||||
<string name="watchface_resolution_doesnt_match">Watchface resolution doesnt match device screen. Watchface is %1$s device screen is %2$s</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue