This repository has been archived by the owner on Feb 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
app/src/main/java/me/s1204/galaxycamsnd/DeviceAdminReceiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,43 @@ | ||
package me.s1204.galaxycamsnd; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.provider.Settings; | ||
import android.widget.Toast; | ||
|
||
public class DeviceAdminReceiver extends android.app.admin.DeviceAdminReceiver { | ||
|
||
void doDisable(Context context) { | ||
if (Settings.System.canWrite(context)) { | ||
Settings.System.putInt(context.getContentResolver(), CameraActivity.camera_forced_shuttersound_key, 0); | ||
} | ||
} | ||
|
||
void showToast(Context context, String msg) { | ||
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show(); | ||
} | ||
|
||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
doDisable(context); | ||
} | ||
|
||
@Override | ||
public void onEnabled(Context context, Intent intent) { | ||
doDisable(context); | ||
showToast(context, context.getString(R.string.admin_receiver_status_enabled)); | ||
} | ||
|
||
@Override | ||
public CharSequence onDisableRequested(Context context, Intent intent) { | ||
context.startActivity(new Intent(context, DisableActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); | ||
return context.getString(R.string.admin_receiver_status_disable_warning); | ||
} | ||
|
||
@Override | ||
public void onDisabled(Context context, Intent intent) { | ||
context.startActivity(new Intent(context, DisableActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); | ||
showToast(context, context.getString(R.string.admin_receiver_status_disabled)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<device-admin /> | ||
<device-admin xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<uses-policies> | ||
<disable-camera /> | ||
</uses-policies> | ||
</device-admin> |