Skip to content

Commit

Permalink
Merge pull request #1118 from khimaros/master
Browse files Browse the repository at this point in the history
app preference for custom power trigger
  • Loading branch information
meefik authored Oct 20, 2019
2 parents 7bb5a2c + d576fc4 commit 8fa920f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 3 deletions.
11 changes: 10 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
</intent-filter>
</receiver>
<receiver
android:name="PowerReceiver"
android:enabled="false"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.SCREEN_ON" />
<action android:name="android.intent.action.SCREEN_OFF" />
</intent-filter>
</receiver>
<receiver
android:name=".ActionReceiver"
android:enabled="true"
Expand All @@ -113,4 +122,4 @@
android:permission="android.permission.BIND_JOB_SERVICE" />
</application>

</manifest>
</manifest>
13 changes: 13 additions & 0 deletions app/src/main/java/ru/meefik/linuxdeploy/PowerReceiver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package ru.meefik.linuxdeploy;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class PowerReceiver extends BroadcastReceiver {

@Override
public void onReceive(final Context context, Intent intent) {
EnvUtils.execService(context, "start", "core/power");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PropertiesStore extends ParamUtils {
public static final String name = "properties_conf";
private static final String[] params = {"method", "distrib", "arch", "suite", "source_path",
"target_type", "target_path", "disk_size", "fs_type", "user_name", "user_password",
"privileged_users", "locale", "dns", "net_trigger", "init", "init_path", "init_level",
"privileged_users", "locale", "dns", "net_trigger", "power_trigger", "init", "init_path", "init_level",
"init_user", "init_async", "ssh_port", "ssh_args", "pulse_host", "pulse_port", "graphics",
"vnc_display", "vnc_depth", "vnc_dpi", "vnc_width", "vnc_height", "vnc_args",
"x11_display", "x11_host", "x11_sdl", "x11_sdl_delay", "fb_display", "fb_dev",
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<string name="locale" translatable="false">C</string>
<string name="dns" translatable="false"></string>
<string name="net_trigger" translatable="false"></string>
<string name="power_trigger" translatable="false"></string>
<string name="is_init" translatable="false">false</string>
<string name="init" translatable="false">run-parts</string>
<string name="init_path" translatable="false">/etc/rc.local</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@
<!-- NET_TRIGGER -->
<string name="title_net_trigger_preference">Network trigger</string>
<string name="dialog_title_net_trigger_preference">Path to trigger script</string>
<!-- POWER_TRIGGER -->
<string name="title_power_trigger_preference">Power trigger</string>
<string name="dialog_title_power_trigger_preference">Path to trigger script</string>

<!-- INIT -->
<string name="init_preferences">INIT</string>
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/res/xml/properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@
android:summary="@string/net_trigger"
android:title="@string/title_net_trigger_preference" />

<EditTextPreference
android:defaultValue="@string/power_trigger"
android:dialogTitle="@string/dialog_title_power_trigger_preference"
android:key="power_trigger"
android:summary="@string/power_trigger"
android:title="@string/title_power_trigger_preference" />

</PreferenceCategory>

<PreferenceCategory android:title="@string/init_preferences">
Expand Down Expand Up @@ -235,4 +242,4 @@

</PreferenceCategory>

</PreferenceScreen>
</PreferenceScreen>

0 comments on commit 8fa920f

Please sign in to comment.