Commit c8f8664b authored by Румен Петров's avatar Румен Петров
Browse files

append "libdir" to path broadcast

Will allow terminal application to setup aliases.

Also remove useless in production information logging.
parent 0705ade5
......@@ -11,6 +11,7 @@
android:required="false"/>
<uses-permission android:name="${termApplicationId}.permission.PREPEND_TO_PATH"/>
<uses-permission android:name="${termApplicationId}.permission.APPEND_TO_PATH"/>
<application
android:name=".Application"
......@@ -69,6 +70,7 @@
<receiver android:name=".PathBroadcast">
<intent-filter>
<action android:name="${termApplicationId}.broadcast.PREPEND_TO_PATH"/>
<action android:name="${termApplicationId}.broadcast.APPEND_TO_PATH"/>
</intent-filter>
</receiver>
......
......@@ -21,29 +21,36 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import static com.termoneplus.securebox.Application.APP_TAG;
import android.text.TextUtils;
public class PathBroadcast extends BroadcastReceiver {
private static final String ACTION_PATH_PREPEND_BROADCAST = BuildConfig.TERM_APPLICATION_ID + ".broadcast.PREPEND_TO_PATH";
private static final String ACTION_PATH_APPEND_BROADCAST = BuildConfig.TERM_APPLICATION_ID + ".broadcast.APPEND_TO_PATH";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (TextUtils.isEmpty(action)) return;
String packageName = context.getPackageName();
Log.i(APP_TAG, "BroadcastReceiver packageName: " + packageName);
String action = intent.getAction();
Log.i(APP_TAG, "BroadcastReceiver action: " + action);
if (action == null) return;
if (action.equals(ACTION_PATH_PREPEND_BROADCAST)) {
/* The directory we want prepended goes into the result extras */
Bundle result = getResultExtras(true);
result.putString(packageName, Application.bindir.getPath());
setResultCode(Activity.RESULT_OK);
switch (action) {
case ACTION_PATH_PREPEND_BROADCAST: {
/* The directory we want prepended goes into the result extras */
Bundle result = getResultExtras(true);
result.putString(packageName, Application.bindir.getPath());
setResultCode(Activity.RESULT_OK);
break;
}
case ACTION_PATH_APPEND_BROADCAST: {
/* The directory we want appended goes into the result extras */
Bundle result = getResultExtras(true);
result.putString(packageName, Application.libdir.getPath());
setResultCode(Activity.RESULT_OK);
break;
}
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment