Skip to content

Commit

Permalink
Add forced firmware update mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
Mi-Walkie-Talkie-by-Darkhorse committed Mar 3, 2022
1 parent f60dbfa commit 0bbc399
Show file tree
Hide file tree
Showing 13 changed files with 447 additions and 33 deletions.
5 changes: 3 additions & 2 deletions app/res/layout/activity_seal_shark_mcu_update.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
<ImageView android:layout_gravity="center" android:id="@id/iv_state_view" android:visibility="visible" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/firmware_icon_upgrade" />
</FrameLayout>
</FrameLayout>
<TextView android:textSize="15.0sp" android:textColor="@color/black50" android:gravity="center" android:layout_gravity="center_horizontal" android:id="@id/tv_state" android:visibility="visible" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="26.0dip" />
<TextView android:textSize="15.0sp" android:textColor="@color/black50" android:layout_gravity="center_horizontal" android:id="@id/dialog_update_info_version_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="26.0dip" />
<TextView android:textSize="15.0sp" android:textColor="@color/black50" android:gravity="center" android:layout_gravity="center_horizontal" android:id="@id/tv_state" android:visibility="visible" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10.0dip" />
<TextView android:textSize="14.0sp" android:textColor="@color/black50" android:gravity="center" android:layout_gravity="center_horizontal" android:id="@id/tv_power_prompt" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10.0dip" />
<RelativeLayout android:layout_width="fill_parent" android:layout_height="0.0dip" android:layout_weight="1.0">
<TextView android:textSize="15.0sp" android:textColor="@color/select_color" android:gravity="center" android:id="@id/btn_update" android:background="@drawable/common_corner_rect" android:visibility="visible" android:layout_width="fill_parent" android:layout_height="42.0dip" android:layout_marginBottom="20.0dip" android:text="@string/update_start" android:layout_alignParentBottom="true" android:layout_marginStart="23.0dip" android:layout_marginEnd="23.0dip" />
<TextView android:textSize="15.0sp" android:textColor="@color/select_color" android:gravity="center" android:id="@id/btn_update" android:background="@drawable/common_corner_rect" android:visibility="visible" android:layout_width="fill_parent" android:layout_height="42.0dip" android:layout_marginBottom="20.0dip" android:layout_alignParentBottom="true" android:layout_marginStart="23.0dip" android:layout_marginEnd="23.0dip" />
</RelativeLayout>
</LinearLayout>
3 changes: 2 additions & 1 deletion app/res/layout/activity_update_ble.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<com.ifengyu.intercom.ui.widget.view.ProgressCircle android:id="@id/update_progress" android:layout_width="fill_parent" android:layout_height="fill_parent" />
<ImageView android:id="@id/update_dev_is_newsest" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/connect_success" />
</RelativeLayout>
<TextView android:textSize="14.0sp" android:textColor="@color/black60" android:gravity="center" android:layout_gravity="center_horizontal" android:id="@id/update_state" android:visibility="gone" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="27.0dip" android:lineSpacingMultiplier="1.3" />
<TextView android:textSize="14.0sp" android:textColor="@color/black60" android:layout_gravity="center_horizontal" android:id="@id/dialog_update_info_version_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="27.0dip" />
<TextView android:textSize="14.0sp" android:textColor="@color/black60" android:gravity="center" android:layout_gravity="center_horizontal" android:id="@id/update_state" android:visibility="gone" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10.0dip" android:lineSpacingMultiplier="1.3" />
<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:textSize="15.0sp" android:textColor="@color/black80" android:gravity="center" android:id="@id/update_start_click" android:background="@drawable/common_corner_rect" android:paddingTop="15.0dip" android:paddingBottom="15.0dip" android:clickable="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="23.5dip" android:layout_marginRight="23.5dip" android:layout_marginBottom="27.0dip" android:text="@string/update_start" android:layout_alignParentBottom="true" />
<TextView android:textSize="15.0sp" android:textColor="@color/black80" android:gravity="center" android:id="@id/update_sure_click" android:background="@drawable/common_corner_rect" android:paddingTop="15.0dip" android:paddingBottom="15.0dip" android:visibility="gone" android:clickable="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="23.5dip" android:layout_marginRight="23.5dip" android:layout_marginBottom="27.0dip" android:text="@string/sure" android:layout_alignParentBottom="true" />
Expand Down
5 changes: 3 additions & 2 deletions app/res/values/public.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4470,7 +4470,7 @@
<public type="id" name="update_icon" id="0x7f0904b1" />
<public type="id" name="update_progress" id="0x7f0904b2" />
<public type="id" name="update_restart_click" id="0x7f0904b3" />
<public type="id" name="update_start_click" id="0x7f0904b4" />
<public type="id" name="zero_corner_chip" id="0x7f0904b4" />
<public type="id" name="update_state" id="0x7f0904b5" />
<public type="id" name="update_sure_click" id="0x7f0904b6" />
<public type="id" name="update_version" id="0x7f0904b7" />
Expand Down Expand Up @@ -4515,7 +4515,6 @@
<public type="id" name="wrapper_reset_rotate" id="0x7f0904de" />
<public type="id" name="wrapper_rotate_by_angle" id="0x7f0904df" />
<public type="id" name="wrapper_states" id="0x7f0904e0" />
<public type="id" name="zero_corner_chip" id="0x7f0904e1" />
<public type="integer" name="abc_config_activityDefaultDur" id="0x7f0a0000" />
<public type="integer" name="abc_config_activityShortDur" id="0x7f0a0001" />
<public type="integer" name="anim_duration" id="0x7f0a0002" />
Expand Down Expand Up @@ -5876,6 +5875,8 @@
<public type="string" name="zhixiashi_or_hangkang" id="0x7f1103a2" />
<public type="string" name="zhixiashi_or_hangkang_en" id="0x7f1103a3" />
<public type="string" name="frequency_mhz" id="0x7f1103a4" />
<public type="string" name="hardware_version" id="0x7f1103a5" />
<public type="string" name="flash_file_text" id="0x7f1103a6" />
<public type="style" name="AVLoadingIndicatorView" id="0x7f120000" />
<public type="style" name="AVLoadingIndicatorView.Large" id="0x7f120001" />
<public type="style" name="AVLoadingIndicatorView.Small" id="0x7f120002" />
Expand Down
2 changes: 2 additions & 0 deletions app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -999,4 +999,6 @@ Please enable [Location] in [Settings]."</string>
<string name="zhixiashi_or_hangkang_en">Municipalities or SAR</string>
<string name="zhixiashi_or_hangkang">@string/zhixiashi_or_hangkang_en</string>
<string name="frequency_mhz">Frequency value, MHz</string>
<string name="hardware_version">"Hardware version\u0020"</string>
<string name="flash_file_text">Flash \"%s\"</string>
</resources>
2 changes: 1 addition & 1 deletion app/smali/com/google/android/material/R$id.smali
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@

.field public static final wrap_content:I = 0x7f0904dc

.field public static final zero_corner_chip:I = 0x7f0904e1
.field public static final zero_corner_chip:I = 0x7f0904b4


# direct methods
Expand Down
2 changes: 1 addition & 1 deletion app/smali/com/ifengyu/blelib/R$id.smali
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@

.field public static final wrap_content:I = 0x7f0904dc

.field public static final zero_corner_chip:I = 0x7f0904e1
.field public static final zero_corner_chip:I = 0x7f0904b4


# direct methods
Expand Down
4 changes: 1 addition & 3 deletions app/smali/com/ifengyu/intercom/R$id.smali
Original file line number Diff line number Diff line change
Expand Up @@ -2411,8 +2411,6 @@

.field public static final update_restart_click:I = 0x7f0904b3

.field public static final update_start_click:I = 0x7f0904b4

.field public static final update_state:I = 0x7f0904b5

.field public static final update_sure_click:I = 0x7f0904b6
Expand Down Expand Up @@ -2501,7 +2499,7 @@

.field public static final wrapper_states:I = 0x7f0904e0

.field public static final zero_corner_chip:I = 0x7f0904e1
.field public static final zero_corner_chip:I = 0x7f0904b4


# direct methods
Expand Down
2 changes: 1 addition & 1 deletion app/smali/com/ifengyu/intercom/g/a.smali
Original file line number Diff line number Diff line change
Expand Up @@ -3082,7 +3082,7 @@
invoke-virtual {v4, v2, v1}, Lcom/ifengyu/intercom/g/c/a;->a(Ljava/lang/String;Ljava/lang/String;)Lcom/ifengyu/intercom/g/c/a;

.line 31
invoke-static {}, Lcom/ifengyu/intercom/i/d0;->J()I
invoke-static {}, Lcom/ifengyu/intercom/i/d0;->Ju()I

move-result v1

Expand Down
97 changes: 94 additions & 3 deletions app/smali_classes2/com/ifengyu/intercom/i/d0.smali
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@
.method public static D()I
.locals 3

.line 1
invoke-static {}, Lcom/ifengyu/intercom/i/d0;->fwdir()Z

move-result v0

if-nez v0, :cond_0

invoke-static {}, Lcom/ifengyu/intercom/i/d0;->A()Landroid/content/SharedPreferences;

move-result-object v0
Expand All @@ -112,6 +117,7 @@

move-result v0

:cond_0
return v0
.end method

Expand Down Expand Up @@ -240,10 +246,36 @@
return v0
.end method

.method public static Ju()I
.locals 1

invoke-static {}, Lcom/ifengyu/intercom/i/d0;->fwdir()Z

move-result v0

if-nez v0, :cond_0

invoke-static {}, Lcom/ifengyu/intercom/i/d0;->J()I

move-result v0

return v0

:cond_0
const/4 v0, 0x2

return v0
.end method

.method public static K()I
.locals 3

.line 1
invoke-static {}, Lcom/ifengyu/intercom/i/d0;->fwdir()Z

move-result v0

if-nez v0, :cond_0

invoke-static {}, Lcom/ifengyu/intercom/i/d0;->I()Landroid/content/SharedPreferences;

move-result-object v0
Expand All @@ -256,6 +288,7 @@

move-result v0

:cond_0
return v0
.end method

Expand Down Expand Up @@ -1561,6 +1594,58 @@
return v0
.end method

.method private static fwdir()Z
.locals 3

:try_start_0
invoke-static {}, Landroid/os/Environment;->getExternalStorageState()Ljava/lang/String;

move-result-object v0

const-string v1, "mounted"

invoke-virtual {v1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result v1

if-nez v1, :cond_0

const-string v1, "mounted_ro"

invoke-virtual {v1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result v0

if-eqz v0, :cond_1

:cond_0
new-instance v0, Ljava/io/File;

invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

move-result-object v1

const-string v2, "Mi-walkie-talkie.firmware"

invoke-direct {v0, v1, v2}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

invoke-virtual {v0}, Ljava/io/File;->isDirectory()Z
:try_end_0
.catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_0

move-result v0

:cond_1
return v0

:catch_0
move-exception v0

const/4 v0, 0x0

return v0
.end method

.method public static g()I
.locals 3

Expand Down Expand Up @@ -2084,7 +2169,12 @@
.method public static l()I
.locals 3

.line 1
invoke-static {}, Lcom/ifengyu/intercom/i/d0;->fwdir()Z

move-result v0

if-nez v0, :cond_0

invoke-static {}, Lcom/ifengyu/intercom/i/d0;->j()Landroid/content/SharedPreferences;

move-result-object v0
Expand All @@ -2097,6 +2187,7 @@

move-result v0

:cond_0
return v0
.end method

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.class public Lcom/ifengyu/intercom/ui/activity/SealSharkMcuUpdateActivity;
.super Lcom/ifengyu/intercom/ui/baseui/BaseActivity;
.super Lcom/ifengyu/intercom/ui/baseui/BaseUpdateActivity;
.source "SealSharkMcuUpdateActivity.java"

# interfaces
Expand Down Expand Up @@ -41,7 +41,7 @@
.locals 1

.line 1
invoke-direct {p0}, Lcom/ifengyu/intercom/ui/baseui/BaseActivity;-><init>()V
invoke-direct {p0}, Lcom/ifengyu/intercom/ui/baseui/BaseUpdateActivity;-><init>()V

const/4 v0, 0x0

Expand Down Expand Up @@ -1020,6 +1020,10 @@
.method private z()V
.locals 5

iget-object v2, p0, Lcom/ifengyu/intercom/ui/baseui/BaseUpdateActivity;->fwf:Ljava/io/File;

if-nez v2, :cond_2

.line 1
iget-object v0, p0, Lcom/ifengyu/intercom/ui/activity/SealSharkMcuUpdateActivity;->z:Lcom/ifengyu/intercom/bean/McuUpdateInfoModel;

Expand Down Expand Up @@ -1101,6 +1105,7 @@

if-eqz v3, :cond_0

:cond_2
const/4 v0, 0x4

.line 6
Expand Down Expand Up @@ -1315,13 +1320,15 @@
.locals 1

.line 1
invoke-super {p0, p1}, Lcom/ifengyu/intercom/ui/baseui/BaseActivity;->onCreate(Landroid/os/Bundle;)V
invoke-super {p0, p1}, Lcom/ifengyu/intercom/ui/baseui/BaseUpdateActivity;->onCreate(Landroid/os/Bundle;)V

const p1, 0x7f0c004c

.line 2
invoke-virtual {p0, p1}, Lcom/ifengyu/intercom/ui/baseui/BaseActivity;->setContentView(I)V

invoke-super {p0}, Lcom/ifengyu/intercom/ui/baseui/BaseUpdateActivity;->initUI()V

.line 3
invoke-virtual {p0}, Landroid/app/Activity;->getIntent()Landroid/content/Intent;

Expand Down Expand Up @@ -1396,7 +1403,7 @@
.locals 1

.line 1
invoke-super {p0}, Lcom/ifengyu/intercom/ui/baseui/BaseActivity;->onDestroy()V
invoke-super {p0}, Lcom/ifengyu/intercom/ui/baseui/BaseUpdateActivity;->onDestroy()V

const/4 v0, 0x0

Expand All @@ -1413,7 +1420,7 @@
.locals 1

.line 1
invoke-super {p0}, Lcom/ifengyu/intercom/ui/baseui/BaseActivity;->onPause()V
invoke-super {p0}, Lcom/ifengyu/intercom/ui/baseui/BaseUpdateActivity;->onPause()V

.line 2
invoke-static {}, Lcom/ifengyu/intercom/eventbus/a;->a()Lcom/squareup/otto/b;
Expand All @@ -1429,7 +1436,7 @@
.locals 1

.line 1
invoke-super {p0}, Lcom/ifengyu/intercom/ui/baseui/BaseActivity;->onResume()V
invoke-super {p0}, Lcom/ifengyu/intercom/ui/baseui/BaseUpdateActivity;->onResume()V

.line 2
invoke-static {}, Lcom/ifengyu/intercom/eventbus/a;->a()Lcom/squareup/otto/b;
Expand Down
Loading

0 comments on commit 0bbc399

Please sign in to comment.