-
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add toggle for special access to hardware accelerators by Google apps
- Loading branch information
1 parent
c1d3b1e
commit 9fafcc8
Showing
4 changed files
with
101 additions
and
0 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
46 changes: 46 additions & 0 deletions
46
...m/android/settings/applications/specialaccess/GoogleSpecialAcceleratorAccessFragment.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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.android.settings.applications.specialaccess; | ||
|
||
import android.app.ActivityThread; | ||
import android.ext.settings.BoolSetting; | ||
import android.ext.settings.ExtSettings; | ||
import android.os.RemoteException; | ||
|
||
import com.android.internal.util.GoogleCameraUtils; | ||
import com.android.settings.R; | ||
import com.android.settings.ext.BoolSettingFragment; | ||
import com.android.settingslib.widget.FooterPreference; | ||
|
||
public class GoogleSpecialAcceleratorAccessFragment extends BoolSettingFragment { | ||
private static final String TAG = GoogleSpecialAcceleratorAccessFragment.class.getSimpleName(); | ||
|
||
@Override | ||
protected BoolSetting getSetting() { | ||
return ExtSettings.ALLOW_GOOGLE_APPS_SPECIAL_ACCESS_TO_ACCELERATORS; | ||
} | ||
|
||
@Override | ||
protected CharSequence getTitle() { | ||
return resText(R.string.Google_apps_special_accelerator_access_title); | ||
} | ||
|
||
@Override | ||
protected CharSequence getMainSwitchTitle() { | ||
return resText(R.string.Google_apps_special_accelerator_access_main_switch); | ||
} | ||
|
||
@Override | ||
protected void onMainSwitchChanged(boolean state) { | ||
if (GoogleCameraUtils.isCustomSeInfoNeededForAccessToAccelerators(requireContext())) { | ||
try { | ||
ActivityThread.getPackageManager().updateSeInfo(GoogleCameraUtils.PACKAGE_NAME); | ||
} catch (RemoteException e) { | ||
throw e.rethrowFromSystemServer(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
protected FooterPreference makeFooterPref(FooterPreference.Builder builder) { | ||
return builder.setTitle(R.string.Google_apps_special_accelerator_access_footer).build(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...oid/settings/applications/specialaccess/GoogleSpecialAcceleratorAccessPrefController.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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.android.settings.applications.specialaccess; | ||
|
||
import android.content.Context; | ||
import android.ext.settings.ExtSettings; | ||
|
||
import com.android.settings.R; | ||
import com.android.settings.ext.BoolSettingFragmentPrefController; | ||
|
||
public class GoogleSpecialAcceleratorAccessPrefController extends BoolSettingFragmentPrefController { | ||
|
||
public GoogleSpecialAcceleratorAccessPrefController(Context ctx, String key) { | ||
super(ctx, key, ExtSettings.ALLOW_GOOGLE_APPS_SPECIAL_ACCESS_TO_ACCELERATORS); | ||
} | ||
|
||
@Override | ||
public int getAvailabilityStatus() { | ||
if (!mContext.getResources().getBoolean( | ||
com.android.internal.R.bool.config_Google_apps_can_have_special_access_to_accelerators)) { | ||
return UNSUPPORTED_ON_DEVICE; | ||
} | ||
|
||
return super.getAvailabilityStatus(); | ||
} | ||
|
||
@Override | ||
protected CharSequence getSummaryOn() { | ||
return resText(R.string.Google_apps_special_accelerator_access_summary_granted); | ||
} | ||
|
||
@Override | ||
protected CharSequence getSummaryOff() { | ||
return resText(R.string.Google_apps_special_accelerator_access_summary_not_granted); | ||
} | ||
} |